How hash3lizer/sillyrat works
Project type and purpose
• This is a cross-platform Remote Access Trojan (RAT) tool written in pure Python.
• It has two main roles:
a. server.py – the command-and-control server that binds to an IP:port, listens for incoming clients, and exposes a CLI to manage sessions.
b. client payloads – generated via the “generate” command (using pyinstaller or as a raw .py), which connect back to the server and execute remote commands (shell, sysinfo, screenshot, persistence, etc.).
File structure
• Top-level:
• server.py – entry point for server/C2 commands (bind, generate, sessions, connect, help).
• requirements.txt – dependencies (e.g., pyinstaller).
• mods/ – client‐side modules:
– main.py – client entry point (connects to server, dispatches commands).
– client.py – handles low-level network I/O and base64 encoding.
– sysinfo.py, screenshot.py, persistence.py – feature plugins.
– consts.py, imports.py – shared constants and dynamic imports.
• No database or external storage; all session info is in memory.
Key insights from README
• Two modes: “generate” (build payload) and “bind” (launch C2).
• Uses base64 over TCP, built-in shell, sysinfo dump, screenshot capture, persistence hooks.
• Pure Python, cross-platform – payloads must be built on target OS for executables.
Main components
a. Payload Generator
• Input: server.py CLI “generate” command + address/port flags
• Uses pyinstaller (or direct .py) to produce the client binary or script
b. C2 Server (server.py)
• CLI layer (bind, sessions, connect, help)
• Network listener (TCP socket)
• Session Manager (in-memory list of connected clients)
• Command Dispatcher (routes admin commands to specific client)
c. Client Payload (mods/main.py + mods/*.py)
• Network client (connects to server address:port, reconnect loop)
• Base64 encode/decode layer
• Plugin system (shell, sysinfo, screenshot, persistence)
d. External Libraries & Tools
• pyinstaller – for compiling payloads
• Python 3 stdlib – sockets, subprocess, system APIs
e. Network Layer
• TCP socket channel (bidirectional)
• Base64-encoded command/response protocol
Relationships & interactions
1. Admin runs server.py generate → Payload Generator → Output: payload.py or payload executable.
2. Admin runs server.py bind → C2 Server listens on TCP.
3. Payload launched on target host → mods/main.py connects back to C2.
4. C2 Server registers session → Session Manager tracks client ID.
5. Admin uses sessions / connect → Dispatches command via Network layer.
6. Client receives command → Plugin loader (imports.py → dispatches to the correct module) → Executes then returns result.
7. C2 displays output in admin CLI.
Architectural patterns & design principles
• Modular plugin architecture for client features (each feature in its own module).
• Single-threaded, event-loop style in both server and client (serialize commands over a socket).
• Separation of concerns: generator vs C2 vs client.
• In-memory session management (no persistence).