Path: blob/master/scripts/meterpreter/get_local_subnets.rb
19715 views
##1# WARNING: Metasploit no longer maintains or accepts meterpreter scripts.2# If you'd like to improve this script, please try to port it as a post3# module instead. Thank you.4##567# Meterpreter script that display local subnets8# Provided by Nicob <nicob [at] nicob.net>9# Ripped from http://blog.metasploit.com/2006/10/meterpreter-scripts-and-msrt.html1011@@exec_opts = Rex::Parser::Arguments.new(12"-h" => [ false, "Help menu." ]13)14def usage15print_line("Get a list of local subnets based on the host's routes")16print_line("USAGE: run get_local_subnets")17print_line(@@exec_opts.usage)18raise Rex::Script::Completed19end2021@@exec_opts.parse(args) { |opt, idx, val|22case opt23when "-h"24usage25end26}2728client.net.config.each_route { |route|29# Remove multicast and loopback interfaces30next if route.subnet =~ /^(224\.|127\.)/31next if route.subnet == '0.0.0.0'32next if route.netmask == '255.255.255.255'33print_line("Local subnet: #{route.subnet}/#{route.netmask}")34}353637