You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script was used to showcase the power of libdebug during the Workshop at the CyberChallenge.IT 2024 Finals. An explanation of the script, along with a brief introduction to libdebug, is available in the official stream of the event, starting from timestamp 2:17:00.
fromlibdebugimportdebuggerfromstringimportascii_letters, digits# Enable the escape_antidebug option to bypass the ptrace calld=debugger("main", escape_antidebug=True)
defcallback(_, __):
# This will automatically issue a continue when the breakpoint is hitpassdefon_enter_nanosleep(t, _):
# This sets every argument to NULL to make the syscall failt.syscall_arg0=0t.syscall_arg1=0t.syscall_arg2=0t.syscall_arg3=0alphabet=ascii_letters+digits+"_{}"flag=b""best_hit_count=0whileTrue:
forcinalphabet:
r=d.run()
# Any time we call run() we have to reset the breakpoint and syscall handlerbp=d.breakpoint(0x13e1, hardware=True, callback=callback, file="binary")
d.handle_syscall("clock_nanosleep", on_enter=on_enter_nanosleep)
d.cont()
r.sendline(flag+c.encode())
# This makes the debugger wait for the process to terminated.wait()
response=r.recvline()
# `run()` will automatically kill any still-running process, but it's good practice to do it manuallyd.kill()
ifb"Yeah"inresponse:
# The flag is correctflag+=c.encode()
print(flag)
breakifbp.hit_count>best_hit_count:
# We have found a new flag characterbest_hit_count=bp.hit_countflag+=c.encode()
print(flag)
breakifc=="}":
breakprint(flag)