向scanf输入非ASCII字符("%s") [英] Inputting Non ASCII characters to scanf("%s")
问题描述
%s
?我尝试插入十六进制字符,如 \x08\xDE\xAD
等等(以演示缓冲区溢出)。 输入的不是一个命令行参数,而是一个到程序里面的scanf。
假设你想在stdin上提供任意数据(因为你使用 scanf
)读取数据。)
你可以使用shell以创建数据并将其传送到您的程序中,例如
printf'\x08\xDE\xAD'|你的程序
请注意,只有在没有空白字符时才会工作因为 scanf
与一个%s
格式停在空白处)。
Is there a way one can issue non ascii hex characters to a scanf that uses %s
? I'm trying to insert hexadecimal chars like \x08\xDE\xAD
and so on (to demonstrate buffer overflow).
The input is not to a command line parameter, but to a scanf inside the program.
I assume you want to feed arbitrary data on stdin (since you read with scanf
).
You can use the shell to create the data and pipe it into your program, e.g.
printf '\x08\xDE\xAD' | yourprogram
Note that this will only work as long as there are no white-space characters to be fed (because scanf
with a %s
format stops at white-space).
这篇关于向scanf输入非ASCII字符("%s")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!