metasploit-runner 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/MetasploitPenTestScript/version.rb +1 -1
- data/lib/metasploit/constants.rb +1 -0
- data/lib/metasploit/exploit.rb +15 -1
- data/lib/metasploit/exploit_run_description.rb +17 -1
- data/spec/exploit_spec.rb +87 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa74a612b220bdf4518066c980c75bc676a768a
|
4
|
+
data.tar.gz: aa3574a74021210c57a9510cb082ae07924e8133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c242eb34af6da8d8dd0e773230eb4d660567286f65f5435748ac025124fa0951b7dc3e47d427c2a124800aa61eeb2afd56a346a065536b1bbc5829fa7be4815f
|
7
|
+
data.tar.gz: 61f2ae1bc235e8eacd839a1b11a4f7c6614a6776e777bf827487d7ffd2cb2cc34a5d7ed81c5dced766202930a67cfbbeae0bdf65f98fa707e16469ddf5cbcf9c
|
data/lib/metasploit/constants.rb
CHANGED
@@ -13,6 +13,7 @@ module CONSTANTS
|
|
13
13
|
USING_DEFAULT_SSL_MESSAGE = '[*] Using SSL=TRUE'
|
14
14
|
IMPORTING_DATA_MESSAGE = '[*] Importing scan data from Nexpose...'
|
15
15
|
SCANNING_MESSAGE = '[*] Scanning all your things with WebScan...'
|
16
|
+
AUDIT_MESSAGE = '[*] Performing web audit...'
|
16
17
|
EXPLOIT_MESSAGE = '[*] Exploiting all your things...'
|
17
18
|
REQUIRED_WORKSPACE_MESSAGE = 'PWNED! Workspace Name is required'
|
18
19
|
SKIPPING_IMPORT_MESSAGE = '[*] Nexpose Console option was not passed, skipping Nexpose Import'
|
data/lib/metasploit/exploit.rb
CHANGED
@@ -16,6 +16,8 @@ module Metasploit
|
|
16
16
|
|
17
17
|
do_metasploit_scan(rpc_client, run_details)
|
18
18
|
|
19
|
+
do_metasploit_audit(rpc_client, run_details)
|
20
|
+
|
19
21
|
do_metasploit_exploit(rpc_client, run_details)
|
20
22
|
end
|
21
23
|
|
@@ -47,6 +49,18 @@ module Metasploit
|
|
47
49
|
wait_for_task_to_stop_running(rpc_client, CONSTANTS::SCANNING_MESSAGE, scan['task_id'])
|
48
50
|
end
|
49
51
|
|
52
|
+
def self.do_metasploit_audit(rpc_client, run_details)
|
53
|
+
audit = rpc_client.call('pro.start_webaudit', {
|
54
|
+
'workspace' => run_details.workspace_name,
|
55
|
+
'DS_URLS' => run_details.device_ip_to_scan,
|
56
|
+
'DS_MAX_REQUESTS' => run_details.audit_max_requests,
|
57
|
+
'DS_MAX_MINUTES' => run_details.audit_max_minutes,
|
58
|
+
'DS_MAX_THREADS' => run_details.audit_max_threads,
|
59
|
+
'DS_MAX_INSTANCES' => run_details.audit_max_instances
|
60
|
+
})
|
61
|
+
wait_for_task_to_stop_running(rpc_client, CONSTANTS::AUDIT_MESSAGE, audit['task_id'])
|
62
|
+
end
|
63
|
+
|
50
64
|
def self.do_metasploit_exploit(rpc_client, run_details)
|
51
65
|
sploit = rpc_client.call('pro.start_exploit', {'workspace' => run_details.workspace_name})
|
52
66
|
wait_for_task_to_stop_running(rpc_client, CONSTANTS::EXPLOIT_MESSAGE, sploit['task_id'])
|
@@ -65,4 +79,4 @@ module Metasploit
|
|
65
79
|
wait_for_task_to_stop_running(rpc_client, status_message, task_id) if status == CONSTANTS::RUNNING_IMPORT_STATUS
|
66
80
|
end
|
67
81
|
end
|
68
|
-
end
|
82
|
+
end
|
@@ -35,6 +35,22 @@ class ExploitRunDescription
|
|
35
35
|
@@device_ip_to_scan_value = value
|
36
36
|
end
|
37
37
|
|
38
|
+
def audit_max_requests
|
39
|
+
1000
|
40
|
+
end
|
41
|
+
|
42
|
+
def audit_max_minutes
|
43
|
+
3
|
44
|
+
end
|
45
|
+
|
46
|
+
def audit_max_threads
|
47
|
+
5
|
48
|
+
end
|
49
|
+
|
50
|
+
def audit_max_instances
|
51
|
+
3
|
52
|
+
end
|
53
|
+
|
38
54
|
def device_ip_to_scan
|
39
55
|
"http://#{@@device_ip_to_scan_value}"
|
40
56
|
end
|
@@ -67,4 +83,4 @@ class ExploitRunDescription
|
|
67
83
|
(value_to_check.nil? || value_to_check.empty?) ? default : value_to_check
|
68
84
|
end
|
69
85
|
|
70
|
-
end
|
86
|
+
end
|
data/spec/exploit_spec.rb
CHANGED
@@ -17,6 +17,11 @@ describe 'exploit' do
|
|
17
17
|
@expected_webscan_task_id = '12'
|
18
18
|
@expected_import_task_id = '1'
|
19
19
|
@expected_exploit_task_id = '13'
|
20
|
+
@expected_audit_task_id = '14'
|
21
|
+
@expected_audit_max_requests = 1000
|
22
|
+
@expected_audit_max_minutes = 3
|
23
|
+
@expected_audit_max_threads = 5
|
24
|
+
@expected_audit_max_instances = 3
|
20
25
|
@mock_rpc_client = get_mock_rpc_client
|
21
26
|
@mock_device_ip_to_scan = '127.0.0.1'
|
22
27
|
@mock_device_url_to_scan = "http://#{@mock_device_ip_to_scan}"
|
@@ -137,8 +142,8 @@ describe 'exploit' do
|
|
137
142
|
.once
|
138
143
|
.ordered
|
139
144
|
|
140
|
-
#Expecting
|
141
|
-
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(
|
145
|
+
#Expecting 7 because we are mocking 6 above and the global :call mock in get_mock_rpc_client
|
146
|
+
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(7).times
|
142
147
|
|
143
148
|
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
144
149
|
end
|
@@ -197,8 +202,82 @@ describe 'exploit' do
|
|
197
202
|
.once
|
198
203
|
.ordered
|
199
204
|
|
200
|
-
#Expecting
|
201
|
-
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(
|
205
|
+
#Expecting 7 because we are mocking 6 above and the global :call mock in get_mock_rpc_client
|
206
|
+
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(7).times
|
207
|
+
|
208
|
+
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe 'start an audit' do
|
214
|
+
|
215
|
+
it 'should kick off an audit' do
|
216
|
+
expect(@mock_rpc_client).to receive(:call)
|
217
|
+
.with('pro.start_webaudit', {
|
218
|
+
'workspace' => @expected_workspace_name,
|
219
|
+
'DS_URLS' => @mock_device_url_to_scan,
|
220
|
+
'DS_MAX_REQUESTS' => @expected_audit_max_requests,
|
221
|
+
'DS_MAX_MINUTES' => @expected_audit_max_minutes,
|
222
|
+
'DS_MAX_THREADS' => @expected_audit_max_threads,
|
223
|
+
'DS_MAX_INSTANCES' => @expected_audit_max_instances
|
224
|
+
})
|
225
|
+
|
226
|
+
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
227
|
+
end
|
228
|
+
|
229
|
+
describe 'wait for audit to be over' do
|
230
|
+
before(:each) do
|
231
|
+
|
232
|
+
expect(@mock_rpc_client).to receive(:call)
|
233
|
+
.with('pro.start_webaudit', {
|
234
|
+
'workspace' => @expected_workspace_name,
|
235
|
+
'DS_URLS' => @mock_device_url_to_scan,
|
236
|
+
'DS_MAX_REQUESTS' => @expected_audit_max_requests,
|
237
|
+
'DS_MAX_MINUTES' => @expected_audit_max_minutes,
|
238
|
+
'DS_MAX_THREADS' => @expected_audit_max_threads,
|
239
|
+
'DS_MAX_INSTANCES' => @expected_audit_max_instances
|
240
|
+
})
|
241
|
+
.and_return({'task_id' => @expected_audit_task_id})
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should call to check the status of the audit' do
|
245
|
+
expect(@mock_rpc_client).to receive(:call).with('pro.task_status', @expected_audit_task_id)
|
246
|
+
|
247
|
+
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'should call to check the status until it is not running' do
|
251
|
+
expect(@mock_rpc_client).to receive(:call)
|
252
|
+
.with('pro.task_status', @expected_audit_task_id)
|
253
|
+
.and_return({'14'=>{'status' => 'running', 'progress' => 3, 'info' => 'Auditing your website'}})
|
254
|
+
.exactly(3).times
|
255
|
+
.ordered
|
256
|
+
|
257
|
+
expect(@mock_rpc_client).to receive(:call)
|
258
|
+
.with('pro.task_status', @expected_audit_task_id)
|
259
|
+
.and_return({'14'=>{'status' => 'not running', 'progress' => 100, 'info' => 'Complete'}})
|
260
|
+
.once
|
261
|
+
.ordered
|
262
|
+
|
263
|
+
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should sleep for 3 seconds if the status is still running' do
|
267
|
+
expect(@mock_rpc_client).to receive(:call)
|
268
|
+
.with('pro.task_status', @expected_audit_task_id)
|
269
|
+
.and_return({'14'=>{'status' => 'running', 'progress' => 3, 'info' => 'Auditing your website'}})
|
270
|
+
.exactly(3).times
|
271
|
+
.ordered
|
272
|
+
|
273
|
+
expect(@mock_rpc_client).to receive(:call)
|
274
|
+
.with('pro.task_status', @expected_audit_task_id)
|
275
|
+
.and_return({'14'=>{'status' => 'not running', 'progress' => 100, 'info' => 'Complete'}})
|
276
|
+
.once
|
277
|
+
.ordered
|
278
|
+
|
279
|
+
#Expecting 7 because we are mocking 6 above and the global :call mock in get_mock_rpc_client
|
280
|
+
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(7).times
|
202
281
|
|
203
282
|
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
204
283
|
end
|
@@ -257,14 +336,15 @@ describe 'exploit' do
|
|
257
336
|
.once
|
258
337
|
.ordered
|
259
338
|
|
260
|
-
#Expecting
|
261
|
-
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(
|
339
|
+
#Expecting 7 because we are mocking 6 above and the global :call mock in get_mock_rpc_client
|
340
|
+
expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(7).times
|
262
341
|
|
263
342
|
Metasploit::Exploit.start(@expected_connection, @expected_port, @expected_uri, @expected_ssl, @expected_token, @expected_workspace_name, @expected_nexpose_console_name, @mock_device_ip_to_scan)
|
264
343
|
end
|
265
344
|
end
|
266
345
|
end
|
267
346
|
|
347
|
+
|
268
348
|
end
|
269
349
|
end
|
270
350
|
|
@@ -281,4 +361,4 @@ def get_mock_rpc_client
|
|
281
361
|
.and_return(mock_rpc_client)
|
282
362
|
|
283
363
|
mock_rpc_client
|
284
|
-
end
|
364
|
+
end
|