1.
Link:_https://mirrorgm.cloudapp.net/web100_ffabc3b9682add59fe1e83a599f001b8/
Gợi ý:
_https://mirrorgm.cloudapp.net/web100_ffabc3b9682add59fe1e83a599f001b8/hint.txt
Đây là một dạng bài bypass sql
command:
$username= $_GET['username'];
$password = md5($_GET['password']);
$result = $db->query("SELECT * FROM admin where username_salt1337=((('$username') and password_salt1337=('$password')) and 1=2)");
Có thể bypass bằng cách nhập vào username giá trị sao cho đoạn sau ') and password_salt1337=('$password'))and 1=2), trở thành comment hoặc là sql command khác.Tài liệu về mysql comment tạiđây:
_http://dev.mysql.com/doc/refman/5.1/en/comments.html.
Trong mysql, để comment có 3 cách:
1. 1 ký tự # ở cuối"
2. 2 ký tự -- và ít nhất một dấu cách(whitespace) ở cuối
3. /* */ giống C/C++
Tuy nhiên người ra đề đã chặn những commend loại này và giới hạn số lượng ký tự nhập vào username( thậm chí lọc cả khoảng trắng). Ví dụ :
username ="'))) or 1-- ". Báo Bad input
username ="‘’))) or '1'='1'--". Báo Sorry, UserName is too long
Vì vậy để bypass chỉ còn cách thêm dấu ';'(thông báo kết thúc truy vấn sql), và thay khoảng trắng bằng or(1):
username ="')))or(1);".
FLag : SVATTT_sql_inj3ct10n_4_n3wbi3s
2.
Link : https://mirrorgm.cloudapp.net/web200_8e50f3b1a3c5311633284743e22baea5/
Gợi ý : https://mirrorgm.cloudapp.net/web200_8e50f3b1a3c5311633284743e22baea5/hint.txt
$password = $_GET['password'];
$checkcrc = dechex(crc32($password));
if (strpos($password, "Anonymous") === false || $checkcrc !=="deadc0de")
{
echo "
"."Bad password"."
";
die();
}
.......................
$result = $db->query("SELECT * FROM web200 where code='$password'");
Một dạng bài rất hay gặp trong các ctf wargameĐầu tiên ta nhận thấy password nhập vào phải thoải mãn điều kiện:
Có chứa chuỗi "Anonymous". Đồng thời
dechex(crc32($password)) === "deadc0de"
(đọc thêm ở đây để biết vì sao có === _http://php.net/manual/en/function.strpos.php, phần warning)
Giá trị password nhập vào phải để query trên trả về kết quả đúng( bypass giống bài 1)
Tài liệu tham khảo về hàm băm crc32 và một số thứ liên quan:
1.http://www.danielvik.com/2010/10/calculating-reverse-crc.html
2.http://www.danielvik.com/2012/01/finding-reverse-crc-patch-with-readable.html
3.http://reveng.sourceforge.net/
4.http://blog.affien.com/archives/2005/07/15/reversing-crc/
5.Google với key: reversing CRC và CRC32
Nhận xét: password để bypass sql command và đoạn kiểm tra strpos: "Anonymous'or(1);" CRC32. Theo các link trên.
giả sử : 1 xâu A có mã crc32(A) = 0x12345678
chúng ta có trước một mã crc32 (B) = 0xdeadc0de
Thì từ A chúng ta chỉ cần thêm 4 byte ( vào sau, trước, giữa) để tạo ra B( ở đây tôi sẽ chọn ở cuối). Tuy nhiên trong 4 byte này có thể sẽ có ký tự không nhìn thấy( đọc link 1). Như vậy chúng ta đã có:
dechex(crc32("Anonymous'or(1);") = b2d0c45c
dechex(crc32("Anonymous'or(1);X") = deadc0de
Trong đó X là xâu cần tìm.
Tham khảo link 2 + source code cuối bài viết (file ReverseCRC.zip)
Sửa file ReverseCRC.cpp. Ở hàm main sửa thành
int main(void)
{
testOneAscii(0xb2d0c45c, 0xdeadc0de);
/* testMany(0xaaaaaaaa, 100);
testMany(0x12345678, 100);
testMany(0xffffffff, 100);
testManyAscii(0x00000000, 100);
testManyAscii(0xaaaaaaaa, 100);
testManyAscii(0x12345678, 100);
testManyAscii(0xffffffff, 100);
*/
system("PAUSE");
return 0;
}
Chạy thử: String to add: 3TUZMLpassword nhập vào Anonymous'or(1);3TUZML
Anonymous: Not bad! Here is your flag SVATTT_crc_0r_n0t_CRC
