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
@@ -67,10 +67,10 @@ module Ronin
67
67
  :usage => 'TITLE',
68
68
  :description => 'Title to filter by'
69
69
 
70
- query_option :describing, :type => String,
71
- :flag => '-d',
72
- :usage => 'DESC',
73
- :desc => 'Description to filter by'
70
+ query_option :describing, :type => String,
71
+ :flag => '-d',
72
+ :usage => 'DESC',
73
+ :description => 'Description to filter by'
74
74
 
75
75
  query_option :licensed_under, :type => String,
76
76
  :flag => '-L',
@@ -43,6 +43,11 @@ module Ronin
43
43
  #
44
44
  # REPO Repository to uninstall
45
45
  #
46
+ # ## Examples
47
+ #
48
+ # ronin uninstall repo
49
+ # ronin uninstall repo@github.com
50
+ #
46
51
  class Uninstall < Command
47
52
 
48
53
  summary 'Uninstalls Ronin Repositories'
@@ -50,6 +55,11 @@ module Ronin
50
55
  argument :repo, :type => String,
51
56
  :description => 'Repository to uninstall'
52
57
 
58
+ examples [
59
+ "ronin uninstall repo",
60
+ "ronin uninstall repo@github.com"
61
+ ]
62
+
53
63
  #
54
64
  # Sets up the install command.
55
65
  #
@@ -43,6 +43,11 @@ module Ronin
43
43
  #
44
44
  # REPO Repository to update
45
45
  #
46
+ # ## Examples
47
+ #
48
+ # ronin update repo
49
+ # ronin update repo@github.com
50
+ #
46
51
  class Update < Command
47
52
 
48
53
  summary 'Updates Ronin Repositories'
@@ -50,6 +55,11 @@ module Ronin
50
55
  argument :repo, :type => String,
51
56
  :description => 'Repository to update'
52
57
 
58
+ examples [
59
+ "ronin update repo",
60
+ "ronin update repo@github.com"
61
+ ]
62
+
53
63
  #
54
64
  # Sets up the install command.
55
65
  #
@@ -94,7 +104,7 @@ module Ronin
94
104
  # @param [Repository] repository
95
105
  # The repository that was updated.
96
106
  #
97
- def print_cache_errors(repo)
107
+ def print_cache_errors(repository)
98
108
  repository.script_paths.each do |script_path|
99
109
  if script_path.cache_exception
100
110
  print_exception script_path.cache_exception
@@ -60,36 +60,45 @@ module Ronin
60
60
 
61
61
  summary 'Manages URLs'
62
62
 
63
- query_option :http, :type => true
64
- query_option :https, :type => true
65
-
66
- query_option :hosts, :type => Array,
67
- :flag => '-H',
68
- :usage => 'HOST [...]'
69
-
70
- query_option :ports, :type => Array[Integer],
71
- :flag => '-P',
72
- :usage => 'PORT [...]'
73
-
74
- query_option :directory, :type => String,
75
- :flag => '-d',
76
- :usage => 'SUBDIR'
77
-
78
- query_option :with_query_param, :type => Array,
79
- :flag => '-q',
80
- :usage => 'NAME [...]'
81
-
82
- query_option :with_query_value, :type => Array,
83
- :flag => '-Q',
84
- :usage => 'VALUE [...]'
85
-
86
- option :list, :type => true,
87
- :default => true,
88
- :flag => '-l'
89
-
90
- option :import, :type => String,
91
- :flag => '-i',
92
- :usage => 'FILE'
63
+ query_option :http, :type => true,
64
+ :description => 'Searches for http:// URLs'
65
+
66
+ query_option :https, :type => true,
67
+ :description => 'Searches for https:// URLs'
68
+
69
+ query_option :hosts, :type => Array,
70
+ :flag => '-H',
71
+ :usage => 'HOST [...]',
72
+ :description => 'Searches for the associated HOST(s)'
73
+
74
+ query_option :ports, :type => Array[Integer],
75
+ :flag => '-P',
76
+ :usage => 'PORT [...]',
77
+ :description => 'Searches for the associated PORT(s)'
78
+
79
+ query_option :directory, :type => String,
80
+ :flag => '-d',
81
+ :description => 'Searches for the associated DIRECTORY'
82
+
83
+ query_option :with_query_param, :type => Array,
84
+ :flag => '-q',
85
+ :usage => 'NAME [...]',
86
+ :description => 'Searches for the associated query-param NAME(s)'
87
+
88
+ query_option :with_query_value, :type => Array,
89
+ :flag => '-Q',
90
+ :usage => 'VALUE [...]',
91
+ :description => 'Searches for the associated query-param VALUE(s)'
92
+
93
+ option :list, :type => true,
94
+ :default => true,
95
+ :flag => '-l',
96
+ :description => 'Lists the URLs'
97
+
98
+ option :import, :type => String,
99
+ :flag => '-i',
100
+ :usage => 'FILE',
101
+ :description => 'Imports URLs from the FILE'
93
102
 
