Remote administration tool for Windows.
Aufheben is a Python-based RAT demonstrating C2 concepts, Windows persistence mechanisms, and post-exploitation techniques. Built to understand how malware operates and how to defend against it. This is basically an old tool i made when i was understanding red team concepts and i thought i'd post it. Enjoy :).
Note: This is a learning project. The code intentionally contains limitations (Such as the persistence path being in desktop). Production malware is significantly more complex and stealthy.
C2 Communication:
- AES-CTR encryption (static key for demo)
- Custom binary protocol
- 6-byte length headers
0xFEEDBEEFFACEheartbeat signal- Multi-client session management
- Automatic reconnection
Client Capabilities:
- File upload/download with streaming
- Command execution (visible/hidden)
- Interactive shell (cmd/powershell switching)
- Screenshot capture (PNG format)
- Process enumeration
- Recursive file search
- Keylogger (captures keystrokes)
- Clipboard logger (monitors copy/paste)
- Microphone recording
- Windows event log clearing (System/Application/Security)
Persistence & Privilege Escalation:
- Windows Task Scheduler integration
- UAC bypass via fodhelper technique
- Automatic privilege detection
- Mutex-based duplicate prevention
- Remote update mechanism
- Self-destruct with cleanup
Stealth Features:
- Background execution (no console window)
- Hidden file placement
- Encrypted communications
- Heartbeat instead of constant polling
- Configurable persistence intervals
Python 3.8+
Windows OS
pip install -r requirements.txtpython Aufheben_server.pyServer binds to 127.0.0.1:80 by default. Edit source to change.
Deployment:
pyinstaller -F Aufheben_client.py --noconsole --name Aufheben if you don't have pyinstaller, install it with
pip install pyinstallerImportant: Persistence and elevation commands require a compiled .exe.
However if you do want to run Aufheben_client.py without compiling to an .exe comment out the self.migrate() function.
(You would need to have Loggers.py in the same directory in that case)
help - Command list
cd <path> - Change directory
ls - List directory
pwd - Current directory
download <file> - Download file
upload <file> - Upload file
execute <cmd> - Execute command
--DISPLAY - Show output
--LOG - Save output
cmd - Interactive shell
screenshot - Take screenshot
list_proc - List processes
search <ext> <path> - Find files
start_keylogger - Start keylogger
stop_keylogger - Stop and dump
start_cliplogger - Start clipboard logger
stop_cliplogger - Stop and dump
record_mic <sec> - Record audio
persist - Add persistence
update <file> - Update client
self_destruct - Remove client
check_priv - Check privileges
clear_logs - Clear event logs (admin)
bg - Background session
exit - Close connection
sessions - List active sessions
interact <id> - Interact with session
elevate <id> - UAC bypass attempt
elevate_all - UAC bypass all
kill <id> - Terminate session
deploy <file> - Upload/execute on all
--DISPLAY - Show output
--LOG - Save output
--DELETE - Remove after execution
broadcast <cmd> - Execute on all
start_loggers - Start all loggers
stop_loggers - Stop all loggers
update_all <file> - Update all clients
quit - Exit server
The migrate() function handles initial setup and persistence:
- Privilege Detection: Checks if running with admin rights using
IsUserAnAdmin() - File Placement:
- Admin: Copies to
%TEMP%\Aufheben.exe(hidden system directory) - User: Copies to
%USERPROFILE%\Desktop\Aufheben.exe(visible but accessible)
- Admin: Copies to
- Mutex Check: Creates mutex
User_Task5@#to prevent duplicate instances - Task Scheduler Setup: Registers scheduled task for persistence
Important: Migration is currently commented out in activate() because:
- Only works when compiled to
.exe(not Python scripts) - Task Scheduler requires absolute path to executable
- Python interpreter path handling is complex
To enable: Uncomment self.migrate() in the activate() method, then compile with PyInstaller.
The get_external_ip() function has a placeholder:
external_ip = b"ip slot here" # IP LOOKUP CODE GOES HEREThis is intentionally blank. you can add any ip collection method of your choice
Why it's blank: Avoids leaking specific IP lookup services used during development. Also demonstrates that this is demo code, not production malware.
Uses PyCryptodome's AES implementation in CTR mode:
socket_key = b"x\x83\xe1RW\xff\xf1k\xbf\x94\xdef\x88\x8fn\x13:\x9f\xf4\xa5\xf7\x93\xf0l" # Default key. Place your AES key here 16, 24 or 32 bytesTwo trigger types used:
Type 7 (TASK_TRIGGER_LOGON):
- Fires when user logs in
- Used for standard users
- Visible in user's task list
Type 9 (TASK_TRIGGER_BOOT):
- Fires at system boot
- Used for admin/SYSTEM
- Runs before user login
- Located in
\Microsoft\folder (less visible)
Repetition Interval: PT5M (every 5 minutes)
- If process dies, task restarts it within 5 minutes
- Ensures persistence despite crashes
Exploits Windows 10/11 fodhelper.exe (Manage Optional Features):
- Modify registry:
HKCU\Software\Classes\ms-settings\Shell\Open\command - Set
DelegateExecute= "" (empty string) - Set default value to payload path
- Execute
fodhelper.exe(auto-elevates without UAC prompt) - Payload runs with high integrity
The version_control() function handles cleanup:
- Create temporary scheduled task "AufhebenCleanup"
- Set task to run 5 seconds after creation
- Task executes:
cmd /c del [current exe] & schtasks /delete /tn AufhebenCleanup /f - Original process exits
- Task deletes the file and removes itself
- Clean removal with no traces
Why scheduled task? Process can't delete its own running executable. Task waits for process to exit, then deletes file.
Remote update process:
- Server uploads new executable to
%APPDATA% - Client creates "AufhebenCleanup" task
- Task deletes old executable, starts new one, removes itself
- New version begins running
- Old persistence removed, new persistence created
Allows updating deployed clients without manual access.
Uses Windows Task Scheduler:
- Admin: Runs as SYSTEM, stores in
%TEMP%, trigger type 9 (boot) - User: Runs as current user, stores on Desktop, trigger type 7 (logon)
Repeats every 5 minutes if process dies.
Limitation: Only works when compiled to .exe (not Python script).
Uses fodhelper technique:
- Modifies
HKCU\Software\Classes\ms-settings\Shell\Open\command - Triggers
FodHelper - Executes with elevated privileges
Success indicated by trigger type 9 in Task Scheduler.
Problem: migrate() is commented out by default
Why: Task Scheduler needs absolute path to executable:
action.Path = str(self.persistent_exe) # Must be .exe, not .pySolution: Compile first, then uncomment self.migrate() in activate()
Technical reason: Windows Task Scheduler can't execute Python scripts directly. It needs:
- Valid PE executable
- Absolute path (no relative paths)
- .exe extension
This tool was built for the purposes of understanding C2 architecture and Windows internals. I hope you find it useful. If you find bugs or have questions, open an issue. Till then see ya.
This project is for educational/research purposes only. I'm not responsible if you do illegal stuff with it.