Advertisement
Guest User

Untitled

a guest
Mar 11th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. from metasploit.msfrpc import MsfRpcClient
  2. import config
  3.  
  4. # Get info about session in human-readable format for bot
  5. def getInfo(session):
  6.     return 'IP: ' + session['session_host'] + ' , Port: ' + session['tunnel_local'].split(':')[1] + ' , Type: ' \
  7.             + session['type'] + ' , Info: ' + session['info']
  8.  
  9. def getSessionsList():
  10.     return client.sessions.list
  11.  
  12. # Get list of sessions for bot
  13. def getHumanSessionList():
  14.     sessions = list()
  15.     for key, value in getSessionsList().iteritems():
  16.         sessions.append(getInfo(value))
  17.     return sessions
  18.  
  19. # Check for new sessions. Return blank list or list with info
  20. def getNewSessions():
  21.     global sessions
  22.     sessions_human = list()
  23.  
  24.     temp = (set(getSessionsList()) ^ set(sessions))
  25.     print temp
  26.     if temp:
  27.         sessions = getSessionsList()
  28.         for session in temp:
  29.             sessions_human.append(getInfo(sessions[session]))
  30.  
  31.     return sessions_human
  32.  
  33. # Connect to msfrpcd
  34. client = MsfRpcClient(username=config.msfUser, password=config.msfPass, port=config.msfPort, ssl=False)
  35.  
  36. # Get list of sessions for first time
  37. sessions = getSessionsList()
  38.  
  39. a = getNewSessions()
  40. b =5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement