ii4gsp
wargame.kr 7번 [md5 password] 본문
md5의 인자전달 방식을 보여준다.
Start를 누르자
password 입력칸과 밑에 get source가 있다.
소스코드를 확인해보자
<?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 함수에서 취약점이 발생한다.
md5함수의 인자전달 부분을 보면 두 번째 인자전달 부분에 true가있다.
두 번째 파라미터에 true값이 담기면 default값이 아닌 binary 형태로 출력이 되며 아스키코드 형태로 처리될 수 있다.
구글링 결과 ' or '1과 같은 항상 참이되는 sql injection 공격 구문이 되는 바이너리 코드로 변환될 수 있는 인자값
129581926211651571912466741651878684928을 패스워드에 넣어주자
'웹 해킹 > wargame.kr' 카테고리의 다른 글
wargame.kr 9번 [DB is really GOOD] (0) | 2020.01.14 |
---|---|
wargame.kr 8번 [strcmp] (0) | 2020.01.14 |
wargame.kr 6번 [fly me to the moon] (0) | 2020.01.14 |
wargame.kr 5번 [WTF_CODE] (0) | 2020.01.14 |
wargame.kr 4번 [login filtering] (0) | 2020.01.14 |
Comments