ctf-party 1.3.2 → 1.3.3
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.
- checksums.yaml +4 -4
- data/lib/ctf_party.rb +1 -0
- data/lib/ctf_party/binary.rb +77 -0
- data/lib/ctf_party/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5b53f3731ce007357cb7033f6758bbb8136bd7f66deddc1d519aa246f9aee6c
|
4
|
+
data.tar.gz: 5c17753bd1e9bbf34e82f639531c9fe496ca8dffc68a83b30d32cc05b5c0cc5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2788b1c3b60d2f5ed5a3d05c1971e013f3c02317219368a408b0f375ce9bc3e92d9d67090ca92a39f4dfc908d8c6775d90e4a8cee91736474fd8f3b0ea9e0870
|
7
|
+
data.tar.gz: eae30b24bf35a6f6a8caab27bf13f496cc262abefd3d348f7c5e58835141c0a36261162045a17d86236277a0576b64ed9670d66812e82d3536d066fad4b59807
|
data/lib/ctf_party.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class String
|
4
|
+
# Encode a string into binary
|
5
|
+
# @param opts [Hash] optional parameters
|
6
|
+
# @option opts [Symbol] :bitnumbering Display output with most significant bit
|
7
|
+
# first (+:MSB+ default) or least significant bit first (+:LSB+).
|
8
|
+
# @return [String] the binary encoded string
|
9
|
+
# @example
|
10
|
+
# 'binary'.to_bin # => "011000100110100101101110011000010111001001111001"
|
11
|
+
# 'binary'.to_bin(bitnumbering: :LSB) # => "010001101001011001110110100001100100111010011110"
|
12
|
+
def to_bin(opts = {})
|
13
|
+
opts[:bitnumbering] ||= :MSB
|
14
|
+
# convert
|
15
|
+
return unpack1('B*') if opts[:bitnumbering] == :MSB
|
16
|
+
return unpack1('b*') if opts[:bitnumbering] == :LSB
|
17
|
+
|
18
|
+
raise ArgumentError ':bitnumbering expects :MSB or :LSB'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Alias for {String#to_bin}.
|
22
|
+
def str2bin(opts = {})
|
23
|
+
to_bin(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Encode a string into binary in place as described
|
27
|
+
# for {String#to_bin}.
|
28
|
+
# @example
|
29
|
+
# a = 'binary'
|
30
|
+
# a.to_bin!
|
31
|
+
# a # => "011000100110100101101110011000010111001001111001"
|
32
|
+
def to_bin!(opts = {})
|
33
|
+
replace(to_bin(opts))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Alias for {String#to_bin!}.
|
37
|
+
def str2bin!(opts = {})
|
38
|
+
to_bin!(opts)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Decode a binary string
|
42
|
+
# @param opts [Hash] optional parameters
|
43
|
+
# @option opts [Symbol] :bitnumbering Display input with most significant bit
|
44
|
+
# first (+:MSB+ default) or least significant bit first (+:LSB+).
|
45
|
+
# @return [String] the binary decoded string
|
46
|
+
# @example
|
47
|
+
# '011000100110100101101110011000010111001001111001'.from_bin # => "binary"
|
48
|
+
# '010001101001011001110110100001100100111010011110'.from_bin(bitnumbering: :LSB) # => "binary"
|
49
|
+
def from_bin(opts = {})
|
50
|
+
opts[:bitnumbering] ||= :MSB
|
51
|
+
# convert
|
52
|
+
return Array(self).pack('B*') if opts[:bitnumbering] == :MSB
|
53
|
+
return Array(self).pack('b*') if opts[:bitnumbering] == :LSB
|
54
|
+
|
55
|
+
raise ArgumentError ':bitnumbering expects :MSB or :LSB'
|
56
|
+
end
|
57
|
+
|
58
|
+
# Alias for {String#from_bin}.
|
59
|
+
def bin2str(opts = {})
|
60
|
+
from_bin(opts)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Decode a binary string in place as described
|
64
|
+
# for {String#from_bin}.
|
65
|
+
# @example
|
66
|
+
# a = "011000100110100101101110011000010111001001111001"
|
67
|
+
# a.from_bin!
|
68
|
+
# a # => "binary"
|
69
|
+
def from_bin!(opts = {})
|
70
|
+
replace(from_bin(opts))
|
71
|
+
end
|
72
|
+
|
73
|
+
# Alias for {String#from_bin!}.
|
74
|
+
def bin2str!(opts = {})
|
75
|
+
from_bin!(opts)
|
76
|
+
end
|
77
|
+
end
|
data/lib/ctf_party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ctf-party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre ZANNI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.8'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1.8'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: yard
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- bin/ctf_party_console
|
136
136
|
- lib/ctf_party.rb
|
137
137
|
- lib/ctf_party/base64.rb
|
138
|
+
- lib/ctf_party/binary.rb
|
138
139
|
- lib/ctf_party/case.rb
|
139
140
|
- lib/ctf_party/cgi.rb
|
140
141
|
- lib/ctf_party/digest.rb
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.1.
|
171
|
+
rubygems_version: 3.1.4
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: A library to enhance and speed up script/exploit writing for CTF players
|