我在使用的时候遇到的输入输出的问题
Joaus-source opened this issue · 1 comments
我在使用winpwn测试本地的可执行程序的时候,出现了以下的问题
1.返回的pid为0
- 无法接收打开的进程的输出,自然也无法写入,事实上我也不知道到底有没有创建进程成功,因为上面返回的pid是0
我的测试程序代码如下:
`#include <stdio.h>
#include <windows.h>
#include
#include
using namespace std;
int main()
{
setbuf(stdout,0);
setbuf(stdin,0);
setbuf(stderr,0);
cout << "Hello welcome To winpwn Test\nPlease input your luckey number\n";
int number;
while(1)
{
cin >> number;
if(number == 99)
{
system("cmd");
}
else{
cout << "try again!"<< endl;
}
}
return 1;
}
我写的python脚本:
# -- coding: utf-8 --
"""
Created on Fri Aug 14 21:58:01 2020
@author: 美好的一天
"""
from winpwn import *
context.log_level = 'debug'
context.arch = 'amd64'
p = process("D:\Program Files (x86)\CodeBlocks\Project\test.exe")
#sleep(10)
#p.recvuntil("Please input your luckey number\n")
print(p.recvall())
p.sendline('99')
p.interactive()`
在使用recvall的时候会一直停留在recv这里
`runfile('E:/CTF/PythonScripts/WinpwnTest.py', wdir='E:/CTF/PythonScripts')
+: Create process success #pid 0x0
而在我不使用recv直接sendline的报错就是这样
` runfile('E:/CTF/PythonScripts/WinpwnTest.py', wdir='E:/CTF/PythonScripts')
+: Create process success #pid 0x0
<bound method tube.recv of <winpwn.winpwn.process object at 0x00000216C941B5C0>>
0000 39 39 0d 0a |99..
Traceback (most recent call last):
File "", line 1, in
runfile('E:/CTF/PythonScripts/WinpwnTest.py', wdir='E:/CTF/PythonScripts')
File "E:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "E:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "E:/CTF/PythonScripts/WinpwnTest.py", line 18, in
p.sendline('99')
File "E:\anaconda\lib\site-packages\winpwn\winpwn.py", line 40, in sendline
return self.send(buf+newline)
File "E:\anaconda\lib\site-packages\winpwn\winpwn.py", line 34, in send
showbuf(buf)
File "E:\anaconda\lib\site-packages\winpwn\misc.py", line 141, in showbuf
os.write(sys.stdout.fileno(), Latin1_encode(buf))
UnsupportedOperation: fileno`
解决了,首先我的可执行文件路径写的是Windows风格的。然后是fileno这个问题直接用命令行去执行就不会有报错,用spyder去执行就会有这个报错,很迷。。