emonti-rbkb 0.6.1.3 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +191 -24
- data/bin/b64 +2 -54
- data/bin/bgrep +2 -88
- data/bin/blit +2 -94
- data/bin/c +2 -11
- data/bin/crc32 +2 -57
- data/bin/d64 +2 -38
- data/bin/dedump +2 -50
- data/bin/hexify +2 -82
- data/bin/len +2 -71
- data/bin/plugsrv +56 -61
- data/bin/rstrings +2 -120
- data/bin/slice +2 -71
- data/bin/telson +2 -106
- data/bin/unhexify +2 -62
- data/bin/urldec +2 -53
- data/bin/urlenc +2 -52
- data/bin/xor +2 -57
- data/lib/rbkb/cli/b64.rb +27 -0
- data/lib/rbkb/cli/bgrep.rb +78 -0
- data/lib/rbkb/cli/blit.rb +86 -0
- data/lib/rbkb/cli/chars.rb +20 -0
- data/lib/rbkb/cli/crc32.rb +29 -0
- data/lib/rbkb/cli/d64.rb +22 -0
- data/lib/rbkb/cli/dedump.rb +47 -0
- data/lib/rbkb/cli/hexify.rb +64 -0
- data/lib/rbkb/cli/len.rb +70 -0
- data/lib/rbkb/cli/rstrings.rb +102 -0
- data/lib/rbkb/cli/slice.rb +43 -0
- data/lib/rbkb/cli/telson.rb +116 -0
- data/lib/rbkb/cli/unhexify.rb +53 -0
- data/lib/rbkb/cli/urldec.rb +31 -0
- data/lib/rbkb/cli/urlenc.rb +31 -0
- data/lib/rbkb/cli/xor.rb +40 -0
- data/lib/rbkb/cli.rb +212 -0
- data/lib/rbkb/extends.rb +16 -14
- data/lib/rbkb/plug/blit.rb +5 -5
- data/lib/rbkb/plug/proxy.rb +23 -0
- data/lib/rbkb.rb +2 -2
- metadata +22 -5
- data/lib/rbkb/command_line.rb +0 -41
data/README.rdoc
CHANGED
@@ -1,74 +1,217 @@
|
|
1
|
+
= rbkb
|
1
2
|
|
2
|
-
|
3
|
+
* http://www.github.com/emonti/rbkb
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Ruby BlackBag (rbkb)
|
3
8
|
|
4
9
|
A miscellaneous collection of command-line tools and ruby library helpers
|
5
10
|
related to pen-testing and reversing.
|
6
11
|
|
7
|
-
|
12
|
+
=== Rationale
|
8
13
|
|
9
14
|
Disclaimer:
|
10
15
|
Most of what's in the black bag came from a desire to do less typing.
|
11
16
|
But there might be a few clever things that were added by accident.
|
12
17
|
|
13
|
-
|
14
|
-
RBkB is inspired by Matasano BlackBag (a set of similar tools written in C).
|
18
|
+
rbkb is inspired by Matasano BlackBag (a set of similar tools written in C).
|
15
19
|
|
16
20
|
See:
|
17
21
|
* http://www.matasano.com/log/1048/blackbag-091-new-link-and-minor-fixes/
|
18
22
|
* http://www.matasano.com/log/552/code-release-blackbag-09-binary-protocol-reversing-unix-thingies/
|
19
23
|
|
20
24
|
Things go into the black bag as they are stolen (as a compliment!) or dreamed
|
21
|
-
up, usually
|
22
|
-
|
25
|
+
up, usually for simplifying some repetetive task or a desire for a new tool.
|
23
26
|
|
24
27
|
Along the way, some of tools in the blackbag spirit make their way into 'rbkb'
|
25
|
-
that may or may not make it to 'bkb' right away (
|
28
|
+
that may or may not make it to 'bkb' right away (if ever). Similarly some of
|
26
29
|
the things in 'bkb' have not yet made it to 'rbkb' (and may not).
|
27
30
|
|
31
|
+
|
32
|
+
== SYNOPSIS:
|
33
|
+
|
28
34
|
=== Command Line Tools
|
29
35
|
|
30
36
|
The tools almost all support '-h', but I'll admit this only goes so far.
|
31
|
-
See usage.txt for a bit of extra info on the various tools.
|
37
|
+
See usage.txt for usage and a bit of extra info on the various tools.
|
32
38
|
|
33
39
|
When I get some spare time, I'll try and do up some examples of using all
|
34
40
|
the tools.
|
35
41
|
|
36
42
|
|
37
|
-
|
43
|
+
=== Monkey Patches
|
44
|
+
|
45
|
+
Most of rbkb is implemented as a bunch of monkeypatches to Array, String,
|
46
|
+
Numeric and other base classes. If this suits your fancy (some people despise
|
47
|
+
monkeypatches, this is not their fancy) then you can 'require "rbkb"' from
|
48
|
+
your irb sessions and own scripts. This will let you do things like the
|
49
|
+
following (just some samples, see rdoc for more).
|
50
|
+
|
51
|
+
My dirty secret: I use IRB for like... everything
|
52
|
+
|
53
|
+
Do stuff with strings:
|
54
|
+
|
55
|
+
## sexify with hexify
|
56
|
+
foo = "helu foo" #=> "helu foo"
|
57
|
+
foo.hexify #=> "68656c7520666f6f"
|
58
|
+
|
59
|
+
## a little easier to read
|
60
|
+
foo.hexify(:delim => ' ') #=> "68 65 6c 75 20 66 6f 6f"
|
61
|
+
|
62
|
+
# and back
|
63
|
+
_.unhexify #=> "helu foo"
|
64
|
+
|
65
|
+
## break out your hexdump -C styles
|
66
|
+
foodump = "helu foo".hexdump(:out => StringIO.new)
|
67
|
+
#=> "00000000 68 65 6c 75 20 66 6f 6f |helu foo|\n00000008\n"
|
68
|
+
puts foodump
|
69
|
+
# 00000000 68 65 6c 75 20 66 6f 6f |helu foo|
|
70
|
+
# 00000008
|
71
|
+
# => nil
|
72
|
+
foo.hexdump(:out => $stdout)
|
73
|
+
# 00000000 68 65 6c 75 20 66 6f 6f |helu foo|
|
74
|
+
# 00000008
|
75
|
+
# => nil
|
76
|
+
|
77
|
+
## reverse a hexdump
|
78
|
+
foodump.dehexdump #=> "helu foo"
|
79
|
+
|
80
|
+
## 'strings' like /usr/bin/strings
|
81
|
+
dat = File.read("/bin/ls")
|
82
|
+
pp dat.strings
|
83
|
+
# [[4132, 4143, :ascii, "__PAGEZERO\000"],
|
84
|
+
# [4188, 4195, :ascii, "__TEXT\000"],
|
85
|
+
# ...
|
86
|
+
# [72427, 72470, :ascii, "*Apple Code Signing Certification Authority"],
|
87
|
+
# [72645, 72652, :ascii, "X[N~EQ "]]
|
88
|
+
|
89
|
+
|
90
|
+
## look for stuff in binaries
|
91
|
+
dat.bgrep("__PAGEZERO") #=> [[4132, 4142, "__PAGEZERO"], [40996, 41006, "__PAGEZERO"]]
|
92
|
+
dat.bgrep(0xCAFEBABE.to_bytes) #=> [[0, 4, "\312\376\272\276"]]
|
93
|
+
|
94
|
+
|
95
|
+
Do stuff with numbers:
|
96
|
+
|
97
|
+
## Do you have an irrational distaste for pack/unpack? I do.
|
98
|
+
0xff.to_bytes #=> "\000\000\000\377"
|
99
|
+
be = 0xff.to_bytes(:big) #=> "\000\000\000\377"
|
100
|
+
le = 0xff.to_bytes(:little) #=> "\377\000\000\000"
|
101
|
+
le16 = 0xff.to_bytes(:little,2) #=> "\377\000"
|
102
|
+
|
103
|
+
## Strings can go the other way too
|
104
|
+
[be, le, le16].map {|n| n.dat_to_num(:big) } # default
|
105
|
+
#=> [255, 4278190080, 65280]
|
106
|
+
[be, le, le16].map {|n| n.dat_to_num(:little) }
|
107
|
+
#=> [4278190080, 255, 255]
|
108
|
+
|
109
|
+
## Calculate padding for a given alignment
|
110
|
+
10.pad(16) #=> 6
|
111
|
+
16.pad(16) #=> 0
|
112
|
+
30.pad(16) #=> 2
|
113
|
+
32.pad(16) #=> 0
|
114
|
+
|
115
|
+
|
116
|
+
Web 2."oh no you di'int!":
|
38
117
|
|
39
|
-
|
118
|
+
xss="<script>alert('helu ' + document.cookie)</script"
|
40
119
|
|
41
|
-
|
42
|
-
|
43
|
-
|
120
|
+
# URL percent-encode stuff
|
121
|
+
xss.urlenc
|
122
|
+
#=> "%3cscript%3ealert%28%27helu%3a%20%27%20%2b%20document.cookie%29%3c%2fscript%3e"
|
44
123
|
|
45
|
-
|
124
|
+
_.b64
|
125
|
+
#=> "JTNjc2NyaXB0JTNlYWxlcnQlMjglMjdoZWx1JTNhJTIwJTI3JTIwJTJiJTIwZG9jdW1lbnQuY29va2llJTI5JTNjJTJmc2NyaXB0JTNl"
|
46
126
|
|
127
|
+
## And back
|
128
|
+
_.d64
|
129
|
+
#=> "%3cscript%3ealert%28%27helu%3a%20%27%20%2b%20document.cookie%29%3c%2fscript%3e"
|
130
|
+
|
131
|
+
_.urldec
|
132
|
+
#=> "<script>alert('helu: ' + document.cookie)</script>"
|
133
|
+
|
134
|
+
|
135
|
+
Miscellaneous stuff:
|
136
|
+
|
137
|
+
# rediculous laziness!
|
138
|
+
0x41.printable? #=> true
|
139
|
+
0x01.printable? #=> false
|
140
|
+
|
141
|
+
# Make random gobbledygook and insults
|
142
|
+
"helu foo".randomize #=> "ouofleh "
|
143
|
+
"helu foo".randomize #=> "foul hoe"
|
144
|
+
|
145
|
+
|
146
|
+
Pretend (badly) to be smart:
|
147
|
+
|
148
|
+
# Cletus say's he's "sneaky"
|
149
|
+
cletus = "my secrets are safe".xor("sneaky")
|
150
|
+
#=> "\036\027E\022\016\032\001\v\021\022K\030\001\vE\022\n\037\026"
|
151
|
+
|
152
|
+
# Only not really so sneaky
|
153
|
+
cletus.xor "my secrets" #=> "sneakysnea&a!x qxzb"
|
154
|
+
cletus.xor "my secrets are" #=> "sneakysneakysn(k*ls"
|
155
|
+
cletus.xor "sneaky" #=> "my secrets are safe"
|
156
|
+
|
157
|
+
# Now make Cletus feel worse. With... MATH!
|
158
|
+
# (ala entropy scores)
|
159
|
+
"A".entropy #=> 0.0
|
160
|
+
"AB".entropy #=> 1.0
|
161
|
+
"BC".entropy #=> 1.0
|
162
|
+
(0..255).map {|x| x.chr}.join.entropy #=> 8.0
|
163
|
+
|
164
|
+
# "You see, Cletus, you might have done this..."
|
165
|
+
sdat = "my secrets are very secret "*60
|
166
|
+
require 'openssl'
|
167
|
+
c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
168
|
+
c.encrypt
|
169
|
+
c.key = Digest::SHA1.hexdigest("sneaky")
|
170
|
+
c.iv = c.random_iv
|
171
|
+
|
172
|
+
# "So, Cletus, when you say 'sneaky'... this is exactly how 'sneaky' you are"
|
173
|
+
c.update(sdat).entropy
|
174
|
+
#=> 7.64800383393901
|
175
|
+
sdat.xor("sneaky").entropy
|
176
|
+
#=> 3.77687372599433
|
177
|
+
sdat.entropy
|
178
|
+
#=> 3.07487577558377
|
179
|
+
|
180
|
+
I do recommend the rdoc if you're interested in more of these little helpers.
|
181
|
+
I'll to keep the comments useful and up to date.
|
182
|
+
|
183
|
+
|
184
|
+
== REQUIREMENTS:
|
185
|
+
|
186
|
+
* eventmachine >= 0.12.0
|
187
|
+
|
188
|
+
|
189
|
+
== INSTALL:
|
47
190
|
|
48
191
|
=== Gem Installation
|
49
192
|
|
50
|
-
|
193
|
+
rbkb is available as a gem from github:
|
51
194
|
|
52
195
|
gem sources -a http://gems.github.com #(you only have to do this once)
|
53
196
|
gem install emonti-rbkb
|
54
197
|
|
55
198
|
|
56
|
-
==== Install Note
|
199
|
+
==== Gem Install Note
|
57
200
|
|
58
|
-
Installing as root may be risky depending on your rubygems
|
59
|
-
don't really recommend using 'sudo gem install'.
|
60
|
-
of is I blew away my
|
61
|
-
perl, so I considered this providence and didn't
|
62
|
-
differently about 'rubygems'
|
201
|
+
Installing the gem as root may be risky depending on your rubygems
|
202
|
+
configuration so I don't really recommend using 'sudo gem install'.
|
203
|
+
Worst case scenario I know of is I blew away my OSX-shipped '/usr/bin/crc32'
|
204
|
+
this way. It was written in perl, so I considered this providence and didn't
|
205
|
+
look back. But you may feel differently about 'rubygems' clobbering a file in
|
206
|
+
/usr/bin.
|
63
207
|
|
64
208
|
When installing as a regular user, however, rubygems may stick rbkb's
|
65
209
|
executable bin/* files somewhere unexpected. To find out where these are and
|
66
|
-
either add them to your PATH or copy/symlink them somewhere else
|
67
|
-
/usr/local/bin/
|
210
|
+
either add them to your PATH or copy/symlink them somewhere else like
|
211
|
+
/usr/local/bin/ do this:
|
68
212
|
|
69
213
|
gem contents emonti-rbkb
|
70
214
|
|
71
|
-
|
72
215
|
=== Manual installation:
|
73
216
|
|
74
217
|
... or ... you can also install manually without rubygems.
|
@@ -84,4 +227,28 @@ Run this to generate docs with rdoc the same way the gem would have:
|
|
84
227
|
|
85
228
|
rdoc --main README.rdoc README.rdoc usage.txt lib
|
86
229
|
|
230
|
+
== LICENSE:
|
231
|
+
|
232
|
+
(The MIT License)
|
233
|
+
|
234
|
+
Copyright (c) 2009 Eric Monti, Matasano Security
|
235
|
+
|
236
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
237
|
+
a copy of this software and associated documentation files (the
|
238
|
+
'Software'), to deal in the Software without restriction, including
|
239
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
240
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
241
|
+
permit persons to whom the Software is furnished to do so, subject to
|
242
|
+
the following conditions:
|
243
|
+
|
244
|
+
The above copyright notice and this permission notice shall be
|
245
|
+
included in all copies or substantial portions of the Software.
|
246
|
+
|
247
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
248
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
249
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
250
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
251
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
252
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
253
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
87
254
|
|
data/bin/b64
CHANGED
@@ -1,57 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Author Eric Monti emonti at matasano
|
3
|
-
#
|
4
|
-
# b64 converts strings or raw data to base-64 encoding.
|
5
|
-
#
|
6
|
-
# Usage: b64 -h
|
7
|
-
#
|
8
|
-
require 'rbkb'
|
9
|
-
require 'rbkb/command_line'
|
10
|
-
require 'base64'
|
11
|
-
|
12
|
-
include RBkB::CommandLine
|
13
|
-
|
14
|
-
#-------------------------------------------------------------------------------
|
15
|
-
# Init options and arg parsing
|
16
|
-
OPTS = {}
|
17
|
-
arg = bkb_stdargs(nil, OPTS)
|
18
|
-
arg = bkb_inputargs(arg, OPTS)
|
19
|
-
|
20
|
-
arg.banner += " <data | blank for stdin>"
|
21
|
-
|
22
|
-
#------------------------------------------------------------------------------
|
23
|
-
# Add local options
|
24
|
-
arg.separator ""
|
25
|
-
arg.separator " Output options:"
|
26
|
-
|
27
|
-
arg.on("-l", "--length LEN", Numeric,
|
28
|
-
"Encode in lines of LEN characters") do |l|
|
29
|
-
(OPTS[:len] = l) > 15 or raise "length must be at least 16"
|
30
|
-
end
|
31
|
-
|
32
|
-
#------------------------------------------------------------------------------
|
33
|
-
# Parse arguments
|
34
|
-
arg.parse!(ARGV) rescue bail "Error: #{$!}\n#{arg}"
|
35
|
-
|
36
|
-
# default string arg
|
37
|
-
if OPTS[:indat].nil? and a=ARGV.shift
|
38
|
-
OPTS[:indat] = a.dup
|
39
|
-
end
|
40
|
-
|
41
|
-
# catchall
|
42
|
-
if ARGV.length != 0
|
43
|
-
bail "Error: bad arguments - #{ARGV.join(' ')}\n-h|--help for more info."
|
44
|
-
end
|
45
|
-
|
46
|
-
OPTS[:indat] ||= STDIN.read()
|
47
|
-
|
48
|
-
#------------------------------------------------------------------------------
|
49
|
-
# Do Stuff
|
50
|
-
|
51
|
-
if OPTS[:len]
|
52
|
-
Base64.b64encode(OPTS[:indat], OPTS[:len])
|
53
|
-
else
|
54
|
-
puts OPTS[:indat].b64
|
55
|
-
end
|
56
2
|
|
3
|
+
require "rbkb/cli/b64"
|
57
4
|
|
5
|
+
Rbkb::Cli::B64.run()
|
data/bin/bgrep
CHANGED
@@ -1,91 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# searches for a binary string in input
|
3
|
-
# string is provided 'hexified'
|
4
|
-
#
|
5
|
-
# usage: bgrep 'deadbeef' file
|
6
|
-
#
|
7
|
-
# use -h for more info
|
8
2
|
|
9
|
-
require
|
10
|
-
require 'rbkb/command_line'
|
11
|
-
|
12
|
-
include RBkB::CommandLine
|
13
|
-
|
14
|
-
#-------------------------------------------------------------------------------
|
15
|
-
# Init options and arg parsing
|
16
|
-
OPTS = {
|
17
|
-
:start_off => 0,
|
18
|
-
:end_off => -1,
|
19
|
-
:align => nil
|
20
|
-
}
|
21
|
-
|
22
|
-
arg = bkb_stdargs(nil, OPTS)
|
23
|
-
|
24
|
-
arg.banner += " <subject> <file | blank for stdin>"
|
25
|
-
|
26
|
-
arg.on("-x", "--[no-]hex", "Specify subject as hex (default: false)") do |x|
|
27
|
-
OPTS[:hex] = x
|
28
|
-
end
|
29
|
-
|
30
|
-
arg.on("-r", "--[no-]regex", "Specify subject as regex (default: false)") do |r|
|
31
|
-
OPTS[:rx] = r
|
32
|
-
end
|
33
|
-
|
34
|
-
arg.on("-a", "--align=BYTES", Numeric,
|
35
|
-
"Only match on alignment boundary") do |a|
|
36
|
-
OPTS[:align] = a
|
37
|
-
end
|
38
|
-
|
39
|
-
arg.on("-n", "--[no-]filename", "Suppress prefixing of filenames.") do |n|
|
40
|
-
OPTS[:suppress_fname] = n
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
#------------------------------------------------------------------------------
|
45
|
-
# Parse arguments
|
46
|
-
begin
|
47
|
-
arg.parse!
|
48
|
-
|
49
|
-
unless find = ARGV.shift
|
50
|
-
raise "need subject argument"
|
51
|
-
end
|
52
|
-
|
53
|
-
if OPTS[:hex] and OPTS[:rx]
|
54
|
-
raise "-r and -x are mutually exclusive"
|
55
|
-
end
|
56
|
-
|
57
|
-
if OPTS[:hex]
|
58
|
-
raise "you specified -x for hex and the subject isn't" unless find.ishex?
|
59
|
-
find = find.unhexify
|
60
|
-
elsif OPTS[:rx]
|
61
|
-
find = Regexp.new(find, Regexp::MULTILINE)
|
62
|
-
end
|
63
|
-
|
64
|
-
align = OPTS[:align]
|
65
|
-
|
66
|
-
if fname=ARGV.shift
|
67
|
-
dat = File.read(fname)
|
68
|
-
fname = nil unless ARGV[0] # only print filename for multiple files
|
69
|
-
else
|
70
|
-
fname = nil
|
71
|
-
dat = STDIN.read
|
72
|
-
end
|
73
|
-
|
74
|
-
loop do
|
75
|
-
dat.bgrep(find, align) do |hit_start, hit_end, match|
|
76
|
-
print "#{fname}:" if fname and not OPTS[:suppress_fname]
|
77
|
-
|
78
|
-
puts("#{(hit_start).to_hex.rjust(8,"0")}:"+
|
79
|
-
"#{(hit_end).to_hex.rjust(8,"0")}:b:"+
|
80
|
-
"#{match.inspect}")
|
81
|
-
end
|
82
|
-
|
83
|
-
break unless fname=ARGV.shift
|
84
|
-
dat = File.read(fname)
|
85
|
-
end
|
86
|
-
|
87
|
-
rescue
|
88
|
-
STDERR.puts $!, " use -h for help"
|
89
|
-
exit 1
|
90
|
-
end
|
3
|
+
require "rbkb/cli/bgrep"
|
91
4
|
|
5
|
+
Rbkb::Cli::Bgrep.run()
|
data/bin/blit
CHANGED
@@ -1,97 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# blit is for use with any of the "plug" tools such as telson, feed, blitplug.
|
4
|
-
# It is used to send data over a socket via their OOB blit listener.
|
5
|
-
#
|
6
|
-
# Usage: blit [options] <data | blank for stdin>
|
7
|
-
# -h, --help Show this message
|
8
|
-
# -v, --version Show version and exit
|
9
|
-
# -f, --file FILENAME Input from FILENAME
|
10
|
-
# -t, --trans-protocol=PROTO Blit transport protocol TCP/UDP
|
11
|
-
# -b, --blitsrv=ADDR:PORT Where to send blit messages
|
12
|
-
# -i, --peer-index=IDX Index for remote peer to receive
|
13
|
-
# -l, --list-peers Lists the peer array for the target
|
14
|
-
# -k, --kill Stops the remote event loop.
|
15
|
-
#
|
16
2
|
|
17
|
-
require
|
18
|
-
require 'rbkb/plug'
|
19
|
-
require 'rbkb/command_line.rb'
|
20
|
-
|
21
|
-
require 'socket'
|
22
|
-
|
23
|
-
include RBkB::CommandLine
|
24
|
-
|
25
|
-
#------------------------------------------------------------------------------
|
26
|
-
# Init options and arg parsing
|
27
|
-
|
28
|
-
OPTS = {
|
29
|
-
:b_addr => Plug::Blit::DEFAULT_IPADDR,
|
30
|
-
:b_port => Plug::Blit::DEFAULT_PORT,
|
31
|
-
:bp_proto => :TCP,
|
32
|
-
:b_peeridx => 0,
|
33
|
-
}
|
34
|
-
|
35
|
-
blit_msg = nil
|
36
|
-
|
37
|
-
arg = bkb_stdargs(nil, OPTS)
|
38
|
-
arg = bkb_inputargs(arg, OPTS)
|
39
|
-
|
40
|
-
arg.banner += " <data | blank for stdin>"
|
41
|
-
|
42
|
-
|
43
|
-
#------------------------------------------------------------------------------
|
44
|
-
# Add local options here
|
45
|
-
|
46
|
-
arg.on("-t", "--trans-protocol=PROTO", "Blit transport protocol TCP/UDP") do |t|
|
47
|
-
OPTS[:b_proto] = t.upcase.to_sym
|
48
|
-
end
|
49
|
-
|
50
|
-
arg.on("-b", "--blitsrv=ADDR:PORT", "Where to send blit messages") do |b|
|
51
|
-
unless(m=/^(?:([\w\.]+):)?(\d+)$/.match(b))
|
52
|
-
bail "invalid blit address/port"
|
53
|
-
end
|
54
|
-
OPTS[:b_port] = m[2].to_i
|
55
|
-
OPTS[:b_port] = m[1] if m[1]
|
56
|
-
end
|
57
|
-
|
58
|
-
arg.on("-i", "--peer-index=IDX", Numeric, "Index for remote peer to receive") do |i|
|
59
|
-
OPTS[:b_peeridx] = i
|
60
|
-
end
|
61
|
-
|
62
|
-
arg.on("-l", "--list-peers", "Lists the peer array for the target") do
|
63
|
-
blit_msg = Plug::Blit.make_list_peers
|
64
|
-
end
|
65
|
-
|
66
|
-
arg.on("-k", "--kill", "Stops the remote event loop.") do
|
67
|
-
blit_msg = Plug::Blit.make_kill
|
68
|
-
end
|
69
|
-
|
70
|
-
#------------------------------------------------------------------------------
|
71
|
-
# Parse arguments
|
72
|
-
arg.parse!(ARGV) rescue bail "Error: #{$!}\nUse -h|--help for more info."
|
73
|
-
|
74
|
-
unless blit_msg
|
75
|
-
if OPTS[:indat].nil?
|
76
|
-
OPTS[:indat] = (ARGV.length > 0)? ARGV.join(" ") : STDIN.read()
|
77
|
-
end
|
78
|
-
blit_msg = Plug::Blit.make_sendmsg(OPTS[:b_peeridx], OPTS[:indat])
|
79
|
-
end
|
80
|
-
|
81
|
-
#------------------------------------------------------------------------------
|
82
|
-
# Do stuff
|
83
|
-
|
84
|
-
begin
|
85
|
-
Plug::Blit.blit_init(
|
86
|
-
:addr => OPTS[:b_addr],
|
87
|
-
:port => OPTS[:b_port],
|
88
|
-
:protocol => OPTS[:b_proto]
|
89
|
-
)
|
90
|
-
|
91
|
-
Plug::Blit.blit_raw(blit_msg)
|
92
|
-
|
93
|
-
rescue
|
94
|
-
bail $!
|
95
|
-
exit 1
|
96
|
-
end
|
3
|
+
require "rbkb/cli/blit"
|
97
4
|
|
5
|
+
Rbkb::Cli::Blit.run()
|
data/bin/c
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Author Eric Monti (emonti at matasano)
|
3
2
|
|
4
|
-
require
|
5
|
-
require 'rbkb/command_line'
|
6
|
-
|
7
|
-
include RBkB::CommandLine
|
8
|
-
|
9
|
-
if ARGV[0] !~ /[1-9][0-9]*/ or ARGV[1].nil? or ARGV.size > 2
|
10
|
-
bail "Usage: #{$0} 100 A; # print 100 A's'\n"
|
11
|
-
end
|
12
|
-
|
13
|
-
print ARGV[1] * ARGV[0].to_i
|
3
|
+
require "rbkb/cli/chars"
|
14
4
|
|
5
|
+
Rbkb::Cli::Chars.run()
|
data/bin/crc32
CHANGED
@@ -1,60 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# (emonti at matasano) Matasano Security LLC
|
3
|
-
#
|
4
|
-
# crc32.rb : returns a crc32 checksum in hex from stdin or a file
|
5
|
-
#
|
6
|
-
# Usage: crc32 [options]
|
7
|
-
# -h, --help Show this message
|
8
|
-
# -v, --version Show version and exit
|
9
|
-
# -f, --file FILENAME Input from FILENAME
|
10
|
-
# -r, --range=START[:END] Start and optional end range
|
11
|
-
# -x, --hexrange=START[:END] same, but in hex
|
12
2
|
|
13
|
-
require
|
14
|
-
require 'rbkb/command_line'
|
15
|
-
|
16
|
-
include RBkB::CommandLine
|
17
|
-
|
18
|
-
OPTS = {:first => 0, :last => -1}
|
19
|
-
arg = bkb_stdargs(nil, OPTS)
|
20
|
-
arg = bkb_inputargs(arg, OPTS)
|
21
|
-
|
22
|
-
arg.on("-r", "--range=START[:END]", "Start and optional end range") do |r|
|
23
|
-
|
24
|
-
raise "-x and -r are mutually exclusive" if OPTS[:first]
|
25
|
-
|
26
|
-
unless m=/^(-?[0-9]+)(?::(-?[0-9]+))?$/.match(r)
|
27
|
-
raise "invalid range #{r.inspect}"
|
28
|
-
end
|
29
|
-
|
30
|
-
OPTS[:first] = $1.to_i
|
31
|
-
OPTS[:last] = $2.to_i if $2
|
32
|
-
end
|
33
|
-
|
34
|
-
arg.on("-x", "--hexrange=START[:END]", "same, but in hex") do |r|
|
35
|
-
|
36
|
-
raise "-x and -r are mutually exclusive" if OPTS[:first]
|
37
|
-
|
38
|
-
unless m=/^(-?[0-9a-f]+)(?::(-?[0-9a-f]+))?$/i.match(r)
|
39
|
-
raise "invalid range #{r.inspect}"
|
40
|
-
end
|
41
|
-
|
42
|
-
OPTS[:first]=($1[0,1] == '-')? ($1[1..-1]).hex_to_num * -1 : $1.hex_to_num
|
43
|
-
if $2
|
44
|
-
OPTS[:last]=($2[0,1] == '-')? ($2[1..-1]).hex_to_num * -1 : $2.hex_to_num
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
begin
|
49
|
-
arg.parse!
|
50
|
-
|
51
|
-
raise "bad arguments #{ARGV.join(" ").inspect}" unless (ARGV.length == 0)
|
52
|
-
|
53
|
-
OPTS[:indat] ||= STDIN.read()
|
54
|
-
|
55
|
-
puts OPTS[:indat][ OPTS[:first] .. OPTS[:last] ].crc32.to_hex
|
56
|
-
|
57
|
-
rescue
|
58
|
-
bail "Error: #{$!}\n#{arg}"
|
59
|
-
end
|
3
|
+
require "rbkb/cli/crc32"
|
60
4
|
|
5
|
+
Rbkb::Cli::Crc32.run()
|
data/bin/d64
CHANGED
@@ -1,41 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Author Eric Monti (emonti at matasano)
|
3
|
-
#
|
4
|
-
# d64 converts a base-64 encoded string back to its orginal form.
|
5
|
-
#
|
6
|
-
# Usage: d64 -h
|
7
|
-
#
|
8
|
-
require 'rbkb'
|
9
|
-
require 'rbkb/command_line'
|
10
2
|
|
11
|
-
|
12
|
-
|
13
|
-
#-------------------------------------------------------------------------------
|
14
|
-
# Init options and arg parsing
|
15
|
-
OPTS = {}
|
16
|
-
arg = bkb_stdargs(nil, OPTS)
|
17
|
-
arg = bkb_inputargs(arg, OPTS)
|
18
|
-
|
19
|
-
arg.banner += " <data | blank for stdin>"
|
20
|
-
|
21
|
-
#------------------------------------------------------------------------------
|
22
|
-
# Parse arguments
|
23
|
-
arg.parse!(ARGV) rescue bail "Error: #{$!}\n#{arg}"
|
24
|
-
|
25
|
-
# default string arg
|
26
|
-
if OPTS[:indat].nil? and a=ARGV.shift
|
27
|
-
OPTS[:indat] = a.dup
|
28
|
-
end
|
29
|
-
|
30
|
-
# catchall
|
31
|
-
if ARGV.length != 0
|
32
|
-
bail "Error: bad arguments - #{ARGV.join(' ')}\n-h|--help for more info."
|
33
|
-
end
|
34
|
-
|
35
|
-
OPTS[:indat] ||= STDIN.read()
|
36
|
-
|
37
|
-
#------------------------------------------------------------------------------
|
38
|
-
# Do Stuff
|
39
|
-
|
40
|
-
print OPTS[:indat].d64
|
3
|
+
require "rbkb/cli/d64"
|
41
4
|
|
5
|
+
Rbkb::Cli::D64.run()
|
data/bin/dedump
CHANGED
@@ -1,53 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Author Eric Monti (emonti at matasano)
|
3
|
-
#
|
4
|
-
# Reverses a hexdump back to raw data. Designed to work with hexdumps created
|
5
|
-
# by Unix utilities like 'xxd' as well as 'hexdump -C'.
|
6
|
-
|
7
|
-
require 'rbkb'
|
8
|
-
require 'rbkb/command_line'
|
9
|
-
|
10
|
-
include RBkB::CommandLine
|
11
|
-
|
12
|
-
#------------------------------------------------------------------------------
|
13
|
-
# Init options and arg parsing
|
14
|
-
OPTS = {:len => 16}
|
15
|
-
arg = bkb_stdargs(nil, OPTS)
|
16
|
-
|
17
|
-
arg.banner += " <input-file | blank for stdin>"
|
18
|
-
|
19
|
-
#------------------------------------------------------------------------------
|
20
|
-
# Add local options
|
21
|
-
|
22
|
-
arg.on("-l", "--length LEN", Numeric,
|
23
|
-
"Bytes per line in hexdump (default: #{OPTS[:len]})") do |l|
|
24
|
-
bail("Length must be greater than zero") unless (OPTS[:len] = l) > 0
|
25
|
-
end
|
26
|
-
|
27
|
-
#------------------------------------------------------------------------------
|
28
|
-
# Parse arguments
|
29
|
-
arg.parse!(ARGV) rescue bail "Error: #{$!}\nUse -h|--help for more info."
|
30
|
-
|
31
|
-
if OPTS[:indat].nil? and a=ARGV.shift
|
32
|
-
OPTS[:indat] = File.open(a, "rb") rescue "Error: Can't open file '#{a}'"
|
33
|
-
end
|
34
|
-
|
35
|
-
# catchall
|
36
|
-
if ARGV.length != 0
|
37
|
-
bail "Error: bad arguments - #{ARGV.join(' ')}\n-h|--help for more info."
|
38
|
-
end
|
39
|
-
|
40
|
-
# Default to standard input
|
41
|
-
OPTS[:indat] ||= STDIN.read()
|
42
|
-
|
43
|
-
#------------------------------------------------------------------------------
|
44
|
-
# Do stuff
|
45
|
-
|
46
|
-
exit 1 unless((OPTS[:len] ||= OPTS[:indat].length) > 0)
|
47
|
-
|
48
|
-
OPTS[:indat].dehexdump(
|
49
|
-
:len => OPTS[:len],
|
50
|
-
:out => STDOUT
|
51
|
-
) rescue bail "Error: #{$!}"
|
52
2
|
|
3
|
+
require "rbkb/cli/dedump"
|
53
4
|
|
5
|
+
Rbkb::Cli::Dedump.run()
|