rex-text 0.2.21 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rex/text/version.rb +1 -1
- data/lib/rex/text/xor.rb +29 -19
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 190d1c71b613ee194a0aac2cf30a1f9e64aa3840
|
4
|
+
data.tar.gz: 5be68027d74cf0f41e7cd988274f0f95ef2d6568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfce79358cf4dcfae393fa5af505e5c5b319553e5c163fcdfd6ca038049078cc2a2d1280bde198af9ed8efc883643acb248b1af77ae8853671885d948de8230
|
7
|
+
data.tar.gz: 3359f81978ca710c11ae51f774cc370598d8289cbe640c536e9279f07cba5c8293a10c527cbedecb7dd2131543ca56d86e8a9940fffc2cc0e94631a16baecd48
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rex/text/version.rb
CHANGED
data/lib/rex/text/xor.rb
CHANGED
@@ -1,28 +1,38 @@
|
|
1
1
|
# -*- coding: binary -*-
|
2
2
|
|
3
|
-
module Rex
|
4
|
-
|
3
|
+
module Rex::Text
|
4
|
+
# XOR a string against a variable-length key
|
5
|
+
#
|
6
|
+
# @param key [String] XOR key
|
7
|
+
# @param value [String] String to XOR
|
8
|
+
# @return [String] XOR'd string
|
9
|
+
def self.xor(key, value)
|
10
|
+
unless key && value
|
11
|
+
raise ArgumentError, 'XOR key and value must be supplied'
|
12
|
+
end
|
5
13
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
xor_key = key.kind_of?(Integer) || key.nil? ? key.to_i : key.to_i(16)
|
13
|
-
unless xor_key.between?(0, 255)
|
14
|
-
raise ArgumentError, 'XOR key should be between 0x00 to 0x0f'
|
15
|
-
end
|
14
|
+
xor_key =
|
15
|
+
case key
|
16
|
+
when String
|
17
|
+
if key.empty?
|
18
|
+
raise ArgumentError, 'XOR key must not be empty'
|
19
|
+
end
|
16
20
|
|
17
|
-
|
21
|
+
key
|
22
|
+
when Integer
|
23
|
+
unless key.between?(0x00, 0xff)
|
24
|
+
raise ArgumentError, 'XOR key must be between 0x00 and 0xff'
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
buf << [xor_byte].pack('c')
|
27
|
+
# Convert integer to string
|
28
|
+
[key].pack('C')
|
22
29
|
end
|
23
30
|
|
24
|
-
|
25
|
-
|
31
|
+
# Get byte arrays for key and value
|
32
|
+
xor_key = xor_key.bytes
|
33
|
+
xor_value = value.bytes
|
26
34
|
|
35
|
+
# XOR value against cycled key
|
36
|
+
xor_value.zip(xor_key.cycle).map { |v, k| v ^ k }.pack('C*')
|
27
37
|
end
|
28
|
-
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David 'thelightcosine' Maloney
|
@@ -88,7 +88,7 @@ cert_chain:
|
|
88
88
|
G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
|
89
89
|
8mVuTXnyJOKRJA==
|
90
90
|
-----END CERTIFICATE-----
|
91
|
-
date:
|
91
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
92
92
|
dependencies:
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: bundler
|
metadata.gz.sig
CHANGED
Binary file
|