[dvwa] Command Injection

简介: [dvwa] Command Injection

命令注入

0x01 low

没有过滤,直接利用 127.0.0.1 && ip a

函数

php_uname(mode) 动态地检查服务器的操作系统

‘s’:操作系统名称

‘n’:网络主机名

‘r’:操作系统发行版本号

‘v’:操作系统版本

‘m’:机器类型

若操作系统名称为windows, php_uname将显示Windows NT

stristr(string $haystack, string $needle)

从串haystack中找子串needle,返回子串或false

命令执行中&, | && || ;都可以拼接命令,即一次执行多条命令

使用127.0.0.1&&ip a看到本机的Ip(ip a 在linux中,windows中为ipconfig,操作系统不同,执行的命令不同)

程序提供了rce条件,利用的方式有很多,如创建特权用户,查看敏感文件等等

0x02 medium

&& 和;被ban,考虑其他拼接符

& | || 可用

如127.0.0.1 & ip a

0x03 high

& ; | - $ ( ) ` || 被ban

代码有个小纰漏,'| '为或号接空格被过滤

127.0.0.1 |ip a可绕过

0x04 impossible

对输入的字符串重新操作,白名单验证

stripslashes( $target )删除字符串中的反斜杠

explode( “.”, $target )将字符串以.为分界分割为数组

接收数组中的数字重组为点分十进制ip格式,

0x05 小妙招

命令行中&相当于||,即前面语句出错执行后面语句

0x05 Repair 修复漏洞

system|passthru|exec|popen|proc_open|move_uploaded_file|eval|copy|shell_exec|assert

这些函数会导致危险,过滤即可

还有一些符号,比如();&|/\<空格>等等

$stringing = "system|passthru|exec|popen|proc_open|move_uploaded_file|eval|copy|shell_exec|assert";
  $suspects = explode("|",$stringing);
  $punctuation = array("(",")","&","|","/","\\",";"," ");
  $suspects = array_merge($suspects,$punctuation);
  $allnull = array();
  for ($i = 0;$i<count($suspects);$i += 1){
    array_push($allnull,'Hacker');
  }
  $count = 0;
  $target = str_replace($suspects,$allnull,$target,$count);
  if($count>0){
    die("trying RCE, no way");
  }


相关文章
|
19天前
|
SQL 安全 数据库
[dvwa] sql injection(Blind)
[dvwa] sql injection(Blind)
|
19天前
|
SQL 安全 数据库
[dvwa] sql injection
[dvwa] sql injection
|
SQL 安全 PHP
Drupal 7.31 GetShell via /includes/database/database.inc SQL Injection Exploit
http://www.beebeeto.com/pdb/poc-2014-0100/ #!/usr/bin/env python # coding=utf-8 """ Site: http://www.
1535 0
|
SQL Windows 数据库管理
Locate and Attack Domain SQL Servers without Scanning
In this blog I'll share a new PowerShell script that uses Service Principal Name (SPN) recor...
910 0