首页 » PHP教程 » php168注入技巧_DVWA之敕令注入

php168注入技巧_DVWA之敕令注入

访客 2024-12-14 0

扫一扫用手机浏览

文章目录 [+]

命令连接符

command1 && command2 先实行命令1后实行命令2

php168注入技巧_DVWA之敕令注入

命令1 |命令2 只实行命令2

command1 & command2 先实行命令2后实行命令1

以上三种连接符在windows和linux环境下都支持

难度(低)

审计代码

<?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_exec( 'ping ' . $target ); } else { // nix $cmd = shell_exec( 'ping -c 4 ' . $target ); } // Feedback for the end user echo "<pre>{$cmd}</pre>";}?>

可以创造直接针对操作系统类型进行ping,没有对输入的数据作出任何过滤,非常危险。

开始操作:

选择命令注入模块

在文本框里输入"192.168.0.1 && net user",得到以下系统中所有的用户

创造乱码,

乱码办理方法:

办理此问题的方法:在DVWA-master\dvwa\include目录下找到dvwaPage.inc.php文件中所有的"charset=utf-8",修正"charset=gb2312",即可

显示效果

192.168.0.1 && net user

难度(中)

代码审计

<?phpif( 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>";}?>

可以看到,比较Low级别的代码,做事器端对ip参数做了一定过滤,即把"&" 、";"删除,实质上采取的是黑名单机制,因此依旧存在安全问题。

漏洞利用

输入127.0.0.1 |迪尔

127.0.0.1 & ipconfig

难度(高)

代码审计

<?phpif( isset( $_POST[ 'Submit' ] ) ) { // Get input $target = trim($_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>";}?>

比较Medium级别的代码,High级别的代码进一步完善了黑名单,但由于黑名单机制的局限性,我们依然可以绕过。

黑名单看似过滤了所有的造孽字符,但仔细不雅观察到是把|(把稳这里|后有一个空格)更换为空字符,于是 |成了"漏网之鱼"。

漏洞利用

127.0.0.1|目录

标签:

相关文章

大数据绯闻,介绍隐私泄露背后的真相

近年来,随着互联网技术的飞速发展,大数据成为了各行各业的热门话题。在大数据带给人们便利的隐私泄露问题也日益凸显,引发了一场场绯闻。...

PHP教程 2024-12-16 阅读0 评论0

大数据脚印,解码未来社会的足迹

随着互联网技术的飞速发展,大数据已经成为当今社会不可或缺的一部分。大数据脚印,作为人们日常生活中留下的数字痕迹,不仅揭示了人类社会...

PHP教程 2024-12-16 阅读0 评论0

大数据蓝图,构建智能时代的基石

随着互联网技术的飞速发展,大数据时代已经来临。大数据作为新时代的产物,正在深刻地改变着我们的生产、生活、思维方式。本文将从大数据蓝...

PHP教程 2024-12-16 阅读0 评论0