Forensicsmedium
Cloudy with a Chance of Breach
by Pavel Knespl (capyplivl)
An incident response challenge on a compromised monitoring server. An attacker hit a command injection bug in a Flask app, gained root, and left AWS credentials behind. Recovering those creds gives access to a private S3 bucket holding the flag.
Solve
- Read the monitoring app at
/opt/netmon/app.pyand find the command injection in thelookupfunction (raw input passed tonslookupwithshell=True). - Review
~/.bash_historyand/etc/cron.d/netmon-backupto learn that logs sync to an S3 bucket namedmeridian-netmon-logs. - Find the leaked AWS credentials the attacker dropped in
/tmp/creds_bkp_4e8f21.txt. - Configure the environment with the discovered credentials:
export AWS_ACCESS_KEY_ID="AKIAZPCYMLDLEN2D7AWH" export AWS_SECRET_ACCESS_KEY="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" export AWS_DEFAULT_REGION="us-east-1" - List the bucket directly to work around restricted permissions:
aws s3 ls s3://meridian-netmon-logs/ - Download and read the flag:
aws s3 cp s3://meridian-netmon-logs/flag.txt -
Flag: SVIUSCG{l00ks_4_l1ttl3_cl0udy}