ronin-support 0.4.0.rc1 → 0.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.yardopts +1 -0
  2. data/ChangeLog.md +10 -0
  3. data/Gemfile +1 -1
  4. data/README.md +1 -1
  5. data/Rakefile +8 -0
  6. data/gemspec.yml +2 -1
  7. data/lib/ronin/extensions.rb +1 -1
  8. data/lib/ronin/extensions/enumerable.rb +1 -1
  9. data/lib/ronin/extensions/file.rb +1 -1
  10. data/lib/ronin/extensions/ip_addr.rb +1 -1
  11. data/lib/ronin/extensions/kernel.rb +1 -1
  12. data/lib/ronin/extensions/meta.rb +1 -1
  13. data/lib/ronin/extensions/regexp.rb +1 -1
  14. data/lib/ronin/extensions/resolv.rb +1 -1
  15. data/lib/ronin/extensions/string.rb +1 -1
  16. data/lib/ronin/formatting.rb +1 -1
  17. data/lib/ronin/formatting/binary.rb +1 -1
  18. data/lib/ronin/formatting/digest.rb +1 -1
  19. data/lib/ronin/formatting/extensions.rb +1 -1
  20. data/lib/ronin/formatting/extensions/binary.rb +1 -1
  21. data/lib/ronin/formatting/extensions/binary/file.rb +1 -1
  22. data/lib/ronin/formatting/extensions/binary/integer.rb +1 -1
  23. data/lib/ronin/formatting/extensions/binary/string.rb +1 -1
  24. data/lib/ronin/formatting/extensions/digest.rb +1 -1
  25. data/lib/ronin/formatting/extensions/digest/file.rb +1 -1
  26. data/lib/ronin/formatting/extensions/digest/string.rb +1 -1
  27. data/lib/ronin/formatting/extensions/html.rb +1 -1
  28. data/lib/ronin/formatting/extensions/html/integer.rb +1 -1
  29. data/lib/ronin/formatting/extensions/html/string.rb +1 -1
  30. data/lib/ronin/formatting/extensions/http.rb +1 -1
  31. data/lib/ronin/formatting/extensions/http/integer.rb +1 -1
  32. data/lib/ronin/formatting/extensions/http/string.rb +1 -1
  33. data/lib/ronin/formatting/extensions/sql.rb +1 -1
  34. data/lib/ronin/formatting/extensions/sql/string.rb +1 -1
  35. data/lib/ronin/formatting/extensions/text.rb +1 -1
  36. data/lib/ronin/formatting/extensions/text/array.rb +1 -1
  37. data/lib/ronin/formatting/extensions/text/string.rb +1 -1
  38. data/lib/ronin/formatting/html.rb +1 -1
  39. data/lib/ronin/formatting/http.rb +1 -1
  40. data/lib/ronin/formatting/sql.rb +1 -1
  41. data/lib/ronin/formatting/text.rb +1 -1
  42. data/lib/ronin/fuzzing.rb +1 -1
  43. data/lib/ronin/fuzzing/extensions.rb +1 -1
  44. data/lib/ronin/fuzzing/extensions/string.rb +1 -1
  45. data/lib/ronin/fuzzing/fuzzing.rb +1 -1
  46. data/lib/ronin/mixin.rb +1 -1
  47. data/lib/ronin/network.rb +1 -1
  48. data/lib/ronin/network/esmtp.rb +1 -1
  49. data/lib/ronin/network/extensions.rb +1 -1
  50. data/lib/ronin/network/extensions/esmtp.rb +1 -1
  51. data/lib/ronin/network/extensions/esmtp/net.rb +1 -1
  52. data/lib/ronin/network/extensions/http.rb +1 -1
  53. data/lib/ronin/network/extensions/http/net.rb +1 -1
  54. data/lib/ronin/network/extensions/http/uri/http.rb +1 -1
  55. data/lib/ronin/network/extensions/imap.rb +1 -1
  56. data/lib/ronin/network/extensions/imap/net.rb +1 -1
  57. data/lib/ronin/network/extensions/pop3.rb +1 -1
  58. data/lib/ronin/network/extensions/pop3/net.rb +1 -1
  59. data/lib/ronin/network/extensions/smtp.rb +1 -1
  60. data/lib/ronin/network/extensions/smtp/net.rb +1 -1
  61. data/lib/ronin/network/extensions/ssl.rb +1 -1
  62. data/lib/ronin/network/extensions/ssl/net.rb +1 -1
  63. data/lib/ronin/network/extensions/tcp.rb +1 -1
  64. data/lib/ronin/network/extensions/tcp/net.rb +1 -1
  65. data/lib/ronin/network/extensions/telnet.rb +1 -1
  66. data/lib/ronin/network/extensions/telnet/net.rb +1 -1
  67. data/lib/ronin/network/extensions/udp.rb +1 -1
  68. data/lib/ronin/network/extensions/udp/net.rb +1 -1
  69. data/lib/ronin/network/http.rb +1 -1
  70. data/lib/ronin/network/http/exceptions.rb +1 -1
  71. data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -1
  72. data/lib/ronin/network/http/http.rb +103 -72
  73. data/lib/ronin/network/http/proxy.rb +1 -1
  74. data/lib/ronin/network/imap.rb +1 -1
  75. data/lib/ronin/network/mixins.rb +1 -1
  76. data/lib/ronin/network/mixins/esmtp.rb +1 -1
  77. data/lib/ronin/network/mixins/http.rb +3 -3
  78. data/lib/ronin/network/mixins/imap.rb +1 -1
  79. data/lib/ronin/network/mixins/mixin.rb +1 -1
  80. data/lib/ronin/network/mixins/pop3.rb +1 -1
  81. data/lib/ronin/network/mixins/smtp.rb +1 -1
  82. data/lib/ronin/network/mixins/ssl.rb +144 -0
  83. data/lib/ronin/network/mixins/tcp.rb +6 -5
  84. data/lib/ronin/network/mixins/telnet.rb +1 -1
  85. data/lib/ronin/network/mixins/udp.rb +29 -3
  86. data/lib/ronin/network/network.rb +1 -1
  87. data/lib/ronin/network/pop3.rb +1 -1
  88. data/lib/ronin/network/smtp.rb +1 -1
  89. data/lib/ronin/network/smtp/email.rb +1 -1
  90. data/lib/ronin/network/smtp/smtp.rb +1 -1
  91. data/lib/ronin/network/ssl.rb +3 -6
  92. data/lib/ronin/network/tcp.rb +27 -28
  93. data/lib/ronin/network/telnet.rb +1 -1
  94. data/lib/ronin/network/udp.rb +56 -19
  95. data/lib/ronin/path.rb +1 -1
  96. data/lib/ronin/spec/ui/output.rb +1 -1
  97. data/lib/ronin/support.rb +1 -1
  98. data/lib/ronin/support/inflector.rb +1 -1
  99. data/lib/ronin/support/support.rb +1 -1
  100. data/lib/ronin/support/version.rb +2 -2
  101. data/lib/ronin/templates.rb +1 -1
  102. data/lib/ronin/templates/erb.rb +1 -1
  103. data/lib/ronin/templates/template.rb +1 -1
  104. data/lib/ronin/ui/output.rb +1 -1
  105. data/lib/ronin/ui/output/helpers.rb +1 -1
  106. data/lib/ronin/ui/output/output.rb +1 -1
  107. data/lib/ronin/ui/output/terminal.rb +1 -1
  108. data/lib/ronin/ui/output/terminal/color.rb +1 -1
  109. data/lib/ronin/ui/output/terminal/raw.rb +1 -1
  110. data/lib/ronin/ui/shell.rb +67 -7
  111. data/lib/ronin/wordlist.rb +51 -1
  112. data/spec/extensions/ip_addr_spec.rb +1 -1
  113. data/spec/network/http/http_spec.rb +193 -0
  114. data/spec/network/tcp_spec.rb +244 -0
  115. data/spec/network/udp_spec.rb +245 -0
  116. data/spec/spec_helper.rb +5 -0
  117. data/spec/ui/shell_spec.rb +7 -3
  118. data/spec/wordlist_spec.rb +25 -0
  119. metadata +35 -19
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -54,17 +54,15 @@ module Ronin
54
54
  # # => UDPSocket
