Pymem icon indicating copy to clipboard operation
Pymem copied to clipboard

Python interpreter injection

Open Chassss opened this issue 1 year ago • 3 comments

Describe the bug Whenever injecting the python interpreter into any process theres a good 50/50 chance it'll crash the program, been dealing with this ever since 3.11 came out because i didnt wanna reinstall 3.10 specifically for pymem

Your Environment

  1. python version - happens in both 3.11.5 and 3.12.0
  2. os version - Windows 11 10.0.22621 Build 2261
  3. pymem version - 1.12.0 and 1.13.0 although version of pymem shouldnt matter

Expected behavior The python interpreter sucessfully injects without crashing the program

Traceback The only traceback that happens is

raise RuntimeError('Could not allocate memory for shellcode') RuntimeError: Could not allocate memory for shellcode

ctypes.getlasterror returns 5 (access denied) because the python interpreter crashed the program so its trying to write to a non existent process

theirs no traceback when injecting the python interpreter

Chassss avatar Nov 25 '23 20:11 Chassss

I've done some debugging on this and was able to reproduce the crashes with 3.12 but not 3.11; from what I've gathered from debugging the process we're injecting into it seems that the global object allocator is not being set for some reason

it should be getting set by our initialize call which I've confirmed is being called

StarrFox avatar Jan 17 '24 09:01 StarrFox

Is there any fix to this. I don't want to use any other lib for python as of now and injecting the interpreter seems to me as the only reason to use pymem.

It's because it's wayyy too good, but it doesn't work unfortunately.

devvratmiglani avatar Jun 19 '24 02:06 devvratmiglani