Skip to content

Commit 31184c6

Browse files
committed
Land rapid7#4223, specs for DB console command output
Wrap specs around current behavior of the DB command dispatcher, in order to make upcoming refactor painless. MSP-11622 #land
2 parents 9eda84e + a208519 commit 31184c6

File tree

1 file changed

+157
-138
lines changed

1 file changed

+157
-138
lines changed

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

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

14+
it { is_expected.to respond_to :active? }
15+
it { is_expected.to respond_to :arg_host_range }
16+
it { is_expected.to respond_to :arg_port_range }
17+
it { is_expected.to respond_to :cmd_creds_help }
18+
it { is_expected.to respond_to :cmd_creds_tabs }
19+
it { is_expected.to respond_to :cmd_db_autopwn }
20+
it { is_expected.to respond_to :cmd_db_autopwn_help }
21+
it { is_expected.to respond_to :cmd_db_connect }
22+
it { is_expected.to respond_to :cmd_db_connect_help }
23+
it { is_expected.to respond_to :cmd_db_disconnect }
24+
it { is_expected.to respond_to :cmd_db_disconnect_help }
25+
it { is_expected.to respond_to :cmd_db_driver }
26+
it { is_expected.to respond_to :cmd_db_driver_help }
27+
it { is_expected.to respond_to :cmd_db_export_help }
28+
it { is_expected.to respond_to :cmd_db_hosts_help }
29+
it { is_expected.to respond_to :cmd_db_import_help }
30+
it { is_expected.to respond_to :cmd_db_import_tabs }
31+
it { is_expected.to respond_to :cmd_db_nmap }
32+
it { is_expected.to respond_to :cmd_db_notes }
33+
it { is_expected.to respond_to :cmd_db_notes_help }
34+
it { is_expected.to respond_to :cmd_db_rebuild_cache }
35+
it { is_expected.to respond_to :cmd_db_rebuild_cache_help }
36+
it { is_expected.to respond_to :cmd_db_services }
37+
it { is_expected.to respond_to :cmd_db_services_help }
38+
it { is_expected.to respond_to :cmd_db_status }
39+
it { is_expected.to respond_to :cmd_db_vulns }
40+
it { is_expected.to respond_to :cmd_db_vulns_help }
41+
it { is_expected.to respond_to :cmd_hosts }
42+
it { is_expected.to respond_to :cmd_hosts_help }
43+
it { is_expected.to respond_to :cmd_loot_help }
44+
it { is_expected.to respond_to :cmd_notes_help }
45+
it { is_expected.to respond_to :cmd_services_help }
46+
it { is_expected.to respond_to :cmd_vulns_help }
47+
it { is_expected.to respond_to :cmd_workspace_help }
48+
it { is_expected.to respond_to :cmd_workspace_tabs }
49+
it { is_expected.to respond_to :commands }
50+
it { is_expected.to respond_to :creds_add }
51+
it { is_expected.to respond_to :creds_add_non_replayable_hash }
52+
it { is_expected.to respond_to :creds_add_ntlm_hash }
53+
it { is_expected.to respond_to :creds_add_password }
54+
it { is_expected.to respond_to :creds_add_ssh_key }
55+
it { is_expected.to respond_to :creds_search }
56+
it { is_expected.to respond_to :db_check_driver }
57+
it { is_expected.to respond_to :db_connect_postgresql }
58+
it { is_expected.to respond_to :db_find_tools }
59+
it { is_expected.to respond_to :db_parse_db_uri_postgresql }
60+
it { is_expected.to respond_to :deprecated_commands }
61+
it { is_expected.to respond_to :each_host_range_chunk }
62+
it { is_expected.to respond_to :make_sortable }
63+
it { is_expected.to respond_to :name }
64+
it { is_expected.to respond_to :report_store_local }
65+
it { is_expected.to respond_to :set_rhosts_from_addrs }
66+
1467
describe "#cmd_creds" do
1568
describe "add-password" do
1669
let(:username) { "username" }
@@ -42,18 +95,59 @@
4295
end
4396
end
4497