55
55
  #
56
56
  # @example
57
- # udp_connect('www.wired.com',80) do |sock|
58
- # puts sock.readlines
57
+ # udp_connect('www.wired.com',80) do |socket|
58
+ # puts socket.readlines
59
59
  # end
60
60
  #
61
61
  # @api public
62
62
  #
63
63
  def udp_connect(host,port,local_host=nil,local_port=nil)
64
- host = host.to_s
65
- local_host = if local_host
66
- local_host.to_s
67
- end
64
+ host = host.to_s
65
+ local_host = (local_host || '0.0.0.0').to_s
68
66
 
69
67
  socket = UDPSocket.new
70
68
  socket.bind(local_host,local_port) if (local_host && local_port)
@@ -105,11 +103,11 @@ module Ronin
105
103
  # @api public
106
104
  #
107
105
  def udp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
108
- sock = udp_connect(host,port,local_host,local_port)
109
- sock.write(data)
106
+ socket = udp_connect(host,port,local_host,local_port)
107
+ socket.write(data)
110
108
 
111
- yield sock if block_given?
112
- return sock
109
+ yield socket if block_given?
110
+ return socket
113
111
  end
114
112
 
115
113
  #
@@ -140,14 +138,53 @@ module Ronin
140
138
  # @api public
141
139
  #
