-2

I would like to know if in metasploit for any given exploit its possible to use a target list instead of a single target and if possible how is that done?

schroeder
  • 123,438
  • 55
  • 284
  • 319
ampf27
  • 3
  • 1
  • 3

1 Answers1

4

Traditionally, this worked for non-exploits using RHOSTS:

Scanners and most other auxiliary modules use the ‘RHOSTS’ option instead of ‘RHOST’. RHOSTS can take IP ranges (192.168.1.20-192.168.1.30), CIDR ranges (192.168.1.0/24), multiple ranges separated by commas (192.168.1.0/24, 192.168.3.0/24), and line-separated host list files (file:/tmp/hostlist.txt).

Recent work extended RHOSTS usage to include exploits, as well:

msf5 exploit(linux/ssh/symantec_smg_ssh) > set RHOSTS 172.16.185.218, 172.16.231.122
RHOSTS => 172.16.185.218, 172.16.231.122
msf5 exploit(linux/ssh/symantec_smg_ssh) > run
[*] Exploiting target 172.16.185.218

[*] 172.16.185.218:22 - Attempt to login...
[-] 172.16.185.218:22 SSH - Failed authentication
[*] Exploiting target 172.16.231.122
[*] 172.16.231.122:22 - Attempt to login...
[-] 172.16.231.122:22 SSH - Failed authentication
[*] Exploit completed, but no session was created.
msf5 exploit(linux/ssh/symantec_smg_ssh) 

This also works with files as described:

$ cat /tmp/hostlist.txt
172.16.185.218
172.16.231.122
$ fg
msfconsole

msf5 exploit(linux/ssh/symantec_smg_ssh) > set RHOSTS file:/tmp/hostlist.txt
RHOSTS => file:/tmp/hostlist.txt
msf5 exploit(linux/ssh/symantec_smg_ssh) > run
[*] Exploiting target 172.16.185.218

[*] 172.16.185.218:22 - Attempt to login...
[-] 172.16.185.218:22 SSH - Failed authentication
[*] Exploiting target 172.16.231.122
[*] 172.16.231.122:22 - Attempt to login...
[-] 172.16.231.122:22 SSH - Failed authentication
[*] Exploit completed, but no session was created.
msf5 exploit(linux/ssh/symantec_smg_ssh) 
gowenfawr
  • 71,975
  • 17
  • 161
  • 198
  • Don't know why I get this error '> run [-] Auxiliary failed: Msf::OptionValidateError One or more options failed to validate: RHOSTS.' using a file (one host per line) – Philippe Delteil Jan 16 '21 at 20:43
  • 1
    @PhilippeDelteil I have same problem, I checked my hosts file and I found still containing some DOMAIN (failed when my script resolve them to ip some of that domain) , it's all must be an IP address, so I just remove it and worked fine – Fthr Mar 22 '21 at 01:37