md5 password view-source code
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..";
}
}
?>
LOS에서 똑같은 문제를 풀어봐서 순식간에 풀었다.
PHP md5 함수에서 인자로 true를 적으면 raw 값을 출력하기 때문에 이 점을 이용해 SQL injection을 수행할 수 있다.
129581926211651571912466741651878684928 라는 값에는 ' or ' 8 이라는 값이 들어있기 때문에 SQL 쿼리문을 참으로 만들어준다.
'Wargame > wargame.kr' 카테고리의 다른 글
[Wargame.kr] md5_compare 풀이 (236p) (0) | 2020.07.29 |
---|---|
[Wargame.kr] DB is really GOOD 풀이 (220p) (0) | 2020.07.29 |
[Wargame.kr] strcmp 풀이 (212p) (0) | 2020.07.28 |
[Wargame.kr] login_filtering 풀이 (136p) (0) | 2020.07.28 |
[Wargame.kr] fly me to the moon 풀이 (191p) (0) | 2020.05.25 |