142
140
  def udp_session(host,port,local_host=nil,local_port=nil)
143
- sock = udp_connect(host,port,local_host,local_port)
141
+ socket = udp_connect(host,port,local_host,local_port)
144
142
 
145
- yield sock if block_given?
143
+ yield socket if block_given?
146
144
 
147
- sock.close
145
+ socket.close
148
146
  return nil
149
147
  end
150
148
 
149
+ #
150
+ # Connects to a specified host and port, sends the given data and then
151
+ # closes the connection.
152
+ #
153
+ # @param [String] data
154
+ # The data to send through the connection.
155
+ #
156
+ # @param [String] host
157
+ # The host to connect to.
158
+ #
159
+ # @param [Integer] port
160
+ # The port to connect to.
161
+ #
162
+ # @param [String] local_host (nil)
163
+ # The local host to bind to.
164
+ #
165
+ # @param [Integer] local_port (nil)
166
+ # The local port to bind to.
167
+ #
168
+ # @return [true]
169
+ # The data was successfully sent.
170
+ #
171
+ # @example
172
+ # buffer = "GET /" + ('A' * 4096) + "\n\r"
173
+ # udp_send(buffer,'victim.com',80)
174
+ # # => true
175
+ #
176
+ # @api public
177
+ #
178
+ # @since 0.4.0
179
+ #
180
+ def udp_send(data,host,port,local_host=nil,local_port=nil)
181
+ udp_session(host,port,local_host,local_port) do |socket|
182
+ socket.write(data)
183
+ end
184
+
185
+ return true
186
+ end
187
+
151
188
  #
152
189
  # Reads the banner from the service running on the given host and port.
153
190
  #
@@ -177,8 +214,8 @@ module Ronin
177
214
  def udp_banner(host,port,local_host=nil,local_port=nil)
178
215
  banner = nil
179
216
 
180
- udp_session(host,port,local_host,local_port) do |sock|
181
- banner = sock.readline
217
+ udp_session(host,port,local_host,local_port) do |socket|
218
+ banner = socket.readline
182
219
  end
183
220
 
184
221
  yield banner if block_given?
@@ -202,8 +239,8 @@ module Ronin
202
239
  #
203
240
  # @api public
204
241
  #
205
- def udp_server(port,host='0.0.0.0')
206
- host = host.to_s
242
+ def udp_server(port=nil,host=nil)
243
+ host = (host || '0.0.0.0').to_s
207
244
  server = UDPSocket.new
208
245
 
209
246
  server.bind(host,port)
@@ -237,7 +274,7 @@ module Ronin
237
274
  #
238
275
  # @api public
239
276
  #
240
- def udp_server_session(port,host='0.0.0.0',&block)
277
+ def udp_server_session(port=nil,host=nil,&block)
241
278
  server = udp_server(port,host,&block)
242
279
 
243
280
  server.close()
data/lib/ronin/path.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
data/lib/ronin/support.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Support
22
22
  # ronin-support version
23
- VERSION = '0.4.0.rc1'
23
+ VERSION = '0.4.0.rc2'
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -26,6 +26,68 @@ module Ronin
26
26
  #
27
27
  # Spawns a ReadLine powered interactive Shell.
28
28
  #