94
103
  protected
95
104
 
@@ -45,6 +45,11 @@ module Ronin
45
45
  #
46
46
  # TEMPLATE Options word template (alpha:7 numeric:1-3)
47
47
  #
48
+ # ## Examples
49
+ #
50
+ # ronin wordlist alpha:7 numeric:1-3
51
+ # ronin wordlist --input text.txt -m e:3 -m a:@ -m o:0
52
+ #
48
53
  # @since 1.4.0
49
54
  #
50
55
  class Wordlist < Command
@@ -68,7 +73,12 @@ module Ronin
68
73
  :descriptions => 'Mutations rules'
69
74
 
70
75
  argument :template, :type => Array,
71
- :description => 'Options word template (alpha:7 numeric:1-3)'
76
+ :description => 'Options word template [CHARSET:[LENGTH|RANGE] ...]'
77
+
78
+ examples [
79
+ "ronin wordlist alpha:7 numeric:1-3",
80
+ "ronin wordlist --input text.txt -m e:3 -m a:@ -m o:0"
81
+ ]
72
82
 
73
83
  #
74
84
  # Executes the wordlist command.
@@ -19,3 +19,4 @@
19
19
 
20
20
  require 'ronin/ui/console/console'
21
21
  require 'ronin/ui/console/commands'
22
+ require 'ronin/ui/console/shell'
@@ -17,125 +17,58 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/config'
21
-
22
- require 'set'
20
+ require 'shellwords'
23
21
  require 'tempfile'
24
22
 
25
23
  module Ronin
26
24
  module UI
27
25
  module Console
28
26
  #
29
- # Allows for executing shell commands prefixed by a `!`.
27
+ # Allows for calling {Console} commands via the `.` prefix.
28
+ #
29
+ # ## Commands
30
+ #
31
+ # * {edit .edit}
30
32
  #
31
33
  # @since 1.2.0
32
34
  #
33
35
  # @api private
34
36
  #
35
37
  module Commands
36
- # Names and statuses of executables.
37
- EXECUTABLES = Hash.new do |hash,key|
38
- hash[key] = Config::BIN_DIRS.any? do |dir|
39
- path = File.join(dir,key)
40
-
41
- (File.file?(path) && File.executable?(path))
42
- end
43
- end
44
-
45
- # Prefixes that denote a command, instead of Ruby code.
46
- PREFIXES = Set['!', '.']
47
-
48
- # Blacklist of known commands that conflict with Ruby keywords.
49
- BLACKLIST = Set[
50
- '[', 'ap', 'begin', 'case', 'class', 'def', 'fail', 'false',
51
- 'for', 'if', 'lambda', 'load', 'loop', 'module', 'p', 'pp',
52
- 'print', 'proc', 'puts', 'raise', 'require', 'true', 'undef',
53
- 'unless', 'until', 'warn', 'while'
54
- ]
38
+ # Regexp to recognize `.commands`.
39
+ PATTERN = /^\.[a-z][a-z0-9_]*/
55
40
 
56
41
  #
57
- # Dynamically execute shell commands, instead of Ruby.
42
+ # Check for the `.` prefix, and attempt to call the Console command.
58
43
  #
59
44
  # @param [String] input
60
45
  # The input from the console.
61
46
  #
62
47
  def loop_eval(input)
