DVWA : Command Injection

难度:Low代码解析<?phpif( isset( $_POST[ 'Submit' ] ) ) { // Get input $target = $_REQUEST[ 'ip' ]; // Determine OS and execute the ping command. if( stristr( php_uname( 's' ), 'Windows NT' ) ) { // Windows $cmd = shell
摘要由CSDN通过智能技术生成

难度:Low

代码解析

<?php

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

    // 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>";
}

?> 

1.stristr() PHP stristr() 函数

stristr() 函数搜索字符串在另一字符串中的第一次出现。

语法:stristr(string,search,before_search)

参数 描述
string 必需。规定被搜索的字符串。
search

必需。规定要搜索的字符串。

如果该参数是数字,则搜索匹配该数字对应的 ASCII 值的字符。

before_search

可选。默认值为 "false" 的布尔值。

如果设置为 "true",它将返回 search 参数第一次出现之前的字符串部分。

 返回字符串的剩余部分(从匹配点)。如果未找到所搜索的字符串,则返回 FALSE。

2.php_uname() PHP中php_uname的用法详解

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

参数

mode 是单个字符,用于定义要返回什么信息:

'a':此为默认。包含序列 "s n r v m" 里的所有模式。

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

'n':主机名。例如ÿ

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值