29
+ # ## Simple Shell
30
+ #
31
+ # require 'ronin/ui/shell'
32
+ # require 'ronin/network/tcp'
33
+ #
34
+ # include Ronin::Network::TCP
35
+ #
36
+ # tcp_session('victim.com',1337) do |socket|
37
+ # UI::Shell.new(:name => 'bind_shell') do |shell,line|
38
+ # socket.puts "#{line}; echo 'EOC'"
39
+ #
40
+ # socket.each_line do |output|
41
+ # puts output
42
+ #
43
+ # break if output.chomp == 'EOC'
44
+ # end
45
+ # end
46
+ # end
47
+ #
48
+ # ## Shell with Commands
49
+ #
50
+ # require 'ronin/ui/shell'
51
+ # require 'ronin/network/http'
52
+ #
53
+ # class HTTPShell < Ronin::UI::Shell
54
+ #
55
+ # include Ronin::Network::HTTP
56
+ #
57
+ # def initialize(host)
58
+ # super(:name => host)
59
+ #
60
+ # @host = host
61
+ # end
62
+ #
63
+ # protected
64
+ #
65
+ # def get(path)
66
+ # print_response http_get(:host => @host, :path => path)
67
+ # end
68
+ #
69
+ # def post(path,*params)
70
+ # print_response http_post(
71
+ # :host => @host,
72
+ # :path => path,
73
+ # :post_data => Hash[params.map { |param| param.split('=') }]
74
+ # )
75
+ # end
76
+ #
77
+ # private
78
+ #
79
+ # def print_response(response)
80
+ # response.canonical_each do |name,value|
81
+ # puts "#{name}: #{value}"
82
+ # end
83
+ #
84
+ # puts
85
+ #
86
+ # puts response.body
87
+ # end
88
+ #
89
+ # end
90
+ #
29
91
  # @api semipublic
30
92
  #
31
93
  class Shell
@@ -70,15 +132,15 @@ module Ronin
70
132
  # @since 0.3.0
71
133
  #
72
134
  def initialize(options={},&block)
73
- @name = options.fetch(:name,'')
135
+ @name = options[:name]
74
136
  @prompt = options.fetch(:prompt,DEFAULT_PROMPT)
75
137
 
76
- @commands = Set[:help, :exit]
138
+ @commands = Set['help', 'exit']
77
139
 
78
140
  self.class.ancestors.each do |subclass|
79
141
  if subclass < Shell
80
142
  subclass.protected_instance_methods(false).each do |name|
81
- @commands << name.to_sym
143
+ @commands << name.to_s
82
144
  end
83
145
  end
84
146
  end
@@ -163,10 +225,8 @@ module Ronin
163
225
  # ignore empty lines
164
226
  return false unless command
165
227
 
166
- command = command.to_sym
167
-
168
228
  # no explicitly calling handler
169
- return false if command == :handler
229
+ return false if command == 'handler'
170
230
 
171
231
  unless @commands.include?(command)
172
232
  print_error "Invalid command: #{command}"
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
4
  # This file is part of Ronin Support.
5
5
  #
@@ -19,6 +19,8 @@
19
19
 
20
20
  require 'ronin/fuzzing/extensions'
21
21
 
22
+ require 'set'
23
+
22
24
  module Ronin
23
25
  #
24
26
  # An Enumerable class for iterating over wordlist files or lists of words.
@@ -71,6 +73,54 @@ module Ronin
71
73
  yield self if block_given?
72
74
  end
73
75
 
76
+ #
77
+ # Parses the text into a unique Set of words.
78
+ #
79
+ # @param [#each_line] text
80
+ # The text to parse.
81
+ #
82
+ # @yield [word]
83
+ # If a block is given, it will be passed every unique word,
84
+ # the first time it is seen.
85
+ #
86
+ # @yieldparam [String] word
87
+ # A unique word from the text.
88
+ #
89
+ # @return [SortedSet]
90
+ # The unique set of words from the text.
91
+ #
92
+ def self.parse(text)
93
+ words_seen = SortedSet[]
94
+
95
+ text.each_line do |line|
96
+ line.split.each do |word|
97
+ if block_given?
98
+ yield word unless words_seen.include?(word)
99
+ end
100
+
101
+ words_seen << word
102
+ end
103
+ end
104
+
105
+ return words_seen
106
+ end
107
+
108
+ #
109
+ # Builds a new wordlist from the text.
110
+ #
111
+ # @param [#each_line] text
112
+ # The text to parse.
113
+ #
114
+ # @param [Hash{Regexp,String,Symbol => Symbol,#each}] mutations
115
+ # Additional mutations for the wordlist.
116
+ #
117
+ # @return [Wordlist]
118
+ # The newly build wordlist.
119
+ #
120
+ def self.build(text,mutations={})
121
+ new(parse(text),mutations)
122
+ end
123
+
74
124
  #
75
125
  # Iterates over each word in the list.
76
126
  #
@@ -159,7 +159,7 @@ describe IPAddr do
159
159
  let(:ip) { IPAddr.new('127.0.0.1') }
160
160
  let(:bad_ip) { IPAddr.new('0.0.0.0') }
161
161
 
162
- describe "#lookup" do
162
+ describe "#lookup", :network do
163
163
  let(:nameserver) { '4.2.2.1' }
164
164
 
165
165
  it "should lookup the host-name for an IP" do