63
- if PREFIXES.include?(input[0,1])
48
+ if (@buffer.nil? && input =~ PATTERN)
64
49
  command = input[1..-1]
65
- name, arguments = command.split(' ')
50
+ name, arguments = Shellwords.shellsplit(command)
66
51
 
67
- unless BLACKLIST.include?(name)
68
- if Commands.singleton_class.method_defined?(name)
69
- arguments ||= []
52
+ if Commands.singleton_class.method_defined?(name)
53
+ arguments ||= []
70
54
 
71
- return Commands.send(name,*arguments)
72
- elsif executable?(name)
73
- return system(command)
74
- end
55
+ return Commands.send(name,*arguments)
75
56
  end
76
57
  end
77
58
 
78
59
  super(input)
79
60
  end
80
61
 
81
- #
82
- # Equivalent of the `cd` command, using `Dir.chdir`.
83
- #
84
- # @param [Array<String>] arguments
85
- # The arguments of the command.
86
- #
87
- # @return [Boolean]
88
- # Specifies whether the directory change was successful.
89
- #
90
- def Commands.cd(*arguments)
91
- old_pwd = Dir.pwd
92
-
93
- new_cwd = if arguments.empty?
94
- Config::HOME
95
- elsif arguments.first == '-'
96
- unless ENV['OLDPWD']
97
- print_warning 'cd: OLDPWD not set'
98
- return false
99
- end
100
-
101
- ENV['OLDPWD']
102
- else
103
- arguments.first
104
- end
105
-
106
- Dir.chdir(new_cwd)
107
- ENV['OLDPWD'] = old_pwd
108
- return true
109
- end
110
-
111
- #
112
- # Equivalent of the `export` or `set` commands.
113
- #
114
- # @param [Array<String>] arguments
115
- # The arguments of the command.
116
- #
117
- # @return [true]
118
- #
119
- def Commands.export(*arguments)
120
- arguments.each do |pair|
121
- name, value = pair.split('=',2)
122
-
123
- ENV[name] = value
124
- end
125
- end
126
-
127
62
  #
128
63
  # Edits a path and re-loads the code.
129
64
  #
130
- # @param [Array<String>] path
65
+ # @param [String] path
131
66
  # The path of the file to re-load.
132
67
  #
133
68
  # @return [Boolean]
134
69
  # Specifies whether the code was successfully re-loaded.
135
70
  #
136
- def Commands.edit(*arguments)
137
- path = arguments.first
138
-
71
+ def self.edit(path=nil)
139
72
  if ENV['EDITOR']
140
73
  path ||= Tempfile.new(['ronin-console', '.rb']).path
141
74
 
@@ -145,21 +78,6 @@ module Ronin
145
78
  return false
146
79
  end
147
80
  end
148
-
149
- protected
150
-
151
- #
152
- # Determines if an executable exists on the system.
153
- #
154
- # @param [String] name
155
- # The program name or path.
156
- #
157
- # @return [Boolean]
158
- # Specifies whether the executable exists.
159
- #
160
- def executable?(name)
161
- (File.file?(name) && File.executable?(name)) || EXECUTABLES[name]
162
- end
163
81
  end
164
82
  end
165
83
  end
