Skip to content

Commit c65db18

Browse files
committed
Add rudimentary specs and fix some help wording
1 parent 1931024 commit c65db18

File tree

2 files changed

+41
-6
lines changed
  • lib/msf/ui/console/command_dispatcher
  • spec/lib/msf/ui/command_dispatcher

2 files changed

+41
-6
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,22 +658,23 @@ def cmd_creds_help
658658
print_line " creds [filter options] [address range]"
659659
print_line
660660
print_line "Usage - Adding credentials:"
661-
print_line " creds add-ntlm <user> <password> [domain]"
661+
print_line " creds add-ntlm <user> <ntlm hash> [domain]"
662662
print_line " creds add-password <user> <password> [realm]"
663-
print_line " creds add-ssh-key <user> </path/to/id_rsa> [realm]"
663+
print_line " creds add-ssh-key <user> </path/to/id_rsa>"
664+
#print_line "Where [realm type] can be one of:"
665+
#Metasploit::Model::Realm::Key::SHORT_NAMES.each do |short, description|
666+
# print_line " #{short} - #{description}"
667+
#end
664668

665669
print_line
666670
print_line "General options"
667671
print_line " -h,--help Show this help information"
668672
print_line
669-
print_line "Filter options"
673+
print_line "Filter options for listing"
670674
print_line " -P,--password <regex> List passwords that match this regex"
671675
print_line " -p,--port <portspec> List creds with logins on services matching this port spec"
672676
print_line " -s <svc names> List creds matching comma-separated service names"
673677
print_line " -u,--user <regex> List users that match this regex"
674-
#print_line
675-
#print_line "Add options"
676-
#print_line " --realm-type <type> One of: domain, db2, sid, pgdb. (Defaults to domain)"
677678

678679
print_line
679680
print_line "Examples, listing:"
@@ -930,6 +931,8 @@ def cmd_creds_tabs(str, words)
930931
else
931932
[]
932933
end
934+
#when 5
935+
# tabs = Metasploit::Model::Realm::Key::SHORT_NAMES.keys
933936
else
934937
tabs = []
935938
end

spec/lib/msf/ui/command_dispatcher/db_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@
1111
described_class.new(driver)
1212
end
1313

14+
describe "#cmd_creds" do
15+
describe "add-password" do
16+
let(:username) { "username" }
17+
let(:password) { "password" }
18+
context "when no core exists" do
19+
it "should add a Core" do
20+
expect {
21+
subject.cmd_creds("add-password", username, password)
22+
}.to change{ Metasploit::Credential::Core.count }.by 1
23+
end
24+
end
25+
context "when a core already exists" do
26+
before(:each) do
27+
priv = FactoryGirl.create(:metasploit_credential_password, data: password)
28+
pub = FactoryGirl.create(:metasploit_credential_public, username: username)
29+
core = FactoryGirl.create(:metasploit_credential_core,
30+
private: priv,
31+
public: pub,
32+
realm: nil,
33+
workspace: Mdm::Workspace.last)
34+
end
35+
it "should not add a Core" do
36+
expect {
37+
subject.cmd_creds("add-password", username, password)
38+
}.to_not change{ Metasploit::Credential::Core.count }
39+
end
40+
end
41+
end
42+
end
43+
1444
describe "#cmd_workspace" do
1545
describe "-h" do
1646
it "should show a help message" do
@@ -183,6 +213,7 @@
183213

184214
end
185215

216+
=begin
186217
describe "#cmd_creds" do
187218
describe "-h" do
188219
it "should show a help message" do
@@ -206,6 +237,7 @@
206237
end
207238
end
208239
end
240+
=end
209241

210242
describe "#cmd_db_import" do
211243
describe "-h" do

0 commit comments

Comments
 (0)