Files
metasploit-gs/scripts/meterpreter/get_local_subnets.rb
T

31 lines
812 B
Ruby
Raw Normal View History

2009-10-26 15:14:28 +00:00
# $Id$
2007-05-22 21:08:47 +00:00
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(
2009-10-26 04:43:59 +00:00
"-h" => [ false, "Help menu." ]
2009-10-25 21:03:42 +00:00
)
2009-10-26 04:43:59 +00:00
def usage
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
end
2009-10-25 21:03:42 +00:00
@@exec_opts.parse(args) { |opt, idx, val|
case opt
when "-h"
2009-10-26 04:43:59 +00:00
usage
2009-10-25 21:03:42 +00:00
end
}
2007-05-22 21:08:47 +00:00
client.net.config.each_route { |route|
# Remove multicast and loopback interfaces
next if route.subnet =~ /^(224\.|127\.)/
2008-11-14 17:12:38 +00:00
next if route.subnet == '0.0.0.0'
2007-05-22 21:08:47 +00:00
next if route.netmask == '255.255.255.255'
print_line("Local subnet: #{route.subnet}/#{route.netmask}")
2008-11-14 17:12:38 +00:00
}