Networked
Source-backed referenceA photo upload becomes PHP code. A cleanup job turns a filename into a shell command. A sudo helper turns a network setting into root execution. Three small trust-boundary failures form one complete chain.
- 1. Public source
/backup/backup.tarThe build places four web-source files inside the document root. - 2. Web execution
shell.php.gif → apacheThe suffix survives renaming; Apache explicitly maps embedded .php. to PHP. - 3. Scheduled execution
filename → shell → gullyA three-minute cleanup job concatenates an unquoted path into exec(). - 4. Root execution
input → ifcfg → rootSudo authorizes a helper whose generated config is sourced by ifup.
The scenario
The supplied lab recreates the HTB “Networked” attack chain using a CentOS 7 container, Apache, PHP, cron, and a deliberately unsafe network-configuration helper. The landing page is sparse, while the upload and gallery pages are not linked from it.
The intended route starts with a publicly served backup, reaches the Apache worker through an uploaded PHP-bearing file, becomes gully through a cron command-injection bug, and finally crosses a sudo boundary into container root. The two flag files mark the latter two stages.
Review only—nothing was run
The local web source, scripts, Docker configuration, entrypoint, README, readable text copies, and temporary PHP copies were inspected. Public documentation and upstream network-script source were read for context. No supplied file was executed, no Docker image was built or started, and no request was sent to a lab endpoint. The PDF could not be previewed in this environment and was not used as independent evidence.
What a complete solve means
- Explain how a file can look like an image to one component and execute as PHP to another.
- Follow the exact stored filename, rather than guess the client address visible to the container.
- Connect writable directory entries to a scheduled command running under a different account.
- Locate the actual shell parse in the root path: sourcing the generated configuration.
- Distinguish source-supported behavior, README-reported results, and runtime proof not collected here.
The central idea
Data is not harmless just because it is called a photo, a filename, or a network setting. Follow how the next component interprets it.
The central correction
The upload checks print rejection messages but do not terminate. The recreation is weaker than the README's “bypass the checks” description suggests.
Reveal lab-only credentials and default flag values
The Dockerfile creates gully with password gully. This is a training credential, not a recovered secret. No SSH server is installed or published by the supplied configuration.
Compose defaults FLAG to the following 32-character string. The entrypoint writes its first half to the user file and its remainder to the root file. These are defaults derived from configuration, not flags read from a running container.
0123456789abcdef0123456789abcdef| File | Default contents, before newline | Configured access |
|---|---|---|
/home/gully/user.txt | 0123456789abcdef | Owner gully:gully, mode 0400. |
/root/root.txt | 0123456789abcdef | Written by the root entrypoint, mode 0400. |
A custom FLAG changes both parts. The split point is length / 2 rounded down, so an odd-length value leaves the extra character in the root part.