ronin 1.4.1 → 1.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.document +1 -0
  2. data/.gitignore +1 -0
  3. data/ChangeLog.md +38 -1
  4. data/Gemfile +10 -10
  5. data/README.md +1 -1
  6. data/Rakefile +13 -2
  7. data/bin/ronin-net-proxy +25 -0
  8. data/gemspec.yml +21 -2
  9. data/lib/bond/completions/ronin.rb +16 -5
  10. data/lib/ronin/arch.rb +5 -5
  11. data/lib/ronin/auto_load.rb +22 -1
  12. data/lib/ronin/campaign.rb +1 -1
  13. data/lib/ronin/database/database.rb +36 -25
  14. data/lib/ronin/installation.rb +2 -2
  15. data/lib/ronin/model/model.rb +5 -6
  16. data/lib/ronin/model/types/description.rb +0 -3
  17. data/lib/ronin/os.rb +2 -2
  18. data/lib/ronin/password.rb +1 -1
  19. data/lib/ronin/repository.rb +6 -6
  20. data/lib/ronin/script/path.rb +1 -2
  21. data/lib/ronin/spec/database.rb +16 -4
  22. data/lib/ronin/ui/cli/cli.rb +1 -1
  23. data/lib/ronin/ui/cli/command.rb +50 -7
  24. data/lib/ronin/ui/cli/commands/console.rb +15 -6
  25. data/lib/ronin/ui/cli/commands/creds.rb +1 -1
  26. data/lib/ronin/ui/cli/commands/database.rb +41 -29
  27. data/lib/ronin/ui/cli/commands/emails.rb +20 -15
  28. data/lib/ronin/ui/cli/commands/help.rb +18 -5
  29. data/lib/ronin/ui/cli/commands/hosts.rb +34 -27
  30. data/lib/ronin/ui/cli/commands/install.rb +21 -4
  31. data/lib/ronin/ui/cli/commands/ips.rb +34 -23
  32. data/lib/ronin/ui/cli/commands/net/proxy.rb +403 -0
  33. data/lib/ronin/ui/cli/commands/repos.rb +4 -4
  34. data/lib/ronin/ui/cli/commands/uninstall.rb +10 -0
  35. data/lib/ronin/ui/cli/commands/update.rb +11 -1
  36. data/lib/ronin/ui/cli/commands/urls.rb +39 -30
  37. data/lib/ronin/ui/cli/commands/wordlist.rb +11 -1
  38. data/lib/ronin/ui/console.rb +1 -0
  39. data/lib/ronin/ui/console/commands.rb +16 -98
  40. data/lib/ronin/ui/console/shell.rb +184 -0
  41. data/lib/ronin/url.rb +3 -3
  42. data/lib/ronin/url_scheme.rb +3 -3
  43. data/lib/ronin/version.rb +1 -1
  44. data/man/ronin-campaigns.1.md +78 -0
  45. data/man/ronin-console.1.md +72 -0
  46. data/man/ronin-creds.1.md +66 -0
  47. data/man/ronin-database.1.md +82 -0
  48. data/man/ronin-emails.1.md +72 -0
  49. data/man/ronin-exec.1.md +49 -0
  50. data/man/ronin-help.1.md +34 -0
  51. data/man/ronin-hosts.1.md +78 -0
  52. data/man/ronin-install.1.md +79 -0
  53. data/man/ronin-ips.1.md +81 -0
  54. data/man/ronin-net-proxy.1.md +86 -0
  55. data/man/ronin-repos.1.md +77 -0
  56. data/man/ronin-uninstall.1.md +67 -0
  57. data/man/ronin-update.1.md +67 -0
  58. data/man/ronin-urls.1.md +84 -0
  59. data/man/ronin-wordlist.1.md +53 -0
  60. data/man/ronin.1.md +26 -0
  61. data/ronin.gemspec +38 -109
  62. data/spec/installation_spec.rb +2 -1
  63. data/spec/spec_helper.rb +2 -0
  64. data/spec/ui/cli/classes/test_command.rb +7 -0
  65. data/spec/ui/cli/command_spec.rb +235 -7
  66. metadata +217 -96
