GXYCTF2019/BUUCTF-WEB:StrongestMind
python数学运算提交脚本题。
这里用了requests库爬取网页,re库提取所需要的地方然后循环1000次提交。
难点在于这道题需要延续上一次提交的内容。
中间还是挺曲折的,因为容器突然断掉访问不上等原因。。
最终自己写脚本如下,1005也就是防止意外发生,如果网络情况较好可能不用考虑我这点:
import requests import re import time url = "http://e770f71c-4daf-4ec7-a204-140f283bfe26.node3.buuoj.cn/" s = requests.session() source = s.get(url) view = source.text equation = eval("".join(re.findall("\<br\>\<br\>(.*?)\<br\>\<br\>\<form",view))) data = {'answer':equation} flag = s.post("http://e770f71c-4daf-4ec7-a204-140f283bfe26.node3.buuoj.cn/", data = data) for i in range(1005): try: equation = eval("".join(re.findall("\<br\>\<br\>(\d.*?)\<br\>\<br\>\<form",flag.text))) #print(equation) flag = s.post("http://e770f71c-4daf-4ec7-a204-140f283bfe26.node3.buuoj.cn/", data = {'answer':equation}) print(flag.text) time.sleep(0.5) except: pass
官方exp:
from requests import * import re s = session() a = s.get("http://172.21.4.12:10044/index.php") pattern = re.findall(r'\d+.[+-].\d+', a.text) c = eval(pattern[0]) a = s.post("http://172.21.4.12:10044/index.php", data = {"answer" : c}) for i in range(1000): pattern = re.findall(r'\d+.[+-].\d+', a.text) c = eval(pattern[0]) print(c) a = s.post("http://172.21.4.12:10044/index.php", data = {"answer" : c}) print(a.text)