45-
describe "#cmd_workspace" do
98+
describe "#cmd_db_export" do
4699
describe "-h" do
47100
it "should show a help message" do
48-
db.cmd_workspace "-h"
101+
db.cmd_db_export "-h"
49102
@output.should =~ [
50103
"Usage:",
51-
" workspace List workspaces",
52-
" workspace [name] Switch workspace",
53-
" workspace -a [name] ... Add workspace(s)",
54-
" workspace -d [name] ... Delete workspace(s)",
55-
" workspace -r <old> <new> Rename workspace",
56-
" workspace -h Show this help information"
104+
" db_export -f <format> [-a] [filename]",
105+
" Format can be one of: xml, pwdump"
106+
]
107+
end
108+
end
109+
end
110+
111+
describe "#cmd_db_import" do
112+
describe "-h" do
113+
it "should show a help message" do
114+
db.cmd_db_import "-h"
115+
@output.should =~ [
116+
"Usage: db_import <filename> [file2...]",
117+
"Filenames can be globs like *.xml, or **/*.xml which will search recursively",
118+
"Currently supported file types include:",
119+
" Acunetix",
120+
" Amap Log",
121+
" Amap Log -m",
122+
" Appscan",
123+
" Burp Session XML",
124+
" CI",
125+
" Foundstone",
126+
" FusionVM XML",
127+
" IP Address List",
128+
" IP360 ASPL",
129+
" IP360 XML v3",
130+
" Libpcap Packet Capture",
131+
" Metasploit PWDump Export",
132+
" Metasploit XML",
133+
" Metasploit Zip Export",
134+
" Microsoft Baseline Security Analyzer",
135+
" NeXpose Simple XML",
136+
" NeXpose XML Report",
137+
" Nessus NBE Report",
138+
" Nessus XML (v1)",
139+
" Nessus XML (v2)",
140+
" NetSparker XML",
141+
" Nikto XML",
142+
" Nmap XML",
143+
" OpenVAS Report",
144+
" OpenVAS XML",
145+
" Outpost24 XML",
146+
" Qualys Asset XML",
147+
" Qualys Scan XML",
148+
" Retina XML",
149+
" Spiceworks CSV Export",
150+
" Wapiti XML"
57151
]
58152
end
59153
end
@@ -80,6 +174,53 @@
80174
end
81175
end
82176

177+
describe "#cmd_loot" do
178+
describe "-h" do
179+
it "should show a help message" do
180+
db.cmd_loot "-h"
181+
@output.should =~ [
182+
"Usage: loot <options>",
183+
" Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]",
184+
" Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [-t [type]",
185+
" Del: loot -d [addr1 addr2 ...]",
186+
" -a,--add Add loot to the list of addresses, instead of listing",
187+
" -d,--delete Delete *all* loot matching host and type",
188+
" -f,--file File with contents of the loot to add",
189+
" -i,--info Info of the loot to add",
190+
" -t <type1,type2> Search for a list of types",
191+
" -h,--help Show this help information",
192+
" -S,--search Search string to filter by"
193+
]
194+
end
195+
end
196+
197+
end
198+
199+
describe "#cmd_notes" do
200+
describe "-h" do
201+
it "should show a help message" do
202+
db.cmd_notes "-h"
203+
@output.should =~ [
204+
"Usage: notes [-h] [-t <type1,type2>] [-n <data string>] [-a] [addr range]",
205+
" -a,--add Add a note to the list of addresses, instead of listing",
206+
" -d,--delete Delete the hosts instead of searching",
207+
" -n,--note <data> Set the data for a new note (only with -a)",
208+
" -t <type1,type2> Search for a list of types",
209+
" -h,--help Show this help information",
210+
" -R,--rhosts Set RHOSTS from the results of the search",
211+
" -S,--search Regular expression to match for search",
212+
" --sort <field1,field2> Fields to sort by (case sensitive)",
213+
"Examples:",
214+
" notes --add -t apps -n 'winzip' 10.1.1.34 10.1.20.41",
215+
" notes -t smb.fingerprint 10.1.1.34 10.1.20.41",
216+
" notes -S 'nmap.nse.(http|rtsp)' --sort type,output"
217+
]
218+
219+
end
220+
end
221+
222+
end
223+
83224
describe "#cmd_services" do
84225
describe "-h" do
85226
it "should show a help message" do
@@ -167,142 +308,20 @@
167308

168309
end
169310

