cms站群管理系统,wordpress所含数据库文件,广州安全教育平台账号找回,企业网站建设设计公司dvwa靶场命令执⾏漏洞
high难度的源码#xff1a;
$target trim($_REQUEST[ ‘ip’ ]);是一个接收id值的变量 array_keys()函数功能是返回包含原数组中所有键名的一个新数组。 str_replace() 函数如下#xff0c;把字符串 “Hello world!” 中的字符 “world” 替换为 “S…dvwa靶场命令执⾏漏洞
high难度的源码
$target trim($_REQUEST[ ‘ip’ ]);是一个接收id值的变量 array_keys()函数功能是返回包含原数组中所有键名的一个新数组。 str_replace() 函数如下把字符串 “Hello world!” 中的字符 “world” 替换为 “Shanghai” str_replace(world,Shanghai,Hello world!);shell_exec函数是执行Linux命令函数可以获取全部数据 ?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$html . pre{$cmd}/pre;
}?
这段源码中的substitutions是一个php关联数组它交互过滤了所有的特殊字符将他们置为空但是经过观察’| ’ 有一段空格没有成功过滤
$substitutions array( ,; ,| ,- ,$ ,( ,) , ,|| ,);impossible难度的源码
这段代码中加入了CSRF token如果user的token值与更改密码时的token值不相等或者不存在seesion_token值便会报错这样就防止了伪造攻击 stripslashes()函数过滤字符串中的反斜杠。 explode()函数将所有的字符串打散成为数组。 is_numeric() 函数用于检测变量是否为数字或数字字符串。 Anti-CSRF token同时对参数ip进行严格的限制只有“数字.数字.数字.数字”的输入才会被接受因此不存在命令注入漏洞。 防范措施获取要测试的IP利用函数根据.将其分割成4个数值再重新拼接后进行测试。 $target $octet[0] . . . $octet[1] . . . $octet[2] . . . $octet[3];限制了只有数字.数字.数字.数字才会接受所以杜绝了命令注入漏洞
?phpif( isset( $_POST[ Submit ] ) ) {// Check Anti-CSRF tokencheckToken( $_REQUEST[ user_token ], $_SESSION[ session_token ], index.php );// Get input$target $_REQUEST[ ip ];$target stripslashes( $target );// Split the IP into 4 octects$octet explode( ., $target );// Check IF each octet is an integerif( ( is_numeric( $octet[0] ) ) ( is_numeric( $octet[1] ) ) ( is_numeric( $octet[2] ) ) ( is_numeric( $octet[3] ) ) ( sizeof( $octet ) 4 ) ) {// If all 4 octets are ints put the IP back together.$target $octet[0] . . . $octet[1] . . . $octet[2] . . . $octet[3];// 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$html . pre{$cmd}/pre;}else {// Ops. Let the user name theres a mistake$html . preERROR: You have entered an invalid IP./pre;}
}// Generate Anti-CSRF token
generateSessionToken();?