← All scrolls
巻 rank
Darkest Hour CTF · Misc

GDBjail 1: escaping a debugger jail

A GDB session behind a blacklist that only blocks the python commands.

16 Feb 20251 min read
#jail#gdb

Description

Lets see how you escape hell , i mean gdb

remote connection

nc pwn.dh.securinets.tn 2016

And we’re given a python code

import gdb 

## gdb -x jail.py main
gdb.execute("start")

while 1:
    
    try :
    
        command=input("> ")
        parts=command.split()  
    
        blacklist=["python","python-interactive"]
        ## validation 
        for blacklisted_word in blacklist:
            if parts[0] in blacklisted_word : 
                print("!!!! no pasaran !!!!")
                continue

        gdb.execute(command)
    except gdb.error as e:
        print(e)
    except : 
        pass        

AI helped me on this one , i asked it how to get a shell from a GDB environment and under those restrictions to get a flag and he gave me some commands from which this one worked !

GDB1