ctf-party 1.0.0 → 1.1.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ctf_party_console +0 -0
  3. data/lib/ctf_party.rb +1 -0
  4. data/lib/ctf_party/base64.rb +2 -10
  5. data/lib/ctf_party/digest.rb +12 -10
  6. data/lib/ctf_party/flag.rb +1 -1
  7. data/lib/ctf_party/hex.rb +134 -0
  8. data/lib/ctf_party/rot.rb +2 -2
  9. data/lib/ctf_party/version.rb +1 -1
  10. metadata +17 -63
  11. data/.rubocop.yml +0 -29
  12. data/.yardopts +0 -4
  13. data/.yardopts-dev +0 -6
  14. data/Gemfile +0 -6
  15. data/Gemfile.lock +0 -52
  16. data/README.md +0 -57
  17. data/Rakefile +0 -11
  18. data/bin/ctf_party_setup +0 -6
  19. data/docs/.nojekyll +0 -0
  20. data/docs/About.md +0 -5
  21. data/docs/CHANGELOG.md +0 -5
  22. data/docs/README.md +0 -52
  23. data/docs/_coverpage.md +0 -10
  24. data/docs/_media/logo.png +0 -0
  25. data/docs/_navbar.md +0 -3
  26. data/docs/_sidebar.md +0 -13
  27. data/docs/index.html +0 -31
  28. data/docs/pages/documentation.md +0 -30
  29. data/docs/pages/install.md +0 -84
  30. data/docs/pages/publishing.md +0 -39
  31. data/docs/pages/quick-start.md +0 -23
  32. data/docs/pages/usage.md +0 -61
  33. data/docs/vendor/docsify.js +0 -1
  34. data/docs/vendor/plugins/emoji.min.js +0 -1
  35. data/docs/vendor/plugins/search.min.js +0 -1
  36. data/docs/vendor/prismjs/components/prism-ruby.min.js +0 -1
  37. data/docs/vendor/themes/vue.css +0 -1
  38. data/docs/yard/String.html +0 -2909
  39. data/docs/yard/Version.html +0 -121
  40. data/docs/yard/_index.html +0 -123
  41. data/docs/yard/class_list.html +0 -51
  42. data/docs/yard/css/common.css +0 -1
  43. data/docs/yard/css/full_list.css +0 -58
  44. data/docs/yard/css/style.css +0 -496
  45. data/docs/yard/file.LICENSE.html +0 -70
  46. data/docs/yard/file.README.html +0 -124
  47. data/docs/yard/file_list.html +0 -61
  48. data/docs/yard/frames.html +0 -17
  49. data/docs/yard/index.html +0 -124
  50. data/docs/yard/js/app.js +0 -303
  51. data/docs/yard/js/full_list.js +0 -216
  52. data/docs/yard/js/jquery.js +0 -4
  53. data/docs/yard/method_list.html +0 -275
  54. data/docs/yard/top-level-namespace.html +0 -112
  55. data/test/test_string.rb +0 -134
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c9bbfee898723defee53d242711a127753c3bef4f6828477d4f686e4487713e
4
- data.tar.gz: 69f0e9e1e7bb5fd27dcbd37b2c86d8ce6514307f3eb413d196e89822ad8e6e6e
3
+ metadata.gz: aa3a85e4dd2db7d636cd1e6f66ca0b32fb34567886901b1102eae35fcb1fbb1c
4
+ data.tar.gz: aa6c2db8fb07651887d5711d0bfb6b544d422c4f091aaf1893cc6d345e467cc6
5
5
  SHA512:
