访问IP:http://106.75.108.111:1111/
页面应该是需要我提交一些东西;看看网页源代码:
网页源码有提示: 这里应该是需要用3个数字+所给的字符进行加密看看是否与Ciphertext相等,而且必须是10秒内提交!否则需要重新加密。这里需要我们编写脚本,因为需要从请求的数据中获取值,所以转包看看。
抓取的数据中网页提交了cookie,同时服务器返回了Ciphertext,所以编写代码:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib,urllib2,json
import hashlib
import re
import requests
url = 'http://106.75.108.111:1111'
def sha_1(data):
sha_1 = hashlib.sha1()
sha_1.update(data)
sha = sha_1.hexdigest()
return sha
def key(key1,key2):#爆破3个数字
c='0123456789'
str1 = key1
cipher = key2
for i in c:
for j in c:
for k in c:
if sha_1(i+j+k+str1) == cipher:
# print (i+j+k)
return i+j+k
def get_info():
r = requests.post("http://106.75.108.111:1111")#请求IP
key2 = r.headers['Ciphertext']#获取Ciphertext
cookies = r.cookies#获取cookie
html = r.text#获取网页内容
res = r'\+(.*?)\)'#正则表达式
key1 = re.findall(res,html)[0]#匹配正则
print key1#输出明文
return key1,key2,cookies#返回明文 密文 cookies
def postx(number,cookies):
cookies = cookies#传递cookies
values={'pass':number}#构造值
response = requests.post("http://106.75.108.111:1111",cookies=cookies,data=values)#post请求提交
return response.text#返回请求内容
def sum(text):
res = r'<!--.*?([\d\+\-\*]+).*?-->'#构造正则
key3 = re.findall(res,text)[0]#正则匹配
result = eval(key3)#eval将字符串str当成有效的表达式来求值并返回计算结果
return result#返回flag
if __name__ == '__main__':
(key1,key2,cookies)=get_info()#获取标示
number = key(key1,key2)#获取3个数字
result1 = postx(number,cookies)#获取post请求内容
result2 = sum(result1)#获取flag
print result2#输出flag
print postx(result2,cookies)
代码:首先请求url,并获取cookie,明文,Ciphertext;再利用明文和Ciphertext进行爆破;爆破得出的所需要的3个数字,再将数据和cookie一起提交到服务器。服务器返回信息,读取获取flag
执行脚本,获取flag: