ctf-party 2.1.0 → 2.2.0
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/bin/ctf-party +58 -8
- data/lib/ctf_party/cgi.rb +1 -0
- data/lib/ctf_party/hex.rb +4 -2
- data/lib/ctf_party/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b19410e0b443bc237d10f61d2f85caff731309e95142c66d5d74897b3b296319
|
4
|
+
data.tar.gz: b446182ee4883bddcabb9cfa108d62712d74ab004fe9b1f4180db7ae42e4dcd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e38e7605cd1bf2bd7d9bcef501c93d6c5e1789a8488a6a150380e364822f24c981f265e319654527e0e804f6bcb7f3c6e2337d39abc54d081c602de43aca6056
|
7
|
+
data.tar.gz: 4cb5c641ec6cbdc40e35387068c8befc1b658d586bae0a52a8c13cdf5cd93068c05e250d48274810e2f276bb61681bf7be0b862da0699d672b857f47a66c50cc
|
data/bin/ctf-party
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
# Ruby internal
|
5
5
|
require 'pp'
|
6
|
+
require 'shellwords' # for shellescape cmd
|
6
7
|
# Project internal
|
7
8
|
require 'ctf_party'
|
8
9
|
require 'ctf_party/version'
|
@@ -10,6 +11,7 @@ require 'ctf_party/version'
|
|
10
11
|
require 'docopt'
|
11
12
|
|
12
13
|
cmd_whitelist = {
|
14
|
+
# ctf-party commands
|
13
15
|
alternatecase: 'Change one characte on two upcase and the other downcase',
|
14
16
|
bin2hex: 'Encode an binary string to a hexadecimal string',
|
15
17
|
bin2str: 'Alias for from_bin',
|
@@ -45,27 +47,62 @@ cmd_whitelist = {
|
|
45
47
|
to_hex: 'Encode a string into hexadecimal',
|
46
48
|
to_hexip: 'Encode a dotted decimal IP into a hexadecimal one',
|
47
49
|
urldecode: 'URL-decode the string',
|
48
|
-
|
50
|
+
urldecode_component: 'URL-decode the URL component string',
|
51
|
+
urlencode: 'URL-encode the string',
|
52
|
+
urlencode_component: 'URL-encode the URL component string',
|
53
|
+
# native string commands
|
54
|
+
bytesize: 'https://rubyapi.org/3.1/o/string#method-i-bytesize',
|
55
|
+
capitalize: 'https://rubyapi.org/3.1/o/string#method-i-capitalize',
|
56
|
+
chomp: 'https://rubyapi.org/3.1/o/string#method-i-chomp',
|
57
|
+
chop: 'https://rubyapi.org/3.1/o/string#method-i-chop',
|
58
|
+
downcase: 'https://rubyapi.org/3.1/o/string#method-i-downcase',
|
59
|
+
dump: 'https://rubyapi.org/3.1/o/string#method-i-dump',
|
60
|
+
hex: 'https://rubyapi.org/3.1/o/string#method-i-hex',
|
61
|
+
inspect: 'https://rubyapi.org/3.1/o/string#method-i-inspect',
|
62
|
+
length: 'https://rubyapi.org/3.1/o/string#method-i-length',
|
63
|
+
lstrip: 'https://rubyapi.org/3.1/o/string#method-i-lstrip',
|
64
|
+
reverse: 'https://rubyapi.org/3.1/o/string#method-i-reverse',
|
65
|
+
rstrip: 'https://rubyapi.org/3.1/o/string#method-i-rstrip',
|
66
|
+
scrub: 'https://rubyapi.org/3.1/o/string#method-i-scrub',
|
67
|
+
shellescape: 'https://rubyapi.org/3.1/o/string#method-i-shellescape',
|
68
|
+
size: 'https://rubyapi.org/3.1/o/string#method-i-size',
|
69
|
+
squeeze: 'https://rubyapi.org/3.1/o/string#method-i-squeeze',
|
70
|
+
strip: 'https://rubyapi.org/3.1/o/string#method-i-strip',
|
71
|
+
succ: 'https://rubyapi.org/3.1/o/string#method-i-succ',
|
72
|
+
swapcase: 'https://rubyapi.org/3.1/o/string#method-i-swapcase',
|
73
|
+
undump: 'https://rubyapi.org/3.1/o/string#method-i-undump',
|
74
|
+
unicode_normalize: 'https://rubyapi.org/3.1/o/string#method-i-unicode_normalize',
|
75
|
+
upcase: 'https://rubyapi.org/3.1/o/string#method-i-upcase'
|
49
76
|
}
|
50
77
|
|
51
78
|
doc = <<~DOCOPT
|
52
|
-
ctf-party by noraj
|
79
|
+
ctf-party v#{Version::VERSION} by noraj
|
53
80
|
|
54
81
|
Usage:
|
55
|
-
ctf-party <string> <cmd>... [--debug]
|
82
|
+
ctf-party <string> <cmd>... [--row --file] [--debug]
|
56
83
|
ctf-party --list-commands [--debug]
|
57
84
|
ctf-party -h | --help
|
58
85
|
ctf-party --version
|
59
86
|
|
87
|
+
Parameters:
|
88
|
+
<string> The string to manipulate, read from STDIN if equal to "-"
|
89
|
+
<cmd> Command to apply to the string, cf. --list-commands
|
90
|
+
|
60
91
|
Options:
|
61
92
|
-l, --list-commands List available commands (see https://noraj.github.io/ctf-party/yard/String.html)
|
93
|
+
-r, --row Apply the transformation to each row
|
94
|
+
-f, --file Interpret the string as a filename, if file doesn't exist it will still be treated as a string
|
62
95
|
--debug Display arguments
|
63
96
|
-h, --help Show this screen
|
64
97
|
--version Show version
|
65
98
|
|
66
99
|
Examples:
|
67
100
|
ctf-party 'security' to_hex
|
68
|
-
ctf-party 'NzQ2Zjc0NmY=' from_b64
|
101
|
+
ctf-party 'NzQ2Zjc0NmY=' from_b64 hex2bin
|
102
|
+
curl -s https://example.org | ctf-party - htmlescape
|
103
|
+
seq 1 10 | ctf-party - dec2hex hex2bin --row
|
104
|
+
cut -d : -f 1 /etc/passwd | ctf-party - randomcase --row
|
105
|
+
ctf-party /etc/passwd str2hex --row --file
|
69
106
|
DOCOPT
|
70
107
|
|
71
108
|
begin
|
@@ -73,11 +110,24 @@ begin
|
|
73
110
|
# use case 1, using the tool
|
74
111
|
pp args if args['--debug']
|
75
112
|
if args['<string>']
|
113
|
+
args['<string>'] = $stdin.read.chomp if args['<string>'] == '-'
|
114
|
+
args['<string>'] = File.read(args['<string>']) if args['--file'] && File.exist?(args['<string>'])
|
76
115
|
wrong_cmd = args['<cmd>'] - cmd_whitelist.keys.map(&:to_s)
|
77
116
|
if wrong_cmd.empty?
|
78
|
-
|
79
|
-
|
80
|
-
|
117
|
+
if args['--row']
|
118
|
+
output = ''
|
119
|
+
args['<string>'].each_line(chomp: true) do |line|
|
120
|
+
output_line = line
|
121
|
+
args['<cmd>'].each do |cmd|
|
122
|
+
output_line = output_line.public_send(cmd)
|
123
|
+
end
|
124
|
+
output += "#{output_line}\n"
|
125
|
+
end
|
126
|
+
else
|
127
|
+
output = args['<string>']
|
128
|
+
args['<cmd>'].each do |cmd|
|
129
|
+
output = output.public_send(cmd)
|
130
|
+
end
|
81
131
|
end
|
82
132
|
puts output
|
83
133
|
else
|
@@ -85,7 +135,7 @@ begin
|
|
85
135
|
end
|
86
136
|
elsif args['--list-commands']
|
87
137
|
cmd_whitelist.each do |k, v|
|
88
|
-
puts "#{k.to_s.ljust(
|
138
|
+
puts "#{k.to_s.ljust(25)}#{v}"
|
89
139
|
end
|
90
140
|
end
|
91
141
|
# use case 2, help: already handled by docopt
|
data/lib/ctf_party/cgi.rb
CHANGED
data/lib/ctf_party/hex.rb
CHANGED
@@ -59,8 +59,10 @@ class String
|
|
59
59
|
out = ('0' * (opts[:padding] - out.size)) + out if out.size < opts[:padding]
|
60
60
|
# char case management
|
61
61
|
out = out.upcase if opts[:case] == :upper
|
62
|
-
# adding prefix must be done after case change
|
63
|
-
out = out.scan(/.{2}/).map
|
62
|
+
# adding prefix must be done after case change, complex conditional to avoid cropping when odd byte lenght
|
63
|
+
out = (out.size.odd? ? [out[0]] + out[1..].scan(/.{1,2}/) : out.scan(/.{2}/)).map do |x|
|
64
|
+
opts[:prefixall] + x
|
65
|
+
end.join
|
64
66
|
return opts[:prefix] + out
|
65
67
|
end
|
66
68
|
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre ZANNI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|