Hello I am Arsalan. Offensive Security Engineer, I blog about Cyber security, CTF writeup, Programming, Blockchain and more about tech. born and raised in indonesia, currently living in indonesia
Writeup Mobile Penetration Testing challenge wreckit CTF 2021
Published on 14 Jun 2021
WreckIT CTF Writeup Mobile Category
This my first post in 2021 kinda busy in real life also, I have to finish my thesis on time.
okay on 13 June my friend and I playing WreckIT CTF, WreckIT CTF is an annual CTF Cybersecurity competition
event from Politeknik Siber dan Sandi Negara, I solved all of the Mobile challenge and some user flag in the penetration testing box challenge
in this post, I will cover all Mobile challenges.
in this challenge, we are given an android application, the apps looks like this
the app has nothing fancy, it just showing us a picture and some string, with no input or anything else
so I guess we have to reverse the code. after doing dynamic analysis and reading the logcat, I found something
suspicious when I open the app.
seems like the app is deleting a file, and also I can’t find the string “Hello can you see me ?” inside the app
but I found a write function and delete function inside the flags.java.
so I assume that the app will write an odex file on /data/user/0/com.wreckit.otherxide/files/ then after the
file is written the apps load a class called com.wreckit.otherxide.flag from the odex file, after that
the file is removed by del() function. in order to reverse the odex file, we have to patch the app so it won’t
delete the odex file after being written. so I decided to patch the del() function from the
library file libxide.so. firstly we have to pull the lib from app data using command
I use binary ninja to patch the lib since I am a cool kid lol. there’s 3 function that looks suspicious
this is the del() function
now we have to patch the del() function so it won’t call the remove function instead set %eax register to 1 or 0
since the comparison will check either eax is 0 or 1. so the app doesn’t crash after del() being called.
now we have to change call remove
looks like we successfully patch the lib and save the odex file from being deleted in runtime.
now we have to reverse-engineer the odex file. the odex file is located in
/data/data/com.wreckit.otherxide/files
now we have to pull the odex file using the command
we can rename the file to pcrebgb.jar, I use an online decompiler to read the source code of the odex file.
according to the source code, the flag is encrypted using AES ECB. I also found the key and encrypted flag, and Hello can you see me ? string here.
key = P4t1entisk03nTji
encrytped flag = 18u+W+Mw782qr9tQDXXUgWjPPqwFpf5nZ4naKbPzmSM=
in order to decrypt the flag, I use the same java code and modify it a little bit to make it works outside the android device.
here is my solver to get the flag
FLAG: WRECKIT{J4r_Lar1_5aaT_rUnT1me}
Ezhax
in this challenge we are given an android application, the apps look like this
after doing static analysis, I found that there’s a suspicious string inside the MainActivity.java
as you can see there’s some sort of string looks promising as username and password. but the password “ggezhaxtrac3!”
in variable s is passed to a function
at this point we have to understand how d.c.a.a.b() works, then I found that, there’s an AES CBC encryption implementation
inside d.c.a.a.b
so we have to encrypt “ggezhaxtrac3!” with AES CBC using 99, 108, 107, 105, 110, 103, 116, 102, 112, 97, 105, 114, 122, 101, 103, 103 as the key.
here is my encryption code to get the password:
run and we got the password
DA7B33A1E6D228E0564F6E3490411085
but this is not the flag we are looking for since the flag should be formatted as WRECKIT{}.
and still, there’s no flag inside the dashboard activity
but, if we back to the MainActivity.java source there’s also some suspicious byte array
and if I try to convert the array as ASCII, I found a string that looks like our password.
here is the code that I use to convert these array to ASCII