I am trying to write all the write logs of a binary program into a file for further analysis. I am using radare2 for it. I don't know what's the issue, I am not able to write the 'dte' output to a file. It prints on the console but doesn't write to a file even after redirection. 'dtd' is working fine and writing to the file. Here in the below code log2.txt comes up empty.

import r2pipe

r = r2pipe.open('simpleAES', flags=['-d'])
r.cmd('e dbg.trace=1')
r.cmd('des 100') 

output1 = r.cmd('dtd')
output2 = r.cmd('dte')

f = open("log1.txt", "w")

f = open("log2.txt", "w")

I am using a simple C code for analysis and using raise(SIGINT); for setting breakpoint in the C program. Do you have any idea how I can write the 'dte' output to a file.

Code that I am debugging:

#include <signal.h>
int main (void)
    printf("loop started");
    int i = 0;
    for (i = 0; i < 10; ++i) {
      printf("Hello ");
    printf("loop completed");
    return 0;
  • Could you clarify how you set breakpoints? – bart1e Jul 18 '19 at 16:39
  • using raise(SIGINT) in the C program to set the breakpoint. – tarun14110 Jul 18 '19 at 18:25
  • Can you show this program? – bart1e Jul 18 '19 at 18:33
  • 1
    @bart1e added the code. – tarun14110 Jul 18 '19 at 18:42
  • raise(SIGINT) will send to your program SIGINT signal (it's like pressing CTRL+C - it will terminate your application if no handler for SIGINT is registered). If you want to set breakpoint in C, you can use asm("int $3") in GCC, or db address in r2. – bart1e Jul 18 '19 at 18: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.