emonti-rbkb 0.6.1.3 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/lib/rbkb/extends.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# Author Eric Monti (emonti at matasano)
|
2
|
-
require "base64"
|
3
2
|
require "stringio"
|
4
3
|
require 'zlib'
|
5
4
|
require 'open3'
|
6
5
|
require 'sha1'
|
7
6
|
|
8
|
-
module
|
7
|
+
module Rbkb
|
9
8
|
DEFAULT_BYTE_ORDER=:big
|
10
9
|
HEXCHARS = [("0".."9").to_a, ("a".."f").to_a].flatten
|
11
10
|
end
|
@@ -33,7 +32,6 @@ end if not defined? with
|
|
33
32
|
# Mixins and class-specific items
|
34
33
|
|
35
34
|
class String
|
36
|
-
|
37
35
|
# shortcut for hex sanity with regex
|
38
36
|
def ishex? ; (self =~ /^[a-f0-9]+$/i)? true : false ; end
|
39
37
|
|
@@ -44,7 +42,7 @@ class String
|
|
44
42
|
unless (opts[:rx] ||= /[^A-Za-z0-9_\.~-]/).kind_of? Regexp
|
45
43
|
raise "rx must be a regular expression for a character class"
|
46
44
|
end
|
47
|
-
hx =
|
45
|
+
hx = Rbkb::HEXCHARS
|
48
46
|
|
49
47
|
s.gsub(opts[:rx]) do |c|
|
50
48
|
c=c[0]
|
@@ -60,10 +58,17 @@ class String
|
|
60
58
|
end
|
61
59
|
|
62
60
|
# Base64 encode
|
63
|
-
def b64
|
61
|
+
def b64(len=nil)
|
62
|
+
ret = [self].pack("m").gsub("\n", "")
|
63
|
+
if len and Numeric === len
|
64
|
+
ret.scan(/.{1,#{len}}/).join("\n") + "\n"
|
65
|
+
else
|
66
|
+
ret
|
67
|
+
end
|
68
|
+
end
|
64
69
|
|
65
70
|
# Base64 decode
|
66
|
-
def d64;
|
71
|
+
def d64; self.unpack("m")[0]; end
|
67
72
|
|
68
73
|
# right-align to 'a' alignment padded with 'p'
|
69
74
|
def ralign(a, p=' ')
|
@@ -100,7 +105,7 @@ class String
|
|
100
105
|
raise "rx must be a regular expression for a character class"
|
101
106
|
end
|
102
107
|
|
103
|
-
hx=
|
108
|
+
hx=Rbkb::HEXCHARS
|
104
109
|
|
105
110
|
out=Array.new
|
106
111
|
|
@@ -344,6 +349,7 @@ class String
|
|
344
349
|
pos += endoff
|
345
350
|
end
|
346
351
|
end
|
352
|
+
return ret
|
347
353
|
end
|
348
354
|
|
349
355
|
# A 'strings' method a-la unix strings utility. Finds printable strings in
|
@@ -563,7 +569,7 @@ class Numeric
|
|
563
569
|
# (only :big has meaning)
|
564
570
|
# siz: pack to this size. larger numbers will wrap
|
565
571
|
def to_chars(order=nil, siz=nil)
|
566
|
-
order ||=
|
572
|
+
order ||= Rbkb::DEFAULT_BYTE_ORDER
|
567
573
|
n=self
|
568
574
|
siz ||= self.size
|
569
575
|
ret=[]
|
@@ -600,12 +606,12 @@ class Numeric
|
|
600
606
|
#
|
601
607
|
def to_hex(o=nil, s=nil)
|
602
608
|
to_chars(o,s) {|c|
|
603
|
-
|
609
|
+
Rbkb::HEXCHARS[c.clear_bits(0xf) >> 4]+Rbkb::HEXCHARS[c.clear_bits(0xf0)]
|
604
610
|
}.join
|
605
611
|
end
|
606
612
|
|
607
613
|
# XXX TODO Fixme for new to_bytes/char etc.
|
608
|
-
# def to_guid(order=
|
614
|
+
# def to_guid(order=Rbkb::DEFAULT_BYTE_ORDER)
|
609
615
|
# raw = self.to_bytes(order, 16)
|
610
616
|
# a,b,c,d,*e = raw.unpack("VvvnC6").map{|x| x.to_hex}
|
611
617
|
# e = e.join
|
@@ -657,7 +663,6 @@ class Object
|
|
657
663
|
end
|
658
664
|
end
|
659
665
|
|
660
|
-
|
661
666
|
module Enumerable
|
662
667
|
def each_recursive(&block)
|
663
668
|
self.each do |n|
|
@@ -667,6 +672,3 @@ module Enumerable
|
|
667
672
|
end
|
668
673
|
end
|
669
674
|
|
670
|
-
__END__
|
671
|
-
|
672
|
-
|
data/lib/rbkb/plug/blit.rb
CHANGED
@@ -74,7 +74,7 @@ module Plug
|
|
74
74
|
|
75
75
|
def self.make_mute(peerno)
|
76
76
|
self.blit_header(:squelch) +
|
77
|
-
peerno.to_bytes(
|
77
|
+
peerno.to_bytes(:big, 2)
|
78
78
|
end
|
79
79
|
|
80
80
|
def unmute
|
@@ -87,7 +87,7 @@ module Plug
|
|
87
87
|
|
88
88
|
def self.make_squelch(peerno)
|
89
89
|
self.blit_header(:squelch) +
|
90
|
-
peerno.to_bytes(
|
90
|
+
peerno.to_bytes(:big, 2)
|
91
91
|
end
|
92
92
|
|
93
93
|
def sendmsg
|
@@ -121,8 +121,8 @@ module Plug
|
|
121
121
|
# str data
|
122
122
|
def self.make_sendmsg(idx, dat)
|
123
123
|
self.blit_header(:sendmsg) +
|
124
|
-
idx.to_bytes(
|
125
|
-
dat.size.to_bytes(
|
124
|
+
idx.to_bytes(:big, 2) +
|
125
|
+
dat.size.to_bytes(:big, 4) +
|
126
126
|
dat
|
127
127
|
end
|
128
128
|
|
@@ -150,7 +150,7 @@ module Plug
|
|
150
150
|
|
151
151
|
def self.make_delete(idx=0)
|
152
152
|
self.blit_header(:delete) +
|
153
|
-
idx.to_bytes(
|
153
|
+
idx.to_bytes(:big, 2)
|
154
154
|
end
|
155
155
|
|
156
156
|
def list_peers
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module Plug
|
3
|
+
module Proxy
|
4
|
+
include Base
|
5
|
+
attr_accessor :target
|
6
|
+
|
7
|
+
def initialize(transport, target)
|
8
|
+
@transport = transport
|
9
|
+
@peers = ProxyPeerList.new(self)
|
10
|
+
@kind = :proxy
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class ProxyPeerList < PeerList
|
16
|
+
|
17
|
+
def add_peer(addr)
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_peer_manually(*args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rbkb.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emonti-rbkb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Monti
|
@@ -34,6 +34,7 @@ executables:
|
|
34
34
|
- dedump
|
35
35
|
- hexify
|
36
36
|
- len
|
37
|
+
- plugsrv
|
37
38
|
- rex
|
38
39
|
- rstrings
|
39
40
|
- slice
|
@@ -42,7 +43,6 @@ executables:
|
|
42
43
|
- urldec
|
43
44
|
- urlenc
|
44
45
|
- xor
|
45
|
-
- plugsrv
|
46
46
|
extensions: []
|
47
47
|
|
48
48
|
extra_rdoc_files: []
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- bin/dedump
|
60
60
|
- bin/hexify
|
61
61
|
- bin/len
|
62
|
+
- bin/plugsrv
|
62
63
|
- bin/rex
|
63
64
|
- bin/rstrings
|
64
65
|
- bin/slice
|
@@ -67,14 +68,30 @@ files:
|
|
67
68
|
- bin/urldec
|
68
69
|
- bin/urlenc
|
69
70
|
- bin/xor
|
70
|
-
- bin/plugsrv
|
71
71
|
- lib/rbkb.rb
|
72
|
-
- lib/rbkb/
|
72
|
+
- lib/rbkb/cli.rb
|
73
|
+
- lib/rbkb/cli/b64.rb
|
74
|
+
- lib/rbkb/cli/bgrep.rb
|
75
|
+
- lib/rbkb/cli/blit.rb
|
76
|
+
- lib/rbkb/cli/chars.rb
|
77
|
+
- lib/rbkb/cli/crc32.rb
|
78
|
+
- lib/rbkb/cli/d64.rb
|
79
|
+
- lib/rbkb/cli/dedump.rb
|
80
|
+
- lib/rbkb/cli/hexify.rb
|
81
|
+
- lib/rbkb/cli/len.rb
|
82
|
+
- lib/rbkb/cli/rstrings.rb
|
83
|
+
- lib/rbkb/cli/slice.rb
|
84
|
+
- lib/rbkb/cli/telson.rb
|
85
|
+
- lib/rbkb/cli/unhexify.rb
|
86
|
+
- lib/rbkb/cli/urldec.rb
|
87
|
+
- lib/rbkb/cli/urlenc.rb
|
88
|
+
- lib/rbkb/cli/xor.rb
|
73
89
|
- lib/rbkb/extends.rb
|
74
|
-
- lib/rbkb/plug.rb
|
75
90
|
- lib/rbkb/plug/blit.rb
|
76
91
|
- lib/rbkb/plug/peer.rb
|
77
92
|
- lib/rbkb/plug/plug.rb
|
93
|
+
- lib/rbkb/plug/proxy.rb
|
94
|
+
- lib/rbkb/plug.rb
|
78
95
|
has_rdoc: true
|
79
96
|
homepage: http://www.matasano.com
|
80
97
|
post_install_message:
|
data/lib/rbkb/command_line.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# Author Eric Monti (emonti at matasano)
|
2
|
-
require 'optparse'
|
3
|
-
|
4
|
-
module RBkB
|
5
|
-
module CommandLine
|
6
|
-
# exits with a message on stderr
|
7
|
-
def bail(msg)
|
8
|
-
STDERR.puts msg if msg
|
9
|
-
exit 1
|
10
|
-
end
|
11
|
-
|
12
|
-
# returns a OptionsParser object with blackbag standard options
|
13
|
-
def bkb_stdargs(o=OptionParser.new, cfg=OPTS)
|
14
|
-
o=OptionParser.new
|
15
|
-
o.banner = "Usage: #{File.basename $0} [options]"
|
16
|
-
|
17
|
-
o.on("-h", "--help", "Show this message") do
|
18
|
-
bail(o)
|
19
|
-
end
|
20
|
-
|
21
|
-
o.on("-v", "--version", "Show version and exit") do
|
22
|
-
bail("Ruby BlackBag version #{RBkB::VERSION}")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# returns a OptionsParser object with blackbag input options
|
27
|
-
def bkb_inputargs(o=OptionParser.new, cfg=OPTS)
|
28
|
-
o.on("-f", "--file FILENAME",
|
29
|
-
"Input from FILENAME") do |f|
|
30
|
-
begin
|
31
|
-
cfg[:indat] = File.read(f)
|
32
|
-
rescue
|
33
|
-
bail "File Error: #{$!}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
return o
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|