C2
c2 server using Django
Install / Use
/learn @hsjafari/C2README
C2-v2.0 Django Project
This project is a Command & Control (C2) server built with Django. It provides several API endpoints for agent registration, command delivery, result submission, and file upload. The server uses HTTPS for secure communication. <img width="1916" height="927" alt="Screenshot from 2025-08-23 18-25-35" src="https://github.com/user-attachments/assets/cd9a9aaa-1b04-4538-af06-2e4b7d53ac3c" /> <img width="1916" height="927" alt="Screenshot from 2025-08-23 18-28-36" src="https://github.com/user-attachments/assets/f950069d-eb72-4196-816b-6fa0877f8c03" /> <img width="1916" height="927" alt="Screenshot from 2025-08-23 18-28-50" src="https://github.com/user-attachments/assets/e03ef31e-b0da-44a6-8b25-e6f098c859f6" />
Features
- Agent registration and persistence check
- Command delivery to agents
- Result submission from agents
- File upload support
- Secure HTTPS server
API Endpoints
POST /reg/
Parameters:
ComputerName(string): Name of the computerFQDNUser(string): FQDN userhash_id(string): Unique agent ID
Response:
{
"status": "true",
"isPersisted": "<true|false>"
}
POST /is_per/
Parameters:
hash_id(string): Unique agent ID
Response:
{
"status": "true"
}
POST /get_cmd/
Parameters:
hash_id(string): Unique agent ID
Response:
{
"command": "<command string>",
"id": "<command id>"
}
POST /send_res/
Parameters:
hash_id(string): Unique agent IDresult(string): Command result
Response:
{
"status": "result saved"
}
POST /upload/
Parameters:
- File upload parameters (see implementation)
Response: Standard file upload response
Running the Server
To run the server with HTTPS enabled:
python3 manage.py runserver_plus --cert-file cert.pem --key-file key.pem 0.0.0.0:8000
Generating SSL Certificate and Key
To generate a self-signed certificate and key for development, use the following command:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost"
This will create cert.pem and key.pem files in your project directory. Use these files to run the server securely..
Requirements
Install dependencies with:
pip install -r requirements.txt
License
MIT License