6
- metadata.gz: 58b042d0a45a771eb5889438497c15c8126039016b70362d0dcffd58b41a35442735351a14d099744603a778a3dc9684e76a1f72334adca4b2124552205e0b2f
7
- data.tar.gz: 35c6e42f0c33448bba0acfd9ac126221ac557cfd47f4042edf844aed7bccf0272aaba52e38ee184959dbe0c56630f10c08575b6f0be25e9eeb3bd2a21ac02537
6
+ metadata.gz: b1eebe8e48be92a2f4ce8141f6c41a8f4023a3db5d4091358b41a41f5f3b4d123552e382c323d80e29db256818934b2ca8f036e23af10f56a4c1a04861a4f9d9
7
+ data.tar.gz: 067e1e47c7bad059917fa3774c9d5f37eb9ba37dcd0d8df0320a01bffeccae90a1958d8de8d41d6308040f5cc21e07025a5a34f4b6ef9ce8165ebb7246349134
File without changes
@@ -5,3 +5,4 @@ require 'ctf_party/base64'
5
5
  require 'ctf_party/rot'
6
6
  require 'ctf_party/digest'
7
7
  require 'ctf_party/flag'
8
+ require 'ctf_party/hex'
@@ -27,11 +27,7 @@ class String
27
27
  # myStr.to_b64! # => nil
28
28
  # myStr # => "UnVieQ=="
29
29
  def to_b64!(opts = {})
30
- opts[:mode] ||= :strict
31
- replace(to_b64) if opts[:mode] == :strict ||
32
- opts[:mode] == :rfc4648
33
- replace(to_b64(mode: :rfc2045)) if opts[:mode] == :rfc2045
34
- replace(to_b64(mode: :urlsafe)) if opts[:mode] == :urlsafe
30
+ replace(to_b64(opts))
35
31
  end
36
32
 
37
33
  # Decode the string from base64
@@ -57,11 +53,7 @@ class String
57
53
  # a.from_b64! # => nil
58
54
  # a # => "Hello world!"
59
55
  def from_b64!(opts = {})
60
- opts[:mode] ||= :strict
61
- replace(from_b64) if opts[:mode] == :strict ||
62
- opts[:mode] == :rfc4648
63
- replace(from_b64(mode: :rfc2045)) if opts[:mode] == :rfc2045
64
- replace(from_b64(mode: :urlsafe)) if opts[:mode] == :urlsafe
56
+ replace(from_b64(opts))
65
57
  end
66
58
 
67
59
  # Is the string encoded in base64?
@@ -13,7 +13,7 @@ class String
13
13
  Digest::MD5.hexdigest self
14
14
  end
15
15
 
16
- # Calculate the md5 hash of the string in place as described for {#md5}.
16
+ # Calculate the md5 hash of the string in place as described for {String#md5}.
17
17
  # @example
18
18
  # a = '\o/' # => "\\o/"
19
19
  # a.md5! # => "881419964e480e66162da521ccc25ebf"
@@ -31,7 +31,8 @@ class String
31
31
  Digest::SHA1.hexdigest self
32
32
  end
33
33
 
34
- # Calculate the sha1 hash of the string in place as described for {#sha1}.
34
+ # Calculate the sha1 hash of the string in place as described for
35
+ # {String#sha1}.
35
36
  # @example
36
37
  # bob = 'alice' # => "alice"
37
38
  # bob.sha1! # => "522b276a356bdf39013dfabea2cd43e141ecc9e8"
@@ -55,7 +56,8 @@ class String
55
56
  Digest::SHA2.new(opts[:bitlen]).hexdigest self
56
57
  end
57
58
 
58
- # Calculate the sha2 hash of the string in place as described for {#sha2}.
59
+ # Calculate the sha2 hash of the string in place as described for
60
+ # {String#sha2}.
59
61
  # @example
60
62
  # th = 'try harder' # => "try harder"
61
63
  # th.sha2!(bitlen: 384) # => "bb7f60b9562a19c3a83c23791440af11591c42ede9..."
@@ -64,32 +66,32 @@ class String
64
66
  replace(sha2(opts))
65
67
  end
66
68
 
67
- # Alias for {#sha2} with default value ( +sha2(bitlen: 256)+ ).
69
+ # Alias for {String#sha2} with default value ( +sha2(bitlen: 256)+ ).
68
70
  def sha2_256
69
71
  sha2
70
72
  end
71
73
 
72
- # Alias for {#sha2!} with default value ( +sha2!(bitlen: 256)+ ).
74
+ # Alias for {String#sha2!} with default value ( +sha2!(bitlen: 256)+ ).
73
75
  def sha2_256!