170-
describe "#cmd_notes" do
171-
describe "-h" do
172-
it "should show a help message" do
173-
db.cmd_notes "-h"
174-
@output.should =~ [
175-
"Usage: notes [-h] [-t <type1,type2>] [-n <data string>] [-a] [addr range]",
176-
" -a,--add Add a note to the list of addresses, instead of listing",
177-
" -d,--delete Delete the hosts instead of searching",
178-
" -n,--note <data> Set the data for a new note (only with -a)",
179-
" -t <type1,type2> Search for a list of types",
180-
" -h,--help Show this help information",
181-
" -R,--rhosts Set RHOSTS from the results of the search",
182-
" -S,--search Regular expression to match for search",
183-
" --sort <field1,field2> Fields to sort by (case sensitive)",
184-
"Examples:",
185-
" notes --add -t apps -n 'winzip' 10.1.1.34 10.1.20.41",
186-
" notes -t smb.fingerprint 10.1.1.34 10.1.20.41",
187-
" notes -S 'nmap.nse.(http|rtsp)' --sort type,output"
188-
]
189-
190-
end
191-
end
192-
193-
end
194-
195-
describe "#cmd_loot" do
196-
describe "-h" do
197-
it "should show a help message" do
198-
db.cmd_loot "-h"
199-
@output.should =~ [
200-
"Usage: loot <options>",
201-
" Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]",
202-
" Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [-t [type]",
203-
" Del: loot -d [addr1 addr2 ...]",
204-
" -a,--add Add loot to the list of addresses, instead of listing",
205-
" -d,--delete Delete *all* loot matching host and type",
206-
" -f,--file File with contents of the loot to add",
207-
" -i,--info Info of the loot to add",
208-
" -t <type1,type2> Search for a list of types",
209-
" -h,--help Show this help information",
210-
" -S,--search Search string to filter by"
211-
]
212-
end
213-
end
214-
215-
end
216-
217-
=begin
218-
describe "#cmd_creds" do
219-
describe "-h" do
220-
it "should show a help message" do
221-
db.cmd_creds "-h"
222-
@output.should =~ [
223-
"Usage: creds [addr range]",
224-
"List credentials. If an address range is given, show only credentials with",
225-
"logins on hosts within that range.",
226-
" -h,--help Show this help information",
227-
" -c,--columns Columns of interest",
228-
" -P,--password <regex> List passwords that match this regex",
229-
" -p,--port <portspec> List creds with logins on services matching this port spec",
230-
" -s <svc names> List creds matching comma-separated service names",
231-
" -u,--user <regex> List users that match this regex",
232-
"Examples:",
233-
" creds # Default, returns all credentials",
234-
" creds 1.2.3.4/24 # nmap host specification",
235-
" creds -p 22-25,445 # nmap port specification",
236-
" creds -s ssh,smb # All creds associated with a login on SSH or SMB services"
237-
]
238-
end
239-
end
240-
end
241-
=end
242-
243-
describe "#cmd_db_import" do
244-
describe "-h" do
245-
it "should show a help message" do
246-
db.cmd_db_import "-h"
247-
@output.should =~ [
248-
"Usage: db_import <filename> [file2...]",
249-
"Filenames can be globs like *.xml, or **/*.xml which will search recursively",
250-
"Currently supported file types include:",
251-
" Acunetix",
252-
" Amap Log",
253-
" Amap Log -m",
254-
" Appscan",
255-
" Burp Session XML",
256-
" CI",
257-
" Foundstone",
258-
" FusionVM XML",
259-
" IP Address List",
260-
" IP360 ASPL",
261-
" IP360 XML v3",
262-
" Libpcap Packet Capture",
263-
" Metasploit PWDump Export",
264-
" Metasploit XML",
265-
" Metasploit Zip Export",
266-
" Microsoft Baseline Security Analyzer",
267-
" NeXpose Simple XML",
268-
" NeXpose XML Report",
269-
" Nessus NBE Report",
270-
" Nessus XML (v1)",
271-
" Nessus XML (v2)",
272-
" NetSparker XML",
273-
" Nikto XML",
274-
" Nmap XML",
275-
" OpenVAS Report",
276-
" OpenVAS XML",
277-
" Outpost24 XML",
278-
" Qualys Asset XML",
279-
" Qualys Scan XML",
280-
" Retina XML",
281-
" Spiceworks CSV Export",
282-
" Wapiti XML"
283-
]
284-
end
285-
end
286-
end
287-
288-
describe "#cmd_db_export" do
311+
describe "#cmd_workspace" do
289312
describe "-h" do
290313
it "should show a help message" do
291-
db.cmd_db_export "-h"
314+
db.cmd_workspace "-h"
292315
@output.should =~ [
293316
"Usage:",
294-
" db_export -f <format> [-a] [filename]",
295-
" Format can be one of: xml, pwdump"
317+
" workspace List workspaces",
318+
" workspace [name] Switch workspace",
319+
" workspace -a [name] ... Add workspace(s)",
320+
" workspace -d [name] ... Delete workspace(s)",
321+
" workspace -r <old> <new> Rename workspace",
322+
" workspace -h Show this help information"
296323
]
297324
end
298325
end
299326
end
300-
301-
describe "#db_nmap" do
302-
it "should have some specs describing its output"
303-
end
304-
305-
describe "#db_rebuild_cache" do
306-
it "should have some specs describing its output"
307-
end
308327
end

0 commit comments

Comments
 (0)