ciphr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +22 -0
- data/README.md +316 -0
- data/Rakefile +7 -0
- data/TODO +320 -0
- data/bin/ciphr +62 -0
- data/ciphr.gemspec +32 -0
- data/lib/ciphr.rb +35 -0
- data/lib/ciphr/function_registry.rb +47 -0
- data/lib/ciphr/functions.rb +62 -0
- data/lib/ciphr/functions/base_radix.rb +205 -0
- data/lib/ciphr/functions/bitwise.rb +80 -0
- data/lib/ciphr/functions/crypto.rb +44 -0
- data/lib/ciphr/functions/openssl.rb +104 -0
- data/lib/ciphr/functions/reader.rb +44 -0
- data/lib/ciphr/functions/simple.rb +121 -0
- data/lib/ciphr/functions/url.rb +38 -0
- data/lib/ciphr/functions/zlib.rb +94 -0
- data/lib/ciphr/parser.rb +77 -0
- data/lib/ciphr/stream.rb +49 -0
- data/lib/ciphr/version.rb +3 -0
- data/pkg/ciphr-0.0.1.gem +0 -0
- data/spec/ciphr_spec.rb +21 -0
- data/spec/functions_spec.rb +31 -0
- data/spec/randomizer_spec.rb +55 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/stream_spec.rb +38 -0
- data/tests/commands.sh +30 -0
- data/tests/output.r26.2.0.0.bin +0 -0
- data/tests/output.r26.2.1.1.bin +0 -0
- data/tests/output.r30.2.0.0.bin +0 -0
- data/tests/output.r30.2.1.1.bin +0 -0
- data/tests/output.r34.2.0.0.bin +0 -0
- data/tests/output.r34.2.1.1.bin +0 -0
- data/tests/testcase.r26.bin +0 -0
- data/tests/testcase.r30.bin +0 -0
- data/tests/testcase.r34.bin +0 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e70f6b9ae3a9a53aa202128b800df0272bc0f9d0
|
4
|
+
data.tar.gz: 750425aee3a673a2f97cfc17e4a50332f45cdf43
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 612d14a6513c7656311c132cb6b58a8babfd0bbc9bd81958daa4d40e9dd8adfd504df37c6e2fe919fd6f6455f9109afb1dba5d1d32503c11d3aa8ad9c8f18eca
|
7
|
+
data.tar.gz: 6dc7c4137ce5b4adf216f4b808f25b16825eddad0a6b3944179fed4c899680ae52d1532991ab51388ebdcf27c6f0468032a9e335e9ff061ecede2d84c5b27dcf
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ciphr (0.0.1)
|
5
|
+
base32 (~> 0.3.2)
|
6
|
+
parslet (~> 1.5.0)
|
7
|
+
slop (~> 3.6.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
base32 (0.3.2)
|
13
|
+
blankslate (2.1.2.4)
|
14
|
+
diff-lcs (1.2.5)
|
15
|
+
parslet (1.5.0)
|
16
|
+
blankslate (~> 2.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
rspec (3.4.0)
|
19
|
+
rspec-core (~> 3.4.0)
|
20
|
+
rspec-expectations (~> 3.4.0)
|
21
|
+
rspec-mocks (~> 3.4.0)
|
22
|
+
rspec-core (3.4.2)
|
23
|
+
rspec-support (~> 3.4.0)
|
24
|
+
rspec-expectations (3.4.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.4.0)
|
27
|
+
rspec-mocks (3.4.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.4.0)
|
30
|
+
rspec-support (3.4.1)
|
31
|
+
slop (3.6.0)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.3)
|
38
|
+
ciphr!
|
39
|
+
rake (~> 10.5.0)
|
40
|
+
rspec (~> 3.4.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Chris Frohoff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,316 @@
|
|
1
|
+
# Ciphr
|
2
|
+
|
3
|
+
Ciphr is a CLI tool for performing and composing encoding, decoding, encryption,
|
4
|
+
decryption, hashing, and other various operations on streams of data. It takes
|
5
|
+
provided data, file data, or data from stdin, and executes a pipeline of
|
6
|
+
functions on the data stream, writing the resulting data to stdout. It was
|
7
|
+
designed primarily for use in the information security domain, mostly for quick
|
8
|
+
or casual data manipulation for forensics, penetration testing, or
|
9
|
+
capture-the-flag events; it likely could have other unforseen uses, but should
|
10
|
+
be presumed to be an experimental toy as no effort was made to make included
|
11
|
+
cryptographic functions robust against attacks (timing attacks, etc), and it is
|
12
|
+
recommended not to use any included functions in any on-line security
|
13
|
+
mechanisms.
|
14
|
+
|
15
|
+
## Examples
|
16
|
+
|
17
|
+
```console
|
18
|
+
$ ciphr '"abc"'
|
19
|
+
abc
|
20
|
+
$ ciphr '"abc"' hex
|
21
|
+
616263
|
22
|
+
$ ciphr '"abc"' hex ~hex
|
23
|
+
abc
|
24
|
+
$ ciphr '"616263"' ~hex
|
25
|
+
abc
|
26
|
+
$ ciphr 0x616263
|
27
|
+
abc
|
28
|
+
$ ciphr 0x616263 hex
|
29
|
+
616263
|
30
|
+
$ ciphr 0b10101010 bin
|
31
|
+
10101010
|
32
|
+
$ ciphr 0b10101010 hex
|
33
|
+
aa
|
34
|
+
$ ciphr 255 hex
|
35
|
+
ff
|
36
|
+
$ ciphr 65
|
37
|
+
A
|
38
|
+
$ ciphr '""' md5 hex
|
39
|
+
d41d8cd98f00b204e9800998ecf8427e
|
40
|
+
$ echo -n "" | ciphr md5 hex
|
41
|
+
d41d8cd98f00b204e9800998ecf8427e
|
42
|
+
$ ciphr '"abc"' sha1 hex
|
43
|
+
a9993e364706816aba3e25717850c26c9cd0d89d
|
44
|
+
$ echo -n "abc" | ciphr sha1 | xxd -ps
|
45
|
+
a9993e364706816aba3e25717850c26c9cd0d89d
|
46
|
+
$ echo -n "abc" | ciphr 'xor["abc"] hex'
|
47
|
+
000000
|
48
|
+
$ echo -n "abc" | ciphr xor[0x01] hex
|
49
|
+
606362
|
50
|
+
$ echo -n "abc" | ciphr xor[0x01]
|
51
|
+
`cb
|
52
|
+
$ echo -n "abc" | ciphr xor[0x020304]
|
53
|
+
cag
|
54
|
+
$ echo -n "abc" | ciphr 'aes128cbc["super secret key"] hex'
|
55
|
+
1e98110410ea0aa59a31ddc462d720d07e1e01268e405ee9fba29b3f91752e0c
|
56
|
+
$ echo -n "abc" | ciphr 'aes128cbc["super secret key"] hex ~hex ~aes128cbc["super secret key"]'
|
57
|
+
abc
|
58
|
+
$ ciphr @/etc/hosts
|
59
|
+
127.0.0.1 localhost
|
60
|
+
$ ciphr @/etc/hosts md5 hex
|
61
|
+
8f4491642052129e98cc211b4f32d9c5
|
62
|
+
$ ciphr @/etc/hosts xor[0x01]
|
63
|
+
036/1/1/mnb`minru
|
64
|
+
$ ciphr @/etc/hosts aes-128-cbc[@/etc/hosts] hex
|
65
|
+
3033c8627781ae2152d0b25f1acd3397161d5e8462164716539502ad908163e13eec1a73ee03ba89a877ac49fd04d7a3
|
66
|
+
$ ciphr @/etc/hosts aes-128-cbc[@/etc/hosts] ~aes-128-cbc[@/etc/hosts]
|
67
|
+
127.0.0.1 localhost
|
68
|
+
$ ciphr @/etc/hosts aes-128-cbc[0xdeadbeefdeadbeefdeadbeefdeadbeef] hex
|
69
|
+
92638d3f10a303938b48bd4a108744ed4216c99b005ddc19cce752af53ef089be1e43a446fda55c4e76036f31612459f
|
70
|
+
$ ciphr @/etc/hosts aes-128-cbc[0xdeadbeefdeadbeefdeadbeefdeadbeef] ~aes-128-cbc[0xdeadbeefdeadbeefdeadbeefdeadbeef]
|
71
|
+
127.0.0.1 localhost
|
72
|
+
```
|
73
|
+
|
74
|
+
## Installation
|
75
|
+
|
76
|
+
Must be cloned and installed until it gets into rubygems.org after being cleaned
|
77
|
+
up
|
78
|
+
|
79
|
+
Requires bundler to be installed (`gem install bundler`)
|
80
|
+
|
81
|
+
```shell
|
82
|
+
git clone https://github.com/frohoff/ciphr.git
|
83
|
+
cd ciphr
|
84
|
+
bundle install
|
85
|
+
bundle exec rake install
|
86
|
+
```
|
87
|
+
|
88
|
+
## Usage
|
89
|
+
|
90
|
+
```shell
|
91
|
+
$ ciphr -v -h
|
92
|
+
Usage: ciphr [options] [spec]
|
93
|
+
-h, --help
|
94
|
+
-v, --verbose
|
95
|
+
-n, --no-newline
|
96
|
+
-N, --newline
|
97
|
+
-x, --xargs-mode
|
98
|
+
-0, --null
|
99
|
+
Available Functions: aliases ([args])
|
100
|
+
md4 (input)
|
101
|
+
md5 (input)
|
102
|
+
sha (input)
|
103
|
+
sha1 (input)
|
104
|
+
sha224 (input)
|
105
|
+
sha256 (input)
|
106
|
+
sha384 (input)
|
107
|
+
sha512 (input)
|
108
|
+
hmac-md4, hmacmd4 (input, key)
|
109
|
+
hmac-md5, hmacmd5 (input, key)
|
110
|
+
hmac-sha, hmacsha (input, key)
|
111
|
+
hmac-sha1, hmacsha1 (input, key)
|
112
|
+
hmac-sha224, hmacsha224 (input, key)
|
113
|
+
hmac-sha256, hmacsha256 (input, key)
|
114
|
+
hmac-sha384, hmacsha384 (input, key)
|
115
|
+
hmac-sha512, hmacsha512 (input, key)
|
116
|
+
aes-128-cbc, aes128cbc (input, key)
|
117
|
+
aes-128-cbc-hmac-sha1, aes128cbchmacsha1 (input, key)
|
118
|
+
aes-128-cbc-hmac-sha256, aes128cbchmacsha256 (input, key)
|
119
|
+
aes-128-cfb, aes128cfb (input, key)
|
120
|
+
aes-128-cfb1, aes128cfb1 (input, key)
|
121
|
+
aes-128-cfb8, aes128cfb8 (input, key)
|
122
|
+
aes-128-ctr, aes128ctr (input, key)
|
123
|
+
aes-128-ecb, aes128ecb (input, key)
|
124
|
+
aes-128-ofb, aes128ofb (input, key)
|
125
|
+
aes-128-xts, aes128xts (input, key)
|
126
|
+
aes-192-cbc, aes192cbc (input, key)
|
127
|
+
aes-192-cfb, aes192cfb (input, key)
|
128
|
+
aes-192-cfb1, aes192cfb1 (input, key)
|
129
|
+
aes-192-cfb8, aes192cfb8 (input, key)
|
130
|
+
aes-192-ctr, aes192ctr (input, key)
|
131
|
+
aes-192-ecb, aes192ecb (input, key)
|
132
|
+
aes-192-ofb, aes192ofb (input, key)
|
133
|
+
aes-256-cbc, aes256cbc (input, key)
|
134
|
+
aes-256-cbc-hmac-sha1, aes256cbchmacsha1 (input, key)
|
135
|
+
aes-256-cbc-hmac-sha256, aes256cbchmacsha256 (input, key)
|
136
|
+
aes-256-cfb, aes256cfb (input, key)
|
137
|
+
aes-256-cfb1, aes256cfb1 (input, key)
|
138
|
+
aes-256-cfb8, aes256cfb8 (input, key)
|
139
|
+
aes-256-ctr, aes256ctr (input, key)
|
140
|
+
aes-256-ecb, aes256ecb (input, key)
|
141
|
+
aes-256-ofb, aes256ofb (input, key)
|
142
|
+
aes-256-xts, aes256xts (input, key)
|
143
|
+
aes128 (input, key)
|
144
|
+
aes192 (input, key)
|
145
|
+
aes256 (input, key)
|
146
|
+
bf (input, key)
|
147
|
+
bf-cbc, bfcbc (input, key)
|
148
|
+
bf-cfb, bfcfb (input, key)
|
149
|
+
bf-ecb, bfecb (input, key)
|
150
|
+
bf-ofb, bfofb (input, key)
|
151
|
+
camellia-128-cbc, camellia128cbc (input, key)
|
152
|
+
camellia-128-cfb, camellia128cfb (input, key)
|
153
|
+
camellia-128-cfb1, camellia128cfb1 (input, key)
|
154
|
+
camellia-128-cfb8, camellia128cfb8 (input, key)
|
155
|
+
camellia-128-ecb, camellia128ecb (input, key)
|
156
|
+
camellia-128-ofb, camellia128ofb (input, key)
|
157
|
+
camellia-192-cbc, camellia192cbc (input, key)
|
158
|
+
camellia-192-cfb, camellia192cfb (input, key)
|
159
|
+
camellia-192-cfb1, camellia192cfb1 (input, key)
|
160
|
+
camellia-192-cfb8, camellia192cfb8 (input, key)
|
161
|
+
camellia-192-ecb, camellia192ecb (input, key)
|
162
|
+
camellia-192-ofb, camellia192ofb (input, key)
|
163
|
+
camellia-256-cbc, camellia256cbc (input, key)
|
164
|
+
camellia-256-cfb, camellia256cfb (input, key)
|
165
|
+
camellia-256-cfb1, camellia256cfb1 (input, key)
|
166
|
+
camellia-256-cfb8, camellia256cfb8 (input, key)
|
167
|
+
camellia-256-ecb, camellia256ecb (input, key)
|
168
|
+
camellia-256-ofb, camellia256ofb (input, key)
|
169
|
+
camellia128 (input, key)
|
170
|
+
camellia192 (input, key)
|
171
|
+
camellia256 (input, key)
|
172
|
+
cast (input, key)
|
173
|
+
cast-cbc, castcbc (input, key)
|
174
|
+
cast5-cbc, cast5cbc (input, key)
|
175
|
+
cast5-cfb, cast5cfb (input, key)
|
176
|
+
cast5-ecb, cast5ecb (input, key)
|
177
|
+
cast5-ofb, cast5ofb (input, key)
|
178
|
+
des (input, key)
|
179
|
+
des-cbc, descbc (input, key)
|
180
|
+
des-cfb, descfb (input, key)
|
181
|
+
des-cfb1, descfb1 (input, key)
|
182
|
+
des-cfb8, descfb8 (input, key)
|
183
|
+
des-ecb, desecb (input, key)
|
184
|
+
des-ede, desede (input, key)
|
185
|
+
des-ede-cbc, desedecbc (input, key)
|
186
|
+
des-ede-cfb, desedecfb (input, key)
|
187
|
+
des-ede-ofb, desedeofb (input, key)
|
188
|
+
des-ede3, desede3 (input, key)
|
189
|
+
des-ede3-cbc, desede3cbc (input, key)
|
190
|
+
des-ede3-cfb, desede3cfb (input, key)
|
191
|
+
des-ede3-cfb1, desede3cfb1 (input, key)
|
192
|
+
des-ede3-cfb8, desede3cfb8 (input, key)
|
193
|
+
des-ede3-ofb, desede3ofb (input, key)
|
194
|
+
des-ofb, desofb (input, key)
|
195
|
+
des3 (input, key)
|
196
|
+
desx (input, key)
|
197
|
+
desx-cbc, desxcbc (input, key)
|
198
|
+
rc2 (input, key)
|
199
|
+
rc2-40-cbc, rc240cbc (input, key)
|
200
|
+
rc2-64-cbc, rc264cbc (input, key)
|
201
|
+
rc2-cbc, rc2cbc (input, key)
|
202
|
+
rc2-cfb, rc2cfb (input, key)
|
203
|
+
rc2-ecb, rc2ecb (input, key)
|
204
|
+
rc2-ofb, rc2ofb (input, key)
|
205
|
+
rc4 (input, key)
|
206
|
+
rc4-40, rc440 (input, key)
|
207
|
+
rc4-hmac-md5, rc4hmacmd5 (input, key)
|
208
|
+
seed (input, key)
|
209
|
+
seed-cbc, seedcbc (input, key)
|
210
|
+
seed-cfb, seedcfb (input, key)
|
211
|
+
seed-ecb, seedecb (input, key)
|
212
|
+
seed-ofb, seedofb (input, key)
|
213
|
+
aes-128-ccm, aes128ccm (input, key)
|
214
|
+
aes-128-gcm, aes128gcm (input, key)
|
215
|
+
aes-192-ccm, aes192ccm (input, key)
|
216
|
+
aes-192-gcm, aes192gcm (input, key)
|
217
|
+
aes-256-ccm, aes256ccm (input, key)
|
218
|
+
aes-256-gcm, aes256gcm (input, key)
|
219
|
+
blowfish (input, key)
|
220
|
+
id-aes128-ccm, idaes128ccm (input, key)
|
221
|
+
id-aes128-gcm, idaes128gcm (input, key)
|
222
|
+
id-aes128-wrap, idaes128wrap (input, key)
|
223
|
+
id-aes192-ccm, idaes192ccm (input, key)
|
224
|
+
id-aes192-gcm, idaes192gcm (input, key)
|
225
|
+
id-aes192-wrap, idaes192wrap (input, key)
|
226
|
+
id-aes256-ccm, idaes256ccm (input, key)
|
227
|
+
id-aes256-gcm, idaes256gcm (input, key)
|
228
|
+
id-aes256-wrap, idaes256wrap (input, key)
|
229
|
+
id-smime-alg-cms3deswrap, idsmimealgcms3deswrap (input, key)
|
230
|
+
b2, base2, bin, binary (input)
|
231
|
+
b8, base8, oct, octal (input)
|
232
|
+
b16, base16, hex, hexidecimal (input)
|
233
|
+
b32, base32, b32-std, base32-std (input)
|
234
|
+
b64, base64, b64-psq, b64-std, base64-psq, base64-std (input)
|
235
|
+
b64-ps, b64-utf7, base64-ps, base64-utf7 (input)
|
236
|
+
b64-ph, b64-file, base64-ph, base64-file (input)
|
237
|
+
b64-hu, b64-url, base64-hu, base64-url (input)
|
238
|
+
b64-duh, b64-yui, base64-duh, base64-yui (input)
|
239
|
+
b64-dh, b64-xml-name, base64-dh, base64-xml-name (input)
|
240
|
+
b64-uc, b64-xml-id, base64-uc, base64-xml-id (input)
|
241
|
+
b64-uh, b64-prog-id-1, base64-uh, base64-prog-id-1 (input)
|
242
|
+
b64-du, b64-prog-id-2, base64-du, base64-prog-id-2 (input)
|
243
|
+
b64-xh, b64-regex, base64-xh, base64-regex (input)
|
244
|
+
r2, rad2, radix2 (input)
|
245
|
+
r3, rad3, radix3 (input)
|
246
|
+
r4, rad4, radix4 (input)
|
247
|
+
r5, rad5, radix5 (input)
|
248
|
+
r6, rad6, radix6 (input)
|
249
|
+
r7, rad7, radix7 (input)
|
250
|
+
r8, rad8, radix8 (input)
|
251
|
+
r9, rad9, radix9 (input)
|
252
|
+
r10, rad10, radix10 (input)
|
253
|
+
r11, rad11, radix11 (input)
|
254
|
+
r12, rad12, radix12 (input)
|
255
|
+
r13, rad13, radix13 (input)
|
256
|
+
r14, rad14, radix14 (input)
|
257
|
+
r15, rad15, radix15 (input)
|
258
|
+
r16, rad16, radix16 (input)
|
259
|
+
r17, rad17, radix17 (input)
|
260
|
+
r18, rad18, radix18 (input)
|
261
|
+
r19, rad19, radix19 (input)
|
262
|
+
r20, rad20, radix20 (input)
|
263
|
+
r21, rad21, radix21 (input)
|
264
|
+
r22, rad22, radix22 (input)
|
265
|
+
r23, rad23, radix23 (input)
|
266
|
+
r24, rad24, radix24 (input)
|
267
|
+
r25, rad25, radix25 (input)
|
268
|
+
r26, rad26, radix26 (input)
|
269
|
+
r27, rad27, radix27 (input)
|
270
|
+
r28, rad28, radix28 (input)
|
271
|
+
r29, rad29, radix29 (input)
|
272
|
+
r30, rad30, radix30 (input)
|
273
|
+
r31, rad31, radix31 (input)
|
274
|
+
r32, rad32, radix32 (input)
|
275
|
+
r33, rad33, radix33 (input)
|
276
|
+
r34, rad34, radix34 (input)
|
277
|
+
r35, rad35, radix35 (input)
|
278
|
+
r36, rad36, radix36 (input)
|
279
|
+
deflate (input)
|
280
|
+
gzip, gz (input)
|
281
|
+
and-trunc (input, input)
|
282
|
+
or-trunc (input, input)
|
283
|
+
xor-trunc (input, input)
|
284
|
+
and (input, input)
|
285
|
+
or (input, input)
|
286
|
+
xor (input, input)
|
287
|
+
not (input)
|
288
|
+
url, uri, cgi (input)
|
289
|
+
cat, catenate (input)
|
290
|
+
repack (input, ch1, ch2)
|
291
|
+
tr, translate (input, ch1, ch2)
|
292
|
+
repl, replace (input, search, replace)
|
293
|
+
rc4-ruby (input, key)
|
294
|
+
|
295
|
+
|
296
|
+
```
|
297
|
+
|
298
|
+
## Developing
|
299
|
+
Check out code:
|
300
|
+
```shell
|
301
|
+
git clone https://github.com/frohoff/ciphr.git
|
302
|
+
cd ciphr
|
303
|
+
```
|
304
|
+
|
305
|
+
Run command from exploded gem/project directory:
|
306
|
+
```shell
|
307
|
+
bundle exec ruby -Ilib bin/ciphr [args]
|
308
|
+
```
|
309
|
+
|
310
|
+
## Contributing
|
311
|
+
|
312
|
+
1. Fork it
|
313
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
314
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
315
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
316
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,320 @@
|
|
1
|
+
TODO:
|
2
|
+
==========================
|
3
|
+
|
4
|
+
Document use of bash anon named pipes with @ syntax
|
5
|
+
spaces in various places in grammar (between @ and filename, spaces inside of [] and () for calls)
|
6
|
+
|
7
|
+
xor hangs with large keyfiles
|
8
|
+
Context objects, Classes method_missing delegate to singleton instance
|
9
|
+
TTY handling: default trailing newline, colors/escapes for non-printable
|
10
|
+
tr, replace functions
|
11
|
+
interleave/concat multiple streams
|
12
|
+
vararg functions
|
13
|
+
switch endianness
|
14
|
+
|
15
|
+
fix
|
16
|
+
-----------
|
17
|
+
bug in b64 decoding of HFF= => HFE=
|
18
|
+
|
19
|
+
robustness
|
20
|
+
-----------
|
21
|
+
* graceful handling of mismatched data size (key size, base64 chunks, xor)
|
22
|
+
* errors for bad function name or args
|
23
|
+
* case insensitivity for ~b16
|
24
|
+
* high level classification of functions (util, bitwise, hash, cipher, mac, etc)
|
25
|
+
* handling of optional arguments (IVs/nonces, # rounds, etc) without breaking pipe argument prepending
|
26
|
+
* escape/encode non-printable chars if outputting to tty http://blog.bogojoker.com/2009/04/check-if-your-ruby-script-is-in-a-pipe/
|
27
|
+
* description for functions in help
|
28
|
+
|
29
|
+
completeness
|
30
|
+
-----------
|
31
|
+
base64 variants
|
32
|
+
* %/url, b32, ascii85, escape-sequence (\x, String.dump), xml/html
|
33
|
+
* bitwise ops: variants for mismatched lengths?
|
34
|
+
|
35
|
+
|
36
|
+
features
|
37
|
+
---------------
|
38
|
+
functions
|
39
|
+
bitwise ops
|
40
|
+
shift right/left (circular rotate vs fill)
|
41
|
+
not/and/or (similar to xor)
|
42
|
+
hashes
|
43
|
+
crc/adler
|
44
|
+
crypt/scrypt/bcrypt/pbkdf
|
45
|
+
ciphers
|
46
|
+
substitution: caeser/rot/dvorak/vigenère/affine/atbash/avgad/albam
|
47
|
+
physical: rotor/enigma
|
48
|
+
byte ops
|
49
|
+
prepend/append
|
50
|
+
indexed head/tail/substring
|
51
|
+
reverse bits/nibbles/bytes
|
52
|
+
repeat bytes
|
53
|
+
compression
|
54
|
+
gzip/deflate/lz*/bzip2/snappy/rle
|
55
|
+
http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv
|
56
|
+
generators
|
57
|
+
random bytes
|
58
|
+
|
59
|
+
revamp streams
|
60
|
+
http://readruby.io/io
|
61
|
+
https://github.com/javanthropus/io-like
|
62
|
+
https://github.com/javanthropus/stream
|
63
|
+
https://github.com/rubygems/rubygems/blob/master/lib/rubygems/package/digest_io.rb
|
64
|
+
https://github.com/krypt/binyo
|
65
|
+
https://gist.github.com/tlrobinson/967710
|
66
|
+
https://www.ruby-forum.com/topic/58563
|
67
|
+
https://github.com/jdleesmiller/event_state
|
68
|
+
https://github.com/slagyr/statemachine/
|
69
|
+
namespacing in case of simple name collisions
|
70
|
+
string literals
|
71
|
+
alternative quotes (a la ruby/perl/python, %q[] %Q{} qq() """ ''') http://en.wikibooks.org/wiki/Ruby_Programming/Alternate_quotes
|
72
|
+
allow \xXX escaping
|
73
|
+
extension mechanism (via other gems or simple files)
|
74
|
+
varargs for functions
|
75
|
+
non pipe statements variable writing/reading
|
76
|
+
|
77
|
+
|
78
|
+
random ideas
|
79
|
+
-------------
|
80
|
+
`strings` extraction
|
81
|
+
regex search/replace support
|
82
|
+
fn for executing shell/ruby
|
83
|
+
multi-round hash support
|
84
|
+
|
85
|
+
|
86
|
+
cleanliness
|
87
|
+
-----------
|
88
|
+
refactor variable buffering (probably will improve perf)
|
89
|
+
break up functions
|
90
|
+
|
91
|
+
goals and philosophy
|
92
|
+
==========================
|
93
|
+
functions on streams of bytes
|
94
|
+
kiss: crypto, hashes, bitwise ops, encodings, compression, simple transforms
|
95
|
+
most complex use case: generate rails cookie from marshalled data and secret
|
96
|
+
strive for streaming impls and low memory usage even for large input documents
|
97
|
+
pull/read (vs push/write) based API
|
98
|
+
shell friendly syntax
|
99
|
+
maximum portability, no native gem deps
|
100
|
+
extensible via external gems adding functions
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
scratch notes
|
105
|
+
==========================
|
106
|
+
|
107
|
+
|
108
|
+
reverse(input,chunksize=1,boundarysize=nil)
|
109
|
+
cat(input1,input2,...,inputn)
|
110
|
+
|
111
|
+
ruby -e 'puts ["c","s"].product(["i","y"]).product(["ph","f"]).product(["r","er","yr","ir"]).map{|a| a.flatten.join}'
|
112
|
+
ciphr
|
113
|
+
cipher
|
114
|
+
ciphyr
|
115
|
+
ciphir
|
116
|
+
cifr
|
117
|
+
cifer
|
118
|
+
cifyr
|
119
|
+
cifir
|
120
|
+
cyphr
|
121
|
+
cypher
|
122
|
+
cyphyr
|
123
|
+
cyphir
|
124
|
+
cyfr
|
125
|
+
cyfer
|
126
|
+
cyfyr
|
127
|
+
cyfir
|
128
|
+
siphr
|
129
|
+
sipher
|
130
|
+
siphyr
|
131
|
+
siphir
|
132
|
+
sifr
|
133
|
+
sifer
|
134
|
+
sifyr
|
135
|
+
sifir
|
136
|
+
syphr
|
137
|
+
sypher
|
138
|
+
syphyr
|
139
|
+
syphir
|
140
|
+
syfr
|
141
|
+
syfer
|
142
|
+
syfyr
|
143
|
+
syfir
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
Gem::Specification.find_all.to_a.select{|s| s.dependencies.any?{|d| d.name=='slop'}}.map{|s| s.name}
|
149
|
+
https://codeclimate.com/github/cloudfoundry/vmc/VMC::Plugin/source_listing.js?line_end=53&line_start=11&path=lib%2Fvmc%2Fplugin.rb
|
150
|
+
https://github.com/mmozuras/pronto
|
151
|
+
http://stackoverflow.com/questions/11827950/create-an-extensible-ruby-gem
|
152
|
+
https://bitbucket.org/ged/strelka/src/dc4b6998813161ab4c94656ce144aa36a85ab65e/lib/strelka/discovery.rb
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices/
|
158
|
+
https://gist.github.com/rtomayko/54177
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
11111111 | 11111111 | 11111111
|
164
|
+
111 | 111 | 111 | 111 | 111 | 111 | 111 | 111
|
165
|
+
|
166
|
+
1 2 3 4 5 6 7 8*1 2 3 4 5 6 7 8*1 2 3 4 5 6 7 8
|
167
|
+
1 2 3*1 2 3*1 2 3*1 2 3*1 2 3*1 2 3*1 2 3*1 2 3
|
168
|
+
|
169
|
+
|
170
|
+
~b64,hmac(abcd,~b64),b16,xor(deef,~b64)
|
171
|
+
~des
|
172
|
+
|
173
|
+
=abcd/^hex/b64/hmac[=abcd/^b64]=/
|
174
|
+
|
175
|
+
{abcd},~hex,b64/hmac-sha1[[{abcd},b64]]
|
176
|
+
|
177
|
+
=abcd ~hex hmac[=foo] ?key
|
178
|
+
|
179
|
+
~[],?@^#{}
|
180
|
+
|
181
|
+
|
182
|
+
0x01
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
foo#bar^baz[]
|
187
|
+
foo;bar|baz()
|
188
|
+
|
189
|
+
(foo|bar)|baz
|
190
|
+
|
191
|
+
((foo)|bar)|baz
|
192
|
+
|
193
|
+
assign var: ?varname
|
194
|
+
ref var: #varname
|
195
|
+
literal: =value
|
196
|
+
separator: " "
|
197
|
+
file reference: @filepath
|
198
|
+
|
199
|
+
% in url
|
200
|
+
used in b64: _-:!/.+=
|
201
|
+
shell ok: ~,.-_{}[]/?%#@^+=:
|
202
|
+
shell not ok: ()|!$&*\;'"<>`
|
203
|
+
|
204
|
+
sh b64
|
205
|
+
` x
|
206
|
+
~ x x
|
207
|
+
!
|
208
|
+
@ x x
|
209
|
+
# x x
|
210
|
+
$ x
|
211
|
+
% x x
|
212
|
+
^ x x
|
213
|
+
& x
|
214
|
+
* x
|
215
|
+
() x
|
216
|
+
- x
|
217
|
+
_ x
|
218
|
+
= x b
|
219
|
+
+ x
|
220
|
+
[] x x
|
221
|
+
{} x x
|
222
|
+
; x
|
223
|
+
: x
|
224
|
+
' x
|
225
|
+
" x
|
226
|
+
, x x
|
227
|
+
. x
|
228
|
+
/ x
|
229
|
+
<> x
|
230
|
+
? x x
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
x(a)|y(b)|z(c)
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
z
|
239
|
+
|
240
|
+
y c
|
241
|
+
|
242
|
+
x b
|
243
|
+
|
244
|
+
a
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
file
|
252
|
+
|
|
253
|
+
V
|
254
|
+
~hex
|
255
|
+
|
|
256
|
+
V
|
257
|
+
stdin --> aes --> hex --> stdout
|
258
|
+
|
259
|
+
|
260
|
+
file1 file2
|
261
|
+
| |
|
262
|
+
V V
|
263
|
+
~hex ~hex
|
264
|
+
| |
|
265
|
+
V V
|
266
|
+
stdin --> aes --> aes -> hex --> stdout
|
267
|
+
|
268
|
+
|
269
|
+
stdin --> md5 --> hex --> stdout
|
270
|
+
|
271
|
+
|
272
|
+
stdin --> md5 --> md5 --> ... -> md5 --> hex --> stdout
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
base64: read multiple loop
|
278
|
+
input.read(4) {|bytes,eof|
|
279
|
+
output.write(encode(bytes))
|
280
|
+
}
|
281
|
+
|
282
|
+
cipher: read full init, read arbitrary loop, special end
|
283
|
+
key.read() {|bytes,eof|
|
284
|
+
@bytes = bytes
|
285
|
+
}
|
286
|
+
input.read(256) {|bytes,eof|
|
287
|
+
output.write(cipher.update)
|
288
|
+
}
|
289
|
+
|
290
|
+
xor-repeat: read full init, read arbitrary loop
|
291
|
+
key.read() {|bytes,eof|}
|
292
|
+
|
293
|
+
|
294
|
+
xor-trunc: read arbitrary loop
|
295
|
+
key.read(1) && input.read(1) {
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
md5: read arbitrary loop, special end
|
301
|
+
|
302
|
+
hmac: read full init, read arbitrary loop, special end
|
303
|
+
|
304
|
+
def pump
|
305
|
+
if input.size >= 1 && key.size >= 1
|
306
|
+
output.write(input.read(1) ^ key.read(1))
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
IDEAS:
|
313
|
+
|
314
|
+
method_missing for arguments in function body
|
315
|
+
|
316
|
+
|
317
|
+
+ for concat
|
318
|
+
* for repeat
|
319
|
+
^ for recurse
|
320
|
+
|