After getting bored from TAMU CTF, I thought of giving Seasides CTF 2019, a try. A big shoutout to Team AlCapwn for creating these awesome challenges. Although It was a 24 hr CTF Competition, but the challenges were really fun to solve and I learnt a lot from them as well.
This Post contains writeups to the following challs::
Browsing to the specified URL, I got some values regarding a device with a uuid = c4ca4238a0b923820dcc509a6f75849b
It looked like a md5hash so I tried to crack it in the first place.. And to my surprise ..
So I made a simple brute-forcer in python which created md5 hashes of 1,2……49,50 And used a simple curl command to output the result of browser.
1 2 3 4 5 6 7 8 9 10 11
import hashlib import os
m = hashlib.md5()
for i inrange(0,50): m = hashlib.md5() m.update(str(i)) res = m.hexdigest() print'{} => {}'.format(i,res) os.system('curl http://35.200.147.161:32338/device/'+res)
Its just a simple Single-byte XOR cipher which you could remember if you’ve solved cryptopals SET-1 challenges. For this I pulled out my XOR key brute-forcer.
defget_english_score(input_bytes): """Compares each input byte to a character frequency chart and returns the score of a message based on the relative frequency the characters occur in the English language """
defsingle_char_xor(input_bytes, char_value): """Returns the result of each byte being XOR'd with a single value. """ output_bytes = b'' for byte in input_bytes: output_bytes += bytes([byte ^ char_value]) return output_bytes
When I moved on towards the inpcheck function, It took me a second to guess the input as it was in our plain sight. Also I saw that our Input String’s Length has to be 14 to output anything in our flag format which was sea{…}sides
int __cdecl main(int argc, constchar **argv, constchar **envp) { size_t v3; void *s; size_t v5; size_t v6; char *v7; char *v8; char *s1; if ( argc != 2 ) { puts("please_find_me.exe <<key_goes_here>> "); exit(0); } v3 = strlen(argv[1]); s = malloc(v3 + 1); v5 = strlen(argv[1]); memset(s, 0, v5 + 1); v6 = strlen(argv[1]); strncpy((char *)s, argv[1], v6); v7 = (char *)base64(s); v8 = (char *)rot13(v7); s1 = (char *)uuencode(v8); if ( !strcmp(s1, flag_encoded) ) puts("GG!, now put that flag on ye head and fly away!!"); else puts("Nope, wrong flag ye got there m8, try again!"); return0; }
I observed some conversions of our input into various encodings base64, rot13, and uuencode. I knew about the first two, but wth is uuencode…
No Problem, Linux Man Page takes care of that for us. uuencode and uudecode are used to transmit binary files over transmission mediums that do not support other than simple ASCII data. You can read more about it here.
It was also easy to find the flag_encoded variable which was declared.
I simply wrote a python script to reverse the encoding process. And FYI the begin & end line is necessary for using uuencode or else it’ll throw an error.
Thanks for Reading this writeup.. Subscribe to my Newsletter for more updates regarding CTFs. Also Feedback is always appreciated. It won’t take much time though.
And Keep Escalating the Privileges Happy Hacking !!