74
76
  replace(sha2)
75
77
  end
76
78
 
77
- # Alias for {#sha2} with default value ( +sha2(bitlen: 384)+ ).
79
+ # Alias for {String#sha2} with default value ( +sha2(bitlen: 384)+ ).
78
80
  def sha2_384
79
81
  sha2(bitlen: 384)
80
82
  end
81
83
 
82
- # Alias for {#sha2!} with default value ( +sha2!(bitlen: 384)+ ).
84
+ # Alias for {String#sha2!} with default value ( +sha2!(bitlen: 384)+ ).
83
85
  def sha2_384!
84
86
  replace(sha2(bitlen: 384))
85
87
  end
86
88
 
87
- # Alias for {#sha2} with default value ( +sha2(bitlen: 512)+ ).
89
+ # Alias for {String#sha2} with default value ( +sha2(bitlen: 512)+ ).
88
90
  def sha2_512
89
91
  sha2(bitlen: 512)
90
92
  end
91
93
 
92
- # Alias for {#sha2!} with default value ( +sha2!(bitlen: 512)+ ).
94
+ # Alias for {String#sha2!} with default value ( +sha2!(bitlen: 512)+ ).
93
95
  def sha2_512!
94
96
  replace(sha2(bitlen: 512))
95
97
  end
@@ -104,7 +106,7 @@ class String
104
106
  end
105
107
 
106
108
  # Calculate the RIPEMD-160 hash of the string in place as described for
107
- # {#rmd160}.
109
+ # {String#rmd160}.
108
110
  # @example
109
111
  # pl = 'payload' # => "payload"
110
112
  # pl.rmd160! # => "3c6255c112d409dafdb84d5b0edba98dfd27b44f"
@@ -72,7 +72,7 @@ class String
72
72
  end
73
73
 
74
74
  # Format the current string into the configured flag format in place as
75
- # described for {#flag}.
75
+ # described for {String#flag}.
76
76
  def flag!
77
77
  replace(flag)
