Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/metasploit/credential/creation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,8 @@ def create_credential_service(opts={})
workspace_id = opts.fetch(:workspace_id)

host_object = Mdm::Host.where(address: address, workspace_id: workspace_id).first_or_create
service_object = Mdm::Service.where(host_id: host_object.id, port: port, proto: protocol).first_or_initialize
service_object = Mdm::Service.where(host_id: host_object.id, port: port, proto: protocol, name: service_name).first_or_initialize

service_object.name = service_name
service_object.state = "open"
service_object.save!

Expand Down
14 changes: 7 additions & 7 deletions spec/factories/metasploit/credential/importer/pwdumps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@
sequence :wellformed_pwdump do |n|
pwdump_string = <<-EOS
# LM/NTLM Hashes (1 hashes, 1 services)
# 192.168.0.2:4567/snmp ()
# 192.168.0.2:4567/udp (snmp)
metasploit_credential_public_username1:1:aad3b435b51404eeaad3b435b51404ee:79d2d315bcb541a94d4f094a74b46cb2:::

# SSH Private Keys (1 services, 1 keys)
# 114.144.78.235:22/tcp (ssh)
Warning: missing SSH key file 'kljsdlkfjfkl;jasdf;lkasjdf;lkjasdf;lkjasdf;lkj'.

# Hashes (2 hashes, 2 services)
# 192.168.0.2:4567/tcp (snmp)
# 192.168.0.2:4567/udp (snmp)
metasploit_credential_public_username1:40bdee771d42eb80d47a7d34ed7fc0a318927197:::

# 192.168.0.3:4567/tcp (snmp)
# 192.168.0.3:4567/udp (snmp)
metasploit_credential_public_username2:1654f171e0123b54272d82fb7e94bdf214a9b2a4:::

# Plaintext Passwords (2 hashes, 2 services)
# 192.168.0.2:4567/tcp (snmp)
# 192.168.0.2:4567/udp (snmp)
metasploit_credential_public_username1 metasploit_credential_password2

# 192.168.0.3:4567/tcp (snmp)
# 192.168.0.3:4567/udp (snmp)
metasploit_credential_public_username2 metasploit_credential_password3

# Postgres MD5 Hashes (1 hashes, 1 services)
# 192.168.0.2:5432/postgres ()
# 192.168.0.2:5432/tcp (postgres)
metasploit_credential_public_username1:md53175bce1d3201d16594cebf9d7eb3f9d
EOS
StringIO.new(pwdump_string)
end

end
end
2 changes: 1 addition & 1 deletion spec/lib/metasploit/credential/creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
origin_type: :service
}
host = FactoryBot.create(:mdm_host, address: opts[:address], workspace_id: opts[:workspace_id])
FactoryBot.create(:mdm_service, host_id: host.id, port: opts[:port], proto: opts[:protocol])
FactoryBot.create(:mdm_service, host_id: host.id, port: opts[:port], proto: opts[:protocol], name: opts[:service_name])
expect { test_object.create_credential_origin_service(opts)}.to_not change{Mdm::Service.count }
end
end
Expand Down