google / pyringe

Debugger capable of attaching to and injecting code into python processes.
Other
1.63k stars 78 forks source link

WindowsError: [Error 2] The system cannot find the file specified #25

Closed DashLt closed 7 years ago

DashLt commented 7 years ago

When attempting to inject into either a process that runs on python, or a normal python.exe interpreter, I get the error:

  File "<console>", line 1, in <module>  
  File "C:\Python27\lib\site-packages\pyringe\repl.py", line 157, in Attach
    self.inferior.Reinit(pid)  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 480, in Reinit  
    self.__init__(pid, auto_symfile_loading)  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 452, in __init__  
    self.StartGdb()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 498, in StartGdb  
    self._gdb = GdbProxy()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 134, in __init__  
    gdb_version = GdbProxy.Version()  
  File "C:\Python27\lib\site-packages\pyringe\inferior.py", line 237, in Version  
    output = subprocess.check_output(['gdb', '--version']).split('\n')[0]  
  File "C:\Python27\lib\subprocess.py", line 212, in check_output  
    process = Popen(stdout=PIPE, *popenargs, **kwargs)  
  File "C:\Python27\lib\subprocess.py", line 390, in __init__  
    errread, errwrite)  
  File "C:\Python27\lib\subprocess.py", line 640, in _execute_child  
    startupinfo)  
WindowsError: [Error 2] The system cannot find the file specified  
WARNING:root:Inferior is not running.

I'm running Windows 10 on Python 2.7.13.

DashLt commented 7 years ago

I've narrowed it down to a problem with GDB. I've put this binary everywhere I could think it could go (system32, lib/pyringe, lib), changed gdb to gdb.exe, and changed split('\n')[0], to split('\n')[1] since the first line is now:

This binary was built by Equation Solution http://www.Equation.com.

I still have the same error though. Could this be a problem with subprocess?

DashLt commented 7 years ago

Figured it out. Steps to solve:

  1. Download MinGW
  2. Launch installer and wait for packages to download.
  3. In the package selector, go to All Packages, find mingw32-gdb-python, and select it.
  4. Go to file and apply changes.
  5. Navigate to the bin folder in the installation directory (default C:\MinGW), and rename gdb and gdbserver as to remove python-2.7 from their names.
  6. Go to Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables and add the bin folder to the PATH.
BazoShifteight commented 3 years ago

Hi, I am having the same issue, but I am not getting the last line "WARNING:root:Inferior is not running", I get the following traceback :

File "c:/Users/UserOne/Documents/FolderA/FolderB/FolderC/FolderD/ocr.py", line 675, in
digitL, lengthL = DigitSearch(cntL, rectL) File "c:/Users/UserOne/Documents/FolderA/FolderB/FolderC/FolderD/ocr.py", line 451, in DigitSearch
digit, length = TesseractOCR(cnt, rect) File "c:/Users/UserOne/Documents/FolderA/FolderB/FolderC/FolderD/ocr.py", line 256, in TesseractOCR
digit_str = (pytesseract.image_to_string(Image.open(i))) File "C:\Users\UserTwo\anaconda3\envs\virenvTest3\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string config=config) File "C:\Users\UserTwo\anaconda3\envs\virenvTest3\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE) File "C:\Users\UserTwo\anaconda3\envs\virenvTest3\lib\subprocess.py", line 394, in init errread, errwrite) File "C:\Users\UserTwo\anaconda3\envs\virenvTest3\lib\subprocess.py", line 644, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified

After following steps 1-6 I'm still getting the same error. Do I need to carry out both the suggestions from the "I've narrowed it down" post and the steps from the "Figured it out."? Any help will be much appreciated.