rbkb 0.6.11 → 0.6.12
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/rbkb.rb +1 -1
- data/lib/rbkb/extends.rb +38 -33
- data/lib/rbkb/plug.rb +2 -0
- data/rbkb.gemspec +2 -2
- metadata +3 -3
data/History.txt
CHANGED
data/lib/rbkb.rb
CHANGED
data/lib/rbkb/extends.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
require "stringio"
|
5
5
|
require 'zlib'
|
6
6
|
require 'open3'
|
7
|
+
require 'enumerator'
|
7
8
|
|
8
9
|
module Rbkb
|
9
10
|
DEFAULT_BYTE_ORDER=:big
|
@@ -33,8 +34,28 @@ end if not defined? with
|
|
33
34
|
# Mixins and class-specific items
|
34
35
|
|
35
36
|
class String
|
37
|
+
# fake the ruby 1.9 String#bytes method if we don't have one
|
38
|
+
def bytes
|
39
|
+
::Enumerable::Enumerator.new(self, :each_byte)
|
40
|
+
end if not defined?("".bytes)
|
41
|
+
|
42
|
+
# fake the ruby 1.9 String#getbyte method if we don't have one
|
43
|
+
def getbyte(i)
|
44
|
+
self[i]
|
45
|
+
end if RUBY_VERSION.to_f < 1.9 and not defined?("".getbyte)
|
46
|
+
|
47
|
+
# fake the ruby 1.9 String#ord method if we don't have one
|
48
|
+
def ord
|
49
|
+
getbyte(0)
|
50
|
+
end if not defined?("".ord)
|
51
|
+
|
52
|
+
# Works just like each_with_index, but with each_byte
|
53
|
+
def each_byte_with_index
|
54
|
+
bytes.each_with_index {|b,i| yield(b,i) }
|
55
|
+
end
|
56
|
+
|
36
57
|
# shortcut for hex sanity with regex
|
37
|
-
def ishex? ; (self =~ /^[a-f0-9]+$/i)
|
58
|
+
def ishex? ; (self =~ /^[a-f0-9]+$/i) != nil ; end
|
38
59
|
|
39
60
|
# Encode into percent-hexify url encoding format
|
40
61
|
def urlenc(opts={})
|
@@ -46,7 +67,7 @@ class String
|
|
46
67
|
hx = Rbkb::HEXCHARS
|
47
68
|
|
48
69
|
s.gsub(opts[:rx]) do |c|
|
49
|
-
c=c
|
70
|
+
c=c.ord
|
50
71
|
(plus and c==32)? '+' : "%" + (hx[(c >> 4)] + hx[(c & 0xf )])
|
51
72
|
end
|
52
73
|
end
|
@@ -69,24 +90,22 @@ class String
|
|
69
90
|
end
|
70
91
|
|
71
92
|
# Base64 decode
|
72
|
-
def d64; self.unpack("m")
|
93
|
+
def d64; self.unpack("m").first ; end
|
73
94
|
|
74
95
|
# right-align to 'a' alignment padded with 'p'
|
75
96
|
def ralign(a, p=' ')
|
76
|
-
s=self
|
77
97
|
p ||= ' '
|
78
|
-
l =
|
98
|
+
l = self.length
|
79
99
|
pad = l.pad(a)
|
80
|
-
|
100
|
+
self.rjust(pad+l, p)
|
81
101
|
end
|
82
102
|
|
83
103
|
# left-align to 'a' alignment padded with 'p'
|
84
104
|
def lalign(a, p=' ')
|
85
|
-
s=self
|
86
105
|
p ||= ' '
|
87
|
-
l =
|
106
|
+
l = self.length
|
88
107
|
pad = l.pad(a)
|
89
|
-
|
108
|
+
self.ljust(pad+l, p)
|
90
109
|
end
|
91
110
|
|
92
111
|
|
@@ -97,7 +116,6 @@ class String
|
|
97
116
|
# :suffix - suffix after each hex byte
|
98
117
|
#
|
99
118
|
def hexify(opts={})
|
100
|
-
s=self
|
101
119
|
delim = opts[:delim]
|
102
120
|
pre = (opts[:prefix] || "")
|
103
121
|
suf = (opts[:suffix] || "")
|
@@ -110,7 +128,7 @@ class String
|
|
110
128
|
|
111
129
|
out=Array.new
|
112
130
|
|
113
|
-
|
131
|
+
self.each_byte do |c|
|
114
132
|
hc = if (rx and not rx.match c.chr)
|
115
133
|
c.chr
|
116
134
|
else
|
@@ -205,11 +223,6 @@ class String
|
|
205
223
|
# ["t", 242],
|
206
224
|
# ["o", 233],
|
207
225
|
# ["i", 218],
|
208
|
-
# ["a", 176],
|
209
|
-
# ["s", 172],
|
210
|
-
# ["r", 172],
|
211
|
-
# ["n", 167],
|
212
|
-
# ["d", 106],
|
213
226
|
# ...
|
214
227
|
# ]
|
215
228
|
#
|
@@ -219,16 +232,14 @@ class String
|
|
219
232
|
hits.to_a.sort {|a,b| b[1] <=> a[1] }
|
220
233
|
end
|
221
234
|
|
222
|
-
|
223
235
|
# xor against a key. key will be repeated or truncated to self.size.
|
224
236
|
def xor(k)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
end
|
231
|
-
out.string
|
237
|
+
i=0
|
238
|
+
self.bytes.map do |b|
|
239
|
+
x = k.getbyte(i) || k.getbyte(i=0)
|
240
|
+
i+=1
|
241
|
+
(b ^ x).chr
|
242
|
+
end.join
|
232
243
|
end
|
233
244
|
|
234
245
|
|
@@ -256,15 +267,9 @@ class String
|
|
256
267
|
|
257
268
|
|
258
269
|
# Byte rotation as found in lame ciphers.
|
259
|
-
# This was cribbed from Timur Duehr with only a minor change.
|
260
270
|
def rotate_bytes(k=0)
|
261
|
-
|
262
|
-
|
263
|
-
self.each_byte do |b|
|
264
|
-
r[i] = ((b + k) % 384).chr
|
265
|
-
i+=1
|
266
|
-
end
|
267
|
-
return r
|
271
|
+
k = (256 + k) if k < 0
|
272
|
+
self.bytes.map {|c| ((c + k) & 0xff).chr }.join
|
268
273
|
end
|
269
274
|
|
270
275
|
|
@@ -320,7 +325,7 @@ class String
|
|
320
325
|
out.write(" " * (len-i) ) # pad
|
321
326
|
out.write(" ") if i < hlen
|
322
327
|
|
323
|
-
out.write("
|
328
|
+
out.write(" |#{m.tr("\0-\37\177-\377", '.')}|\n")
|
324
329
|
off += m.length
|
325
330
|
end
|
326
331
|
|
data/lib/rbkb/plug.rb
CHANGED
data/rbkb.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rbkb}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.12"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Eric Monti"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-11-02}
|
10
10
|
s.description = %q{Rbkb is a collection of ruby-based pen-testing and reversing tools. Inspired by Matasano Blackbag.}
|
11
11
|
s.email = %q{emonti@matasano.com}
|
12
12
|
s.executables = ["b64", "bgrep", "blit", "c", "crc32", "d64", "dedump", "feed", "hexify", "len", "plugsrv", "rex", "rstrings", "slice", "telson", "unhexify", "urldec", "urlenc", "xor"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbkb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Monti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-02 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
requirements: []
|
196
196
|
|
197
197
|
rubyforge_project: rbkb
|
198
|
-
rubygems_version: 1.3.
|
198
|
+
rubygems_version: 1.3.5
|
199
199
|
signing_key:
|
200
200
|
specification_version: 3
|
201
201
|
summary: Rbkb is a collection of ruby-based pen-testing and reversing tools
|