Trying to Break mktemp

Breaking “mktemp -d”

What I want to do issee what happes when I create the directory mktemp -d was initialy going to create !

I know your name.

First I need to know the name of the directory so I can create it just before I launch it so I can se it fail ! :D

But how to do this ? Hack into the random generator ? Nah. Simpler.

I’ll use gdb and break on mkdir(2), then I’ll print the (char *) contained in %rdi and create it just after it enters mkdir.

$gdb mktemp
gdb> b mkdir
gdb> start -d
gdb> c
gdb> p (char*)$rdi

But did it break ? :O

I does not break! Well I just tested this for 5 attempts to create the directory and watched it fail… then try again, with a different name.

So there is a loop here trying to create te expected random directory but how many times ? We will know in a future episode :D

Next episode

You will find the next of my adventures with mktemp here with a more programmatic approche.

Written on April 5, 2019