import requests from pyquery import PyQuery as PQ user = requests.session() res = user.get('https://ctf.x10sec.org/web2/') # 创建 DOM 树 dom=PQ(res.text) # 查询节点 print(dom('div[name=my_expr]').text().strip())
import requests import re from pyquery import PyQuery as PQ user = requests.session() res = user.get('https://ctf.x10sec.org/web2/') dom=PQ(res.text) get = dom('div[name=my_expr]').text().strip() # 正则提取表达式 去除括号 exp=re.search('^(.+)=.+$', get).group(1) ans = eval(exp) print(ans)
from pyquery import PyQuery as PQ import re import requests
user = requests.session(); res = user.get('https://ctf.x10sec.org/web2/') dom = PQ(res.text) get = dom('div[name=my_expr]').text().strip() exp=re.search('^(.+)=.+$', get).group(1) ans = eval(exp) # POST 提交答案 res = user.post('https://ctf.x10sec.org/web2?action=check_pass',{ 'pass_key' : ans, }); # 判断返回页面 if re.search('Wrong Answer',res.text): print ("Wrong Answer") else: print ("I Get Flag: %s" % PQ(res.text)('div[name=my_expr]').text().strip())