Post

Webhacking.kr - web51

web51

1
2
3
4
5
6
7
8
9
10
<?php
  if($_POST['id'] && $_POST['pw']){
    $db = dbconnect();
    $input_id = addslashes($_POST['id']);
    $input_pw = md5($_POST['pw'],true);
    $result = mysqli_fetch_array(mysqli_query($db,"select id from chall51 where id='{$input_id}' and pw='{$input_pw}'"));
    if($result['id']) solve(51);
    if(!$result['id']) echo "<center><font color=green><h1>Wrong</h1></font></center>";
  }
?>

Solution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
아무 id나 불러오면 됨. 근데 아마 Admin Page이므로 admin으로 로그인해야 할 듯.

php md5($str, true) -> false일 땐 32자리 문자열, true일 때 16바이트 바이너리로 암호화함. 

만약에 16바이트 바이너리에 '='이 포함되는 경우에는 ?

pw=???=??? 이런 형태가 되므로 pw=??? -> 0이 되고 0='???' -> 1이 되어 true가 됨.

따라서 id='admin' and 1이 되므로 true가 되는 것.

pw=9235566

root@bt:~# python -c 'import hashlib;print hashlib.md5("9235566").digest()'

���'='ә�0����� -> ???=??? 형태임.

출처: https://hyunmini.tistory.com/43 [Hyunmini]
This post is licensed under CC BY 4.0 by the author.