ronin 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +11 -0
  2. data/ChangeLog.md +28 -10
  3. data/Gemfile +1 -1
  4. data/README.md +14 -41
  5. data/Rakefile +3 -0
  6. data/gemspec.yml +14 -15
  7. data/lib/bond/completions/ronin.rb +0 -5
  8. data/lib/ronin/address.rb +17 -0
  9. data/lib/ronin/author.rb +1 -1
  10. data/lib/ronin/database/database.rb +11 -3
  11. data/lib/ronin/email_address.rb +33 -0
  12. data/lib/ronin/host_name.rb +57 -6
  13. data/lib/ronin/ip_address.rb +49 -5
  14. data/lib/ronin/license.rb +1 -1
  15. data/lib/ronin/mac_address.rb +39 -1
  16. data/lib/ronin/model/has_license.rb +12 -3
  17. data/lib/ronin/model/importable.rb +65 -0
  18. data/lib/ronin/repository.rb +12 -4
  19. data/lib/ronin/spec/database.rb +1 -1
  20. data/lib/ronin/tcp_port.rb +3 -12
  21. data/lib/ronin/udp_port.rb +2 -11
  22. data/lib/ronin/ui/cli/commands/emails.rb +0 -45
  23. data/lib/ronin/ui/cli/commands/hosts.rb +4 -31
  24. data/lib/ronin/ui/cli/commands/ips.rb +4 -30
  25. data/lib/ronin/ui/cli/commands/urls.rb +5 -45
  26. data/lib/ronin/ui/cli/model_command.rb +17 -27
  27. data/lib/ronin/ui/cli/resources_command.rb +25 -1
  28. data/lib/ronin/ui/cli/script_command.rb +1 -1
  29. data/lib/ronin/ui/console/context.rb +1 -1
  30. data/lib/ronin/url.rb +43 -1
  31. data/lib/ronin/version.rb +1 -1
  32. data/ronin.gemspec +1 -1
  33. data/spec/email_address_spec.rb +20 -0
  34. data/spec/host_name_spec.rb +20 -0
  35. data/spec/ip_address_spec.rb +104 -0
  36. data/spec/mac_address_spec.rb +20 -0
  37. data/spec/url_spec.rb +24 -0
  38. metadata +118 -155
  39. data/lib/ronin/network/mixins.rb +0 -27
  40. data/lib/ronin/network/mixins/esmtp.rb +0 -165
  41. data/lib/ronin/network/mixins/http.rb +0 -723
  42. data/lib/ronin/network/mixins/imap.rb +0 -151
  43. data/lib/ronin/network/mixins/pop3.rb +0 -141
  44. data/lib/ronin/network/mixins/smtp.rb +0 -159
  45. data/lib/ronin/network/mixins/tcp.rb +0 -331
  46. data/lib/ronin/network/mixins/telnet.rb +0 -199
  47. data/lib/ronin/network/mixins/udp.rb +0 -227
  48. data/lib/ronin/spec/ui/output.rb +0 -28
  49. data/lib/ronin/ui/output.rb +0 -21
  50. data/lib/ronin/ui/output/helpers.rb +0 -248
  51. data/lib/ronin/ui/output/output.rb +0 -146
  52. data/lib/ronin/ui/output/terminal.rb +0 -21
  53. data/lib/ronin/ui/output/terminal/color.rb +0 -118
  54. data/lib/ronin/ui/output/terminal/raw.rb +0 -103
  55. data/lib/ronin/ui/shell.rb +0 -92
  56. data/spec/ip_address.rb +0 -84
  57. data/spec/ui/output_spec.rb +0 -32
