调用 printf() 编辑可执行文件
我正在尝试“破解”控制台程序,强制它显示某些内容。问题是我无法打印换行符 (\r\n
)。 使用反汇编程序,我找到了该位置并编辑了二进制文件:
push 4ad0eb46 ; the string (let's pretend "Hi guys")
push 4ad0eb80 ; and the format ("%s")
call near ds:[<&msvcrt.printf>] ; call printf
jmp 4ad0eb4f ; skip data
; now here I coded the strings
mov ds:[4ad289ec],eax ; and here the program resumes
正如我所说,我无法打印换行符。我尝试在格式字符串中编码 "\r\n"
(因此它变成 "%s\r\n"
,就像我在 C 中所做的那样)并打印“大家好\r\n”
,并将其编码在 字符串本身(使其成为 "Hi Guys\x13\x10"
)并得到 "Hi Guys"
和两个奇怪的字符,可能是 0x13 和 0x10 的 ASCII 表示。
I'm trying to "crack" a console program, forcing it to display something. The problem is I can't print a newline (\r\n
).
With a disassebler I found the place and edited the binary:
push 4ad0eb46 ; the string (let's pretend "Hi guys")
push 4ad0eb80 ; and the format ("%s")
call near ds:[<&msvcrt.printf>] ; call printf
jmp 4ad0eb4f ; skip data
; now here I coded the strings
mov ds:[4ad289ec],eax ; and here the program resumes
As I said, I can't print a newline. I tried encode "\r\n"
in the format string (so it becomes "%s\r\n"
, as I would do in C) and get printed "Hi guys\r\n"
, and encode it in the
string itself (making it "Hi guys\x13\x10"
) and get "Hi guys"
and two strange characters, probably the ASCII representation of 0x13 and 0x10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的第二次尝试是将字符直接嵌入到字符串中,这是正确的方法。但是,您使用了错误的字符编号。 ASCII 中用于返回/换行的数字是 13 和 10(十进制),即 0x0d 和 0x0a(十六进制)。您使用了 0x13 和 0x10,它们是不同的字符。
有关字符编号,请参阅代码页 437 中的表格。字符 19 和 16(十进制)确实是一个直指三角形和一个双感叹号。
Your second attempt, with embedding the characters directly into the string, was the right approach. However, you've used the wrong character numbers. The numbers for return/linefeed in ASCII are 13 and 10 (decimal), which is 0x0d and 0x0a (hex). You've used 0x13 and 0x10, which are different characters.
See the table at Code page 437 for the character numbers. The characters 19 and 16 (decimal) are indeed a right pointing triangle and a double exclamation mark.
换行符(在 Windows 中)是
\r\n
。A newline (in Windows) is
\r\n
.