msfrpc-client 1.1.0 → 1.1.1

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: 11744747ce28ee144620957a3c362e3eb1e5b843
4
- data.tar.gz: ef6329d09ec64617a0bd266f4fe0c1ab480c464f
3
+ metadata.gz: eae20060bcf4dfb1bdbfa1fc3f530ed7a7421e8b
4
+ data.tar.gz: d07865830b68e642d3b4d90a3a91da825050eea7
5
5
  SHA512:
6
- metadata.gz: dca81c9fa5e2f6485e188273a061ff88d7554180f3e98ca990e1e5328a5a1ca5d9053a2c6c116e414fa1087814627f778ca9d8c781763567fddcfe38803df6ea
7
- data.tar.gz: bad778fbbc15b44635fd72f41694db3a77296e729dc2324871f627ebd9bb6097f77aa6665f44fc347dbf7b187f5f2315e127fabb92cee0af8e57cccd70faa621
6
+ metadata.gz: af9827831127544c74d2ffdad8f2d7f5b3dda6e8f9ca42e0a2635d147b0ef886eb68ed188afde445ef3afa36d575256da07798c087470f7252f6efaa94e64a77
7
+ data.tar.gz: 9aa9459aab5fc8bdb85ef015641688f7f3b91c3c8383cc4ad50dc2000fb7420dc4a122b7da449594a804c62a6596e47d5e692c7d50d68d0288bf324462768090
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.4.1
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- msfrpc-client (1.1.0)
5
- msgpack
6
- rex
4
+ msfrpc-client (1.1.1)
5
+ msgpack (~> 1)
6
+ rex (~> 2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -12,46 +12,46 @@ GEM
12
12
  filesize (0.1.1)
13
13
  jsobfu (0.4.2)
14
14
  rkelly-remix
15
- json (2.0.3)
15
+ json (2.1.0)
16
16
  metasm (1.0.3)
17
- mini_portile2 (2.1.0)
17
+ mini_portile2 (2.2.0)
18
18
  msgpack (1.1.0)
19
- nokogiri (1.7.0.1)
20
- mini_portile2 (~> 2.1.0)
19
+ nokogiri (1.8.0)
20
+ mini_portile2 (~> 2.2.0)
21
21
  rake (12.0.0)
22
- rb-readline-r7 (0.5.2.0)
23
- rex (2.0.10)
22
+ rb-readline (0.5.4)
23
+ rex (2.0.11)
24
24
  filesize
25
25
  jsobfu (~> 0.4.1)
26
26
  json
27
27
  metasm (~> 1.0.2)
28
28
  nokogiri
29
- rb-readline-r7
29
+ rb-readline
30
30
  robots
31
31
  rkelly-remix (0.0.7)
32
32
  robots (0.10.1)
33
- rspec (3.5.0)
34
- rspec-core (~> 3.5.0)
35
- rspec-expectations (~> 3.5.0)
36
- rspec-mocks (~> 3.5.0)
37
- rspec-core (3.5.4)
38
- rspec-support (~> 3.5.0)
39
- rspec-expectations (3.5.0)
33
+ rspec (3.6.0)
34
+ rspec-core (~> 3.6.0)
35
+ rspec-expectations (~> 3.6.0)
36
+ rspec-mocks (~> 3.6.0)
37
+ rspec-core (3.6.0)
38
+ rspec-support (~> 3.6.0)
39
+ rspec-expectations (3.6.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.5.0)
42
- rspec-mocks (3.5.0)
41
+ rspec-support (~> 3.6.0)
42
+ rspec-mocks (3.6.0)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.5.0)
45
- rspec-support (3.5.0)
44
+ rspec-support (~> 3.6.0)
45
+ rspec-support (3.6.0)
46
46
 
47
47
  PLATFORMS
48
48
  ruby
49
49
 
50
50
  DEPENDENCIES
51
- bundler
51
+ bundler (~> 1)
52
52
  msfrpc-client!
53
- rake
54
- rspec
53
+ rake (~> 12)
54
+ rspec (~> 3)
55
55
 
56
56
  BUNDLED WITH
57
- 1.14.6
57
+ 1.15.1
@@ -19,9 +19,8 @@ rpc = Msf::RPC::Client.new(opts)
19
19
 
20
20
  $stdout.puts "[*] The RPC client is available in variable 'rpc'"
