Winpexpect超时,因为未从生成器接收任何数据

我正在尝试为需要动态分析才能解决的恶意软件类别的“游戏”输入自动化。需要说明的是,我已经解决了游戏问题,我现在正尝试使用python自动执行该过程,而不是使用Ida的调试器手动检查代码。

我正在使用winpexpect,在pexpect的文档中,推荐Windows用户(该文件是32位Windows可执行文件)使用。它正在等待直到子进程输出超时,但是从不接收任何东西。我正在使用的相关代码:

from winpexpect import winspawn as spawn
from sys import stdout
from time import time
from numpy import uint32

child = spawn('TheGame_3.exe')
child.logfile_read = stdout

child.expect('Enter your name: ')
child.sendline('')
child.expect('Enter your choice: ')
child.sendline('3')

等我尝试编写一个简单的脚本来运行,此代码似乎可以完美地工作:

print(input('Enter your name: '))
print(input('Enter your choice: '))

但是当我在实际的exe上运行它时,会出现此错误(Mr-Windy是Windows VM的用户):

Traceback (most recent call last):
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\site-packages\winpexpect.py",line 541,in read_nonblocking
    handle,status,data = self.child_output.get(timeout=timeout)
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\queue.py",line 178,in get
    raise Empty
_queue.Empty

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\site-packages\pexpect.py",line 1378,in expect_loop
    c = self.read_nonblocking (self.maxread,timeout)
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\site-packages\winpexpect.py",line 543,in read_nonblocking
    raise TIMEOUT('Timeout exceeded in read_nonblocking().')
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Mr-Windy\Documents\NPS\Lab6\DirectedInput.py",line 12,in <module>
    child.expect('Enter your name: ')
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\site-packages\pexpect.py",line 1311,in expect
    return self.expect_list(compiled_pattern_list,timeout,searchwindowsize)
  File "C:\Users\Mr-Windy\AppData\Local\Programs\Python\Python37\lib\site-packages\pexpect.py",line 1325,in expect_list
    return self.expect_loop(searcher_re(pattern_list),line 1409,in expect_loop
    raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
<winpexpect.winspawn object at 0x000002869CFC5C88>
version: 2.3 ($Revision: 399 $)
command: TheGame_3.exe
args: ['TheGame_3.exe']
searcher: searcher_re:
    0: re.compile("Enter your name: ")
buffer (last 100 chars): 
before (last 100 chars): 
after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 7696
child_fd: 3
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1

...似乎表明没有任何内容写入标准输出。可执行文件打印到stdout并在正常执行时通过stdin接受输入,所以我真的很困惑我做错了什么。

感谢您的帮助。预先谢谢你。

baobeicuijina 回答:Winpexpect超时,因为未从生成器接收任何数据

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2648806.html

大家都在问