debuggingreverse-engineeringradare2

How to make radare2 accept hex input


I am currently debugging a C program in radare2 called "test", and I was wondering if there is any way for me to send in hex characters as input through radare2. What I mean by this is that when you're running something outside radare2, you could do easily something like this to send hex values as input into an executable:

$ python -c "print('\x42\x97\x53\x8e\x46\x56')" | ./test

But when I opened the file in debug mode in radare2 and tried to input hex values into my program, it didn't treat the characters starting with "\x" as hex characters and instead saw each character as an actual ascii input character. Is it possible for me to replicate the above command inside radare2?


Solution

  • ENVIRONMENT:

    SOLUTION:

    EXAMPLE:

    user@host:~$ echo -e "\x54\x65\x73\x74"
    Test
    
    user@host:~$ r2 /bin/echo
    [0x00001d10]> doo -e "\x54\x65\x73\x74"
    Process with PID 13820 started...
    = attach 13820 13820
    File dbg:///bin/echo  -e "\x54\x65\x73\x74" reopened in read-write mode
    13820
    [0x7ff1924ee090]> dc
    x54x65x73x74
    [0x7ff1924ee090]>
    
    user@host:~$ r2 /bin/echo
    [0x00001d10]> doo -e "\\x54\\x65\\x73\\x74"
    Process with PID 17265 started...
    = attach 17265 17265
    File dbg:///bin/echo  -e "\\x54\\x65\\x73\\x74" reopened in read-write mode
    17265
    [0x7fb080026090]> dc
    Test
    [0x7fb07fd18e06]>