21
21
  if rpc.token
22
- $stdout.puts "[*] Sucessfully authenticated to the server"
22
+ $stdout.puts "[*] Sucessfully authenticated to the server"
23
23
  end
24
24
 
25
25
  $stdout.puts "[*] Starting IRB shell..."
26
26
  Rex::Ui::Text::IrbShell.new(binding).run
27
-
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ require 'msfrpc-client'
5
+ require 'rex/ui'
6
+
7
+ def usage(ropts)
8
+ $stderr.puts ropts
9
+
10
+ if @rpc and @rpc.token
11
+ wspaces = @rpc.call("pro.workspaces") rescue {}
12
+ if wspaces.keys.length > 0
13
+ $stderr.puts "Active Projects:"
14
+ wspaces.each_pair do |k,v|
15
+ $stderr.puts "\t#{k}"
16
+ end
17
+ end
18
+ end
19
+ $stderr.puts ""
20
+ exit(1)
21
+ end
22
+
23
+ opts = {}
24
+
25
+ # Parse script-specific options
26
+ parser = Msf::RPC::Client.option_parser(opts)
27
+ parser.separator('Discover Mandatory Options:')
28
+
29
+ parser.on("--project PROJECT") do |x|
30
+ opts[:project] = x
31
+ end
32
+
33
+ parser.on("--targets TARGETS") do |x|
34
+ opts[:targets] = [x]
35
+ end
36
+
37
+ parser.on("--blacklist BLACKLIST (optional)") do |x|
38
+ opts[:blacklist] = x
39
+ end
40
+
41
+ parser.on("--speed SPEED (optional)") do |x|
42
+ opts[:speed] = x
43
+ end
44
+
45
+ parser.on("--extra-ports PORTS (optional)") do |x|
46
+ opts[:extra_ports] = x
47
+ end
48
+
49
+ parser.on("--blacklist-ports PORTS (optional)") do |x|
50
+ opts[:blacklist_ports] = x
51
+ end
52
+
53
+ parser.on("--custom-ports PORTS (optional)") do |x|
54
+ opts[:custom_ports] = x
55
+ end
56
+
57
+ parser.on("--portscan-timeout TIMEOUT (optional)") do |x|
58
+ opts[:portscan_timeout] = x
59
+ end
60
+
61
+ parser.on("--source-port PORT (optional)") do |x|
62
+ opts[:source_port] = x
63
+ end
64
+
65
+ parser.on("--custom-nmap-options OPTIONS (optional)") do |x|
66
+ opts[:custom_nmap_options] = x
67
+ end
68
+
69
+ parser.on("--disable-udp-probes (optional)") do
70
+ opts[:disable_udp_probes] = true
71
+ end
72
+
73
+ parser.on("--disable-finger-users (optional)") do
74
+ opts[:disable_finger_users] = true
75
+ end
76
+
77
+ parser.on("--disable-snmp-scan (optional)") do
78
+ opts[:disable_snmp_scan] = true
79
+ end
80
+
81
+ parser.on("--disable-service-identification (optional)") do
82
+ opts[:disable_service_identification] = true
83
+ end
84
+
85
+ parser.on("--smb-user USER (optional)") do |x|
86
+ opts[:smb_user] = x
87
+ end
88
+
89
+ parser.on("--smb-pass PASS (optional)") do |x|
90
+ opts[:smb_pass] = x
91
+ end
92
+
93
+ parser.on("--smb-domain DOMAIN (optional)") do |x|
94
+ opts[:smb_domain] = x
95
+ end
96
+
97
+ parser.on("--dry-run (optional)") do
98
+ opts[:dry_run] = true
99
+ end
100
+
101
+ parser.on("--single-scan (optional)") do
102
+ opts[:single_scan] = true
103
+ end
104
+
105
+ parser.on("--fast-detect (optional)") do
106
+ opts[:fast_detect] = true
107
+ end
108
+
109
+ parser.on("--help") do
110
+ $stderr.puts parser
111
+ exit(1)
112
+ end
113
+
114
+ parser.separator('')
115
+ parser.parse!(ARGV)
116
+
117
+ @rpc = Msf::RPC::Client.new(opts)
118
+
119
+ if not @rpc.token
120
+ $stderr.puts "Error: Invalid RPC server options specified"
121
+ $stderr.puts parser
122
+ exit(1)
123
+ end
124
+
125
+ # Provide default values for certain options - If there's no alternative set
126
+ # use the default provided by Pro -- see the documentation.
127
+ project = opts[:project] || usage(parser)
128
+ targets = opts[:targets] || usage(parser)
129
+ blacklist = opts[:blacklist]
130
+ speed = opts[:speed] || "5"
131
+ extra_ports = opts[:extra_ports]
132
+ blacklist_ports = opts[:blacklist_ports]
133
+ custom_ports = opts[:custom_ports]
134
+ portscan_timeout = opts[:portscan_timeout] || 300
135
+ source_port = opts[:source_port]
136
+ custom_nmap_options = opts[:custom_nmap_options] ||
137
+ disable_udp_probes = opts[:disable_udp_probes] || false
138
+ disable_finger_users = opts[:disable_finger_users] || false
139
+ disable_snmp_scan = opts[:disable_snmp_scan] || false
140
+ disable_service_identification = opts[:disable_service_identification] || false
141
+ smb_user = opts[:smb_user] || ""
142
+ smb_pass = opts[:smb_pass] || ""
143
+ smb_domain = opts[:smb_domain] || ""
144
+ single_scan = opts[:single_scan] || false
145
+ fast_detect = opts[:fast_detect] || false
146
+
147
+ # Get the default user from Pro
148
+ user = @rpc.call("pro.default_admin_user")['username']
149
+
150
+ # Create the task object with all options
151
+ task = @rpc.call("pro.start_discover", {
152
+ 'workspace' => project,
153
+ 'username' => user,
154
+ 'ips' => targets,
155
+ 'DS_BLACKLIST_HOSTS' => blacklist,
156
+ 'DS_PORTSCAN_SPEED' => speed,
157
+ 'DS_PORTS_EXTRA' => extra_ports,
158
+ 'DS_PORTS_BLACKLIST' => blacklist_ports,
159
+ 'DS_PORTS_CUSTOM' => custom_ports,
160
+ 'DS_PORTSCAN_TIMEOUT' => portscan_timeout,
161
+ 'DS_PORTSCAN_SOURCE_PORT' => source_port,
162
+ 'DS_CustomNmap' => custom_nmap_options,
163
+ 'DS_UDP_PROBES' => disable_udp_probes,
164
+ 'DS_FINGER_USERS' => disable_finger_users,
165
+ 'DS_SNMP_SCAN' => disable_snmp_scan,
166
+ 'DS_IDENTIFY_SERVICES' => disable_service_identification,
167
+ 'DS_SMBUser' => smb_user,
168
+ 'DS_SMBPass' => smb_pass,
169
+ 'DS_SMBDomain' => smb_domain,
170
+ 'DS_SINGLE_SCAN' => single_scan,
171
+ 'DS_FAST_DETECT' => fast_detect
172
+ })
173
+
174
+ puts "DEBUG: Running task with #{task.inspect}"
175
+
176
+ if not task['task_id']
177
+ $stderr.puts "[-] Error starting the task: #{task.inspect}"
178
+ exit(0)
179
+ end
180
+
181
+ puts "[*] Creating Task ID #{task['task_id']}..."
182
+ while true
183
+ select(nil, nil, nil, 0.50)
184
+
185
+ stat = @rpc.call("pro.task_status", task['task_id'])
186
+
187
+ if stat['status'] == 'invalid'
188
+ $stderr.puts "[-] Error checking task status"
189
+ exit(0)
190
+ end
191
+
192
+ info = stat[ task['task_id'] ]
193
+
194
+ if not info
195
+ $stderr.puts "[-] Error finding the task"
196
+ exit(0)
197
+ end
198
+
199
+ if info['status'] == "error"
200
+ $stderr.puts "[-] Error generating report: #{info['error']}"
201
+ exit(0)
202
+ end
203
+
204
+ break if info['progress'] == 100
205
+ end
206
+
207
+ $stdout.puts "[+] Task Complete!"
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ require 'msfrpc-client'
5
+ require 'rex/ui'
6
+
7
+ def usage(ropts)
8
+ $stderr.puts ropts
9
+
10
+ if @rpc and @rpc.token
11
+ wspaces = @rpc.call("pro.workspaces") rescue {}
12
+ if wspaces.keys.length > 0
13
+ $stderr.puts "Active Projects:"
14
+ wspaces.each_pair do |k,v|
15
+ $stderr.puts "\t#{k}"
16
+ end
17
+ end
18
+ end
19
+ $stderr.puts ""
20
+ exit(1)
21
+ end
22
+
23
+ opts = {}
24
+ opts[:blacklist] = ''
25
+ opts[:whitelist_ports] = ''
26
+ opts[:blacklist_ports] = ''
27
+ opts[:exploit_timeout] = 5
28
+ opts[:limit_sessions] = true
29
+ opts[:ignore_fragile_devices] = true
30
+ opts[:filter_by_os] = true
31
+ opts[:only_match] = false
32
+ opts[:match_vulns] = true
33
+ opts[:match_ports] = true
34
+ opts[:payload_method] = "auto"
35
+ opts[:payload_type] = "meterpreter"
36
+ opts[:payload_ports] = "4000-5000"
37
+ opts[:evasion_level_tcp] = 0
38
+ opts[:evasion_level_app] = 0
39
+ opts[:module_filter] = ''
40
+
41
+ # Parse script-specific options
42
+ parser = Msf::RPC::Client.option_parser(opts)
43
+ parser.separator('Exploit Specific Options:')
44
+
45
+ parser.on("--project PROJECT") do |x|
46
+ opts[:project] = x
47
+ end
48
+
49
+ parser.on("--targets TARGETS") do |x|
50
+ opts[:targets] = x
51
+ end
52
+
53
+ parser.on("--speed SPEED") do |x|
54
+ opts[:speed] = x
55
+ end
56
+
57
+ parser.on("--minimum-rank RANK") do |x|
58
+ opts[:rank] = x
59
+ end
60
+
61
+ parser.on("--blacklist BLACKLIST (optional)") do |x|
62
+ opts[:blacklist] = x
63
+ end
64
+
65
+ parser.on("--whitelist-ports PORTS (optional)") do |x|
66
+ opts[:whitelist_ports] = x
67
+ end
68
+
69
+ parser.on("--blacklist-ports PORTS (optional)") do |x|
70
+ opts[:blacklist_ports] = x
71
+ end
72
+
73
+ parser.on("--exploit-timeout TIMEOUT (optional)") do |x|
74
+ opts[:exploit_timeout] = x
75
+ end
76
+
77
+ parser.on("--limit-sessions (optional)") do |x|
78
+ opts[:limit_sessions] = (x =~ /^(y|t|1)/i ? true : false )
79
+ end
80
+
81
+ parser.on("--ignore-fragile-devices (optional)") do |x|
82
+ opts[:ignore_fragile_devices] = (x =~ /^(y|t|1)/i ? true : false )
83
+ end
84
+
85
+ parser.on("--filter-by-os (optional)") do |x|
86
+ opts[:filter_by_os] = (x =~ /^(y|t|1)/i ? true : false )
87
+ end
88
+
89
+ parser.on("--dry-run (optional)") do |x|
90
+ opts[:only_match] = (x =~ /^(y|t|1)/i ? true : false )
91
+ end
92
+
93
+ parser.on("--match-vulns (optional)") do |x|
94
+ opts[:match_vulns] = (x =~ /^(y|t|1)/i ? true : false )
95
+ end
96
+
97
+ parser.on("--match-ports (optional)") do |x|
98
+ opts[:match_ports] = (x =~ /^(y|t|1)/i ? true : false )
99
+ end
100
+
101
+ parser.on("--payload-method AUTO|REVERSE|BIND (optional)") do |x|
102
+ opts[:payload_method] = x
103
+ end
104
+
105
+ parser.on("--payload-type METERPRETER|SHELL (optional)") do |x|
106
+ opts[:payload_type] = x
107
+ end
108
+
109
+ parser.on("--payload-ports PORTS (optional)") do |x|
110
+ opts[:payload_ports] = x
111
+ end
112
+
113
+ parser.on("--evasion-level-tcp LEVEL (optional)") do |x|
114
+ opts[:evasion_level_tcp] = x
115
+ end
116
+
117
+ parser.on("--evasion-level-app LEVEL (optional)") do |x|
118
+ opts[:evasion_level_app] = x
119
+ end
120
+
121
+ parser.on("--module-filter FILTER (optional)") do |x|
122
+ opts[:module_filter] = x
123
+ end
124
+
125
+ parser.on("--help") do
126
+ $stderr.puts parser
127
+ exit(1)
128
+ end
129
+
130
+ parser.separator('')
131
+ parser.parse!(ARGV)
132
+
133
+ @rpc = Msf::RPC::Client.new(opts)
134
+
135
+ if not @rpc.token
136
+ $stderr.puts "Error: Invalid RPC server options specified"
137
+ $stderr.puts parser
138
+ exit(1)
139
+ end
140
+
141
+ # Store the user's settings
142
+ project = opts[:project] || usage(parser)
143
+ targets = opts[:targets] || usage(parser)
144
+ rank = opts[:rank] || usage(parser)
145
+ speed = opts[:speed] || usage(parser)
146
+ blacklist = opts[:blacklist]
147
+ whitelist_ports = opts[:whitelist_ports]
148
+ blacklist_ports = opts[:blacklist_ports]
149
+ exploit_timeout = opts[:exploit_timeout]
150
+ limit_sessions = opts[:limit_sessions]
151
+ ignore_fragile_devices = opts[:ignore_fragile_devices]
152
+ filter_by_os = opts[:filter_by_os]
153
+ only_match = opts[:only_match]
154
+ match_vulns = opts[:match_vulns]
155
+ match_ports = opts[:match_ports]
156
+ payload_method = opts[:payload_method]
157
+ payload_type = opts[:payload_type]
158
+ payload_ports = opts[:payload_ports]
159
+ evasion_level_tcp = opts[:evasion_level_tcp]
160
+ evasion_level_app = opts[:evasion_level_app]
161
+ module_filter = opts[:module_filter]
162
+ #===
163
+
164
+ # Get the default user
165
+ user = @rpc.call("pro.default_admin_user")['username']
166
+
167
+ # Create the task object with all options
168
+ task = @rpc.call("pro.start_exploit", {
169
+ 'workspace' => project,
170
+ 'username' => user,
171
+ 'DS_WHITELIST_HOSTS' => targets,
172
+ 'DS_BLACKLIST_HOSTS' => blacklist,
173
+ 'DS_WHITELIST_PORTS' => whitelist_ports,
174
+ 'DS_BLACKLIST_PORTS' => blacklist_ports,
175
+ 'DS_MinimumRank' => rank,
176
+ 'DS_EXPLOIT_SPEED' => speed,
177
+ 'DS_EXPLOIT_TIMEOUT' => exploit_timeout,
178
+ 'DS_LimitSessions' => limit_sessions,
179
+ 'DS_IgnoreFragileDevices' => ignore_fragile_devices,
180
+ 'DS_FilterByOS' => filter_by_os,
181
+ 'DS_OnlyMatch' => only_match,
182
+ 'DS_MATCH_VULNS' => match_vulns,
183
+ 'DS_MATCH_PORTS' => match_ports,
184
+ 'DS_PAYLOAD_METHOD' => payload_method,
185
+ 'DS_PAYLOAD_TYPE' => payload_type,
186
+ 'DS_PAYLOAD_PORTS' => payload_ports,
187
+ 'DS_EVASION_LEVEL_TCP' => evasion_level_tcp,
188
+ 'DS_EVASION_LEVEL_APP' => evasion_level_app,
189
+ 'DS_ModuleFilter' => module_filter
190
+ })
191
+
192
+ puts "DEBUG: Running task with #{task.inspect}"
193
+
194
+ if not task['task_id']
195
+ $stderr.puts "[-] Error starting the task: #{task.inspect}"
196
+ exit(0)
197
+ end
198
+
199
+ puts "[*] Creating Task ID #{task['task_id']}..."
200
+ while true
201
+ select(nil, nil, nil, 0.50)
202
+
203
+ stat = @rpc.call("pro.task_status", task['task_id'])
204
+
205
+ if stat['status'] == 'invalid'
206
+ $stderr.puts "[-] Error checking task status"
207
+ exit(0)
208
+ end
209
+
210
+ info = stat[ task['task_id'] ]
211
+
212
+ if not info
213
+ $stderr.puts "[-] Error finding the task"
214
+ exit(0)
215
+ end
216
+
217
+ if info['status'] == "error"
218
+ $stderr.puts "[-] Error generating report: #{info['error']}"
219
+ exit(0)
220
+ end
221
+
222
+ break if info['progress'] == 100
223
+ end
224
+
225
+ $stdout.puts "[+] Task Complete!"