ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Wargame.kr md5 password
    WebHacking/Wargame.kr 2018. 2. 25. 06:26

    이번 문제도 마찬가지로 md5문제다.


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    <?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>
    cs


    보통 md5암호화를 할때와는 다른 md5($ps,true)로 true가 추가되었다.

    뭔가 수상해서 구글링을 해보니 취약점이 있다고 한다. 

    md5를 하면 해쉬값이 만들어지는데 뒤에 true가 붙어버리면 그 해쉬값을 바이너리 형태로 변환 시키는데 그때 sql injection이 가능한데 그때 일어나는 sql injection취약점을 이용한 문제다.


    ex) 9235566

    'WebHacking > Wargame.kr' 카테고리의 다른 글

    Wargame.kr SimpleBoard  (0) 2018.02.26
    Wargame.kr tmitter  (0) 2018.02.25
    Wargame.kr type confusion  (0) 2018.02.25
    Wargame.kr strcmp  (0) 2018.02.25
    Wargame.kr md5 compare  (0) 2018.02.25
Designed by Tistory.