我有一个 linux x86 二进制文件,它要求输入密码并打印出密码是正确还是不正确。我想使用 python 来模糊输入。
下面是我运行二进制文件的屏幕截图,然后给它字符串“asdf”,并收到字符串“不正确”
截屏:
到目前为止,我已经尝试使用 Python3 subprocess 模块来
这是我的脚本
p = subprocess.Popen("/home/pj/Desktop/L1/lab1",stdin=subprocess.PIPE, stdout=subprocess.PIPE)
print (p.communicate()[0])
Run Code Online (Sandbox Code Playgroud)
运行这个脚本的结果是
b'Please supply the code: \nIncorrect\n'
Run Code Online (Sandbox Code Playgroud)
我希望只收到提示,但是在我有机会发送我的输入之前,二进制文件也返回了不正确的响应。
我如何改进我的脚本以便成功地与这个二进制文件交互?