这题做了挺长时间的(当然我认为是被坑了)
先上脚本
import base64
import requests
url="http://114.67.246.176:10279/"
s=requests.session()
header=s.get(url).headers
flag=header['flag']
b64dc=base64.b64decode(flag)
flag2=b64dc[-8:]
flag3=base64.b64decode(flag2)
data={'margin':flag3}
r=s.post(url,data)
print(r.text)
- import base64
import requests
加载两个用到的库 - url=“http://114.67.246.176:10279/”
设置url - s=requests.session()
实例化会话 - header=s.get(url).headers
获取他响应头信息(因为flag在响应头里) - flag=header[‘flag’]
获取响应头里的flag信息 - b64dc=base64.b64decode(flag)
对flag进行一次解码
- flag2=b64dc[-8:]
flag3=base64.b64decode(flag2)
截取上图下方的那串base64,并对他进行第二次解码
(我一直以为只要解码一次然后提交,结果他一直让我快点…)
- data={‘margin’:flag3}
将第二次解码后的值放进data字典,键名为margin - r=s.post(url,data)
print(r.text)
将它post出去就能得到flag了
总结:
在写python脚本的过程中,多运用print()调试
参考文章
python字符串拼接
https://blog.csdn.net/laobai1015/article/details/85116250
python字符串截取
https://www.py.cn/faq/python/13754.html