78
78
  end
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+
3
+ class String
4
+ # Encode an hexadecimal string to a decimal string
5
+ # @param opts [Hash] optional parameters
6
+ # @option opts [String] :prefix Prefix of the input. Default value is a void
7
+ # string. Example of values: +0x+, +\x+.
8
+ # @return [String] the decimal encoded string
9
+ # @example
10
+ # 'ff'.hex2dec # => "255"
11
+ # '\xf3'.hex2dec(prefix: '\x') # => "243"
12
+ def hex2dec(opts = {})
13
+ opts[:prefix] ||= ''
14
+ # remove prefix
15
+ out = sub(opts[:prefix], '')
16
+ # convert
17
+ return out.hex.to_s
18
+ end
19
+
20
+ # Encode an hexadecimal string to a decimal string in place as described
21
+ # for {String#hex2dec}.
22
+ # @example
23
+ # a = 'ff'
24
+ # a.hex2dec!
25
+ # a # => => "255"
26
+ def hex2dec!(opts = {})
27
+ replace(hex2dec(opts))
28
+ end
29
+
30
+ # Encode an decimal string to a hexadecimal string
31
+ # @param opts [Hash] optional parameters
32
+ # @option opts [String] :prefix Prefix of the output. Default value is a void
33
+ # string. Example of values: +0x+, +\x+.
34
+ # @option opts [Symbol] :case Char case of the ouput. Default value +:lower+.
35
+ # Other valid value +:upper+.
36
+ # @return [String] the hexadecimal encoded string
37
+ # @example
38
+ # '255'.dec2hex # => "ff"
39
+ # '255'.dec2hex({prefix: '0x', case: :upper}) # => "0xFF"
40
+ def dec2hex(opts = {})
41
+ opts[:prefix] ||= ''
42
+ opts[:case] ||= :lower
43
+ # convert
44
+ out = to_i.to_s(16)
45
+ # char case management
46
+ out = out.upcase if opts[:case] == :upper
47
+ # adding prefix must be done after case change
48
+ return opts[:prefix] + out
49
+ end
50
+
51
+ # Encode an decimal string to a hexadecimal string in place as described
52
+ # for {String#dec2hex}.
53
+ # @example
54
+ # a = '255'
55
+ # a.dec2hex!
56
+ # a # => "ff"
57
+ def dec2hex!(opts = {})
58
+ replace(dec2hex(opts))
59
+ end
60
+
61
+ # Encode a string into hexadecimal
62
+ # @param opts [Hash] optional parameters
63
+ # @option opts [String] :prefix Prefix of the output. Default value is a void
64
+ # string. Example of values: +0x+, +\x+.
65
+ # @option opts [Symbol] :case Char case of the ouput. Default value +:lower+.
66
+ # Other valid value +:upper+.
67
+ # @option opts [Symbol] :nibble Display output with high nibble first
68
+ # (+:high+ default) or low nibble first (+:low+).
69
+ # @return [String] the hexadecimal encoded string
70
+ # @example
71
+ # 'noraj'.to_hex # => "6e6f72616a"
72
+ # 'noraj'.to_hex(prefix: '0x') # => "0x6e6f72616a"
73
+ # 'noraj'.to_hex(case: :upper) # => "6E6F72616A"
74
+ # 'noraj'.to_hex(nibble: :low) # => "e6f62716a6"
75
+ def to_hex(opts = {})
76
+ opts[:prefix] ||= ''
77
+ opts[:case] ||= :lower
78
+ opts[:nibble] ||= :high
79
+ # convert
80
+ out = ''
81
+ if opts[:nibble] == :high
82
+ out = unpack1('H*')
83
+ elsif opts[:nibble] == :low
84
+ out = unpack1('h*')
85
+ end
86
+ # char case management
87
+ out = out.upcase if opts[:case] == :upper
88
+ # adding prefix must be done after case change
89
+ return opts[:prefix] + out
90
+ end
91
+
92
+ # Encode a string into hexadecimal in place as described
93
+ # for {String#to_hex}.
94
+ # @example
95
+ # a = 'noraj'
96
+ # a.to_hex!
97
+ # a # => "6e6f72616a"
98
+ def to_hex!(opts = {})
99
+ replace(to_hex(opts))
100
+ end
101
+
102
+ # Decode a hexadecimal string
103
+ # @param opts [Hash] optional parameters
104
+ # @option opts [String] :prefix Prefix of the input. Default value is a void
105
+ # string. Example of values: +0x+, +\x+.
106
+ # @option opts [Symbol] :nibble Display input with high nibble first
107
+ # (+:high+ default) or low nibble first (+:low+).
108
+ # @return [String] the hexadecimal decoded string
109
+ # @example
110
+ # "6e6f72616a".from_hex # => "noraj"
111
+ # "0x6e6f72616a".from_hex(prefix: '0x') # => "noraj"
112
+ # "e6f62716a6".from_hex(nibble: :low) # => "noraj"
113
+ def from_hex(opts = {})
114
+ opts[:prefix] ||= ''
115
+ opts[:nibble] ||= :high
116
+ # remove prefix
117
+ out = sub(opts[:prefix], '')
118
+ # convert
119
+ return Array(out).pack('H*') if opts[:nibble] == :high
120
+ return Array(out).pack('h*') if opts[:nibble] == :low
121
+
122
+ raise ArgumentError ':nibble expects :high or :low'
123
+ end
124
+
125
+ # Decode a hexadecimal string in place as described
126
+ # for {String#from_hex}.
127
+ # @example
128
+ # a = "6e6f72616a"
129
+ # a.from_hex!
130
+ # a # => "noraj"
131
+ def from_hex!(opts = {})
132
+ replace(from_hex(opts))
133
+ end
134
+ end
@@ -35,12 +35,12 @@ class String
35
35
  replace(rot(opts))
36
36
  end
37
37
 
38
- # Alias for {#rot} with default value ( +rot(shift: 13)+ ).
38
+ # Alias for {String#rot} with default value ( +rot(shift: 13)+ ).
39
39
  def rot13
40
40
  rot
