1.ブルートフォース
SQLインジェクションは中程度の難易度では使用できないため、げっぷは直接発破に使用されます
二コマンドインジェクション
最初にコードを見てください
<?php
if( 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>";
}
?>
この質問は「&&」と「;」をフィルタリングしていることがわかるので、他のスプライシング文字を使用して挿入します。
例:127.0.0.1 | whoami
3. CSRF
最初にコードを見てください
<?php
if( isset( $_GET[ 'Change' ] ) ) {
// Checks to see where the request came from
if( eregi( $_SERVER[ 'SERVER_NAME' ], $_SERVER[ 'HTTP_REFERER' ] ) ) {
// Get input
$pass_new = $_GET[ 'password_new' ];
$pass_conf = $_GET[ 'password_conf' ];
// Do the passwords match?
if( $pass_new == $pass_conf ) {
// They do!
$pass_new = mysql_real_escape_string( $pass_new );
$pass_new = md5( $pass_new );
// Update the database
$insert = "UPDATE `users` SET password = '$pass_new' WHERE user = '" . dvwaCurrentUser() . "';";
$result = mysql_query( $insert ) or die( '<pre>' . mysql_error() . '</pre>' );
// Feedback for the user
echo "<pre>Password Changed.</pre>";
}
else {
// Issue with passwords matching
echo "<pre>Passwords did not match.</pre>";
}
}
else {
// Didn't come from a trusted source
echo "<pre>That request didn't look correct.</pre>";
}
mysql_close();
}
?>
HTTP_REFERERにSERVER_NAME(httpヘッダーのホストパラメーターとアクセスするホスト名)が含まれているかどうかを確認する必要があることがわかります。
バイパスするには、Webページのファイル名を「accesshostname.html」に変更します。
4。ファイルインクルード
最初にコードを見てください
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );
?>
サーバーがhttp://、https://、…/、…\をフィルタリングしたことがわかります
ただし、str_replace()関数は、二重書き込みを使用して保護手段をスキップできます。
注:絶対パス方式を使用したファイルインクルードでは、フィルタリング手段は無効です。