0

Let's suppose this (very ugly) c code:

#include <stdio.h>
#include <string.h>
#include <signal.h>

char sav_argv[100];

void on_sigtrap(int signo)
{
    if (strcmp(sav_argv, "hello") == 0)
    {
        printf("OK!\n");
    } else {
        printf("NOK\n");
    }
}

int main(int argc, char *argv[])
{
    memset(sav_argv,100,0);
    memcpy(sav_argv,argv[1],100);
    signal(SIGTRAP,on_sigtrap);
    __asm__("int3");
    return 0;
}

I have compiled this c program with gcc (linux 64 bits elf).

What i want to do is to solve it with an angr python script. It does work if i remove the debuger trap but it does not work with debuger trap.

Is there a way to make angr work on this c program ?

Thanks

  • You can use a hook on the int3. Docs. – 0xec Aug 6 '18 at 20:15
  • Good idea but what should i put in hook function? How can i call handler ? – Bob5421 Aug 7 '18 at 5:13
  • Look in the Control Flow section. You can put a jump(addr) to transfer control to the handler. – 0xec Aug 7 '18 at 6:21
  • is it a jump or a call in this case ? – Bob5421 Aug 7 '18 at 7:38
  • Will likely be a call. – 0xec Aug 7 '18 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.