问题描述
我目前正在用radee2调试一个名为 test的C程序,我想知道是否有任何方式可以通过radee2输入十六进制字符作为输入。我的意思是,当您在radare2之外运行某些内容时,可以轻松地执行以下操作以将十六进制值作为输入发送到可执行文件中:
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
但是当我在radee2中以调试模式打开文件并尝试将十六进制值输入到在我的程序中,它没有将以 \x开头的字符视为十六进制字符,而是将每个字符视为实际的ascii输入字符。我可以在radare2中复制以上命令吗?
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?
推荐答案
环境:
ENVIRONMENT:
- radare2: radare2 4.2.0-git 23519 @ linux-x86-64 git。 4.1.1-84-g0c46c3e1e
提交:0c46c3e1e30bb272a5a05fc367d874af32b41fe4内部版本:2020-01-08__09:49:06 - 系统: Ubuntu 18.04.3 LTS
- radare2: radare2 4.2.0-git 23519 @ linux-x86-64 git.4.1.1-84-g0c46c3e1ecommit: 0c46c3e1e30bb272a5a05fc367d874af32b41fe4 build: 2020-01-08__09:49:06
- system: Ubuntu 18.04.3 LTS
解决方案:
SOLUTION:
- 要重新创建radare2中描述的功能,我们可以利用两个
radre2命令,并在输入的
字符串中添加其他转义章程。
- 命令一:doo [args]#使用提供的参数在调试模式下重新打开二进制文件。
- 命令二: dc#继续执行
- 输入中的其他转义章程: \x54\x65\x73\x74-> \\x54\\x65\ \\x73\\x74
示例:
EXAMPLE:
- 将十六进制值传递给/ bin / echo:
user@host:~$ echo -e "\x54\x65\x73\x74" Test
- 尝试相同的方法雷达2:
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]>
- 再次使用radare2,但附加了逃生宪章( \x54 -> \\x54):
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]>
这篇关于如何使radare2接受十六进制输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!