diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index f1e301070b..0e596b35d6 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -700,6 +700,7 @@ class DBManager proof = opts.delete(:proof) source_id = opts.delete(:source_id) source_type = opts.delete(:source_type) + duplicate_ok = opts.delete(:duplicate_ok) # Nil is true for active. active = (opts[:active] || opts[:active].nil?) ? true : false @@ -718,8 +719,14 @@ class DBManager # Get the service service ||= get_service(wspace, host, proto, port) - # Create the cred by username only (so we can change passwords) - cred = service.creds.find_or_initialize_by_user_and_ptype(token[0] || "", ptype) + # If duplicate usernames are okay, find by both user and password (allows + # for actual duplicates to get modified updated_at, sources, etc) + if duplicate_ok + cred = service.creds.find_or_initialize_by_user_and_ptype_and_pass(token[0] || "", ptype, token[1] || "") + else + # Create the cred by username only (so we can change passwords) + cred = service.creds.find_or_initialize_by_user_and_ptype(token[0] || "", ptype) + end # Update with the password cred.pass = (token[1] || "") diff --git a/modules/auxiliary/scanner/snmp/community.rb b/modules/auxiliary/scanner/snmp/community.rb index a17e7bc03d..8fcb37ab9b 100644 --- a/modules/auxiliary/scanner/snmp/community.rb +++ b/modules/auxiliary/scanner/snmp/community.rb @@ -73,7 +73,7 @@ class Metasploit3 < Msf::Auxiliary udp_sock = Rex::Socket::Udp.create( { 'LocalHost' => datastore['CHOST'] || nil, 'Context' => {'Msf' => framework, 'MsfExploit' => self} }) add_socket(udp_sock) - print_status(">> progress (#{batch[0]}-#{batch[-1]}) #{idx}/#{@comms.length * batch.length}...") if datastore['ShowProgress'] + print_status("SNMP scan progress (#{batch[0]}-#{batch[-1]}): #{idx}/#{@comms.length * batch.length}...") if datastore['ShowProgress'] @comms.each do |comm| data1 = create_probe_snmp1(comm) @@ -97,7 +97,7 @@ class Metasploit3 < Msf::Auxiliary end if( (idx+=1) % 1000 == 0) and datastore['ShowProgress'] - print_status(">> progress (#{batch[0]}-#{batch[-1]}) #{idx}/#{@comms.length * batch.length}...") + print_status("SNMP scan progress (#{batch[0]}-#{batch[-1]}): #{idx}/#{@comms.length * batch.length}...") end end end @@ -136,7 +136,7 @@ class Metasploit3 < Msf::Auxiliary if(com) @found[pkt[1]]||={} if(not @found[pkt[1]][com]) - print_status("#{pkt[1]} '#{com}' '#{inf}'") + print_status("SNMP: #{pkt[1]} community string: '#{com}' info: '#{inf}'") @found[pkt[1]][com] = inf end @@ -154,8 +154,10 @@ class Metasploit3 < Msf::Auxiliary :host => pkt[1], :port => pkt[2], :proto => 'udp', + :sname => 'snmp', :user => '', :pass => com, + :duplicate_ok => true, :active => true )