Disclaimer: This repository contains tools and scripts developed strictly for educational purposes as part of a Vulnerability Assessment and Penetration Testing (VAPT) course. Do not use these tools on systems or networks for which you do not have explicit authorization.
This repository contains the source code for a 3rd-year, 6th-semester capstone project in Vulnerability Assessment and Penetration Testing. The project demonstrates a complete data exfiltration lifecycle. It shows how a payload can establish a connection, download a secondary executable, maintain persistence, and exfiltrate specific local files (in this case, SSH keys) back to a control server.
The attack simulation consists of three main components working together:
- Command and Control (C2) Server: A Python-based server that hosts the secondary payload and listens for incoming stolen data.
- Initial Payload (Stager): A PowerShell script that runs on the target machine, downloads the main executable, and sets up a Windows Scheduled Task so the program runs repeatedly.
- Data Exfiltration Client: A compiled C program that silently compresses the user's
.sshdirectory and uploads the resulting ZIP archive to the C2 server.
receiver.py: A Python HTTP server. It serves two purposes: it allows the target to downloadclient.exevia a GET request, and it receives the exfiltrated ZIP files via a POST request. It uses therichlibrary to display a clear, formatted log of received data in the terminal.payload.ps1: The initial script executed on the target. It attempts to downloadclient.exefrom the Python server with built-in retry logic. Once downloaded, it executes the file silently and registers a scheduled task for persistence.reverse_shell.c: The source code forclient.exe. Despite the name, it functions as an exfiltration tool rather than a standard shell. When run, it executes a PowerShell command in memory to locate the.sshfolder, compress its contents into a ZIP archive, and upload it to the server.test.ps1: A minor test file indicating the expected server response format.
- Python 3.x installed on the attacker machine.
- The Python
richlibrary installed (pip install rich). - A C compiler (like GCC or MinGW) to compile the executable.
- A target machine running Windows (for the PowerShell scripts and executable).
- Open
reverse_shell.cin a text editor. - Change the
DEFAULT_IPto the IP address of the machine that will runreceiver.py. - Compile the C program into an executable named
client.exe. If using GCC, the command is:gcc reverse_shell.c -o client.exe
- Place the newly compiled
client.exein the same directory asreceiver.py. - Start the receiver server:
The server will start listening on port 8080 by default.
python receiver.py
- Open
payload.ps1and ensure the$clientUrlvariable matches the IP address of your Python server. - Transfer
payload.ps1to the target Windows machine. - Run the PowerShell script. It will download the client, execute the exfiltration routine, and send the data back to your Python server.
- File Transfer: Serving binaries over HTTP.
- Persistence: Creating scheduled tasks in Windows to maintain access.
- Data Compression: Zipping directories dynamically in memory.
- Data Exfiltration: Sending files out of a network via HTTP POST requests.
- Log Management: Structuring server-side logging for incoming connections and data validation.