@@ -0,0 +1,184 @@
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/config'
21
+
22
+ require 'set'
23
+ require 'shellwords'
24
+
25
+ module Ronin
26
+ module UI
27
+ module Console
28
+ #
29
+ # Allows for executing shell commands prefixed by a `!`.
30
+ #
31
+ # @since 1.5.0
32
+ #
33
+ # @api private
34
+ #
35
+ module Shell
36
+ # Names and statuses of executables.
37
+ EXECUTABLES = Hash.new do |hash,key|
38
+ hash[key] = Config::BIN_DIRS.any? do |dir|
39
+ path = File.join(dir,key)
40
+
41
+ (File.file?(path) && File.executable?(path))
42
+ end
43
+ end
44
+
45
+ # Regexp to recognize `!commands`.
46
+ PATTERN = /^![a-zA-Z][a-zA-Z0-9\._-]*/
47
+
48
+ # Blacklist of known commands that conflict with Ruby keywords.
49
+ BLACKLIST = Set[
50
+ '[', 'ap', 'begin', 'case', 'class', 'def', 'fail', 'false',
51
+ 'for', 'if', 'lambda', 'load', 'loop', 'module', 'p', 'pp',
52
+ 'print', 'proc', 'puts', 'raise', 'require', 'true', 'undef',
53
+ 'unless', 'until', 'warn', 'while'
54
+ ]
55
+
56
+ #
57
+ # Dynamically execute shell commands, instead of Ruby.
58
+ #
59
+ # @param [String] input
60
+ # The input from the console.
61
+ #
62
+ def loop_eval(input)
63
+ if (@buffer.nil? && input =~ PATTERN)
64
+ command = input[1..-1]
65
+ name, arguments = parse_command(command)
66
+
67
+ unless BLACKLIST.include?(name)
68
+ if Shell.singleton_class.method_defined?(name)
69
+ arguments ||= []
70
+
71
+ return Shell.send(name,*arguments)
72
+ elsif executable?(name)
73
+ return Shell.exec(name,*arguments)
74
+ end
75
+ end
76
+ end
77
+
78
+ super(input)
79
+ end
80
+
81
+ #
82
+ # Default command which executes a command in the shell.
83
+ #
84
+ # @param [Array<String>] arguments
85
+ # The arguments of the command.
86
+ #
87
+ # @return [Boolean]
88
+ # Specifies whether the command exited successfully.
89
+ #
90
+ # @since 1.5.0
91
+ #
92
+ def self.exec(*arguments)
93
+ system(Shellwords.shelljoin(arguments))
94
+ end
95
+
96
+ #
97
+ # Equivalent of the `cd` command, using `Dir.chdir`.
98
+ #
99
+ # @param [Array<String>] arguments
100
+ # The arguments of the command.
101
+ #
102
+ # @return [Boolean]
103
+ # Specifies whether the directory change was successful.
104
+ #
105
+ def self.cd(*arguments)
106
+ old_pwd = Dir.pwd
107
+
108
+ new_cwd = if arguments.empty?
109
+ Config::HOME
110
+ elsif arguments.first == '-'
111
+ unless ENV['OLDPWD']
112
+ print_warning 'cd: OLDPWD not set'
113
+ return false
114
+ end
115
+
116
+ ENV['OLDPWD']
117
+ else
118
+ arguments.first
119
+ end
120
+
121
+ Dir.chdir(new_cwd)
122
+ ENV['OLDPWD'] = old_pwd
123
+ return true
124
+ end
125
+
126
+ #
127
+ # Equivalent of the `export` or `set` commands.
128
+ #
129
+ # @param [Array<String>] arguments
130
+ # The arguments of the command.
131
+ #
132
+ # @return [true]
133
+ #
134
+ def self.export(*arguments)
135
+ arguments.each do |pair|
136
+ name, value = pair.split('=',2)
137
+
138
+ ENV[name] = value
139
+ end
140
+ end
141
+
142
+ protected
143
+
144
+ #
145
+ # Parses a Console command.
146
+ #
147
+ # @param [String] command
148
+ # The Console command to parse.
149
+ #
150
+ # @return [String, Array<String>]
151
+ # The command name and additional arguments.
152
+ #
153
+ # @since 1.5.0
154
+ #
155
+ def parse_command(command)
156
+ # evaluate embedded Ruby expressions
157
+ command = command.gsub(/\#\{[^\}]*\}/) do |expression|
158
+ eval(expression[2..-2],Ripl.config[:binding]).to_s.dump
159
+ end
160
+
161
+ arguments = Shellwords.shellsplit(command)
162
+ name = arguments.shift
163
+
164
+ return name, arguments
165
+ end
166
+
167
+ #
168
+ # Determines if an executable exists on the system.
169
+ #
170
+ # @param [String] name
171
+ # The program name or path.
172
+ #
173
+ # @return [Boolean]
174
+ # Specifies whether the executable exists.
175
+ #
176
+ def executable?(name)
177
+ (File.file?(name) && File.executable?(name)) || EXECUTABLES[name]
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ Ripl::Shell.send :include, Ronin::UI::Console::Shell