Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from metasploit.msfrpc import MsfRpcClient
- import config
- # Get info about session in human-readable format for bot
- def getInfo(session):
- return 'IP: ' + session['session_host'] + ' , Port: ' + session['tunnel_local'].split(':')[1] + ' , Type: ' \
- + session['type'] + ' , Info: ' + session['info']
- def getSessionsList():
- return client.sessions.list
- # Get list of sessions for bot
- def getHumanSessionList():
- sessions = list()
- for key, value in getSessionsList().iteritems():
- sessions.append(getInfo(value))
- return sessions
- # Check for new sessions. Return blank list or list with info
- def getNewSessions():
- global sessions
- sessions_human = list()
- temp = (set(getSessionsList()) ^ set(sessions))
- print temp
- if temp:
- sessions = getSessionsList()
- for session in temp:
- sessions_human.append(getInfo(sessions[session]))
- return sessions_human
- # Connect to msfrpcd
- client = MsfRpcClient(username=config.msfUser, password=config.msfPass, port=config.msfPort, ssl=False)
- # Get list of sessions for first time
- sessions = getSessionsList()
- a = getNewSessions()
- b =5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement