ronin-support 0.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/.document +4 -0
  2. data/.rspec +1 -0
  3. data/.yardopts +1 -0
  4. data/COPYING.txt +504 -0
  5. data/ChangeLog.md +4 -0
  6. data/Gemfile +23 -0
  7. data/README.md +98 -0
  8. data/Rakefile +29 -0
  9. data/gemspec.yml +20 -0
  10. data/lib/ronin/extensions.rb +28 -0
  11. data/lib/ronin/extensions/file.rb +63 -0
  12. data/lib/ronin/extensions/ip_addr.rb +220 -0
  13. data/lib/ronin/extensions/kernel.rb +45 -0
  14. data/lib/ronin/extensions/meta.rb +22 -0
  15. data/lib/ronin/extensions/meta/object.rb +24 -0
  16. data/lib/ronin/extensions/string.rb +200 -0
  17. data/lib/ronin/formatting.rb +26 -0
  18. data/lib/ronin/formatting/binary.rb +22 -0
  19. data/lib/ronin/formatting/digest.rb +22 -0
  20. data/lib/ronin/formatting/extensions.rb +25 -0
  21. data/lib/ronin/formatting/extensions/binary.rb +24 -0
  22. data/lib/ronin/formatting/extensions/binary/file.rb +35 -0
  23. data/lib/ronin/formatting/extensions/binary/integer.rb +147 -0
  24. data/lib/ronin/formatting/extensions/binary/string.rb +363 -0
  25. data/lib/ronin/formatting/extensions/digest.rb +23 -0
  26. data/lib/ronin/formatting/extensions/digest/file.rb +117 -0
  27. data/lib/ronin/formatting/extensions/digest/string.rb +80 -0
  28. data/lib/ronin/formatting/extensions/http.rb +23 -0
  29. data/lib/ronin/formatting/extensions/http/integer.rb +57 -0
  30. data/lib/ronin/formatting/extensions/http/string.rb +102 -0
  31. data/lib/ronin/formatting/extensions/text.rb +23 -0
  32. data/lib/ronin/formatting/extensions/text/array.rb +125 -0
  33. data/lib/ronin/formatting/extensions/text/string.rb +206 -0
  34. data/lib/ronin/formatting/http.rb +22 -0
  35. data/lib/ronin/formatting/text.rb +22 -0
  36. data/lib/ronin/network.rb +29 -0
  37. data/lib/ronin/network/esmtp.rb +22 -0
  38. data/lib/ronin/network/extensions.rb +29 -0
  39. data/lib/ronin/network/extensions/esmtp.rb +22 -0
  40. data/lib/ronin/network/extensions/esmtp/net.rb +100 -0
  41. data/lib/ronin/network/extensions/http.rb +22 -0
  42. data/lib/ronin/network/extensions/http/net.rb +661 -0
  43. data/lib/ronin/network/extensions/imap.rb +22 -0
  44. data/lib/ronin/network/extensions/imap/net.rb +124 -0
  45. data/lib/ronin/network/extensions/pop3.rb +22 -0
  46. data/lib/ronin/network/extensions/pop3/net.rb +92 -0
  47. data/lib/ronin/network/extensions/smtp.rb +22 -0
  48. data/lib/ronin/network/extensions/smtp/net.rb +110 -0
  49. data/lib/ronin/network/extensions/ssl.rb +22 -0
  50. data/lib/ronin/network/extensions/ssl/net.rb +147 -0
  51. data/lib/ronin/network/extensions/tcp.rb +22 -0
  52. data/lib/ronin/network/extensions/tcp/net.rb +304 -0
  53. data/lib/ronin/network/extensions/telnet.rb +22 -0
  54. data/lib/ronin/network/extensions/telnet/net.rb +156 -0
  55. data/lib/ronin/network/extensions/udp.rb +22 -0
  56. data/lib/ronin/network/extensions/udp/net.rb +226 -0
  57. data/lib/ronin/network/http.rb +24 -0
  58. data/lib/ronin/network/http/exceptions.rb +22 -0
  59. data/lib/ronin/network/http/exceptions/unknown_request.rb +29 -0
  60. data/lib/ronin/network/http/http.rb +290 -0
  61. data/lib/ronin/network/http/proxy.rb +307 -0
  62. data/lib/ronin/network/imap.rb +49 -0
  63. data/lib/ronin/network/network.rb +41 -0
  64. data/lib/ronin/network/pop3.rb +49 -0
  65. data/lib/ronin/network/smtp.rb +24 -0
  66. data/lib/ronin/network/smtp/email.rb +143 -0
  67. data/lib/ronin/network/smtp/smtp.rb +68 -0
  68. data/lib/ronin/network/ssl.rb +47 -0
  69. data/lib/ronin/network/tcp.rb +22 -0
  70. data/lib/ronin/network/telnet.rb +109 -0
  71. data/lib/ronin/network/udp.rb +22 -0
  72. data/lib/ronin/path.rb +132 -0
  73. data/lib/ronin/support.rb +28 -0
  74. data/lib/ronin/support/inflector.rb +40 -0
  75. data/lib/ronin/support/version.rb +27 -0
  76. data/lib/ronin/templates.rb +23 -0
  77. data/lib/ronin/templates/erb.rb +75 -0
  78. data/lib/ronin/templates/template.rb +161 -0
  79. data/ronin-support.gemspec +10 -0
  80. data/spec/extensions/file_spec.rb +24 -0
  81. data/spec/extensions/ip_addr_spec.rb +171 -0
  82. data/spec/extensions/kernel_spec.rb +30 -0
  83. data/spec/extensions/string_spec.rb +177 -0
  84. data/spec/formatting/binary/helpers/hexdumps.rb +16 -0
  85. data/spec/formatting/binary/helpers/hexdumps/ascii.bin +0 -0
  86. data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +17 -0
  87. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +17 -0
  88. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +17 -0
  89. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +17 -0
  90. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +17 -0
  91. data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +6 -0
  92. data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +17 -0
  93. data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +17 -0
  94. data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +17 -0
  95. data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +17 -0
  96. data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +17 -0
  97. data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +17 -0
  98. data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +17 -0
  99. data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +17 -0
  100. data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +17 -0
  101. data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +17 -0
  102. data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +17 -0
  103. data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +17 -0
  104. data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +6 -0
  105. data/spec/formatting/binary/helpers/hexdumps/repeated.bin +1 -0
  106. data/spec/formatting/binary/integer_spec.rb +140 -0
  107. data/spec/formatting/binary/string_spec.rb +306 -0
  108. data/spec/formatting/digest/string_spec.rb +82 -0
  109. data/spec/formatting/http/integer_spec.rb +42 -0
  110. data/spec/formatting/http/string_spec.rb +76 -0
  111. data/spec/formatting/text/array_spec.rb +105 -0
  112. data/spec/formatting/text/string_spec.rb +180 -0
  113. data/spec/network/http/http_spec.rb +280 -0
  114. data/spec/network/http/proxy_spec.rb +150 -0
  115. data/spec/network/network_spec.rb +8 -0
  116. data/spec/network/ssl_spec.rb +14 -0
  117. data/spec/path_spec.rb +84 -0
  118. data/spec/spec_helper.rb +4 -0
  119. data/spec/support_spec.rb +8 -0
  120. data/spec/templates/classes/example_erb.rb +11 -0
  121. data/spec/templates/classes/example_template.rb +35 -0
  122. data/spec/templates/erb_spec.rb +21 -0
  123. data/spec/templates/helpers/data.rb +9 -0
  124. data/spec/templates/helpers/data/includes/_relative.erb +1 -0
  125. data/spec/templates/helpers/data/templates/example.erb +1 -0
  126. data/spec/templates/template_spec.rb +54 -0
  127. metadata +286 -0
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/digest'
3
+
4
+ describe String do
5
+ subject { "hello" }
6
+
7
+ it "should provide String#md5" do
8
+ should respond_to(:md5)
9
+ end
10
+
11
+ it "should provide String#sha1" do
12
+ should respond_to(:sha1)
13
+ end
14
+
15
+ it "should provide String#sha2" do
16
+ should respond_to(:sha2)
17
+ end
18
+
19
+ it "should provide String#sha256" do
20
+ should respond_to(:sha256)
21
+ end
22
+
23
+ it "should provide String#sha512" do
24
+ should respond_to(:sha512)
25
+ end
26
+
27
+ describe "md5" do
28
+ subject { "test" }
29
+
30
+ let(:digest_md5) { "098f6bcd4621d373cade4e832627b4f6" }
31
+
32
+ it "should return the MD5 digest of itself" do
33
+ subject.md5.should == digest_md5
34
+ end
35
+ end
36
+
37
+ describe "sha1" do
38
+ subject { "test" }
39
+
40
+ let(:digest_sha1) { "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" }
41
+
42
+ it "should return the SHA1 digest of itself" do
43
+ subject.sha1.should == digest_sha1
44
+ end
45
+ end
46
+
47
+ describe "sha2" do
48
+ subject { "test" }
49
+
50
+ let(:digest_sha2) do
51
+ "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
52
+ end
53
+
54
+ it "should return the SHA2 digest of itself" do
55
+ subject.sha2.should == digest_sha2
56
+ end
57
+ end
58
+
59
+ describe "sha256" do
60
+ subject { "test" }
61
+
62
+ let(:digest_sha256) do
63
+ "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
64
+ end
65
+
66
+ it "should return the SHA256 digest of itself" do
67
+ subject.sha256.should == digest_sha256
68
+ end
69
+ end
70
+
71
+ describe "sha512" do
72
+ subject { "test" }
73
+
74
+ let(:digest_sha512) do
75
+ "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"
76
+ end
77
+
78
+ it "should return the SHA512 digest of itself" do
79
+ subject.sha512.should == digest_sha512
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/extensions/http/integer'
3
+
4
+ describe Integer do
5
+ subject { 0x20 }
6
+
7
+ it "should provide String#uri_encode" do
8
+ should respond_to(:uri_encode)
9
+ end
10
+
11
+ it "should provide String#uri_escape" do
12
+ should respond_to(:uri_escape)
13
+ end
14
+
15
+ it "should provide String#format_http" do
16
+ should respond_to(:format_http)
17
+ end
18
+
19
+ describe "uri_encode" do
20
+ let(:uri_encoded) { '%20' }
21
+
22
+ it "should URI encode itself" do
23
+ subject.uri_encode.should == uri_encoded
24
+ end
25
+ end
26
+
27
+ describe "uri_escape" do
28
+ let(:uri_escaped) { '+' }
29
+
30
+ it "should URI escape itself" do
31
+ subject.uri_escape.should == uri_escaped
32
+ end
33
+ end
34
+
35
+ describe "format_http" do
36
+ let(:http_formatted) { '%20' }
37
+
38
+ it "should format the byte" do
39
+ subject.format_http.should == http_formatted
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/extensions/http/string'
3
+
4
+ describe String do
5
+ subject { "hello" }
6
+
7
+ it "should provide String#uri_encode" do
8
+ should respond_to(:uri_encode)
9
+ end
10
+
11
+ it "should provide String#uri_decode" do
12
+ should respond_to(:uri_decode)
13
+ end
14
+
15
+ it "should provide String#uri_escape" do
16
+ should respond_to(:uri_escape)
17
+ end
18
+
19
+ it "should provide String#uri_unescape" do
20
+ should respond_to(:uri_unescape)
21
+ end
22
+
23
+ it "should provide String#format_http" do
24
+ should respond_to(:format_http)
25
+ end
26
+
27
+ describe "uri_encode" do
28
+ subject { "mod % 3" }
29
+
30
+ let(:uri_encoded) { "mod%20%25%203" }
31
+
32
+ it "should URI encode itself" do
33
+ subject.uri_encode.should == uri_encoded
34
+ end
35
+ end
36
+
37
+ describe "uri_decode" do
38
+ subject { "mod%20%25%203" }
39
+
40
+ let(:uri_decoded) { "mod % 3" }
41
+
42
+ it "should URI decode itself" do
43
+ subject.uri_decode.should == uri_decoded
44
+ end
45
+ end
46
+
47
+ describe "uri_escape" do
48
+ subject { "x + y" }
49
+
50
+ let(:uri_escaped) { "x+%2B+y" }
51
+
52
+ it "should URI escape itself" do
53
+ subject.uri_escape.should == uri_escaped
54
+ end
55
+ end
56
+
57
+ describe "uri_unescape" do
58
+ subject { "x+%2B+y" }
59
+
60
+ let(:uri_unescaped) { "x + y" }
61
+
62
+ it "should URI unescape itself" do
63
+ subject.uri_unescape.should == uri_unescaped
64
+ end
65
+ end
66
+
67
+ describe "format_http" do
68
+ subject { "mod % 3" }
69
+
70
+ let(:http_formatted) { "%6d%6f%64%20%25%20%33" }
71
+
72
+ it "should format each byte of the String" do
73
+ subject.format_http.should == http_formatted
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/text'
3
+
4
+ describe Array do
5
+ subject { [] }
6
+
7
+ let(:byte_array) { [0x41, 0x41, 0x20] }
8
+ let(:char_array) { ['A', 'A', ' '] }
9
+ let(:mixed_array) { ['AA', 0x20] }
10
+ let(:string) { 'AA ' }
11
+
12
+ it "should provide Array#bytes" do
13
+ should respond_to(:bytes)
14
+ end
15
+
16
+ it "should provide Array#chars" do
17
+ should respond_to(:chars)
18
+ end
19
+
20
+ it "should provide Array#char_string" do
21
+ should respond_to(:char_string)
22
+ end
23
+
24
+ it "should provide Array#hex_chars" do
25
+ should respond_to(:hex_chars)
26
+ end
27
+
28
+ it "should provide Array#hex_integers" do
29
+ should respond_to(:hex_integers)
30
+ end
31
+
32
+ describe "bytes" do
33
+ it "should convert an Array of bytes to an Array of bytes" do
34
+ byte_array.bytes.should == byte_array
35
+ end
36
+
37
+ it "should convert an Array of chars to an Array of bytes" do
38
+ char_array.bytes.should == byte_array
39
+ end
40
+
41
+ it "should safely handle mixed byte/char/string Arrays" do
42
+ mixed_array.bytes.should == byte_array
43
+ end
44
+ end
45
+
46
+ describe "chars" do
47
+ it "should convert an Array of bytes to an Array of chars" do
48
+ byte_array.chars.should == char_array
49
+ end
50
+
51
+ it "should safely convert an Array of chars to an Array of chars" do
52
+ char_array.chars.should == char_array
53
+ end
54
+
55
+ it "should safely handle mixed byte/char/string Arrays" do
56
+ mixed_array.chars.should == char_array
57
+ end
58
+ end
59
+
60
+ describe "char_string" do
61
+ it "should convert an Array of bytes to a String" do
62
+ byte_array.char_string.should == string
63
+ end
64
+
65
+ it "should convert an Array of chars to a String" do
66
+ char_array.char_string.should == string
67
+ end
68
+
69
+ it "should safely handle mixed byte/char/string Arrays" do
70
+ mixed_array.char_string.should == string
71
+ end
72
+ end
73
+
74
+ describe "hex_chars" do
75
+ let(:hex_chars) { ['\x41', '\x41', '\x20'] }
76
+
77
+ it "should convert an Array of bytes into hexadecimal chars" do
78
+ byte_array.hex_chars.should == hex_chars
79
+ end
80
+
81
+ it "should convert an Array of chars into hexadecimal chars" do
82
+ char_array.hex_chars.should == hex_chars
83
+ end
84
+
85
+ it "should safely handle mixed byte/char/string Arrays" do
86
+ mixed_array.hex_chars.should == hex_chars
87
+ end
88
+ end
89
+
90
+ describe "hex_integers" do
91
+ let(:hex_integers) { ['0x41', '0x41', '0x20'] }
92
+
93
+ it "should convert an Array of bytes into hexadecimal integers" do
94
+ byte_array.hex_integers.should == hex_integers
95
+ end
96
+
97
+ it "should convert an Array of chars into hexadecimal integers" do
98
+ char_array.hex_integers.should == hex_integers
99
+ end
100
+
101
+ it "should safely handle mixed byte/char/string Arrays" do
102
+ mixed_array.hex_integers.should == hex_integers
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,180 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/text'
3
+
4
+ describe String do
5
+ subject { "hello" }
6
+
7
+ it "should provide String#format_chars" do
8
+ should respond_to(:format_chars)
9
+ end
10
+
11
+ it "should provide String#format_bytes" do
12
+ should respond_to(:format_bytes)
13
+ end
14
+
15
+ it "should provide String#random_case" do
16
+ should respond_to(:random_case)
17
+ end
18
+
19
+ it "should provide String#insert_before" do
20
+ should respond_to(:insert_before)
21
+ end
22
+
23
+ it "should provide String#insert_after" do
24
+ should respond_to(:insert_after)
25
+ end
26
+
27
+ describe "format_chars" do
28
+ it "should format each character in the String" do
29
+ subject.format_chars { |c|
30
+ "_#{c}"
31
+ }.should == "_h_e_l_l_o"
32
+ end
33
+
34
+ it "should format specific bytes in a String" do
35
+ subject.format_chars(:include => [104, 108]) { |c|
36
+ c.upcase
37
+ }.should == 'HeLLo'
38
+ end
39
+
40
+ it "should not format specific bytes in a String" do
41
+ subject.format_chars(:exclude => [101, 111]) { |c|
42
+ c.upcase
43
+ }.should == 'HeLLo'
44
+ end
45
+
46
+ it "should format ranges of bytes in a String" do
47
+ subject.format_chars(:include => (104..108)) { |c|
48
+ c.upcase
49
+ }.should == 'HeLLo'
50
+ end
51
+
52
+ it "should not format ranges of bytes in a String" do
53
+ subject.format_chars(:exclude => (104..108)) { |c|
54
+ c.upcase
55
+ }.should == 'hEllO'
56
+ end
57
+
58
+ it "should format specific chars in a String" do
59
+ subject.format_chars(:include => ['h', 'l']) { |c|
60
+ c.upcase
61
+ }.should == 'HeLLo'
62
+ end
63
+
64
+ it "should not format specific bytes in a String" do
65
+ subject.format_chars(:exclude => ['e', 'o']) { |c|
66
+ c.upcase
67
+ }.should == 'HeLLo'
68
+ end
69
+
70
+ it "should format ranges of chars in a String" do
71
+ subject.format_chars(:include => ('h'..'l')) { |c|
72
+ c.upcase
73
+ }.should == 'HeLLo'
74
+ end
75
+
76
+ it "should not format ranges of chars in a String" do
77
+ subject.format_chars(:exclude => ('h'..'l')) { |c|
78
+ c.upcase
79
+ }.should == 'hEllO'
80
+ end
81
+ end
82
+
83
+ describe "format_bytes" do
84
+ it "should format each byte in the String" do
85
+ subject.format_bytes { |b|
86
+ sprintf("%%%x",b)
87
+ }.should == "%68%65%6c%6c%6f"
88
+ end
89
+
90
+ it "should format specific bytes in a String" do
91
+ subject.format_bytes(:include => [104, 108]) { |b|
92
+ b - 32
93
+ }.should == 'HeLLo'
94
+ end
95
+
96
+ it "should not format specific bytes in a String" do
97
+ subject.format_bytes(:exclude => [101, 111]) { |b|
98
+ b - 32
99
+ }.should == 'HeLLo'
100
+ end
101
+
102
+ it "should format ranges of bytes in a String" do
103
+ subject.format_bytes(:include => (104..108)) { |b|
104
+ b - 32
105
+ }.should == 'HeLLo'
106
+ end
107
+
108
+ it "should not format ranges of bytes in a String" do
109
+ subject.format_bytes(:exclude => (104..108)) { |b|
110
+ b - 32
111
+ }.should == 'hEllO'
112
+ end
113
+
114
+ it "should format specific chars in a String" do
115
+ subject.format_bytes(:include => ['h', 'l']) { |b|
116
+ b - 32
117
+ }.should == 'HeLLo'
118
+ end
119
+
120
+ it "should not format specific bytes in a String" do
121
+ subject.format_bytes(:exclude => ['e', 'o']) { |b|
122
+ b - 32
123
+ }.should == 'HeLLo'
124
+ end
125
+
126
+ it "should format ranges of chars in a String" do
127
+ subject.format_bytes(:include => ('h'..'l')) { |b|
128
+ b - 32
129
+ }.should == 'HeLLo'
130
+ end
131
+
132
+ it "should not format ranges of chars in a String" do
133
+ subject.format_bytes(:exclude => ('h'..'l')) { |b|
134
+ b - 32
135
+ }.should == 'hEllO'
136
+ end
137
+ end
138
+
139
+ describe "random_case" do
140
+ it "should capitalize each character when :probability is 1.0" do
141
+ new_string = subject.random_case(:probability => 1.0)
142
+
143
+ subject.upcase.should == new_string
144
+ end
145
+
146
+ it "should not capitalize any characters when :probability is 0.0" do
147
+ new_string = subject.random_case(:probability => 0.0)
148
+
149
+ subject.should == new_string
150
+ end
151
+ end
152
+
153
+ describe "insert_before" do
154
+ it "should inject data before a matched String" do
155
+ subject.insert_before('ll','x').should == "hexllo"
156
+ end
157
+
158
+ it "should inject data before a matched Regexp" do
159
+ subject.insert_before(/l+/,'x').should == "hexllo"
160
+ end
161
+
162
+ it "should not inject data if no matches are found" do
163
+ subject.insert_before(/x/,'x').should == subject
164
+ end
165
+ end
166
+
167
+ describe "insert_after" do
168
+ it "should inject data after a matched String" do
169
+ subject.insert_after('ll','x').should == "hellxo"
170
+ end
171
+
172
+ it "should inject data after a matched Regexp" do
173
+ subject.insert_after(/l+/,'x').should == "hellxo"
174
+ end
175
+
176
+ it "should not inject data if no matches are found" do
177
+ subject.insert_after(/x/,'x').should == subject
178
+ end
179
+ end
180
+ end