Intro
I have devoted the past 48 hours to the H@cktivitycon CTF, run by John Hammond, congon4tor, M_alpha, fumenoid, NightWolf, Blacknote, and CalebStewart, and boy howdy was it a great experience. My team placed 128th out of ~1700 teams that actually scored, so we did not do that bad. The next few posts will be writeups associated with specific challenges/categories that I completed. This post, specifically, is dedicated to the challenges that were too short to be given their own post.
Warmups: Read The Rules
Description
Please follow the rules for this CTF!
Solution
Very difficult, I know. Here’s the rules page.
Hmm… no flag. Let’s try looking at the source code with CTRL+U
.
An easy 50 points.
Mobile: To Do
Description
I made my own app to remind me of all the things I need to do
Solution
I am by no means a mobile god. I’ve worked with Android Studio in the past, but all I did was write scripts because the app was developed for me, and I had no idea how the rest of it worked. However, with strings
on our side, and an eye for what’s not normal, we can get through this challenge with little to no mobile knowledge.
After downloading the apk, I’ll run file to see what I can do with it.
After running unzip
, we’re greeted with this mess.
I’ve obviously cut some of this down because of how large it is, but you’ll notice the todos.db
file in assets. This is not in every application. Thankfully, it’s in the SQLite format, so I can use sqlitebrowser
to open it up. We find only two strings:
ZmxhZ3s1MjZlYWIwNGZmOWFhYjllYTEzODkwMzc4NmE5ODc4Yn0=
VXNlIGFjdHVhbCBlbmNyeXB0aW9uIG5vdCBqdXN0IGJhc2U2NA==
They’re both in base64, so I can just run over to CyberChef and decode the following messages.
flag{526eab04ff9aab9ea138903786a9878b}
- Use actual encryption not just base64
Well, at least they’re trying.
Web: Confidentiality
Description
My school was trying to teach people about the CIA triad so they made all these dumb example applications... as if they know anything about information security. Can you prove these aren't so secure?
Solution
This is a web application, no downloadable source, but there is a deployable instance. Here’s the main page.
Let’s just try their example.
That looks like it literally came from stdout
on the command line. Can we just construct a one-liner using a character like ;
or &&
?
Yup. It’s an easy challenge. We can read the flag using /etc/hosts; cat flag.txt
.
Misc: Redlike
Description
You know, I like the color red. Primary colors are the best colors -- you can do so much with them! Escalate your privileges and retrieve the flag out of root's home directory.
Solution
This was probably the hardest of these “quicker” challenges I solved. I’ll start by SSH-ing into the box, and doing some initial enumeration.
There are no quick and easy SUID/sudo privescs, nor are there cronjobs running. Now, confession, I was lazy and I ran linpeas.sh
, but you can also find this by running ps aux
. Since we’re in a container, it will have a smaller output.
Research
That redis-server
looks interesting. After doing some googling, we learn the following from the official Redis site.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.
Hmmm. I still don’t fully understand what this means. My next idea was to visit IppSec and see if there were any Redis related exploits from HackTheBox. Luckily, there is, from his video writeup of Postman. Now, if you don’t want to spoil that box for yourself, he finds this foothold from HackTricks.
Grab the Flag
We find a lot of ways a misconfigured Redis environment can be leveraged to get command execution and/or privilege escalation. I originally tried dumping the database, but that didn’t get me anywhere. However, one other route that sticks out at me is SSH. I’ll let you read what HackTricks has to say, but the idea is in the redis-cli
, you are the redis
user. If redis
has write permissions to another user’s authorized_keys
file, you can insert your own public key to ssh as a different user.
A common misconfiguration across the board is giving service accounts more privilege than it needs. Surely redis
is somehow able to write to the root
directory? I’ll follow the steps as is from HackTricks, with my own public key.
And in my own VM, I SSH as root to get the flag.