MCPcopy Index your code
hub / github.com/ELMERIKH/PyinMemoryPE / execute_python_code

Function execute_python_code

windows/injection.py:388–402  ·  view source on GitHub ↗
(process, code)

Source from the content-addressed store, hash-verified

386
387
388def execute_python_code(process, code):
389 # Cache the value ?
390 py_dll_name = get_dll_name_from_python_version()
391 pydll_path = find_python_dll_to_inject(process.bitness)
392 if sys.version_info.major == 3:
393 # FOr py3, we may have a per-user install.
394 # Meaning that the vcruntime140.dll will not be in the injected process path
395 # Find it & load-it as well, it should be in the same directory as pythonxx.dll
396 vc_runtime_dll = os.path.join(os.path.dirname(pydll_path), "vcruntime140.dll")
397 load_dll_in_remote_process(process, vc_runtime_dll)
398 # Try to inject the vcrunt
399 load_dll_in_remote_process(process, pydll_path)
400 shellcode, pythoncode = inject_python_command(process, code, py_dll_name)
401 t = process.create_thread(shellcode, pythoncode)
402 return t
403
404
405retrieve_exc = r"""

Callers 2

safe_execute_pythonFunction · 0.85

Calls 5

inject_python_commandFunction · 0.85
create_threadMethod · 0.45

Tested by

no test coverage detected