metasploit-runner 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff96df61da304a50fe9261a61ed81b275115bad
4
- data.tar.gz: b17212e78aa95a8c9577f1928bdbab36975bd410
3
+ metadata.gz: 87b65201b1361ddbc5f3d441ddaabb796a16ef83
4
+ data.tar.gz: 094d207a73b98cb52931b4db4aa8a50ad1f0a562
5
5
  SHA512:
6
- metadata.gz: 855b16bed365745386841cdc0fae3cc61f5a80a115c74bc1cf613e8561842c97a7d2ea7d3f0fc3de9d2b1723449ef3f41a2892f4cc271af7fce6de12091442b6
7
- data.tar.gz: 639a94bbe7a5b88808c420a21fae786f52a62a15dfeee2d4f47158aa9c239788017fada5941eb7b9c8bc0bc0cedb13bb6f008527990d289cc059c0d9d0cfcd2e
6
+ metadata.gz: 91072d871169e598691a9048544200cb71a945f6a3b7577cb5e3590c834cc14c7b31aadd5e2073180ea2769f486a5f0516656400e3853f266bac35ca03c29767
7
+ data.tar.gz: 967f1fe9ca1eca4b2523ef3dcc714daa1749af04962e21b766c73d12692770531f3b305473f306ecc4a06d77efe0e5e9dcb57709ed57775cb7677d30936f1132
data/.travis.yml CHANGED
@@ -1,5 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.1.2"
4
- # uncomment this line if your project needs to run something other than `rake`:
5
- # script: bundle exec rspec spec
3
+ - 2.1.2
4
+ deploy:
5
+ provider: rubygems
6
+ api_key:
7
+ secure: kwPTUQGR25urq/yKIFLcV2TjBalTGU5uWI+jK36I1fatvtbk6geL3BbpPuyiIQOvu2Kge6c5bEQpnOFNNeRW08G7vojhn1aFp7MtKLuE47jazbA1ekGh7Cvyt/actu9wensNAuew87IpJW9Fjxu+5B/RHz678nJqIA4zxFwL1TU=
8
+ gem: metasploit-runner
9
+ on:
10
+ tags: true
11
+ repo: amngibson/metasploit-runner
data/README.md CHANGED
@@ -24,14 +24,22 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- This gem allows you to specify the Metasploit Connection URL, Metasploit Connection Port, Metasploit URI, SSL TRUE/False, Token, Workspace Name, Nexpose Console Name, Device/Target IP.
27
+ This gem allows you to specify the Metasploit Connection URL, Metasploit Connection Port, Metasploit URI, SSL true/false, Token, Workspace Name, Nexpose Console Name, Device/Target IP.
28
+
29
+ The nexpose_console_name is optional, if you specify a nexpose console name it will use the workspace_name, and nexpose console name to pull scan data from a nexpose console.
30
+ IMPORTANT: Your "Site Name" in Nexpose, must match your "Workspace" name in Metasploit and you must add your Nexpose Console to Metasploit for this to work properly.
28
31
 
29
32
  $ exploit "connection_url" "port" "uri" "use_ssl" "token" "workspace_name" "nexpose_console_name" "device_ip_to_scan"
30
33
 
31
- Example:
34
+ Example WITH Nexpose Console Integration:
32
35
 
33
36
  $ exploit "sploit.mydomain.com" "3790" "/api/1.0" "true" "asdlkjhsdfuw1228340asdasf8" "mycoolsoftware-build-28" "nexpose-console-1" "10.0.0.1"
34
37
 
38
+ Example WITHOUT Nexpose Console Integration:
39
+
40
+ $ exploit "sploit.mydomain.com" "3790" "/api/1.0" "true" "asdlkjhsdfuw1228340asdasf8" "mycoolsoftware-build-28" "" "10.0.0.1"
41
+
42
+
35
43
  The if you do not pass the following options they will default to the respective values:
36
44
 
37
45
  port -> 3790
@@ -1,3 +1,3 @@
1
1
  module MetasploitPenTestScript
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -3,6 +3,7 @@ module CONSTANTS
3
3
  DEFAULT_URI = '/api/1.0'
4
4
  DEFAULT_SSL = true
5
5
  RUNNING_IMPORT_STATUS = 'running'
6
+ EXPLOIT_RUNNING_MESSAGE = 'running'
6
7
  REQUIRED_TOKEN_MESSAGE = 'PWNED! Token is required'
7
8
  REQUIRED_CONNECTION_URL_MESSAGE = 'PWNED! Connection URL is required'
8
9
  REQUIRED_DEVICE_IP_TO_SCAN_MESSAGE = 'PWNED! Device IP to scan is required'
@@ -12,6 +13,7 @@ module CONSTANTS
12
13
  USING_DEFAULT_SSL_MESSAGE = '[*] Using SSL=TRUE'
13
14
  IMPORTING_DATA_MESSAGE = '[*] Importing...'
14
15
  SCANNING_MESSAGE = '[*] Scanning all your things...'
16
+ EXPLOIT_MESSAGE = '[*] Exploiting all your things...'
15
17
  REQUIRED_WORKSPACE_MESSAGE = 'PWNED! Workspace Name is required'
