For a list of command line tools, please see CTF Command Line Tools.
As with any profession, having the right tools is crucial for completing any task. After progressing through so many CTF challenges, here’s a list of tools that came up time and time again. I’ll be sharing a brief synopsis of what the tool is, how to use it, and what tasks it’s good at solving. By the end of this, you should have an idea of the common tools that are necessary for CTF challenges.
This one is a bit of a no brainer compared to the others on this list, but it’s so well used that I had to include it on this list.
A text editor is a way to view the contents of a file and potentially edit some of its contents. It’s extremely useful in the exploratory steps, since it allows you to very quickly get an idea of what a file contains. You can very quickly identify a bunch of important things, such as how large the file is and what type of file it is. If it’s a program, then sometimes strings in the program are stored in plain text. I can’t count how many times I was just looking through a file in a text editor, and happened to find the plain-text flag nestled in there.
Text editors come installed by default on almost all machines. On Windows, it’s notepad. On Mac, it’s TextEdit and on Linux, it’s gedit. Of course, you can install your own, which typically have more useful features than the default text editors given. Examples include Sublime, Atom, and VSCode.
GDB stands for the GNU Project Debugger, and is a useful tool for looking at exactly what is happening when a program is run. Essentially, what GDB does is that it gives you access to the underlying assembly code and registers, and allows you to view them as you step through your program. You have access to all sorts of tools, such as stepping through code, setting breakpoints, viewing the stack, or even manually changing the values of variables and registers halfway through execution.
In CTF’s GDB is useful for viewing the underlying assembly and viewing the program state at any point. As an example, suppose a program generates a random number, and then asks you to input it without showing you the random number. With GDB, you can take a peak at the variable that stores the random number while the program is running, and then enter it in.
Below is a short cheat sheet for some of the common commands in GDB.
Here are some of the basic commands of GDB:
run
or r
start
stepi
or si
nexti
or ni
break *0x12345678
0x12345678
continue
or c
info functions
info variables
quit
or q
disassemble <function>
And here are some of the more advanced ones:
set disassembly-flavor intel
starti
info file
layout asm
info registers
p $rip
$RIP
set $eax = 0
$EAX
to 0.x 0x12345678
x/20x $sp
jump <function>
Pwndbg is a GDB plugin that makes debugging in GDB alot easier. Though technically feature complete, GDB can be a bit hard to work with at times due to is non-user-friendly nature. Pwndbg is a python module that is loaded directly into GDB, which provides a bunch of utilities, tools, and shortcuts to make debugging in GDB much smoother.
Some features that it includes are
Ghidra is a software reverse engineering suite of tools, developed by the NSA. It’s most useful feature is the decompiler, which allows you to take an executable, and then give a possible version of the original C code that was used to compile it. This is great for when you want to work out how a binary file works, but you don’t have access to the original source code, and you don’t want to spend hours trawling through the assembly and keeping track of which registers and stack positions store which variables.
However, while decompiling sounds awesome for debugging, it’s important not to rely too much on the decompiler output. For a start, variable and function names are not preserved, so you will often have to spend some time in the beginning going through and taking a guess at what each variable stores and or what each function does. Ghidra provides tools to allow you to rename variables as you work out what they do, as well as add comments, but you will have to manually make these changes.
Also often times the code can changed on decompilation, and some of the original logic may be obfuscated. For example, a typical string might be instead broken up into 7 different variables. In other cases, functions do not display their arguments, and it’s up to you to read the corresponding assembly code in order to try and figure out what is being passed into the function. Hence, it’s important to treat the decompiled code as merely a guideline, and to only often refer to the corresponding assembly code to tell you what is really happening.
pwntools
is a CTF framework and exploit development library. It’s written in python, and provides a bunch of tools which allow you to rapidly prototype code and help with exploiting code. Though there are many useful features, there are two that I have used the most:
pwnlib.tubes.sock
)
pwnlib.tubes.process
)
Pwnlib (the name of the python module) is very useful in automating interactions with programs. Suppose that you have a program where you have to go through a 10 step process before you can enter in some input for an exploit. It would certainly be very tedious to go through those steps every time you wanted to test your exploit so instead, you can automate it in a python script using pwntools. Pwnlib is also really useful if we want to brute force something, since it allows us to rapidly make new connections and test things until we get it right.
Here’s an example, taken from the Cookie Monster challenge from Tutor CTF. We use Pwnlib in order to test the exact right offset for our buffer overflow attack.
from pwn import *
= remote("13.210.180.94", 10001)
conn for i in range(16, 30):
b'Feed the cookie monster: ')
conn.recvuntil(= b'A'*i+b'EIKOOC\n'
s
conn.send(s)print(i, s)
conn.close()
Here, we connect to a server, and then brute force a bunch of different inputs. Note that we use recvuntil
in order to sync our python script with the program. recvuntil
causes our program to wait until we receive the message "Feed the cookie monster: "
before offering up our own input.
HexFiend is a macOS tool for editing hex files. Sometimes, header files can get corrupt, and it’s important to be able to manually access them and change their values.
If you don’t have HexFiend, you can still edit hex through alternative methods. Here are the steps
:%!xxd
and press enter
%
selects the whole file!xdd
runs the xxd shell command%!xxd -r
and press enter
GIMP is an open source image editor. Certain challenges (mainly forensics ones) require you to open an image file and examine it’s contents. Furthermore, certain techniques, such as LSB steganography require you to change the level curves of an image, or modify an image in other ways in order to obtain a flag.
Chrome Devtools are a set of builtin tools that can be used to analyse web pages. One of it’s major use cases is “Inspect Element”, where you can right click on any element on a page ane view the HTML code. You can also look at CSS and Javscript, network packets, cookies and more. There is such a broad range of applications that it would be impossible to list them all here. These tools are an absolute must for any sort of web exploitation.
Burp Suite provides a a whole host of tools for web exploitation. Some of it’s features include:
The full version of Burp Suite costs $400, and contains more tools such as a scanner that automatically goes to a website and tests a bunch of common vulnerabilities. However, we can still get the community version with most of the tools for free.
Radare2 is a framework for reverse engineering and analyzing binaries. It’s usage is similar to GDB in that we can step through assembly code, but it has a tonne of other really useful tools as well which make it alot more powerful. It’s even lower level than GDB, which means that it can do some things that GDB can’t.
Note: All the challenges I’ve done so far I have completed with just vanilla GDB. All writeups are written up with that restriction in mind.