@@ -1,227 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 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/network/udp'
21
- require 'ronin/ui/output/helpers'
22
- require 'ronin/mixin'
23
-
24
- require 'parameters'
25
-
26
- module Ronin
27
- module Network
28
- module Mixins
29
- #
30
- # Adds UDP convenience methods and connection parameters to a class.
31
- #
32
- # Defines the following parameters:
33
- #
34
- # * `host` (`String`) - UDP host.
35
- # * `port` (`Integer`) - UDP port.
36
- # * `local_host` (`String`) - UDP local host.
37
- # * `local_port` (`Integer`) - UDP local port.
38
- # * `server_host` (`String`) - UDP server host.
39
- # * `server_port` (`Integer`) - UDP server port.
40
- #
41
- module UDP
42
- include Mixin
43
-
44
- mixin UI::Output::Helpers, Parameters
45
-
46
- mixin do
47
- # UDP host
48
- parameter :host, :type => String,
49
- :description => 'UDP host'
50
-
51
- # UDP port
52
- parameter :port, :type => Integer,
53
- :description => 'UDP port'
54
-
55
- # UDP local host
56
- parameter :local_host, :type => String,
57
- :description => 'UDP local host'
58
-
59
- # UDP local port
60
- parameter :local_port, :type => Integer,
61
- :description => 'UDP local port'
62
-
63
- # UDP server host
64
- parameter :server_host, :type => String,
65
- :description => 'UDP server host'
66
-
67
- # UDP server port
68
- parameter :server_port, :type => Integer,
69
- :description => 'UDP server port'
70
- end
71
-
72
- protected
73
-
74
- #
75
- # Opens a UDP connection to the host and port specified by the
76
- # `host` and `port` parameters. If the `local_host` and
77
- # `local_port` parameters are set, they will be used for
78
- # the local host and port of the UDP connection.
79
- #
80
- # @yield [socket]
81
- # If a block is given, it will be passed the newly created socket.
82
- #
83
- # @yieldparam [UDPsocket] socket
84
- # The newly created UDPSocket object.
85
- #
86
- # @return [UDPSocket]
87
- # The newly created UDPSocket object.
88
- #
89
- # @example
90
- # udp_connect
91
- # # => UDPSocket
92
- #
93
- # @example
94
- # udp_connect do |sock|
95
- # puts sock.readlines
96
- # end
97
- #
98
- # @api public
99
- #
100
- def udp_connect(&block)
101
- print_info "Connecting to #{self.host}:#{self.port} ..."
102
-
103
- return ::Net.udp_connect(self.host,self.port,self.local_host,self.local_port,&block)
104
- end
105
-
106
- #
107
- # Connects to the host and port specified by the `host` and `port`
108
- # parameters, then sends the given data. If the `local_host` and
109
- # `local_port` instance methods are set, they will be used for the
110
- # local host and port of the UDP connection.
111
- #
112
- # @param [String] data
113
- # The data to send through the connection.
114
- #
115
- # @yield [socket]
116
- # If a block is given, it will be passed the newly created socket.
117
- #
118
- # @yieldparam [UDPsocket] socket
119
- # The newly created UDPSocket object.
120
- #
121
- # @return [UDPSocket]
122
- # The newly created UDPSocket object.
123
- #
124
- # @api public
125
- #
126
- def udp_connect_and_send(data,&block)
127
- print_info "Connecting to #{self.host}:#{self.port} ..."
128
- print_debug "Sending data: #{data.inspect}"
129
-
130
- return ::Net.udp_connect_and_send(data,self.host,self.port,self.local_host,self.local_port,&block)
131
- end
132
-
133
- #
134
- # Creates a UDP session to the host and port specified by the
135
- # `host` and `port` parameters. If the `local_host` and `local_port`
136
- # parameters are set, they will be used for the local host and port
137
- # of the UDP connection.
138
- #
139
- # @yield [socket]
140
- # If a block is given, it will be passed the newly created socket.
141
- # After the block has returned, the socket will then be closed.
142
- #
143
- # @yieldparam [UDPsocket] socket
144
- # The newly created UDPSocket object.
145
- #
146
- # @return [nil]
147
- #
148
- # @api public
149
- #
150
- def udp_session(&block)
151
- print_info "Connecting to #{self.host}:#{self.port} ..."
152
-
153
- ::Net.udp_session(self.host,self.port,self.local_host,self.local_port,&block)
154
-
155
- print_info "Disconnected from #{self.host}:#{self.port}"
156
- return nil
157
- end
158
-
159
- #
160
- # Creates a new UDPServer object listening on `server_host` and
161
- # `server_port` parameters.
162
- #
163
- # @yield [server]
164
- # The given block will be passed the newly created server.
165
- #
166
- # @yieldparam [UDPServer] server
167
- # The newly created server.
168
- #
169
- # @return [UDPServer]
170
- # The newly created server.
171
- #
172
- # @example
173
- # udp_server
174
- #
175
- # @api public
176
- #
177
- def udp_server(&block)
178
- if self.server_host
179
- print_info "Listening on #{self.server_host}:#{self.server_port} ..."
180
- else
181
- print_info "Listening on #{self.server_port} ..."
182
- end
183
-
184
- return ::Net.udp_server(self.server_port,self.server_host,&block)
185
- end
186
-
187
- #
188
- # Creates a new temporary UDPServer object listening on the
189
- # `server_host` and `server_port` parameters.
190
- #
191
- # @yield [server]
192
- # The given block will be passed the newly created server.
193
- # When the block has finished, the server will be closed.
194
- #
195
- # @yieldparam [UDPServer] server
196
- # The newly created server.
197
- #
198
- # @return [nil]
199
- #
200
- # @example
201
- # udp_server_session do |server|
202
- # data, sender = server.recvfrom(1024)
203
- # end
204
- #
205
- # @api public
206
- #
207
- def udp_server_session(&block)
208
- if self.server_host
209
- print_info "Listening on #{self.server_host}:#{self.server_port} ..."
210
- else
211
- print_info "Listening on #{self.server_port} ..."
212
- end
213
-
214
- ::Net.udp_server_session(&block)
215
-
216
- if self.server_host
217
- print_info "Closed #{self.server_host}:#{self.server_port}"
218
- else
219
- print_info "Closed #{self.server_port}"
220
- end
221
-
222
- return nil
223
- end
224
- end
225
- end
226
- end
227
- end
@@ -1,28 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 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/output'
21
-
22
- require 'rspec'
23
-
24
- RSpec.configure do |spec|
25
- spec.before(:suite) do
26
- Ronin::UI::Output.silent! unless ENV['DEBUG']
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 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/output/output'
21
- require 'ronin/ui/output/helpers'
@@ -1,248 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 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/output/output'
21
-
22
- module Ronin
23
- module UI
24
- module Output
25
- #
26
- # Helper methods for printing output.
27
- #
28
- module Helpers
29
- #
30
- # Writes data unless output has been silenced.
31
- #
32
- # @param [String, Object] data
33
- # The data to write.
34
- #
35
- # @return [Integer, nil]
36
- # The number of bytes written.
37
- #
38
- # @since 1.0.0
39
- #
40
- # @api public
41
- #
42
- def write(data)
43
- unless Output.silent?
44
- data = data.to_s
45
-
46
- Output.handler.write(data)
47
- return data.length
48
- end
49
- end
50
-
51
- #
52
- # Prints a character.
53
- #
54
- # @param [String, Integer] data
55
- # The character or byte to print.
56
- #
57
- # @return [String, Integer]
58
- # The byte or character.
59
- #
60
- # @since 1.0.0
61
- #
62
- # @api public
63
- #
64
- def putc(data)
65
- char = data.chr if data.kind_of?(Integer)
66
-
67
- write(data)
68
- return data
69
- end
70
-
71
- #
72
- # Prints one or more messages.
73
- #
74
- # @param [Array] messages
75
- # The messages to print.
76
- #
77
- # @example
78
- # puts 'some data'
79
- #
80
- # @since 0.3.0
81
- #
82
- # @api public
83
- #
84
- def puts(*messages)
85
- unless messages.empty?
86
- messages.each { |message| write("#{message}#{$/}") }
87
- else
88
- write($/)
89
- end
90
-
91
- return nil
92
- end
93
-
94
- #
95
- # Prints formatted data.
96
- #
97
- # @param [String] format
98
- # The format string.
99
- #
100
- # @param [Array] data
101
- # The data to format.
102
- #
103
- # @return [nil]
104
- #
105
- # @since 1.0.0
106
- #
107
- # @api public
108
- #
109
- def printf(format,*data)
110
- write(format % data)
111
- return nil
112
- end
113
-
114
- #
115
- # Prints an `info` message.
116
- #
117
- # @param [Array] message
118
- # The message to print.
119
- #
120
- # @return [Boolean]
121
- # Specifies whether the messages were successfully printed.
122
- #
123
- # @example
124
- # print_info "Connecting ..."
125
- #
126
- # @example Print a formatted message.
127
- # print_info "Connected to %s", host
128
- #
129
- # @since 0.3.0
130
- #
131
- # @api public
132
- #
133
- def print_info(*message)
134
- unless Output.silent?
135
- Output.handler.print_info(format_message(message))
136
- return true
137
- end
138
-
139
- return false
140
- end
141
-
142
- #
143
- # Prints a `debug` message.
144
- #
145
- # @param [Array, String] message
146
- # The message to print.
147
- #
148
- # @return [Boolean]
149
- # Specifies whether the messages were successfully printed.
150
- #
151
- # @example Print a formatted message.
152
- # print_debug "vars: %p %p", vars[0], vars[1]
153
- #
154
- # @since 0.3.0
155
- #
156
- # @api public
157
- #
158
- def print_debug(*message)
159
- if (Output.verbose? && !(Output.silent?))
160
- Output.handler.print_debug(format_message(message))
161
- return true
162
- end
163
-
164
- return false
165
- end
166
-
167
- #
168
- # Prints a `warning` message.
169
- #
170
- # @param [Array, String] message
171
- # The message to print.
172
- #
173
- # @return [Boolean]
174
- # Specifies whether the messages were successfully printed.
175
- #
176
- # @example
177
- # print_warning "Detecting a restricted character in the buffer"
178
- #
179
- # @example Print a formatted message.
180
- # print_warning "Malformed input detected: %p", user_input
181
- #
182
- # @since 0.3.0
183
- #
184
- # @api public
185
- #
186
- def print_warning(*message)
187
- if (Output.verbose? && !(Output.silent?))
188
- Output.handler.print_warning(format_message(message))
189
- return true
190
- end
191
-
192
- return false
193
- end
194
-
195
- #
196
- # Prints an `error` message.
197
- #
198
- # @param [Array, String] message
199
- # The message to print.
200
- #
201
- # @return [Boolean]
202
- # Specifies whether the messages were successfully printed.
203
- #
204
- # @example
205
- # print_error "Could not connect!"
206
- #
207
- # @example Print a formatted message.
208
- # print_error "%p: %s", error.class, error.message
209
- #
210
- # @since 0.3.0
211
- #
212
- # @api public
213
- #
214
- def print_error(*message)
215
- unless Output.silent?
216
- Output.handler.print_error(format_message(message))
217
- return true
218
- end
219
-
220
- return false
221
- end
222
-
223
- protected
224
-
225
- #
226
- # Formats a message to be printed.
227
- #
228
- # @param [Array] message
229
- # The message and additional Objects to format.
230
- #
231
- # @return [String]
232
- # The formatted message.
233
- #
234
- # @since 1.0.0
235
- #
236
- # @api private
237
- #
238
- def format_message(message)
239
- if message.length == 1
240
- message[0]
241
- else
242
- message[0] % message[1..-1]
243
- end
244
- end
245
- end
246
- end
247
- end
248
- end