ronin-support 0.5.0.rc2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- ### 0.5.0 / 2012-05-28
1
+ ### 0.5.0 / 2012-06-16
2
2
 
3
3
  * Added {Float#pack}.
4
4
  * Added {Regexp::WORD}.
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :development do
13
13
  gem 'ripl-multi_line', '~> 0.2'
14
14
  gem 'ripl-auto_indent', '~> 0.1'
15
15
  gem 'ripl-color_result', '~> 0.3'
16
+ gem 'rspec', '~> 2.8'
16
17
 
17
18
  gem 'kramdown', '~> 0.12'
18
19
  end
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Ronin Support
2
2
 
3
- * [Source](http://github.com/ronin-ruby/ronin-support)
4
- * [Issues](http://github.com/ronin-ruby/ronin-support/issues)
5
- * [Documentation](http://rubydoc.info/gems/ronin-support/frames)
3
+ * [Source](https://github.com/ronin-ruby/ronin-support)
4
+ * [Issues](https://github.com/ronin-ruby/ronin-support/issues)
5
+ * [Documentation](http://ronin-ruby.github.com/docs/ronin-support/frames)
6
6
  * [Mailing List](http://groups.google.com/group/ronin-ruby)
7
7
  * [irc.freenode.net #ronin](http://webchat.freenode.net/?channels=ronin&uio=Mj10cnVldd)
8
8
 
@@ -31,6 +31,7 @@ or payloads over many common Source-Code-Management (SCM) systems.
31
31
  * DNS
32
32
  * TCP
33
33
  * UDP
34
+ * SSL
34
35
  * SMTP / ESMTP
35
36
  * POP3
36
37
  * Imap
@@ -43,6 +44,7 @@ or payloads over many common Source-Code-Management (SCM) systems.
43
44
  * Handling exceptions.
44
45
  * Provides Modules/Classes for:
45
46
  * Paths
47
+ * Fuzzing
46
48
  * Wordlists
47
49
  * Erb Templates
48
50
  * UI:
@@ -57,17 +59,17 @@ please see [Everyday Ronin](http://ronin-ruby.github.com/guides/everyday_ronin.h
57
59
  ## Requirements
58
60
 
59
61
  * [Ruby](http://www.ruby-lang.org/) >= 1.8.7
60
- * [chars](http://github.com/postmodern/chars#readme)
62
+ * [chars](https://github.com/postmodern/chars#readme)
61
63
  ~> 0.2
62
- * [hexdump](http://github.com/postmodern/hexdump#readme)
64
+ * [hexdump](https://github.com/postmodern/hexdump#readme)
63
65
  ~> 0.1
64
- * [combinatorics](http://github.com/postmodern/combinatorics#readme)
66
+ * [combinatorics](https://github.com/postmodern/combinatorics#readme)
65
67
  ~> 0.4
66
- * [uri-query_params](http://github.com/postmodern/uri-query_params#readme)
68
+ * [uri-query_params](https://github.com/postmodern/uri-query_params#readme)
67
69
  ~> 0.6
68
- * [data_paths](http://github.com/postmodern/data_paths#readme)
70
+ * [data_paths](https://github.com/postmodern/data_paths#readme)
69
71
  ~> 0.3
70
- * [parameters](http://github.com/postmodern/parameters#readme)
72
+ * [parameters](https://github.com/postmodern/parameters#readme)
71
73
  ~> 0.4
72
74
 
73
75
  ## Install
@@ -7,7 +7,7 @@ description:
7
7
  license: LGPL-3
8
8
  authors: Postmodern
9
9
  email: postmodern.mod3@gmail.com
10
- homepage: http://github.com/ronin-ruby/ronin-support
10
+ homepage: http://ronin-ruby.github.com/
11
11
  has_yard: true
12
12
 
13
13
  required_ruby_version: ">= 1.8.7"
@@ -26,6 +26,8 @@ module Ronin
26
26
  #
27
27
  # Generic Binary Struct class.
28
28
  #
29
+ # ## Example
30
+ #
29
31
  # class Packet < Binary::Struct
30
32
  #
31
33
  # endian :network
@@ -326,6 +326,13 @@ module Ronin
326
326
  @template = self.class.compile(@fields,options)
327
327
  end
328
328
 
329
+ #
330
+ # @see #initialize
331
+ #
332
+ def self.[](*fields)
333
+ new(fields)
334
+ end
335
+
329
336
  #
330
337
  # Translates the type of the field.
331
338
  #
@@ -44,7 +44,7 @@ class File
44
44
  # @api public
45
45
  #
46
46
  def File.each_line(path)
47
- return enum_for(:each_line,path) unless block_given?
47
+ return enum_for(__method__,path) unless block_given?
48
48
 
49
49
  File.open(path) do |file|
50
50
  file.each_line { |line| yield line.chomp }
@@ -79,7 +79,7 @@ class File
79
79
  # @api public
80
80
  #
81
81
  def File.each_row(path,separator=/\s+/)
82
- return enum_for(:each_row,path,separator) unless block_given?
82
+ return enum_for(__method__,path,separator) unless block_given?
83
83
 
84
84
  File.each_line(path) { |line| yield line.split(separator) }
85
85
  end
@@ -63,7 +63,7 @@ class IPAddr
63
63
  # @api public
64
64
  #
65
65
  def IPAddr.extract(text,version=nil,&block)
66
- return enum_for(:extract,text,version).to_a unless block_given?
66
+ return enum_for(__method__,text,version).to_a unless block_given?
67
67
 
68
68
  regexp = case version
69
69
  when :ipv4, :v4, 4
@@ -122,7 +122,7 @@ class IPAddr
122
122
  return IPAddr.new(cidr_or_glob).each(&block)
123
123
  end
124
124
 
125
- return enum_for(:each,cidr_or_glob) unless block
125
+ return enum_for(__method__,cidr_or_glob) unless block
126
126
 
127
127
  if cidr_or_glob.include?('::')
128
128
  separator = '::'
@@ -208,7 +208,7 @@ class IPAddr
208
208
  # @api public
209
209
  #
210
210
  def each
211
- return enum_for(:each) unless block_given?
211
+ return enum_for(__method__) unless block_given?
212
212
 
213
213
  family_mask = MASKS[@family]
214
214
 
@@ -46,7 +46,7 @@ class String
46
46
  # @api public
47
47
  #
48
48
  def each_substring(min=1,&block)
49
- return enum_for(:each_substring,min) unless block
49
+ return enum_for(__method__,min) unless block
50
50
 
51
51
  (0..(length - min)).each do |i|
52
52
  ((i + min)..length).each do |j|
@@ -92,7 +92,7 @@ class String
92
92
  # @api public
93
93
  #
94
94
  def each_unique_substring(min=1,&block)
95
- return enum_for(:each_unique_substring,min) unless block
95
+ return enum_for(__method__,min) unless block
96
96
 
97
97
  unique_strings = {}
98
98
 
@@ -60,7 +60,7 @@ class Integer
60
60
  buffer = []
61
61
 
62
62
  case endian
63
- when :little, :net
63
+ when :little
64
64
  mask = 0xff
65
65
  shift = 0
66
66
 
@@ -70,7 +70,7 @@ class Integer
70
70
  mask <<= 8
71
71
  shift += 8
72
72
  end
73
- when :big
73
+ when :big, :net
74
74
  shift = ((length - 1) * 8)
75
75
  mask = (0xff << shift)
76
76
 
@@ -25,9 +25,8 @@ require 'ronin/binary/template'
25
25
 
26
26
  begin
27
27
  require 'zlib'
28
- rescue Gem::LoadError => e
29
- raise(e)
30
28
  rescue ::LoadError
29
+ $stderr.puts "WARNING: Ruby was not compiled with zlib support"
31
30
  end
32
31
 
33
32
  class String
@@ -92,7 +92,7 @@ class String
92
92
  #
93
93
  # Repeats the String.
94
94
  #
95
- # @param [Enumerable, Integer] lengths
95
+ # @param [Enumerable<Integer>, Integer] lengths
96
96
  # The number of times to repeat the String.
97
97
  #
98
98
  # @yield [repeated]
@@ -141,7 +141,7 @@ class String
141
141
  #
142
142
  # Incrementally fuzzes the String.
143
143
  #
144
- # @param [Hash{Regexp,String => #each}] substitutions
144
+ # @param [Hash{Regexp,String,Symbol => Enumerable,Symbol}] substitutions
145
145
  # Patterns and their substitutions.
146
146
  #
147
147
  # @yield [fuzz]
@@ -163,6 +163,9 @@ class String
163
163
  # p str
164
164
  # end
165
165
  #
166
+ # @example Replace a {Regexp::UNIX_PATH} with {Ronin::Fuzzing#format_strings}:
167
+ # "GET /downloads/".fuzz(:unix_path => :format_string)
168
+ #
166
169
  # @since 0.3.0
167
170
  #
168
171
  # @api public
@@ -174,7 +177,7 @@ class String
174
177
  #
175
178
  # Permutes over every possible mutation of the String.
176
179
  #
177
- # @param [Hash{Regexp,String,Symbol => Symbol,Enumerable}] mutations
180
+ # @param [Hash{Regexp,String,Symbol => Enumerable,Symbol}] mutations
178
181
  # The patterns and substitutions to mutate the String with.
179
182
  #
180
183
  # @yield [mutant]
@@ -40,7 +40,7 @@ module Ronin
40
40
  #
41
41
  # Initializes a new Fuzzer.
42
42
  #
43
- # @param [Hash{Regexp,String => #each}] rules
43
+ # @param [Hash{Regexp,String,Symbol => Enumerable,Symbol}] rules
44
44
  # Patterns and their substitutions.
45
45
  #
46
46
  def initialize(rules)
@@ -20,6 +20,7 @@
20
20
  require 'ronin/network/dns'
21
21
  require 'ronin/network/tcp'
22
22
  require 'ronin/network/udp'
23
+ require 'ronin/network/ssl'
23
24
  require 'ronin/network/unix'
24
25
  require 'ronin/network/smtp'
25
26
  require 'ronin/network/esmtp'
@@ -20,6 +20,7 @@
20
20
  require 'ronin/network/extensions/dns'
21
21
  require 'ronin/network/extensions/tcp'
22
22
  require 'ronin/network/extensions/udp'
23
+ require 'ronin/network/extensions/ssl'
23
24
  require 'ronin/network/extensions/smtp'
24
25
  require 'ronin/network/extensions/esmtp'
25
26
  require 'ronin/network/extensions/pop3'
@@ -27,6 +27,7 @@ require 'net/http'
27
27
  begin
28
28
  require 'net/https'
29
29
  rescue ::LoadError
30
+ $stderr.puts "WARNING: could not load 'net/https'"
30
31
  end
31
32
 
32
33
  module Ronin
@@ -130,7 +130,7 @@ module Ronin
130
130
  #
131
131
  # @example
132
132
  # ssl_session do |socket|
133
- # socket.write("GET /\n\n")
133
+ # socket.write("GET / HTTP/1.1\n\r\n\r")
134
134
  #
135
135
  # socket.each_line { |line| puts line }
136
136
  # end
@@ -107,7 +107,7 @@ module Ronin
107
107
  #
108
108
  # @example
109
109
  # tcp_connect do |socket|
110
- # socket.write("GET /\n\n")
110
+ # socket.write("GET / HTTP/1.1\n\r\n\r")
111
111
  #
112
112
  # puts socket.readlines
113
113
  # socket.close
@@ -22,6 +22,7 @@ require 'ronin/network/tcp'
22
22
  begin
23
23
  require 'openssl'
24
24
  rescue ::LoadError
25
+ $stderr.puts "WARNING: Ruby was not compiled with OpenSSL support"
25
26
  end
26
27
 
27
28
  module Ronin
@@ -99,6 +100,8 @@ module Ronin
99
100
  # @example
100
101
  # socket = ssl_connect('twitter.com',443)
101
102
  #
103
+ # @see http://rubydoc.info/stdlib/openssl/OpenSSL/SSL/SSLSocket
104
+ #
102
105
  # @api public
103
106
  #
104
107
  def ssl_connect(host,port,options={})
@@ -165,11 +168,13 @@ module Ronin
165
168
  #
166
169
  # @example
167
170
  # ssl_session('twitter.com',443) do |sock|
168
- # sock.write("GET /\n\n")
171
+ # sock.write("GET / HTTP/1.1\n\r\n\r")
169
172
  #
170
173
  # sock.each_line { |line| puts line }
171
174
  # end
172
175
  #
176
+ # @see http://rubydoc.info/stdlib/openssl/OpenSSL/SSL/SSLSocket
177
+ #
173
178
  # @api public
174
179
  #
175
180
  def ssl_session(host,port,options={},&block)
@@ -27,6 +27,46 @@ module Ronin
27
27
  #
28
28
  # The TCP Proxy allows for inspecting and manipulating TCP protocols.
29
29
  #
30
+ # ## Example
31
+ #
32
+ # require 'ronin/network/tcp/proxy'
33
+ # require 'hexdump'
34
+ #
35
+ # Ronin::Network::TCP::Proxy.start(:port => 1337, :server => ['www.wired.com', 80]) do |proxy|
36
+ # address = lambda { |socket|
37
+ # addrinfo = socket.peeraddr
38
+ #
39
+ # "#{addrinfo[3]}:#{addrinfo[1]}"
40
+ # }
41
+ # hex = Hexdump::Dumper.new
42
+ #
43
+ # proxy.on_client_data do |client,server,data|
44
+ # puts "#{address[client]} -> #{proxy}"
45
+ # hex.dump(data)
46
+ # end
47
+ #
48
+ # proxy.on_client_connect do |client|
49
+ # puts "#{address[client]} -> #{proxy} [connected]"
50
+ # end
51
+ #
52
+ # proxy.on_client_disconnect do |client,server|
53
+ # puts "#{address[client]} <- #{proxy} [disconnected]"
54
+ # end
55
+ #
56
+ # proxy.on_server_data do |client,server,data|
57
+ # puts "#{address[client]} <- #{proxy}"
58
+ # hex.dump(data)
59
+ # end
60
+ #
61
+ # proxy.on_server_connect do |client,server|
62
+ # puts "#{address[client]} <- #{proxy} [connected]"
63
+ # end
64
+ #
65
+ # proxy.on_server_disconnect do |client,server|
66
+ # puts "#{address[client]} <- #{proxy} [disconnected]"
67
+ # end
68
+ # end
69
+ #
30
70
  # ## Callbacks
31
71
  #
32
72
  # In addition to the events supported by the {Network::Proxy Proxy}
@@ -24,6 +24,28 @@ require 'socket'
24
24
  module Ronin
25
25
  module Network
26
26
  module UDP
27
+ #
28
+ # The UDP Proxy allows for inspecting and manipulating UDP protocols.
29
+ #
30
+ # ## Example
31
+ #
32
+ # require 'ronin/network/udp/proxy'
33
+ # require 'hexdump'
34
+ #
35
+ # Ronin::Network::UDP::Proxy.start(:port => 1337, :server => ['4.2.2.1', 53]) do |proxy|
36
+ # hex = Hexdump::Dumper.new
37
+ #
38
+ # proxy.on_client_data do |(client,(host,port)),server,data|
39
+ # puts "#{host}:#{port} -> #{proxy}"
40
+ # hex.dump(data)
41
+ # end
42
+ #
43
+ # proxy.on_server_data do |(client,(host,port)),server,data|
44
+ # puts "#{host}:#{port} <- #{proxy}"
45
+ # hex.dump(data)
46
+ # end
47
+ #
48
+ # end
27
49
  #
28
50
  # @since 0.5.0
29
51
  #
@@ -51,13 +73,13 @@ module Ronin
51
73
  readable, writtable, errors = IO.select(sockets,nil,sockets)
52
74
 
53
75
  (errors & server_connections).each do |server_socket|
54
- client_socket = client_for(server_socket)
76
+ client_socket = client_connection_for(server_socket)
55
77
 
56
78
  close_connection(client_socket,server_socket)
57
79
  end
58
80
 
59
81
  (readable & server_connections).each do |server_socket|
60
- client_socket = client_for(server_socket)
82
+ client_socket = client_connection_for(server_socket)
61
83
  data, addrinfo = recv(server_socket)
62
84
 
63
85
  server_data(client_socket,server_socket,data)
@@ -115,7 +137,7 @@ module Ronin
115
137
 
116
138
  socket.recvfrom(@buffer_size)
117
139
  when UDPSocket
118
- socket.recv(@buffer_size)
140
+ connection.recvfrom(@buffer_size)
119
141
  end
120
142
  end
121
143
 
@@ -29,6 +29,7 @@ module Ronin
29
29
  include Network::DNS
30
30
  include Network::TCP
31
31
  include Network::UDP
32
+ include Network::SSL
32
33
  include Network::UNIX
33
34
  include Network::SMTP
34
35
  include Network::ESMTP
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Support
22
22
  # ronin-support version
23
- VERSION = '0.5.0.rc2'
23
+ VERSION = '0.5.0'
24
24
  end
25
25
  end
@@ -71,7 +71,7 @@ module Ronin
71
71
  #
72
72
  # Prints one or more messages.
73
73
  #
74
- # @param [Array] messages
74
+ # @param [Array] arguments
75
75
  # The messages to print.
76
76
  #
77
77
  # @example
@@ -81,11 +81,29 @@ module Ronin
81
81
  #
82
82
  # @api public
83
83
  #
84
- def puts(*messages)
85
- unless messages.empty?
86
- messages.each { |message| write("#{message}#{$/}") }
87
- else
84
+ def puts(*arguments)
85
+ if arguments.empty?
88
86
  write($/)
87
+ return nil
88
+ end
89
+
90
+ arguments.each do |argument|
91
+ if argument.kind_of?(Array)
92
+ argument.each { |element| puts(element) }
93
+ else
94
+ str = case argument
95
+ when nil
96
+ if RUBY_VERSION > '1.9'
97
+ ''
98
+ else
99
+ 'nil'
100
+ end
101
+ else
102
+ argument.to_s
103
+ end
104
+
105
+ write("#{str}#{$/}")
106
+ end
89
107
  end
90
108
 
91
109
  return nil
@@ -97,7 +115,7 @@ module Ronin
97
115
  # @param [String] format
98
116
  # The format string.
99
117
  #
100
- # @param [Array] data
118
+ # @param [Array] arguments
101
119
  # The data to format.
102
120
  #
103
121
  # @return [nil]
@@ -106,8 +124,8 @@ module Ronin
106
124
  #
107
125
  # @api public
108
126
  #
109
- def printf(format,*data)
110
- write(format % data)
127
+ def printf(format,*arguments)
128
+ write(format % arguments)
111
129
  return nil
112
130
  end
113
131
 
@@ -32,7 +32,7 @@ module Ronin
32
32
  :quiet
33
33
  end
34
34
 
35
- @handler = if STDOUT.tty?
35
+ @handler = if $stdout.tty?
36
36
  Terminal::Color
37
37
  else
38
38
  Terminal::Raw
@@ -195,7 +195,7 @@ module Ronin
195
195
  # @api public
196
196
  #
197
197
  def each_word(&block)
198
- return enum_for(:each_word) unless block
198
+ return enum_for(__method__) unless block
199
199
 
200
200
  if @path
201
201
  File.open(@path) do |file|
@@ -223,7 +223,7 @@ module Ronin
223
223
  # @api public
224
224
  #
225
225
  def each(&block)
226
- return enum_for(:each) unless block
226
+ return enum_for(__method__) unless block
227
227
 
228
228
  mutator = unless @mutations.empty?
229
229
  Fuzzing::Mutator.new(@mutations)
@@ -77,12 +77,14 @@ describe Network::TCP do
77
77
  let(:data) { "HELO ronin\n" }
78
78
  let(:local_port) { 1024 + rand(65535 - 1024) }
79
79
 
80
+ let(:expected_response) { "250 mx.google.com at your service\r\n" }
81
+
80
82
  it "should connect and then send data" do
81
83
  socket = subject.tcp_connect_and_send(data,host,port)
82
84
  banner = socket.readline
83
85
  response = socket.readline
84
86
 
85
- response.start_with?('250').should be_true
87
+ response.should == expected_response
86
88
 
87
89
  socket.close
88
90
  end
@@ -104,7 +106,7 @@ describe Network::TCP do
104
106
  response = socket.readline
105
107
  end
106
108
 
107
- response.start_with?('250').should be_true
109
+ response.should == expected_response
108
110
 
109
111
  socket.close
110
112
  end
@@ -136,21 +138,22 @@ describe Network::TCP do
136
138
  end
137
139
 
138
140
  describe "#tcp_banner" do
139
- let(:host) { 'smtp.gmail.com' }
140
- let(:port) { 25 }
141
-
141
+ let(:host) { 'smtp.gmail.com' }
142
+ let(:port) { 25 }
142
143
  let(:local_port) { 1024 + rand(65535 - 1024) }
143
144
 
144
- it "should read the service banner" do
145
+ let(:expected_banner) { /^220 mx\.google\.com ESMTP/ }
146
+
147
+ it "should return the read service banner" do
145
148
  banner = subject.tcp_banner(host,port)
146
149
 
147
- banner.start_with?('220').should be_true
150
+ banner.should =~ expected_banner
148
151
  end
149
152
 
150
153
  it "should bind to a local host and port" do
151
154
  banner = subject.tcp_banner(host,port,nil,local_port)
152
155
 
153
- banner.start_with?('220').should be_true
156
+ banner.should =~ expected_banner
154
157
  end
155
158
 
156
159
  it "should yield the banner" do
@@ -160,7 +163,7 @@ describe Network::TCP do
160
163
  banner = yielded_banner
161
164
  end
162
165
 
163
- banner.start_with?('220').should be_true
166
+ banner.should =~ expected_banner
164
167
  end
165
168
  end
166
169
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.rc2
5
- prerelease: 6
4
+ version: 0.5.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Postmodern
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-10 00:00:00.000000000 Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chars
@@ -392,7 +392,7 @@ files:
392
392
  - spec/ui/output_spec.rb
393
393
  - spec/ui/shell_spec.rb
394
394
  - spec/wordlist_spec.rb
395
- homepage: http://github.com/ronin-ruby/ronin-support
395
+ homepage: http://ronin-ruby.github.com/
396
396
  licenses:
397
397
  - LGPL-3
398
398
  post_install_message: