jwtear 1.0.1.pre → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +42 -0
- data/.gitignore +2 -0
- data/Gemfile.lock +24 -22
- data/README.md +21 -4
- data/bin/jwtear +26 -9
- data/jwtear.gemspec +2 -1
- data/lib/jwtear/helpers/utils.rb +8 -6
- data/lib/jwtear/jwe.rb +11 -5
- data/lib/jwtear/jws.rb +21 -1
- data/lib/jwtear/token.rb +2 -3
- data/lib/jwtear/version.rb +1 -1
- data/plugins/bruteforce.rb +6 -15
- data/plugins/generate.rb +1 -1
- data/plugins/wiki.rb +1 -1
- data/plugins/wiki/README.md +16 -12
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 214465c3eb8ab23270f4caa51276a8af5814821515d77a29e7b17b57106a27d1
|
4
|
+
data.tar.gz: b9ecca972fcaa68d4729b1952b66f30aa9c6745070eb4a7261007162ed843277
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4af5ebfe24cef925c15c87672b1572d37858a079d0b1d4044966999637597ff699c7a1be1a50a228329619c64c9ba003c76c9dcfc8b6262647493485c23164a
|
7
|
+
data.tar.gz: 97544a55bc3b65a2342f083dab6a877ae4db6285d4a6187a8116ac10ce5d9f24b72ed488912a0c945c5eae04c0a3384d5f0e5f939ba482d95d00eac6dd76e5aa
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby 2.6
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6.x
|
20
|
+
|
21
|
+
- name: Publish to GPR
|
22
|
+
run: |
|
23
|
+
mkdir -p $HOME/.gem
|
24
|
+
touch $HOME/.gem/credentials
|
25
|
+
chmod 0600 $HOME/.gem/credentials
|
26
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
27
|
+
gem build *.gemspec
|
28
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
29
|
+
env:
|
30
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
31
|
+
OWNER: ${{ github.repository_owner }}
|
32
|
+
|
33
|
+
- name: Publish to RubyGems
|
34
|
+
run: |
|
35
|
+
mkdir -p $HOME/.gem
|
36
|
+
touch $HOME/.gem/credentials
|
37
|
+
chmod 0600 $HOME/.gem/credentials
|
38
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
39
|
+
gem build *.gemspec
|
40
|
+
gem push *.gem
|
41
|
+
env:
|
42
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jwtear (1.0.
|
4
|
+
jwtear (1.0.6)
|
5
|
+
colorize (~> 0.8.1)
|
5
6
|
gli (~> 2.19, >= 2.19.0)
|
6
|
-
json-jwt (~> 1.
|
7
|
+
json-jwt (~> 1.11, >= 1.11.0)
|
7
8
|
jwe (~> 0.4.0)
|
8
9
|
tty-markdown (~> 0.6.0)
|
9
10
|
tty-pager (~> 0.12.1)
|
@@ -11,37 +12,38 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
activesupport (6.0.
|
15
|
+
activesupport (6.0.3.4)
|
15
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
17
|
i18n (>= 0.7, < 2)
|
17
18
|
minitest (~> 5.1)
|
18
19
|
tzinfo (~> 1.1)
|
19
|
-
zeitwerk (~> 2.
|
20
|
-
aes_key_wrap (1.0
|
21
|
-
bindata (2.4.
|
22
|
-
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
aes_key_wrap (1.1.0)
|
22
|
+
bindata (2.4.8)
|
23
|
+
colorize (0.8.1)
|
24
|
+
concurrent-ruby (1.1.7)
|
23
25
|
equatable (0.6.1)
|
24
|
-
gli (2.19.
|
25
|
-
i18n (1.
|
26
|
+
gli (2.19.2)
|
27
|
+
i18n (1.8.5)
|
26
28
|
concurrent-ruby (~> 1.0)
|
27
|
-
json-jwt (1.
|
29
|
+
json-jwt (1.13.0)
|
28
30
|
activesupport (>= 4.2)
|
29
31
|
aes_key_wrap
|
30
32
|
bindata
|
31
33
|
jwe (0.4.0)
|
32
34
|
kramdown (1.16.2)
|
33
|
-
minitest (5.
|
34
|
-
pastel (0.7.
|
35
|
+
minitest (5.14.2)
|
36
|
+
pastel (0.7.4)
|
35
37
|
equatable (~> 0.6)
|
36
38
|
tty-color (~> 0.5)
|
37
|
-
rouge (3.
|
38
|
-
strings (0.1.
|
39
|
+
rouge (3.25.0)
|
40
|
+
strings (0.1.8)
|
39
41
|
strings-ansi (~> 0.1)
|
40
42
|
unicode-display_width (~> 1.5)
|
41
43
|
unicode_utils (~> 1.4)
|
42
|
-
strings-ansi (0.
|
44
|
+
strings-ansi (0.2.0)
|
43
45
|
thread_safe (0.3.6)
|
44
|
-
tty-color (0.
|
46
|
+
tty-color (0.6.0)
|
45
47
|
tty-markdown (0.6.0)
|
46
48
|
kramdown (~> 1.16.2)
|
47
49
|
pastel (~> 0.7.2)
|
@@ -53,13 +55,13 @@ GEM
|
|
53
55
|
strings (~> 0.1.4)
|
54
56
|
tty-screen (~> 0.6)
|
55
57
|
tty-which (~> 0.4)
|
56
|
-
tty-screen (0.
|
57
|
-
tty-which (0.4.
|
58
|
-
tzinfo (1.2.
|
58
|
+
tty-screen (0.8.1)
|
59
|
+
tty-which (0.4.2)
|
60
|
+
tzinfo (1.2.8)
|
59
61
|
thread_safe (~> 0.1)
|
60
|
-
unicode-display_width (1.
|
62
|
+
unicode-display_width (1.7.0)
|
61
63
|
unicode_utils (1.4.0)
|
62
|
-
zeitwerk (2.1
|
64
|
+
zeitwerk (2.4.1)
|
63
65
|
|
64
66
|
PLATFORMS
|
65
67
|
ruby
|
@@ -68,4 +70,4 @@ DEPENDENCIES
|
|
68
70
|
jwtear!
|
69
71
|
|
70
72
|
BUNDLED WITH
|
71
|
-
2.
|
73
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
# Jwtear
|
2
|
-
A modular
|
2
|
+
A modular command-line tool to parse, create and manipulate JSON Web Token(JWT) tokens for security testing purposes.
|
3
3
|
|
4
4
|
## Features
|
5
5
|
- Complete modularity.
|
6
6
|
- All commands are plugins.
|
7
|
-
- Easy to add
|
7
|
+
- Easy to add new plugins.
|
8
8
|
- Support JWS and JWE tokens.
|
9
9
|
- Easy interface for plugins. (follow the template example)
|
10
|
+
- Flexible
|
11
|
+
- token generation based on production-class libraries (e.g. json-jwt, jwe).
|
12
|
+
|
10
13
|
|
11
14
|
### Available plugins
|
12
15
|
- Parse: parses jwt tokens.
|
13
16
|
- jws: manipulate and generate JWS tokens.
|
14
17
|
- jwe: manipulate and generate JWE tokens.
|
15
18
|
- bruteforce: brutefocing JWS signing key
|
16
|
-
- wiki: contains information about JWT, attacks ideas, references.
|
19
|
+
- wiki: contains offline information about JWT, attacks ideas, references.
|
17
20
|
|
18
21
|
## Installation
|
19
22
|
|
@@ -81,7 +84,8 @@ plugins are defined as subcommands. Each subcommand may have one or more argumen
|
|
81
84
|
```
|
82
85
|
$ jwtear parse -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.J8SS8VKlI2yV47C4BtfYukWPx_2welF34Mz7l-MNmkE
|
83
86
|
$ jwtear jws -h '{"alg":"HS256","typ":"JWT"}' -p '{"user":"admin"}' -k p@ss0rd123
|
84
|
-
$ jwtear
|
87
|
+
$ jwtear jwe -header '{"enc":"A192GCM","typ":"JWT"}' --payload '{"user":"admin"}' --key public.pem
|
88
|
+
$ jwtear bruteforce -v -t eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjpudWxsfQ.Tr0VvdP6rVBGBGuI_luxGCOaz6BbhC6IxRTlKOW8UjM -l ~/tmp/pass.list
|
85
89
|
```
|
86
90
|
|
87
91
|
## Add plugin
|
@@ -134,6 +138,19 @@ Once the missing dependencies are installed by the user, the `check_dependencies
|
|
134
138
|
|
135
139
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jwtear.
|
136
140
|
|
141
|
+
1. Fork it ( https://github.com/KINGSABRI/jwtear/fork )
|
142
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
143
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
144
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
145
|
+
5. Create a new Pull Request
|
146
|
+
|
147
|
+
### Areas to contribute
|
148
|
+
- contribution by reporting bugs.
|
149
|
+
- contribution by perfecting the current code.
|
150
|
+
- contribution by adding new plugins.
|
151
|
+
- contribution by enhancing the [jwtear wiki](https://github.com/KINGSABRI/jwtear/tree/master/plugins/wiki).
|
152
|
+
- contribution by requesting features and/or plugins.
|
153
|
+
|
137
154
|
## License
|
138
155
|
|
139
156
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/bin/jwtear
CHANGED
@@ -17,17 +17,17 @@ module JWTear
|
|
17
17
|
module CLI
|
18
18
|
extend GLI::App
|
19
19
|
extend JWTear::Helpers::Utils
|
20
|
-
|
20
|
+
|
21
21
|
program_desc 'Parse, create and manipulate JWT tokens.'
|
22
22
|
|
23
23
|
# CLI settings
|
24
|
-
ENV['GLI_DEBUG'] =
|
25
|
-
autocomplete_commands
|
24
|
+
# ENV['GLI_DEBUG'] = "true" # Uncomment this line for debugging
|
25
|
+
autocomplete_commands true
|
26
26
|
subcommand_option_handling :normal
|
27
|
-
arguments
|
28
|
-
sort_help
|
29
|
-
wrap_help_text
|
30
|
-
synopsis_format
|
27
|
+
arguments :strict
|
28
|
+
sort_help :manually
|
29
|
+
wrap_help_text :verbatim
|
30
|
+
synopsis_format :full
|
31
31
|
|
32
32
|
desc 'Check current and latest version'
|
33
33
|
switch [:v, :version], negatable: false
|
@@ -39,17 +39,34 @@ module JWTear
|
|
39
39
|
dir = File.expand_path(File.join(File.dirname(__FILE__), ['..', 'plugins']))
|
40
40
|
commands_from dir if Dir.exist? dir
|
41
41
|
|
42
|
+
trap("INT") do
|
43
|
+
puts
|
44
|
+
print_error "User interruption!"
|
45
|
+
print_warning "Exiting jwtear process."
|
46
|
+
exit!
|
47
|
+
end
|
48
|
+
|
49
|
+
puts banner if ARGV.empty?
|
42
50
|
on_error do |exception|
|
51
|
+
puts banner
|
43
52
|
case exception
|
53
|
+
when GLI::UnknownGlobalArgument
|
54
|
+
print_error "#{exception.message}"
|
44
55
|
when GLI::MissingRequiredArgumentsException
|
45
56
|
print_error "Option #{exception.message}"
|
46
|
-
|
57
|
+
when OptionParser::MissingArgument
|
58
|
+
print_error "Option #{exception.message}"
|
59
|
+
when GLI::UnknownCommandArgument
|
60
|
+
print_error "#{exception.message}"
|
61
|
+
when GLI::UnknownCommand
|
62
|
+
print_error "#{exception.message}"
|
47
63
|
else
|
48
64
|
print_error "Unknown Exception:"
|
49
65
|
print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline
|
50
66
|
puts exception.full_message
|
51
|
-
exit!
|
52
67
|
end
|
68
|
+
|
69
|
+
true
|
53
70
|
end
|
54
71
|
end
|
55
72
|
end
|
data/jwtear.gemspec
CHANGED
@@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'gli', '~> 2.19', '>= 2.19.0'
|
22
|
-
spec.add_dependency 'json-jwt', '~> 1.
|
22
|
+
spec.add_dependency 'json-jwt', '~> 1.11', '>= 1.11.0'
|
23
23
|
spec.add_dependency 'jwe', "~> 0.4.0"
|
24
24
|
spec.add_dependency 'tty-markdown', "~> 0.6.0"
|
25
25
|
spec.add_dependency 'tty-pager', "~> 0.12.1"
|
26
|
+
spec.add_dependency 'colorize', "~> 0.8.1"
|
26
27
|
|
27
28
|
# spec.add_development_dependency('rake', '~> 0.9.2.2')
|
28
29
|
end
|
data/lib/jwtear/helpers/utils.rb
CHANGED
@@ -19,26 +19,28 @@ module JWTear
|
|
19
19
|
|
20
20
|
# read key as a string or from file(eg. pub_key.pem)
|
21
21
|
def read_key(key)
|
22
|
-
if key
|
23
|
-
File.
|
22
|
+
if File.file?(File.absolute_path(key))
|
23
|
+
File.read(File.absolute_path(key))
|
24
|
+
else
|
25
|
+
key
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
# check_dependencies
|
28
30
|
# check dependencies for plugins and throw a gentle error if not installed
|
29
31
|
# @param deps [Hash]
|
30
|
-
# The key is the
|
32
|
+
# The key is the key is the gem name to be installed, the value is library to be require
|
31
33
|
# @example
|
32
34
|
# deps = {'async-io' => 'async/ip'}
|
33
35
|
# check_dependencies(deps)
|
34
36
|
#
|
35
37
|
def check_dependencies(deps={})
|
36
|
-
return if deps.empty?
|
38
|
+
return if deps.empty? or deps.nil?
|
37
39
|
missing = []
|
38
40
|
|
39
|
-
deps.each do |gem,
|
41
|
+
deps.each do |gem, lib|
|
40
42
|
begin
|
41
|
-
require
|
43
|
+
require lib
|
42
44
|
rescue LoadError
|
43
45
|
missing << gem
|
44
46
|
end
|
data/lib/jwtear/jwe.rb
CHANGED
@@ -58,10 +58,10 @@ module JWTear
|
|
58
58
|
cipher_text = Base64.urlsafe_encode64(@cipher_text, padding: false)
|
59
59
|
authentication_tag = Base64.urlsafe_encode64(@authentication_tag, padding: false)
|
60
60
|
|
61
|
-
"#{header.to_json}" + "
|
62
|
-
"#{encrypted_key}" + "
|
63
|
-
"#{iv}" + "
|
64
|
-
"#{cipher_text}" + "
|
61
|
+
"#{header.to_json}" + ".".bold +
|
62
|
+
"#{encrypted_key}" + ".".bold +
|
63
|
+
"#{iv}" + ".".bold +
|
64
|
+
"#{cipher_text}" + ".".bold +
|
65
65
|
"#{authentication_tag}"
|
66
66
|
end
|
67
67
|
|
@@ -78,7 +78,7 @@ module JWTear
|
|
78
78
|
key = OpenSSL::PKey::RSA.new(key)
|
79
79
|
jwt = JSON::JWT.new(JSON.parse(payload, symbolize_names: true))
|
80
80
|
jwt.header = JSON.parse(header, symbolize_names: true)
|
81
|
-
::JWE.encrypt(payload, key, enc: jwt.header[:enc]) # I had to use this gem as
|
81
|
+
::JWE.encrypt(payload, key, enc: jwt.header[:enc]) # I had to use this gem as jwe does not support A192GCM AFAIK
|
82
82
|
rescue TypeError => e
|
83
83
|
print_bad "Invalid data type."
|
84
84
|
print_warning "Make sure your public/private key file exists."
|
@@ -92,6 +92,12 @@ module JWTear
|
|
92
92
|
exit!
|
93
93
|
end
|
94
94
|
|
95
|
+
# is_encrypted?
|
96
|
+
# to check if the given string in a JSON format or its encrypted.
|
97
|
+
# Used mostly with @encrypted_key as it might come in different format.
|
98
|
+
# @param item [JSON|STRING]
|
99
|
+
#
|
100
|
+
# @return [Boolean]
|
95
101
|
def is_encrypted?(item)
|
96
102
|
JSON.parse item
|
97
103
|
false
|
data/lib/jwtear/jws.rb
CHANGED
@@ -39,7 +39,7 @@ module JWTear
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def to_json_presentation
|
42
|
-
"#{@header.to_json}" + "
|
42
|
+
"#{@header.to_json}" + ".".bold + "#{@payload.to_json}" + ".".bold + "#{Base64.urlsafe_encode64(@signature, padding: false)}"
|
43
43
|
end
|
44
44
|
|
45
45
|
# generate_jws
|
@@ -59,6 +59,8 @@ module JWTear
|
|
59
59
|
puts "Unexpected algorithm '#{jwt.header[:alg]}'."
|
60
60
|
puts e.message
|
61
61
|
exit!
|
62
|
+
rescue Exception => e
|
63
|
+
print_error e.message
|
62
64
|
end
|
63
65
|
|
64
66
|
private
|
@@ -73,6 +75,24 @@ module JWTear
|
|
73
75
|
jwt.to_s
|
74
76
|
else
|
75
77
|
raise JSON::JWS::UnexpectedAlgorithm.new("Encryption algorithm '#{jwt.alg}' requires key.") if key.nil?
|
78
|
+
alg = jwt.alg.upcase
|
79
|
+
case
|
80
|
+
when alg.start_with?("HS")
|
81
|
+
key
|
82
|
+
when alg.start_with?("RS")
|
83
|
+
key = OpenSSL::PKey::RSA.new(key)
|
84
|
+
when alg.start_with?("PS")
|
85
|
+
key = OpenSSL::PKey::RSA.new(key)
|
86
|
+
when alg.start_with?("ES")
|
87
|
+
# key = OpenSSL::PKey::RSA.new(key)
|
88
|
+
print_error("Signing for ECDSA-SHA is not yet implemented")
|
89
|
+
print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline
|
90
|
+
else
|
91
|
+
print_warning("Undefined algorithm. This might generate a wrong token")
|
92
|
+
print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline
|
93
|
+
key
|
94
|
+
end
|
95
|
+
jwt.alg = alg.to_sym
|
76
96
|
jwt.sign(key).to_s
|
77
97
|
end
|
78
98
|
end
|
data/lib/jwtear/token.rb
CHANGED
@@ -23,10 +23,9 @@ module JWTear
|
|
23
23
|
@jwe.parse(token)
|
24
24
|
end
|
25
25
|
rescue Exception => e
|
26
|
-
print_error "
|
26
|
+
print_error "#{method(__method__).owner}##{__method__} : Unknown Exception"
|
27
27
|
print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline
|
28
|
-
puts e
|
29
|
-
puts e.backtrace
|
28
|
+
puts e.full_message
|
30
29
|
exit!
|
31
30
|
end
|
32
31
|
|
data/lib/jwtear/version.rb
CHANGED
data/plugins/bruteforce.rb
CHANGED
@@ -16,7 +16,7 @@ module JWTear
|
|
16
16
|
c.desc "Run verbosely."
|
17
17
|
c.switch [:v, :verbose], negatable: false
|
18
18
|
|
19
|
-
c.example %Q{jwtear bruteforce -t TOKEN -l rockyou.list
|
19
|
+
c.example %Q{jwtear bruteforce -v -t TOKEN -l rockyou.list}
|
20
20
|
c.example %Q{jwtear bruteforce -t TOKEN -l P@ssw0rd123}
|
21
21
|
|
22
22
|
c.action do |_, options, _|
|
@@ -25,7 +25,6 @@ module JWTear
|
|
25
25
|
bf.run(options[:verbose])
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -34,7 +33,7 @@ module JWTear
|
|
34
33
|
include JWTear::Helpers::Utils
|
35
34
|
|
36
35
|
def initialize(token, list)
|
37
|
-
deps = {
|
36
|
+
deps = {}
|
38
37
|
check_dependencies(deps)
|
39
38
|
@token = Token.new
|
40
39
|
@jws = @token.parse(token)
|
@@ -46,9 +45,10 @@ module JWTear
|
|
46
45
|
case
|
47
46
|
when keys.kind_of?(Enumerator::Lazy)
|
48
47
|
keys.each do |key|
|
48
|
+
key.valid_encoding? ? key.strip! : next
|
49
49
|
print_status "Trying password: #{key}" if verbose
|
50
50
|
|
51
|
-
gen_token = @token.generate(:jws, header: @jws.header.to_json, payload
|
51
|
+
gen_token = @token.generate(:jws, header: @jws.header.to_json, payload: @jws.payload.to_json , key: key)
|
52
52
|
sig = gen_token.split('.').last
|
53
53
|
if sig == Base64.urlsafe_encode64(@jws.signature, padding: false)
|
54
54
|
print_good "Password found: #{key}"
|
@@ -56,11 +56,10 @@ module JWTear
|
|
56
56
|
exit!
|
57
57
|
else
|
58
58
|
print_bad "Invalid key: #{key}" if verbose
|
59
|
-
# puts gen_token if verbose
|
60
59
|
end
|
61
60
|
end
|
62
61
|
when keys.kind_of?(String)
|
63
|
-
gen_token = @token.generate(:jws, header: @jws.header.to_json, payload
|
62
|
+
gen_token = @token.generate(:jws, header: @jws.header.to_json, payload: @jws.payload.to_json , key: keys)
|
64
63
|
sig = gen_token.split('.').last
|
65
64
|
if sig == Base64.urlsafe_encode64(@jws.signature, padding: false)
|
66
65
|
print_good "Password found: #{keys}"
|
@@ -68,20 +67,14 @@ module JWTear
|
|
68
67
|
else
|
69
68
|
print_bad "Invalid key: #{keys}"
|
70
69
|
end
|
71
|
-
|
72
70
|
else
|
73
71
|
print_error "Unknown key type"
|
74
72
|
raise
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
78
|
-
|
79
76
|
def handle_key
|
80
|
-
|
81
|
-
read_wordlist(@list)
|
82
|
-
else
|
83
|
-
@list
|
84
|
-
end
|
77
|
+
File.file?(@list) ? read_wordlist(@list) : @list
|
85
78
|
end
|
86
79
|
|
87
80
|
def read_wordlist(file)
|
@@ -89,7 +82,6 @@ module JWTear
|
|
89
82
|
print_status "Found '#{file}' file."
|
90
83
|
File.readlines(file, chomp: true)
|
91
84
|
.lazy
|
92
|
-
.map(&:strip)
|
93
85
|
.reject(&:empty?)
|
94
86
|
.reject(&:nil?)
|
95
87
|
else
|
@@ -97,7 +89,6 @@ module JWTear
|
|
97
89
|
exit!
|
98
90
|
end
|
99
91
|
end
|
100
|
-
|
101
92
|
end
|
102
93
|
end
|
103
94
|
|
data/plugins/generate.rb
CHANGED
@@ -20,7 +20,7 @@ module JWTear
|
|
20
20
|
jws_cmd.desc "Key as a password string or a file public key. eg. P@ssw0rd | eg. public_key.pem"
|
21
21
|
jws_cmd.arg_name 'PASSWORD|PUB_KEY_FILE'
|
22
22
|
jws_cmd.flag [:k, :key]
|
23
|
-
jws_cmd.action do |
|
23
|
+
jws_cmd.action do |_, options, _|
|
24
24
|
gen = Generate.new
|
25
25
|
puts gen.jws_token(options[:header], options[:payload], read_key(options[:key]))
|
26
26
|
end
|
data/plugins/wiki.rb
CHANGED
@@ -5,7 +5,7 @@ module JWTear
|
|
5
5
|
extend JWTear::Helpers::Utils
|
6
6
|
|
7
7
|
desc "A JWT wiki for hackers."
|
8
|
-
long_desc "
|
8
|
+
long_desc "A JWT wiki contains introduction, attack ideas, vulnerable application links and resources."
|
9
9
|
command [:wiki, :w] do |c|
|
10
10
|
|
11
11
|
c.desc "Show the wiki page on terminal"
|
data/plugins/wiki/README.md
CHANGED
@@ -164,6 +164,8 @@ This carries the same meaning as explained under JWE compact serialization, prev
|
|
164
164
|
|
165
165
|
This carries the same meaning as explained under JWE compact serialization, previously. The tag element in the JWE token carries the base64url-encoded value of the JWE authenticated tag, which is an outcome of the encryption process using an AEAD algorithm.
|
166
166
|
|
167
|
+
_source(JWT, JWS and JWE for Not So Dummies! (Part I))_
|
168
|
+
|
167
169
|
---
|
168
170
|
|
169
171
|
|
@@ -185,18 +187,19 @@ This carries the same meaning as explained under JWE compact serialization, prev
|
|
185
187
|
## Vulnerable Applications
|
186
188
|
|
187
189
|
* [Damn Vulnerable Web Services - DVWS](https://github.com/snoopysecurity/dvws)
|
188
|
-
* [Pentesterlab(Free)
|
189
|
-
* [Pentesterlab(PRO)
|
190
|
-
* [Pentesterlab(PRO)
|
191
|
-
* [Pentesterlab(PRO)
|
192
|
-
* [Pentesterlab(PRO)
|
193
|
-
* [Pentesterlab(PRO)
|
194
|
-
* [Pentesterlab(PRO)
|
195
|
-
* [Pentesterlab(PRO)
|
196
|
-
* [Pentesterlab(PRO)
|
197
|
-
* [Pentesterlab(PRO)
|
198
|
-
* [Pentesterlab(PRO)
|
199
|
-
* [Pentesterlab(PRO)
|
190
|
+
* [Pentesterlab(Free) - JSON Web Token I](https://pentesterlab.com/exercises/jwt/)
|
191
|
+
* [Pentesterlab(PRO) - JSON Web Token II](https://pentesterlab.com/exercises/jwt_ii/)
|
192
|
+
* [Pentesterlab(PRO) - JWT III](https://pentesterlab.com/exercises/jwt_iii/)
|
193
|
+
* [Pentesterlab(PRO) - JWT IV](https://pentesterlab.com/exercises/jwt_iv)
|
194
|
+
* [Pentesterlab(PRO) - JWT V](https://pentesterlab.com/exercises/jwt_v)
|
195
|
+
* [Pentesterlab(PRO) - JWT VI](https://pentesterlab.com/exercises/jwt_vi)
|
196
|
+
* [Pentesterlab(PRO) - JWT VII](https://pentesterlab.com/exercises/jwt_vii)
|
197
|
+
* [Pentesterlab(PRO) - JWT VIII](https://pentesterlab.com/exercises/jwt_viii)
|
198
|
+
* [Pentesterlab(PRO) - JWT X](https://pentesterlab.com/exercises/jwt_x/)
|
199
|
+
* [Pentesterlab(PRO) - JWT XI](https://pentesterlab.com/exercises/jwt_xi)
|
200
|
+
* [Pentesterlab(PRO) - JWT XII](https://pentesterlab.com/exercises/jwt_xii)
|
201
|
+
* [Pentesterlab(PRO) - JWT XIII](https://pentesterlab.com/exercises/jwt_iii)
|
202
|
+
* [Pentesterlab(PRO) - JSON Web Encryption](https://pentesterlab.com/exercises/jwe)
|
200
203
|
* [Vulnerable JWT implementations](https://github.com/Sjord/jwtdemo)
|
201
204
|
|
202
205
|
## Resources
|
@@ -210,3 +213,4 @@ This carries the same meaning as explained under JWE compact serialization, prev
|
|
210
213
|
* [Damn Vulnerable Service](https://github.com/snoopysecurity/dvws)
|
211
214
|
* [CSRF JWT redirect leak](https://gist.github.com/stefanocoding/8cdc8acf5253725992432dedb1c9c781)
|
212
215
|
* [Critical vulnerabilities in JSON Web Token libraries](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/)
|
216
|
+
* [JWT Attack Playbook](https://github.com/ticarpi/jwt_tool/wiki)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwtear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KING SABRI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -36,20 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1.
|
39
|
+
version: '1.11'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 1.11.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
49
|
+
version: '1.11'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.
|
52
|
+
version: 1.11.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: jwe
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 0.12.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: colorize
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.8.1
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 0.8.1
|
95
109
|
description: JWTear, a modular command-line tool to parse, create and manipulate JWT
|
96
110
|
tokens for security testing purposes.
|
97
111
|
email:
|
@@ -101,6 +115,7 @@ executables:
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- ".github/workflows/gem-push.yml"
|
104
119
|
- ".gitignore"
|
105
120
|
- CODE_OF_CONDUCT.md
|
106
121
|
- Gemfile
|
@@ -138,12 +153,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
153
|
version: '0'
|
139
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
155
|
requirements:
|
141
|
-
- - "
|
156
|
+
- - ">="
|
142
157
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
158
|
+
version: '0'
|
144
159
|
requirements: []
|
145
|
-
|
146
|
-
rubygems_version: 2.7.6.2
|
160
|
+
rubygems_version: 3.1.4
|
147
161
|
signing_key:
|
148
162
|
specification_version: 4
|
149
163
|
summary: JWTear, a modular command-line tool to parse, create and manipulate JWT tokens
|