MCPcopy Create free account
hub / github.com/Fadi002/de4py / inject_shell

Function inject_shell

de4py/utils/shell.py:47–68  ·  view source on GitHub ↗
(pid, bp=None)

Source from the content-addressed store, hash-verified

45 return -1
46
47def inject_shell(pid, bp=None):
48 pid, injector, pyshell_dll = _resolve_injector_paths(pid, bp)
49 if pid is None:
50 return (None, False)
51
52 if not injector.exists():
53 logger.error(f"Injector not found at {injector}")
54 return (None, False)
55
56 exit_code = execute_command([str(injector), str(pyshell_dll.absolute()), str(pid)])
57
58 if exit_code == 0:
59 time.sleep(1)
60 try:
61 handle = os.open('\\\\.\\pipe\\de4py', os.O_RDWR)
62 return (handle, True)
63 except OSError as e:
64 logger.error(f"Failed to open pipe: {e}")
65 return (None, False)
66 else:
67 logger.error(f"Injector failed with code {exit_code}")
68 return (None, False)
69
70def stealth_inject_shell(pid, bp=None):
71 pid, injector, pyshell_dll = _resolve_injector_paths(pid, bp)

Callers

nothing calls this directly

Calls 3

_resolve_injector_pathsFunction · 0.85
execute_commandFunction · 0.85
openMethod · 0.80

Tested by

no test coverage detected