NETCOMP 3.0
Netcomp CTF competition from Universitas Gajah Mada (UGM), Yogyakarta.
Netcomp is an event designed to provide understanding in the fields of cybersecurity and networking. This event aims to bridge the gap between education and industry, focusing on the development of practical skills.
🔐 Cryptography
I swear this is not a web or reverse
It's been a few months since I only reported HTTP Headers findings 😭
Today, I am pentesting a company's internal web app and wonder if you could help me get a critical finding here...
Author: BerlianGabriel
Jadi, di chall ini diberikan file html yang memiliki script js untuk password verify. Sepertinya ini semacam S-box. Berikut ini source-code dari file html tersebut

Saya coba untuk buat script dalam python dengan mengambil variabel “expected string” dan array “magic” yang berisi BigInteger. Jika ditelusuri, S-box (Substitution box) adalah komponen dasar yang melakukan pertukaran (substitusi) nilai dalam kriptografi kunci simetris. Dalam penyandian blok, kotak ini biasa dipakai untuk menyembunyikan hubungan antara kunci dan teks tersandi (prinsip pengacakan Shannon). Lihat di sini untuk lebih lengkapnya : wikipedia.
Jadi, di dalam script itu terdapat password untuk masuk ke dalam sistem web. Dalam hal ini, logika enkripsinya memang diberikan secara publik :D. Jadi, saya coba menggunakan script di bawah untuk decrypt passwordnya.
expected_string = "7X!7|!@V|7eV77_!|@8S"
magic = [
0x1fa9787f52d6819dac3e51c96c9850ac9a68a000,
0x551e7b2ade66a9cd21538d24f8232eb9e3c6a00,
0x685130edf575c5fd89b4ea52d8ce440fb75d40,
0x4d2b06845e7f210fd15f3697fe234c69919a0,
0x267227d769f1422427c2f550f7852c59bfec,
0xd9fd323c23dd5a26579cb53a8a42996b38,
0x388a9fbf545b3b1a5e4b80376e94de767,
0xadef7b085371d7244d43d0011e7c6d5,
0x18cbc26aefc3b3b1ef4588ce4acc6b,
0x296e5ed6f99d55e5efb08eb856e9,
0x314ef6584d10a8c5226f105685,
0x2798a7a450463592994fc72f,
0x133caaa3da819c1ca0087d,
0x445974d799d8bcf9c3b,
]
magic2 = 0x2971713e56d0006e6a0b48126ca34000
def reverse_hash(expected_char, magic, magic2):
for char in range(33, 127):
result = 0
one_char = -char
for m in reversed(magic):
result *= one_char
result += m
nresult = result % magic2
result = -result // magic2
result += (888 - result) * (result > 127)
result += (888 - result) * (nresult != 0)
result += (888 - result) * (result < 33)
if chr(result) == expected_char:
return chr(char)
return None
password = ''.join(reverse_hash(c, magic, magic2) for c in expected_string)
print(f'Password: {password}')
Script ini digunakan untuk membalikkan proses hashing yang terdapat pada kode JavaScript yang disediakan. Dengan menggunakan perhitungan ulang terhadap setiap karakter dalam expected_string, script ini mencoba menemukan password asli yang menghasilkan string yang sama melalui proses penghitungan yang cukup kompleks menggunakan nilai magic dan magic2.

Flag :
Netcomp{1t_1s_b4S1C4lly_Sb0x}
Thank you for reading this writeup. Support me by buy me a coffee or click this
Last updated