ronin-recon 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.github/workflows/ruby.yml +46 -0
  4. data/.gitignore +20 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +44 -0
  7. data/.ruby-version +1 -0
  8. data/.yardopts +1 -0
  9. data/COPYING.txt +165 -0
  10. data/ChangeLog.md +36 -0
  11. data/Gemfile +62 -0
  12. data/README.md +391 -0
  13. data/Rakefile +74 -0
  14. data/bin/ronin-recon +16 -0
  15. data/data/completions/ronin-recon +95 -0
  16. data/data/templates/worker.rb.erb +67 -0
  17. data/data/wordlists/raft-small-directories.txt.gz +0 -0
  18. data/data/wordlists/subdomains-1000.txt.gz +0 -0
  19. data/examples/recon.rb +24 -0
  20. data/gemspec.yml +57 -0
  21. data/lib/ronin/recon/builtin/dns/lookup.rb +65 -0
  22. data/lib/ronin/recon/builtin/dns/mailservers.rb +64 -0
  23. data/lib/ronin/recon/builtin/dns/nameservers.rb +61 -0
  24. data/lib/ronin/recon/builtin/dns/reverse_lookup.rb +63 -0
  25. data/lib/ronin/recon/builtin/dns/srv_enum.rb +178 -0
  26. data/lib/ronin/recon/builtin/dns/subdomain_enum.rb +105 -0
  27. data/lib/ronin/recon/builtin/dns/suffix_enum.rb +168 -0
  28. data/lib/ronin/recon/builtin/net/ip_range_enum.rb +65 -0
  29. data/lib/ronin/recon/builtin/net/port_scan.rb +84 -0
  30. data/lib/ronin/recon/builtin/net/service_id.rb +75 -0
  31. data/lib/ronin/recon/builtin/ssl/cert_enum.rb +109 -0
  32. data/lib/ronin/recon/builtin/ssl/cert_grab.rb +76 -0
  33. data/lib/ronin/recon/builtin/ssl/cert_sh.rb +77 -0
  34. data/lib/ronin/recon/builtin/web/dir_enum.rb +121 -0
  35. data/lib/ronin/recon/builtin/web/email_addresses.rb +70 -0
  36. data/lib/ronin/recon/builtin/web/spider.rb +93 -0
  37. data/lib/ronin/recon/builtin.rb +34 -0
  38. data/lib/ronin/recon/cli/command.rb +40 -0
  39. data/lib/ronin/recon/cli/commands/completion.rb +61 -0
  40. data/lib/ronin/recon/cli/commands/irb.rb +57 -0
  41. data/lib/ronin/recon/cli/commands/new.rb +203 -0
  42. data/lib/ronin/recon/cli/commands/run.rb +420 -0
  43. data/lib/ronin/recon/cli/commands/test.rb +99 -0
  44. data/lib/ronin/recon/cli/commands/worker.rb +114 -0
  45. data/lib/ronin/recon/cli/commands/workers.rb +80 -0
  46. data/lib/ronin/recon/cli/debug_option.rb +45 -0
  47. data/lib/ronin/recon/cli/printing.rb +122 -0
  48. data/lib/ronin/recon/cli/ruby_shell.rb +51 -0
  49. data/lib/ronin/recon/cli/worker_command.rb +105 -0
  50. data/lib/ronin/recon/cli.rb +50 -0
  51. data/lib/ronin/recon/config.rb +371 -0
  52. data/lib/ronin/recon/dns_worker.rb +41 -0
  53. data/lib/ronin/recon/engine.rb +639 -0
  54. data/lib/ronin/recon/exceptions.rb +45 -0
  55. data/lib/ronin/recon/graph.rb +127 -0
  56. data/lib/ronin/recon/importer.rb +224 -0
  57. data/lib/ronin/recon/input_file.rb +81 -0
  58. data/lib/ronin/recon/message/job_completed.rb +60 -0
  59. data/lib/ronin/recon/message/job_failed.rb +69 -0
  60. data/lib/ronin/recon/message/job_started.rb +60 -0
  61. data/lib/ronin/recon/message/shutdown.rb +38 -0
  62. data/lib/ronin/recon/message/value.rb +76 -0
  63. data/lib/ronin/recon/message/worker_started.rb +51 -0
  64. data/lib/ronin/recon/message/worker_stopped.rb +51 -0
  65. data/lib/ronin/recon/mixins/dns.rb +639 -0
  66. data/lib/ronin/recon/mixins/http.rb +58 -0
  67. data/lib/ronin/recon/mixins.rb +21 -0
  68. data/lib/ronin/recon/output_formats/dir.rb +94 -0
  69. data/lib/ronin/recon/output_formats/dot.rb +155 -0
  70. data/lib/ronin/recon/output_formats/graph_format.rb +48 -0
  71. data/lib/ronin/recon/output_formats/graphviz_format.rb +115 -0
  72. data/lib/ronin/recon/output_formats/pdf.rb +43 -0
  73. data/lib/ronin/recon/output_formats/png.rb +43 -0
  74. data/lib/ronin/recon/output_formats/svg.rb +43 -0
  75. data/lib/ronin/recon/output_formats.rb +48 -0
  76. data/lib/ronin/recon/registry.rb +35 -0
  77. data/lib/ronin/recon/root.rb +33 -0
  78. data/lib/ronin/recon/scope.rb +112 -0
  79. data/lib/ronin/recon/value/parser.rb +113 -0
  80. data/lib/ronin/recon/value.rb +110 -0
  81. data/lib/ronin/recon/value_status.rb +87 -0
  82. data/lib/ronin/recon/values/cert.rb +168 -0
  83. data/lib/ronin/recon/values/domain.rb +88 -0
  84. data/lib/ronin/recon/values/email_address.rb +114 -0
  85. data/lib/ronin/recon/values/host.rb +137 -0
  86. data/lib/ronin/recon/values/ip.rb +123 -0
  87. data/lib/ronin/recon/values/ip_range.rb +155 -0
  88. data/lib/ronin/recon/values/mailserver.rb +61 -0
  89. data/lib/ronin/recon/values/nameserver.rb +61 -0
  90. data/lib/ronin/recon/values/open_port.rb +190 -0
  91. data/lib/ronin/recon/values/url.rb +218 -0
  92. data/lib/ronin/recon/values/website.rb +200 -0
  93. data/lib/ronin/recon/values/wildcard.rb +140 -0
  94. data/lib/ronin/recon/values.rb +32 -0
  95. data/lib/ronin/recon/version.rb +26 -0
  96. data/lib/ronin/recon/web_worker.rb +35 -0
  97. data/lib/ronin/recon/worker.rb +433 -0
  98. data/lib/ronin/recon/worker_pool.rb +203 -0
  99. data/lib/ronin/recon/workers.rb +260 -0
  100. data/lib/ronin/recon.rb +22 -0
  101. data/man/ronin-recon-completion.1 +76 -0
  102. data/man/ronin-recon-completion.1.md +78 -0
  103. data/man/ronin-recon-irb.1 +27 -0
  104. data/man/ronin-recon-irb.1.md +26 -0
  105. data/man/ronin-recon-new.1 +58 -0
  106. data/man/ronin-recon-new.1.md +59 -0
  107. data/man/ronin-recon-run.1 +137 -0
  108. data/man/ronin-recon-run.1.md +115 -0
  109. data/man/ronin-recon-test.1 +53 -0
  110. data/man/ronin-recon-test.1.md +55 -0
  111. data/man/ronin-recon-worker.1 +32 -0
  112. data/man/ronin-recon-worker.1.md +34 -0
  113. data/man/ronin-recon-workers.1 +29 -0
  114. data/man/ronin-recon-workers.1.md +31 -0
  115. data/man/ronin-recon.1 +57 -0
  116. data/man/ronin-recon.1.md +57 -0
  117. data/ronin-recon.gemspec +62 -0
  118. data/scripts/setup +58 -0
  119. metadata +364 -0
