2009-10-26 04:43:59 +00:00
|
|
|
# Meterpreter script that display local subnets
|
|
|
|
# Provided by Nicob <nicob [at] nicob.net>
|
|
|
|
# Ripped from http://blog.metasploit.com/2006/10/meterpreter-scripts-and-msrt.html
|
2007-05-22 21:08:47 +00:00
|
|
|
|
2009-10-25 21:03:42 +00:00
|
|
|
@@exec_opts = Rex::Parser::Arguments.new(
|
2013-09-30 18:47:53 +00:00
|
|
|
"-h" => [ false, "Help menu." ]
|
2009-10-25 21:03:42 +00:00
|
|
|
)
|
2009-10-26 04:43:59 +00:00
|
|
|
def usage
|
2013-09-30 18:47:53 +00:00
|
|
|
print_line("Get a list of local subnets based on the host's routes")
|
|
|
|
print_line("USAGE: run get_local_subnets")
|
|
|
|
print_line(@@exec_opts.usage)
|
|
|
|
raise Rex::Script::Completed
|
2009-10-26 04:43:59 +00:00
|
|
|
end
|
2009-10-25 21:03:42 +00:00
|
|
|
|
|
|
|
@@exec_opts.parse(args) { |opt, idx, val|
|
2013-09-30 18:47:53 +00:00
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
usage
|
|
|
|
end
|
2009-10-25 21:03:42 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 21:08:47 +00:00
|
|
|
client.net.config.each_route { |route|
|
2013-09-30 18:47:53 +00:00
|
|
|
# Remove multicast and loopback interfaces
|
|
|
|
next if route.subnet =~ /^(224\.|127\.)/
|
|
|
|
next if route.subnet == '0.0.0.0'
|
|
|
|
next if route.netmask == '255.255.255.255'
|
|
|
|
print_line("Local subnet: #{route.subnet}/#{route.netmask}")
|
2008-11-14 17:12:38 +00:00
|
|
|
}
|