mirror of
https://github.com/luzhisheng/js_reverse.git
synced 2025-04-20 21:55:07 +08:00
6骚操作session保持检测
This commit is contained in:
parent
c2d8fa7819
commit
118dfdd714
36
猿人学练习/6骚操作session保持检测/main.py
Normal file
36
猿人学练习/6骚操作session保持检测/main.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import re
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def challenge6(page, sign, sessionid):
|
||||||
|
url = "https://www.python-spider.com/api/challenge6"
|
||||||
|
payload = f"page={page}"
|
||||||
|
headers = {
|
||||||
|
'cookie': f'sessionid={sessionid}; sign={sign}',
|
||||||
|
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
|
}
|
||||||
|
response = requests.request("POST", url, headers=headers, data=payload)
|
||||||
|
set_cookie = response.headers.get('Set-Cookie')
|
||||||
|
sign = re.findall(r'sign=(.*?); Path', set_cookie)[0]
|
||||||
|
sessionid = re.findall(r'sessionid=(.*?); expires', set_cookie)[0]
|
||||||
|
return response.text, sign, sessionid
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
data_num = 0
|
||||||
|
sign = ''
|
||||||
|
sessionid = ''
|
||||||
|
for page in range(1, 101):
|
||||||
|
response_text, sign, sessionid = challenge6(page, sign, sessionid)
|
||||||
|
res_dict = json.loads(response_text)
|
||||||
|
data_list = res_dict.get('data')
|
||||||
|
print(data_list)
|
||||||
|
for data in data_list:
|
||||||
|
data_num += int(data.get('value'))
|
||||||
|
print(data_num)
|
||||||
|
print(data_num)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run()
|
14
猿人学练习/6骚操作session保持检测/readme.md
Normal file
14
猿人学练习/6骚操作session保持检测/readme.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 知识点:`session`存在`set-cookie`中
|
||||||
|
|
||||||
|
## 解题思路
|
||||||
|
|
||||||
|
既然题目已经告诉你了是`session`问题,直接看请求内容
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
发现response中存在`set-cookie`内容
|
||||||
|
|
||||||
|
set-cookie: sign=ueozvfnqbj; Path=/
|
||||||
|
set-cookie: sessionid=zp9745ys9dywe1zfs1do604nt70athll; expires=Wed, 01 Feb 2023 14:27:00 GMT; HttpOnly; Max-Age=2160
|
||||||
|
|
||||||
|
将`sign`和`sessionid`添加到下一个请求中,这题就解决了
|
Loading…
x
Reference in New Issue
Block a user