@@ -0,0 +1,190 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-recon is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/value'
22
+
23
+ module Ronin
24
+ module Recon
25
+ module Values
26
+ #
27
+ # Represents a discovered open port.
28
+ #
29
+ # @api public
30
+ #
31
+ class OpenPort < Value
32
+
33
+ # The IP address that the open port listens on.
34
+ #
35
+ # @return [String]
36
+ attr_reader :address
37
+
38
+ # The port number.
39
+ #
40
+ # @return [Integer]
41
+ attr_reader :number
42
+
43
+ # The optional hostname associated with the address.
44
+ #
45
+ # @return [String, nil]
46
+ attr_reader :host
47
+
48
+ # The protocol of the port.
49
+ #
50
+ # @return [:tcp, :udp] protocol
51
+ attr_reader :protocol
52
+
53
+ # The optional service information.
54
+ #
55
+ # @return [String, nil] service
56
+ attr_reader :service
57
+
58
+ # Indiciates whether the open port uses SSL.
59
+ #
60
+ # @return [Boolean]
61
+ attr_reader :ssl
62
+
63
+ #
64
+ # Initializes the open port.
65
+ #
66
+ # @param [String] address
67
+ # The IP address for the open port.
68
+ #
69
+ # @param [Integer] number
70
+ # The port number.
71
+ #
72
+ # @param [String, nil] host
73
+ # The optional hostname associated with the address.
74
+ #
75
+ # @param [:tcp, :udp] protocol
76
+ # The protocol of the port.
77
+ #
78
+ # @param [String, nil] service
79
+ # The optional service information.
80
+ #
81
+ # @param [Boolean] ssl
82
+ # Indicates that the open port uses SSL/TLS.
83
+ #
84
+ def initialize(address,number, host: nil,
85
+ protocol: :tcp,
86
+ service: nil,
87
+ ssl: false)
88
+ @address = address
89
+ @number = number
90
+ @host = host
91
+ @protocol = protocol
92
+ @service = service
93
+ @ssl = ssl
94
+ end
95
+
96
+ #
97
+ # Determines whether the open port uses SSL/TLS.
98
+ #
99
+ # @return [Boolean]
100
+ #
101
+ def ssl?
102
+ @ssl
103
+ end
104
+
105
+ #
106
+ # Compares the value to another value.
107
+ #
108
+ # @param [Values::Value] other
109
+ #
110
+ # @return [Boolean]
111
+ #
112
+ def eql?(other)
113
+ other.kind_of?(self.class) &&
114
+ @address == other.address &&
115
+ @number == other.number &&
116
+ @protocol == other.protocol &&
117
+ @service == other.service &&
118
+ @ssl == other.ssl
119
+ end
120
+
121
+ #
122
+ # The "hash" value of the open port.
123
+ #
124
+ # @return [Integer]
125
+ #
126
+ def hash
127
+ [self.class, @address, @number, @protocol, @service, @ssl].hash
128
+ end
129
+
130
+ #
131
+ # Converts the open port into a String.
132
+ #
133
+ # @return [String]
134
+ # The hot-name/IP and port number.
135
+ #
136
+ def to_s
137
+ "#{@address}:#{@number}"
138
+ end
139
+
140
+ #
141
+ # Converts the open port into an Integer.
142
+ #
143
+ # @return [Integer]
144
+ # The port {#number}.
145
+ #
146
+ def to_i
147
+ @number.to_i
148
+ end
149
+
150
+ alias to_int to_i
151
+
152
+ #
153
+ # Coerces the open port value into JSON.
154
+ #
155
+ # @return [Hash{Symbol => Object}]
156
+ # The Ruby Hash that will be converted into JSON.
157
+ #
158
+ def as_json
159
+ hash = {
160
+ type: :open_port,
161
+ address: @address,
162
+ protocol: @protocol,
163
+ number: @number
164
+ }
165
+
166
+ hash[:service] = @service if @service
167
+ hash[:ssl] = @ssl if @ssl
168
+
169
+ return hash
170
+ end
171
+
172
+ #
173
+ # Returns the type or kind of recon value.
174
+ #
175
+ # @return [:open_port]
176
+ #
177
+ # @note
178
+ # This is used internally to map a recon value class to a printable
179
+ # type.
180
+ #
181
+ # @api private
182
+ #
183
+ def self.value_type
184
+ :open_port
185
+ end
186
+
187
+ end
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,218 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-recon is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/value'
22
+
23
+ require 'uri'
24
+
25
+ module Ronin
26
+ module Recon
27
+ module Values
28
+ #
29
+ # Represents a discovered URL.
30
+ #
31
+ # @api public
32
+ #
33
+ class URL < Value
34
+
35
+ # The parsed URI.
36
+ #
37
+ # @return [URI::HTTP, URI::HTTPS]
38
+ attr_reader :uri
39
+
40
+ # The HTTP status of the URI.
41
+ #
42
+ # @return [Integer, nil]
43
+ attr_reader :status
44
+
45
+ # The HTTP response headers for the URI.
46
+ #
47
+ # @return [Hash{String => String}, nil]
48
+ attr_reader :headers
49
+
50
+ # The HTTP response body for the URI.
51
+ #
52
+ # @return [String, nil]
53
+ attr_reader :body
54
+
55
+ #
56
+ # Initializes the URL object.
57
+ #
58
+ # @param [URI::HTTP, URI::HTTPS, String] url
59
+ #
60
+ # @param [Integer, nil] status
61
+ # The optional HTTP status of the URI.
62
+ #
63
+ # @param [Hash{String => String}, nil] headers
64
+ # The optional HTTP response headers for the URI.
65
+ #
66
+ # @param [String, nil] body
67
+ # The optional HTTP response body for the URI.
68
+ #
69
+ def initialize(url, status: nil, headers: nil, body: nil)
70
+ @uri = URI(url)
71
+
72
+ @status = status
73
+ @headers = headers
74
+ @body = body
75
+ end
76
+
77
+ #
78
+ # The scheme of the URL.
79
+ #
80
+ # @return [String]
81
+ #
82
+ def scheme
83
+ @uri.scheme
84
+ end
85
+
86
+ #
87
+ # The URI's user information.
88
+ #
89
+ # @return [String, nil]
90
+ #
91
+ def userinfo
92
+ @uri.userinfo
93
+ end
94
+
95
+ #
96
+ # The URL's host name.
97
+ #
98
+ # @return [String]
99
+ #
100
+ def host
101
+ @uri.host
102
+ end
103
+
104
+ #
105
+ # The URL's port.
106
+ #
107
+ # @return [Integer]
108
+ #
109
+ def port
110
+ @uri.port
111
+ end
112
+
113
+ #
114
+ # The URL's path.
115
+ #
116
+ # @return [String]
117
+ #
118
+ def path
119
+ @uri.path
120
+ end
121
+
122
+ #
123
+ # The URL's query string.
124
+ #
125
+ # @return [String, nil]
126
+ #
127
+ def query
128
+ @uri.query
129
+ end
130
+
131
+ #
132
+ # The URL's query params.
133
+ #
134
+ # @return [Hash{String => String}, nil]
135
+ #
136
+ def query_params
137
+ @uri.query_params
138
+ end
139
+
140
+ #
141
+ # The URL's fragment string.
142
+ #
143
+ # @return [String, nil]
144
+ #
145
+ def fragment
146
+ @uri.fragment
147
+ end
148
+
149
+ #
150
+ # Compares the value to another value.
151
+ #
152
+ # @param [Values::Value] other
153
+ #
154
+ # @return [Boolean]
155
+ #
156
+ def eql?(other)
157
+ other.kind_of?(self.class) && @uri == other.uri
158
+ end
159
+
160
+ #
161
+ # The "hash" value of the URL.
162
+ #
163
+ # @return [Integer]
164
+ # The hash value of {#uri}.
165
+ #
166
+ def hash
167
+ [self.class, @uri].hash
168
+ end
169
+
170
+ alias to_uri uri
171
+
172
+ #
173
+ # Converts the URL object to a String.
174
+ #
175
+ # @return [String]
176
+ # The URL string.
177
+ #
178
+ def to_s
179
+ @uri.to_s
180
+ end
181
+
182
+ alias to_str to_s
183
+
184
+ #
185
+ # Coerces the URL value into JSON.
186
+ #
187
+ # @return [Hash{Symbol => Object}]
188
+ # The Ruby Hash that will be converted into JSON.
189
+ #
190
+ def as_json
191
+ hash = {type: :url, url: @uri.to_s}
192
+
193
+ hash[:status] = @status if @status
194
+ hash[:headers] = @headers if @headers
195
+ hash[:body] = @body if @body
196
+
197
+ return hash
198
+ end
199
+
200
+ #
201
+ # Returns the type or kind of recon value.
202
+ #
203
+ # @return [:url]
204
+ #
205
+ # @note
206
+ # This is used internally to map a recon value class to a printable
207
+ # type.
208
+ #
209
+ # @api private
210
+ #
211
+ def self.value_type
212
+ :url
213
+ end
214
+
215
+ end
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,200 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-recon is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/value'
22
+
23
+ require 'uri'
24
+
25
+ module Ronin
26
+ module Recon
27
+ module Values
28
+ #
29
+ # Represents a discovered website (ex: `https://example.com`).
30
+ #
31
+ # @api public
32
+ #
33
+ class Website < Value
34
+
35
+ # Indicates whether the website uses `http://` or `https://`.
36
+ #
37
+ # @return [:http, :https]
38
+ attr_reader :scheme
39
+
40
+ # The website's host name.
41
+ #
42
+ # @return [String]
43
+ attr_reader :host
44
+
45
+ # The website's port number.
46
+ #
47
+ # @return [Integer]
48
+ attr_reader :port
49
+
50
+ #
51
+ # Initializes the website.
52
+ #
53
+ # @param [:http, :https] scheme
54
+ # Indicates whether the website uses `http://` or `https://`.
55
+ #
56
+ # @param [String] host
57
+ # The website's host name.
58
+ #
59
+ # @param [Integer] port
60
+ # The website's port number.
61
+ #
62
+ def initialize(scheme,host,port)
63
+ @scheme = scheme
64
+ @host = host
65
+ @port = port
66
+ end
67
+
68
+ #
69
+ # Initializes a new `http://` website.
70
+ #
71
+ # @param [String] host
72
+ # The website's host name.
73
+ #
74
+ # @param [Integer] port
75
+ # The website's port number.
76
+ #
77
+ # @return [Website]
78
+ # The new website value.
79
+ #
80
+ def self.http(host,port=80)
81
+ new(:http,host,port)
82
+ end
83
+
84
+ #
85
+ # Initializes a new `https://` website.
86
+ #
87
+ # @param [String] host
88
+ # The website's host name.
89
+ #
90
+ # @param [Integer] port
91
+ # The website's port number.
92
+ #
93
+ # @return [Website]
94
+ # The new website value.
95
+ #
96
+ def self.https(host,port=443)
97
+ new(:https,host,port)
98
+ end
99
+
100
+ #
101
+ # Parses a URL.
102
+ #
103
+ # @param [String] url
104
+ # The URL string to parse.
105
+ #
106
+ # @return [Website]
107
+ # The parsed website object.
108
+ #
109
+ def self.parse(url)
110
+ uri = URI.parse(url)
111
+
112
+ Values::Website.new(uri.scheme.to_sym,uri.host,uri.port)
113
+ end
114
+
115
+ #
116
+ # Compares the value to another value.
117
+ #
118
+ # @param [Values::Value] other
119
+ #
120
+ # @return [Boolean]
121
+ #
122
+ def eql?(other)
123
+ self.class == other.class &&
124
+ @scheme == other.scheme &&
125
+ @host == other.host &&
126
+ @port == other.port
127
+ end
128
+
129
+ #
130
+ # The "hash" value of the wildcard host name.
131
+ #
132
+ # @return [Integer]
133
+ # The hash value of {#host} and {#port}.
134
+ #
135
+ def hash
136
+ [self.class, @scheme, @host, @port].hash
137
+ end
138
+
139
+ # Mapping of {#scheme} values to URI classes.
140
+ #
141
+ # @api private
142
+ URI_CLASSES = {
143
+ https: URI::HTTPS,
144
+ http: URI::HTTP
145
+ }
146
+
147
+ #
148
+ # Converts the website into a URI.
149
+ #
150
+ # @return [URI::HTTP, URI::HTTPS]
151
+ # The URI object for the website.
152
+ #
153
+ def to_uri
154
+ URI_CLASSES.fetch(@scheme).build(host: @host, port: @port, path: '/')
155
+ end
156
+
157
+ #
158
+ # Converts the website to a String.
159
+ #
160
+ # @return [String]
161
+ # The base URL value for the website.
162
+ #
163
+ def to_s
164
+ if ((@scheme == :https) && (@port != 443)) ||
165
+ ((@scheme == :http) && (@port != 80))
166
+ "#{@scheme}://#{@host}:#{@port}"
167
+ else
168
+ "#{@scheme}://#{@host}"
169
+ end
170
+ end
171
+
172
+ #
173
+ # Coerces the website value into JSON.
174
+ #
175
+ # @return [Hash{Symbol => Object}]
176
+ # The Ruby Hash that will be converted into JSON.
177
+ #
178
+ def as_json
179
+ {type: :website, scheme: @scheme, host: @host, port: @port}
180
+ end
181
+
182
+ #
183
+ # Returns the type or kind of recon value.
184
+ #
185
+ # @return [:website]
186
+ #
187
+ # @note
188
+ # This is used internally to map a recon value class to a printable
189
+ # type.
190
+ #
191
+ # @api private
192
+ #
193
+ def self.value_type
194
+ :website
195
+ end
196
+
197
+ end
198
+ end
199
+ end
200
+ end