41
41
  end
42
42
 
43
- # Alias for {#rot!} with default value ( +rot!(shift: 13)+ ).
43
+ # Alias for {String#rot!} with default value ( +rot!(shift: 13)+ ).
44
44
  def rot13!
45
45
  rot!
46
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Version
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
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.0.0
4
+ version: 1.1.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: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: commonmarker
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,56 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.11'
61
+ version: '5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '5.11'
68
+ version: '5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '12.3'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '12.3'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.4'
89
+ version: '3.5'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.4'
96
+ version: '3.5'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.63'
103
+ version: '0.80'
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: '0.63'
110
+ version: '0.80'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,69 +122,24 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.9'
125
- description: A library to enhance and speed up script/exploit writtingfor CTF players
125
+ description: A library to enhance and speed up script/exploit writingfor CTF players
126
126
  (or security researchers, bug bountyhunters, pentesters but mostly focused on CTF)
127
127
  bypatching the String class to add a short syntax of usual code patterns.
128
128
  email: alexandre.zanni@engineer.com
129
129
  executables:
130
130
  - ctf_party_console
131
- - ctf_party_setup
132
131
  extensions: []
133
132
  extra_rdoc_files: []
134
133
  files:
135
- - ".rubocop.yml"
136
- - ".yardopts"
137
- - ".yardopts-dev"
138
- - Gemfile
139
- - Gemfile.lock
140
134
  - LICENSE.txt
141
- - README.md
142
- - Rakefile
143
135
  - bin/ctf_party_console
144
- - bin/ctf_party_setup
145
- - docs/.nojekyll
146
- - docs/About.md
147
- - docs/CHANGELOG.md
148
- - docs/README.md
149
- - docs/_coverpage.md
150
- - docs/_media/logo.png
151
- - docs/_navbar.md
152
- - docs/_sidebar.md
153
- - docs/index.html
154
- - docs/pages/documentation.md
155
- - docs/pages/install.md
156
- - docs/pages/publishing.md
157
- - docs/pages/quick-start.md
158
- - docs/pages/usage.md
159
- - docs/vendor/docsify.js
160
- - docs/vendor/plugins/emoji.min.js
161
- - docs/vendor/plugins/search.min.js
162
- - docs/vendor/prismjs/components/prism-ruby.min.js
163
- - docs/vendor/themes/vue.css
164
- - docs/yard/String.html
165
- - docs/yard/Version.html
166
- - docs/yard/_index.html
167
- - docs/yard/class_list.html
168
- - docs/yard/css/common.css
169
- - docs/yard/css/full_list.css
170
- - docs/yard/css/style.css
171
- - docs/yard/file.LICENSE.html
172
- - docs/yard/file.README.html
173
- - docs/yard/file_list.html
174
- - docs/yard/frames.html
175
- - docs/yard/index.html
176
- - docs/yard/js/app.js
177
- - docs/yard/js/full_list.js
178
- - docs/yard/js/jquery.js
179
- - docs/yard/method_list.html
180
- - docs/yard/top-level-namespace.html
181
136
  - lib/ctf_party.rb
182
137
  - lib/ctf_party/base64.rb
183
138
  - lib/ctf_party/digest.rb
184
139
  - lib/ctf_party/flag.rb
140
+ - lib/ctf_party/hex.rb
185
141
  - lib/ctf_party/rot.rb
186
142
  - lib/ctf_party/version.rb
187
- - test/test_string.rb
188
143
  homepage: https://orange-cyberdefense.github.io/ctf-party/
189
144
  licenses:
190
145
  - MIT
@@ -210,9 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
165
  - !ruby/object:Gem::Version
211
166
  version: '0'
212
167
  requirements: []
213
- rubygems_version: 3.0.1
168
+ rubygems_version: 3.1.2
214
169
  signing_key:
215
170
  specification_version: 4
216
- summary: A library to enhance and speed up script/exploit writting for CTF players
217
- test_files:
218
- - test/test_string.rb
171
+ summary: A library to enhance and speed up script/exploit writing for CTF players
172
+ test_files: []