md5('value', true);
우리는 이 문제를 본적이 있다. 바로 이 문제 이다.
<?php
if (isset($_GET['view-source'])) {
show_source(__FILE__);
exit();
}
if(isset($_POST['ps'])){
sleep(1);
mysql_connect("localhost","md5_password","md5_password_pz");
mysql_select_db("md5_password");
mysql_query("set names utf8");
/*
create table admin_password(
password char(64) unique
);
*/
include "../lib.php"; // include for auth_code function.
$key=auth_code("md5 password");
$ps = mysql_real_escape_string($_POST['ps']);
$row=@mysql_fetch_array(mysql_query("select * from admin_password where password='".md5($ps,true)."'"));
if(isset($row[0])){
echo "hello admin!"."<br />";
echo "Password : ".$key;
}else{
echo "wrong..";
}
}
?>
<style>
input[type=text] {width:200px;}
</style>
<br />
<br />
<form method="post" action="./index.php">
password : <input type="text" name="ps" /><input type="submit" value="login" />
</form>
<div><a href='?view-source'>get source</a></div>
전체 쿼리가 나와 있지만, 사실 볼 필요는 없다. 우린 쿼리를 파괘하기 위해서 마법의 쓰레기 md5값을 넣어주면 해결 할 수 있다.