16
18
  SKIPPING_IMPORT_MESSAGE = '[*] Nexpose Console option was not passed, skipping Nexpose Import'
17
19
 
@@ -15,6 +15,8 @@ module Metasploit
15
15
  do_nexpose_import(rpc_client, run_details)
16
16
 
17
17
  do_metasploit_scan(rpc_client, run_details)
18
+
19
+ do_metasploit_exploit(rpc_client, run_details)
18
20
  end
19
21
 
20
22
  private
@@ -45,6 +47,11 @@ module Metasploit
45
47
  wait_for_task_to_stop_running(rpc_client, CONSTANTS::SCANNING_MESSAGE, scan['task_id'])
46
48
  end
47
49
 
50
+ def self.do_metasploit_exploit(rpc_client, run_details)
51
+ sploit = rpc_client.call('pro.start_exploit', {'workspace' => run_details.workspace_name})
52
+ wait_for_task_to_stop_running(rpc_client, CONSTANTS::EXPLOIT_MESSAGE, sploit['task_id'])
53
+ end
54
+
48
55
  def self.wait_for_task_to_stop_running(rpc_client, status_message, task_id)
49
56
  sleep(3)
50
57
  status = rpc_client.call('pro.task_status', task_id)
data/spec/exploit_spec.rb CHANGED
@@ -16,6 +16,7 @@ describe 'exploit' do
16
16
  @expected_nexpose_console_name = 'nexpose_console_name'
17
17
  @expected_webscan_task_id = '12'
18
18
  @expected_import_task_id = '1'
19
+ @expected_exploit_task_id = '13'
19
20
  @mock_rpc_client = get_mock_rpc_client
20
21
  @mock_device_ip_to_scan = '127.0.0.1'
21
22
  @mock_device_url_to_scan = "http://#{@mock_device_ip_to_scan}"
@@ -137,7 +138,7 @@ describe 'exploit' do
137
138
  .ordered
138
139
 
139
140
  #Expecting 5 because we are mocking 4 above and the global :call mock in get_mock_rpc_client
140
- expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(5).times
141
+ expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(6).times
141
142
 
142
143
  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)
143
144
  end
@@ -153,7 +154,7 @@ describe 'exploit' do
153
154
  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)
154
155
  end
155
156
 
156
- describe 'wait to be over' do
157
+ describe 'wait for scan to be over' do
157
158
  before(:each) do
158
159
  expect(@mock_rpc_client).to receive(:call)
159
160
  .with('pro.start_webscan', {'workspace' => @expected_workspace_name,
@@ -196,8 +197,68 @@ describe 'exploit' do
196
197
  .once
197
198
  .ordered
198
199
 
199
- #Expecting 5 because we are mocking 4 above and the global :call mock in get_mock_rpc_client
200
- expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(5).times
200
+ #Expecting 6 because we are mocking 4 above and the global :call mock in get_mock_rpc_client
201
+ expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(6).times
202
+
203
+ 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
+ end
205
+ end
206
+ end
207
+
208
+ describe 'start a exploit' do
209
+
210
+ it 'should kick off an exploit' do
211
+ expect(@mock_rpc_client).to receive(:call)
212
+ .with('pro.start_exploit', {'workspace' => @expected_workspace_name})
213
+
214
+ 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)
215
+ end
216
+
217
+ describe 'wait for exploit to be over' do
218
+ before(:each) do
219
+
220
+ expect(@mock_rpc_client).to receive(:call)
221
+ .with('pro.start_exploit', {'workspace' => @expected_workspace_name})
222
+ .and_return({'task_id' => @expected_exploit_task_id})
223
+ end
224
+
225
+ it 'should call to check the status of the exploit' do
226
+ expect(@mock_rpc_client).to receive(:call).with('pro.task_status', @expected_exploit_task_id)
227
+
228
+ 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)
229
+ end
230
+
231
+ it 'should call to check the status until it is not running' do
232
+ expect(@mock_rpc_client).to receive(:call)
233
+ .with('pro.task_status', @expected_exploit_task_id)
234
+ .and_return({'status' => 'running'})
235
+ .exactly(3).times
236
+ .ordered
237
+
238
+ expect(@mock_rpc_client).to receive(:call)
239
+ .with('pro.task_status', @expected_exploit_task_id)
240
+ .and_return({'status' => 'not running'})
241
+ .once
242
+ .ordered
243
+
244
+ 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)
245
+ end
246
+
247
+ it 'should sleep for 3 seconds if the status is still running' do
248
+ expect(@mock_rpc_client).to receive(:call)
249
+ .with('pro.task_status', @expected_exploit_task_id)
250
+ .and_return({'status' => 'running'})
251
+ .exactly(3).times
252
+ .ordered
253
+
254
+ expect(@mock_rpc_client).to receive(:call)
255
+ .with('pro.task_status', @expected_exploit_task_id)
256
+ .and_return({'status' => 'not running'})
257
+ .once
258
+ .ordered
259
+
260
+ #Expecting 6 because we are mocking 4 above and the global :call mock in get_mock_rpc_client
261
+ expect(Metasploit::Exploit).to receive(:sleep).with(3).exactly(6).times
201
262
 
202
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)
203
264
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Gibson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msfrpc-client