当前位置: 首页 > news >正文

DVWA靶场篇(一)——命令执行、CSRF、文件包含

一、命令执行

low

该级别没有对输入进行任何过滤。

输入:127.0.0.1 && whoami

源码分析

<?php

if( isset( $_POST[ 'Submit' ]  ) ) { //检测是否已经提交
    // Get input
    $target = $_REQUEST[ 'ip' ]; #接受ip参数值,赋值给target

    // Determine OS and execute the ping command. 确定操作系统并执行ping命令。
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) { #判断是否为windows操作系统
        // Windows
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 4 ' . $target );
    }

    // Feedback for the end user
    echo "<pre>{$cmd}</pre>"; ##前端回显结果
}

?> 

isset() 函数用于检测变量是否已设置并且非 NULL。

php_uname() 返回运行 PHP 的系统的有关信息。

  • ‘a’:此为默认。包含序列 “s n r v m” 里的所有模式。

  • ’s’:操作系统名称。例如: FreeBSD。

  • ‘n’:主机名。例如: localhost.example.com。

  • ‘r’:版本名称,例如: 5.1.2-RELEASE。

  • ‘v’:版本信息。操作系统之间有很大的不同。

  • ‘m’:机器类型。例如:i386。

stristr("Hello world!","WORLD") 查找 "world" 在 "Hello world!" 中的第一次出现,并返回字符串的剩余部分

medium

源码分析

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    // Get input
    $target = $_REQUEST[ 'ip' ];

    // Set blacklist
    $substitutions = array( #创建一个关联数组,每个键对应一个值
        '&&' => '',
        ';'  => '',
    );

    // Remove any of the charactars in the array (blacklist). 删除数组中的任何字符(黑名单)
    $target = str_replace( array_keys( $substitutions ), $substitutions, $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 4 ' . $target );
    }

    // Feedback for the end user
    echo "<pre>{$cmd}</pre>";
}

?>

array() 函数用于创建数组

创建关联数组:

array_keys() 返回包含数组中所有键名的一个新数组

str_replace() 把字符串 "Hello world!" 中的字符 "world" 替换成 "Peter"

<?phpecho str_replace("world","Peter","Hello world!");?>

此关对&& ; 替换为空。所以输入 127.0.0.1 & whoami进行绕过

high

源码分析

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    // Get input
    $target = trim($_REQUEST[ 'ip' ]);

    // Set blacklist
    $substitutions = array(
        '&'  => '',
        ';'  => '',
        '| ' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    

相关文章:

  • Unity打包出来的APK应用如何判断是否运行在虚拟机上面或者是真实的安卓手机上面
  • 《计算机视觉》——角点检测和特征提取sift
  • 【NPM 版本号控制完全指南:掌握依赖管理的核心艺术】
  • DeepSeek4j 已开源,支持思维链,自定义参数,Spring Boot Starter 轻松集成,快速入门!建议收藏
  • uniapp中对于文件和文件夹的处理,内存的查询
  • Windows11+PyCharm利用MMSegmentation训练自己的数据集保姆级教程
  • Springboot 中如何使用Sentinel
  • fastadmin 接口请求提示跨域
  • Windows系统安装搭建悟空crm客户管理系统 教程
  • SpringBoot+Dubbo+zookeeper 急速入门案例
  • Python爬虫实战:获取笔趣阁图书信息,并做数据分析
  • grep如何排除多个目录?
  • 网易易盾接入DeepSeek,数字内容安全“智”理能力全面升级
  • 2-使用wifidog实现portal
  • Java进阶篇之NIO基础
  • MyBatis常见知识点
  • 荣耀手机Magic3系列、Magic4系列、Magic5系列、Magic6系列、Magic7系列详情对比以及最新二手价格预测
  • vue elementui select下拉库组件鼠标移出时隐藏下拉框
  • C++ 常用的设计模式
  • 实时云渲染:驱动XR技术产业化腾飞的核心引擎
  • 建设工程职称 在哪个网站/美国新冠疫情最新消息
  • 句容做网站/深圳网站设计实力乐云seo
  • 吴志祥最早做的网站是什么网站/全网搜索指数查询
  • 被k掉的网站怎么做才能有收录/如何制作公司网页
  • 枞阳县建设局网站/百度推广在哪里
  • 日本门户网站有哪些/百度联盟广告