@@ -19,6 +19,7 @@
19
19
 
20
20
  require 'ronin/ui/cli/command'
21
21
  require 'ronin/ui/cli/cli'
22
+ require 'ronin/installation'
22
23
 
23
24
  module Ronin
24
25
  module UI
@@ -47,7 +48,7 @@ module Ronin
47
48
 
48
49
  summary 'Displays the list of available commands or prints information on a specific command'
49
50
 
50
- argument :command, :type => Symbol,
51
+ argument :command, :type => String,
51
52
  :description => 'The command to display'
52
53
 
53
54
  #
@@ -55,11 +56,23 @@ module Ronin
55
56
  #
56
57
  def execute
57
58
  if command?
58
- begin
59
- CLI.command(@command).start(['--help'])
60
- rescue UnknownCommand
61
- print_error "unknown command: #{@command}"
59
+ unless CLI.commands.include?(command)
60
+ print_error "Unknown command: #{command.dump}"
61
+ return false
62
62
  end
63
+
64
+ man_page = "ronin-#{command.tr(':','-')}.1"
65
+
66
+ Installation.paths.each do |path|
67
+ man_path = File.join(path,'man',man_page)
68
+
69
+ if File.file?(man_path)
70
+ return system('man',man_path)
71
+ end
72
+ end
73
+
74
+ print_error "No man-page for the command: #{@command}"
75
+ return false
63
76
  else
64
77
  print_array CLI.commands, :title => 'Available commands'
65
78
  end
@@ -56,33 +56,40 @@ module Ronin
56
56
 
57
57
  summary 'Manages HostNames'
58
58
 
59
- query_option :with_ips, :type => Array,
60
- :flag => '-I',
61
- :usage => 'IP [...]'
62
-
63
- query_option :with_ports, :type => Array[Integer],
64
- :flag => '-p',
65
- :usage => 'PORT [...]'
66
-
67
- query_option :domain, :type => String,
68
- :flag => '-D',
69
- :usage => 'DOMAIN'
70
-
71
- query_option :tld, :type => String,
72
- :flag => '-T',
73
- :usage => 'TLD'
74
-
75
- option :list, :type => true,
76
- :default => true,
77
- :flag => '-l'
78
-
79
- option :lookup, :type => String,
80
- :flag => '-L',
81
- :usage => 'IP'
82
-
83
- option :import, :type => String,
84
- :flag => '-i',
85
- :usage => 'FILE'
59
+ query_option :with_ips, :type => Array,
60
+ :flag => '-I',
61
+ :usage => 'IP [...]',
62
+ :description => 'Searches for the associated IP(s)'
63
+
64
+ query_option :with_ports, :type => Array[Integer],
65
+ :flag => '-p',
66
+ :usage => 'PORT [...]',
67
+ :description => 'Searches for the associated PORT(s)'
68
+
69
+ query_option :domain, :type => String,
70
+ :flag => '-D',
71
+ :usage => 'DOMAIN',
72
+ :description => 'Searches for the associated parent DOMAIN'
73
+
74
+ query_option :tld, :type => String,
75
+ :flag => '-T',
76
+ :usage => 'TLD',
77
+ :description => 'Searches for the associated TLD'
78
+
79
+ option :list, :type => true,
80
+ :default => true,
81
+ :flag => '-l',
82
+ :description => 'Lists the HostNames'
83
+
84
+ option :lookup, :type => String,
85
+ :flag => '-L',
86
+ :usage => 'IP',
87
+ :description => 'Looks up HostNames for the IP'
88
+
89
+ option :import, :type => String,
90
+ :flag => '-i',
91
+ :usage => 'FILE',
92
+ :description => 'Imports HostNames from the FILE'
86
93
 
87
94
  #
88
95
  # Queries the {HostName} model.
@@ -46,19 +46,36 @@ module Ronin
46
46
  # ## Arguments
47
47
  #
48
48
  # URI The URI of the Repository
49
+ #
50
+ # ## Examples
51
+ #
52
+ # ronin install git://github.com/user/repo.git
53
+ # ronin install --git git@example.com:/home/secret/repo
49
54
  #
50
55
  class Install < Command
51
56
 
52
57
  summary 'Installs Ronin Repositories'
53
58
 
54
- option :rsync, :type => true
55
- option :svn, :type => true
56
- option :hg, :type => true
57
- option :git, :type => true
59
+ option :rsync, :type => true,
60
+ :description => 'Install via rsync'
61
+
62
+ option :svn, :type => true,
63
+ :description => 'Install via SubVersion (SVN)'
64
+
65
+ option :hg, :type => true,
66
+ :description => 'Install via Mercurial (Hg)'
67
+
68
+ option :git, :type => true,
69
+ :description => 'Install via Git'
58
70
 
59
71
  argument :uri, :type => String,
60
72
  :description => 'The URI of the Repository'
61
73
 
74
+ examples [
75
+ "ronin install git://github.com/user/repo.git",
76
+ "ronin install --git git@example.com:/home/secret/repo"
77
+ ]
78
+
62
79
  #
63
80
  # Sets up the install command.
64
81
  #
@@ -58,32 +58,43 @@ module Ronin
58
58
 
59
59
  summary 'Manages IPAddresses'
60
60
 
61
- query_option :v4, :type => true, :flag => '-4'
62
- query_option :v6, :type => true, :flag => '-6'
63
-
64
- query_option :with_ports, :type => Array[Integer],
65
- :flag => '-p',
66
- :usage => 'PORT [...]'
67
-
68
- query_option :with_macs, :type => Array,
69
- :flag => '-M',
70
- :usage => 'MAC [...]'
71
-
72
- query_option :with_hosts, :type => Array,
73
- :flag => '-H',
74
- :usage => 'HOST [...]'
75
-
76
- option :list, :type => true,
77
- :default => true,
78
- :aliases => '-l'
79
-
80
- option :lookup, :type => String,
81
- :flag => '-L',
82
- :usage => 'HOST'
61
+ query_option :v4, :type => true,
62
+ :flag => '-4',
63
+ :description => 'Searches for IPv4 addresses'
64
+
65
+ query_option :v6, :type => true,
66
+ :flag => '-6',
67
+ :description => 'Searches for IPv6 addresses'
68
+
69
+ query_option :with_ports, :type => Array[Integer],
70
+ :flag => '-p',
71
+ :usage => 'PORT [...]',
72
+ :description => 'Searches for the associated PORT(s)'
73
+
74
+ query_option :with_macs, :type => Array,
75
+ :flag => '-M',
76
+ :usage => 'MAC [...]',
77
+ :description => 'Searches for the associated MAC address(es)'
78
+
79
+ query_option :with_hosts, :type => Array,
80
+ :flag => '-H',
81
+ :usage => 'HOST [...]',
82
+ :description => 'Searches for the associated HOST(s)'
83
+
84
+ option :list, :type => true,
85
+ :default => true,
86
+ :flag => '-l',
87
+ :description => 'Lists the IP addresses'
88
+
89
+ option :lookup, :type => String,
90
+ :flag => '-L',
91
+ :usage => 'HOST',
92
+ :description => 'Looks up the IP addresses for the HOST'
83
93
 
84
94
  option :import, :type => String,
85
95
  :flag => '-i',
86
- :usage => 'FILE'
96
+ :usage => 'FILE',
97
+ :description => 'Imports IP addresses from the FILE'
87
98
 
88
99
  #
89
100
  # Queries the {IPAddress} model.
