五、加固靶機
1.SQL加固:if(is_numeric( $id )) 判斷接收值是數字才允許執行SQL陳述句
2.XSS加固:$name = htmlspecialchars( $_GET[ 'name' ] ); 把接收值轉化為html物體,即把不決議html標簽,
$name = preg_replace( '/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i', '', $_GET[ 'name' ] );把script標簽過濾成空
$name = str_replace( '<script>', '', $_GET[ 'name' ] );更低一級的過濾
3.檔案上傳加固:
if( ( strtolower( $uploaded_ext ) == 'jpg' || strtolower( $uploaded_ext ) == 'jpeg' || strtolower( $uploaded_ext ) == 'png' ) &&
( $uploaded_size < 100000 ) &&
( $uploaded_type == 'image/jpeg' || $uploaded_type == 'image/png' ) &&
getimagesize( $uploaded_tmp ) )
判斷上傳的檔案后綴是否是圖片型別和檔案型別是否是圖片型別
4.檔案包含加固:if( $file != "include.php" && $file != "file1.php" && $file != "file2.php" && $file != "file3.php" )
判斷接收引數值是否是你設定的值,
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );
過濾掉一些注入的關鍵字符,
5.cmd命令執行加固:
$octet = explode( ".", $target );
if( ( is_numeric( $octet[0] ) ) && ( is_numeric( $octet[1] ) ) && ( is_numeric( $octet[2] ) ) && ( is_numeric( $octet[3] ) ) && ( sizeof( $octet ) == 4 ) )
把接收引數分割為4個數字,再判斷四個都是數字才去執行,
$substitutions = array(
'&' => '',
';' => '',
'| ' => '',
'-' => '',
'$' => '',
'(' => '',
')' => '',
'`' => '',
'||' => '',
);
$target = str_replace( array_keys( $substitutions ), $substitutions, $target );
過濾特殊字符
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/335438.html
標籤:其他
上一篇:DC-1詳解(絕對的詳細!)