@@ -0,0 +1,403 @@
1
+ #
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ #
4
+ # This file is part of Ronin.
5
+ #
6
+ # Ronin is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Ronin is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'ronin/ui/cli/command'
21
+ require 'ronin/network/tcp/proxy'
22
+ require 'ronin/network/udp/proxy'
23
+
24
+ require 'hexdump/dumper'
25
+
26
+ module Ronin
27
+ module UI
28
+ module CLI
29
+ module Commands
30
+ module Net
31
+ #
32
+ # Starts a TCP/UDP intercept proxy.
33
+ #
34
+ # ## Usage
35
+ #
36
+ # ronin net:proxy [options]
37
+ #
38
+ # ## Options
39
+ #
40
+ # -v, --[no-]verbose Enable verbose output.
41
+ # -q, --[no-]quiet Disable verbose output.
42
+ # --[no-]silent Silence all output.
43
+ # --[no-]color Enables color output.
44
+ # Default: true
45
+ # -t, --[no-]tcp TCP Proxy.
46
+ # Default: true
47
+ # -u, --[no-]udp UDP Proxy.
48
+ # -x, --[no-]hexdump Enable hexdump output.
49
+ # -H, --host [HOST] Host to listen on.
50
+ # Default: "0.0.0.0"
51
+ # -p, --port [PORT] Port to listen on.
52
+ # -s, --server [HOST[:PORT]] Server to forward connections to.
53
+ # -r, --rewrite [/REGEXP/:STRING] Rewrite rules.
54
+ # --rewrite-client [/REGEXP/:STRING]
55
+ # Client rewrite rules.
56
+ # --rewrite-server [/REGEXP/:STRING]
57
+ # Server rewrite rules.
58
+ # -i, --ignore [/REGEXP/ [...]] Ignore rules.
59
+ # --ignore-client [/REGEXP/ [...]]
60
+ # Client ignore rules.
61
+ # --ignore-server [/REGEXP/ [...]]
62
+ # Server ignore rules.
63
+ # -C, --close [/REGEXP/ [...]] Close rules.
64
+ # --close-client [/REGEXP/ [...]]
65
+ # Client close rules.
66
+ # --close-server [/REGEXP/ [...]]
67
+ # Server close rules.
68
+ # -R, --reset [/REGEXP/ [...]] Reset rules.
69
+ # --reset-client [/REGEXP/ [...]]
70
+ # Client reset rules.
71
+ # --reset-server [/REGEXP/ [...]]
72
+ # Server reset rules.
73
+ #
74
+ # @since 1.5.0
75
+ #
76
+ class Proxy < Command
77
+
78
+ summary 'Starts a TCP/UDP intercept proxy'
79
+
80
+ option :tcp, :type => true,
81
+ :default => true,
82
+ :flag => '-t',
83
+ :description => 'TCP Proxy'
84
+
85
+ option :udp, :type => true,
86
+ :flag => '-u',
87
+ :description => 'UDP Proxy'
88
+
89
+ option :hexdump, :type => true,
90
+ :flag => '-x',
91
+ :description => 'Enable hexdump output'
92
+
93
+ option :host, :type => String,
94
+ :default => Network::Proxy::DEFAULT_HOST,
95
+ :flag => '-H',
96
+ :usage => 'HOST',
97
+ :description => 'Host to listen on'
98
+
99
+ option :port, :type => Integer,
100
+ :flag => '-p',
101
+ :usage => 'PORT',
102
+ :description => 'Port to listen on'
103
+
104
+ option :server, :type => String,
105
+ :flag => '-s',
106
+ :usage => 'HOST[:PORT]',
107
+ :description => 'Server to forward connections to'
108
+
109
+ option :rewrite, :type => Hash[Regexp => String],
110
+ :flag => '-r',
111
+ :usage => '/REGEXP/:STRING',
112
+ :description => 'Rewrite rules'
113
+
114
+ option :rewrite_client, :type => Hash[Regexp => String],
115
+ :usage => '/REGEXP/:STRING',
116
+ :description => 'Client rewrite rules'
117
+
118
+ option :rewrite_server, :type => Hash[Regexp => String],
119
+ :usage => '/REGEXP/:STRING',
120
+ :description => 'Server rewrite rules'
121
+
122
+ option :ignore, :type => Set[Regexp],
123
+ :flag => '-i',
124
+ :usage => '/REGEXP/ [...]',
125
+ :description => 'Ignore rules'
126
+
127
+ option :ignore_client, :type => Set[Regexp],
128
+ :usage => '/REGEXP/ [...]',
129
+ :description => 'Client ignore rules'
130
+
131
+ option :ignore_server, :type => Set[String],
132
+ :usage => '/REGEXP/ [...]',
133
+ :description => 'Server ignore rules'
134
+
135
+ option :close, :type => Set[Regexp],
136
+ :flag => '-C',
137
+ :usage => '/REGEXP/ [...]',
138
+ :description => 'Close rules'
139
+
140
+ option :close_client, :type => Set[Regexp],
141
+ :usage => '/REGEXP/ [...]',
142
+ :description => 'Client close rules'
143
+
144
+ option :close_server, :type => Set[Regexp],
145
+ :usage => '/REGEXP/ [...]',
146
+ :description => 'Server close rules'
147
+
148
+ option :reset, :type => Set[Regexp],
149
+ :flag => '-R',
150
+ :usage => '/REGEXP/ [...]',
151
+ :description => 'Reset rules'
152
+
153
+ option :reset_client, :type => Set[Regexp],
154
+ :usage => '/REGEXP/ [...]',
155
+ :description => 'Client reset rules'
156
+
157
+ option :reset_server, :type => Set[Regexp],
158
+ :usage => '/REGEXP/ [...]',
159
+ :description => 'Server reset rules'
160
+
161
+ #
162
+ # Sets up the proxy command.
163
+ #
164
+ def setup
165
+ super
166
+
167
+ unless server?
168
+ print_error "Must specify the SERVER argument"
169
+ exit -1
170
+ end
171
+
172
+ @server_host, @server_port = server.split(':',2)
173
+ @server_port = if @server_port
174
+ @server_port.to_i
175
+ end
176
+
177
+ if hexdump?
178
+ @hexdumper = Hexdump::Dumper.new
179
+ end
180
+ end
181
+
182
+ #
183
+ # Executes the proxy command.
184
+ #
185
+ def execute
186
+ @proxy = proxy_class.new(
187
+ :port => @port,
188
+ :host => @host,
189
+ :server => [@server_host, @server_port]
190
+ )
191
+
192
+ if tcp?
193
+ @proxy.on_client_connect do |client|
194
+ print_outgoing client, '[connecting]'
195
+ end
196
+
197
+ @proxy.on_client_disconnect do |client,server|
198
+ print_outgoing client, '[disconnecting]'
199
+ end
200
+
201
+ @proxy.on_server_connect do |client,server|
202
+ print_incoming client, '[connected]'
203
+ end
204
+
205
+ @proxy.on_server_disconnect do |client,server|
206
+ print_incoming client, '[disconnected]'
207
+ end
208
+ end
209
+
210
+ if @reset_client
211
+ @reset_client.each do |pattern|
212
+ @proxy.on_client_data do |client,server,data|
213
+ @proxy.reset! if data =~ pattern
214
+ end
215
+ end
216
+ end
217
+
218
+ if @close_client
219
+ @close_client.each do |pattern|
220
+ @proxy.on_client_data do |client,server,data|
221
+ @proxy.close! if data =~ pattern
222
+ end
223
+ end
224
+ end
225
+
226
+ if @ignore_client
227
+ @ignore_client.each do |pattern|
228
+ @proxy.on_client_data do |client,server,data|
229
+ @proxy.ignore! if data =~ pattern
230
+ end
231
+ end
232
+ end
233
+
234
+ if @rewrite_client
235
+ @rewrite_client.each do |pattern,replace|
236
+ @proxy.on_client_data do |client,server,data|
237
+ data.gsub!(pattern,replace)
238
+ end
239
+ end
240
+ end
241
+
242
+ if @reset_server
243
+ @reset_server.each do |pattern|
244
+ @proxy.on_server_data do |client,server,data|
245
+ @proxy.reset! if data =~ pattern
246
+ end
247
+ end
248
+ end
249
+
250
+ if @close_server
251
+ @close_server.each do |pattern|
252
+ @proxy.on_server_data do |client,server,data|
253
+ @proxy.close! if data =~ pattern
254
+ end
255
+ end
256
+ end
257
+
258
+ if @ignore_server
259
+ @ignore_server.each do |pattern|
260
+ @proxy.on_server_data do |client,server,data|
261
+ @proxy.ignore! if data =~ pattern
262
+ end
263
+ end
264
+ end
265
+
266
+ if @rewrite_server
267
+ @rewrite_server.each do |pattern,replace|
268
+ @proxy.on_server_data do |client,server,data|
269
+ data.gsub!(pattern,replace)
270
+ end
271
+ end
272
+ end
273
+
274
+ if @reset
275
+ @reset.each do |pattern|
276
+ @proxy.on_data do |client,server,data|
277
+ @proxy.reset! if data =~ pattern
278
+ end
279
+ end
280
+ end
281
+
282
+ if @close
283
+ @close.each do |pattern|
284
+ @proxy.on_data do |client,server,data|
285
+ @proxy.close! if data =~ pattern
286
+ end
287
+ end
288
+ end
289
+
290
+ if @ignore
291
+ @ignore.each do |pattern|
292
+ @proxy.on_data do |client,server,data|
293
+ @proxy.ignore! if data =~ pattern
294
+ end
295
+ end
296
+ end
297
+
298
+ if @rewrite
299
+ @rewrite.each do |pattern,replace|
300
+ @proxy.on_data do |client,server,data|
301
+ data.gsub!(pattern,replace)
302
+ end
303
+ end
304
+ end
305
+
306
+ @proxy.on_client_data do |client,server,data|
307
+ print_outgoing client
308
+ print_data data
309
+ end
310
+
311
+ @proxy.on_server_data do |client,server,data|
312
+ print_incoming client
313
+ print_data data
314
+ end
315
+
316
+ @proxy.start
317
+ end
318
+
319
+ protected
320
+
321
+ #
322
+ # Determines the Proxy class based on the `--tcp` or `--udp`
323
+ # options.
324
+ #
325
+ # @return [Network::TCP::Proxy, Network::UDP::Proxy]
326
+ # The proxy class.
327
+ #
328
+ def proxy_class
329
+ if udp?
330
+ Network::UDP::Proxy
331
+ elsif tcp?
332
+ Network::TCP::Proxy
333
+ end
334
+ end
335
+
336
+ #
337
+ # Returns the address for the connection.
338
+ #
339
+ # @param [(UDPSocket,(host, port)), TCPSocket, UDPSocket] connection
340
+ # The connection.
341
+ #
342
+ # @return [String]
343
+ # The address of the connection.
344
+ #
345
+ def address(connection)
346
+ case connection
347
+ when Array
348
+ socket, (host, port) = connection
349
+
350
+ "#{host}:#{port}"
351
+ when TCPSocket, UDPSocket
352
+ addrinfo = connection.peeraddr
353
+
354
+ "#{addrinfo[3]}:#{addrinfo[1]}"
355
+ end
356
+ end
357
+
358
+ #
359
+ # Prints a connection header for an incoming event.
360
+ #
361
+ # @param [(UDPSocket,(host, port)), TCPSocket, UDPSocket] client
362
+ # The client.
363
+ #
364
+ # @param [String] event
365
+ # The optional name of the event.
366
+ #
367
+ def print_incoming(client,event=nil)
368
+ print_info "#{address(client)} <- #{@proxy} #{event}"
369
+ end
370
+
371
+ #
372
+ # Prints a connection header for an outgoing event.
373
+ #
374
+ # @param [(UDPSocket,(host, port)), TCPSocket, UDPSocket] client
375
+ # The client.
376
+ #
377
+ # @param [String] type
378
+ # The optional name of the event.
379
+ #
380
+ def print_outgoing(client,type=nil)
381
+ print_info "#{address(client)} -> #{@proxy} #{type}"
382
+ end
383
+
384
+ #
385
+ # Prints data from a message.
386
+ #
387
+ # @param [String] data
388
+ # The data from a message.
389
+ #
390
+ def print_data(data)
391
+ if hexdump?
392
+ @hexdumper.dump(data)
393
+ else
394
+ puts data
395
+ end
396
+ end
397
+
398
+ end
399
+ end
400
+ end
401
+ end
402
+ end
403
+ end