Introduzione
ip = 10.10.10.229Enumerazione
Iniziamo con uno scan di nmap delle prime 1000 tcp.
Bash:
Nmap scan report for 10.10.10.229
Host is up (0.12s latency).
Not shown: 997 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.1 (protocol 2.0)
| ssh-hostkey:
|_ 4096 52:47:de:5c:37:4f:29:0e:8e:1d:88:6e:f9:23:4d:5a (RSA)
80/tcp open http nginx 1.17.4
|_http-server-header: nginx/1.17.4
3306/tcp open mysql MySQL (unauthorized)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.80%E=4%D=6/7%OT=22%CT=1%CU=44350%PV=Y%DS=2%DC=T%G=Y%TM=629FBD9F
OS:%P=x86_64-pc-linux-gnu)SEQ(SP=105%GCD=1%ISR=109%TI=Z%CI=Z%II=I%TS=A)SEQ(
OS:SP=105%GCD=2%ISR=108%TI=Z%CI=Z%TS=A)OPS(O1=M508ST11NW7%O2=M508ST11NW7%O3
OS:=M508NNT11NW7%O4=M508ST11NW7%O5=M508ST11NW7%O6=M508ST11)WIN(W1=FE88%W2=F
OS:E88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%DF=Y%T=40%W=FAF0%O=M508NNSNW
OS:7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF
OS:=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=
OS:%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=
OS:0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RI
OS:PCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
Network Distance: 2 hops
TRACEROUTE (using port 993/tcp)
HOP RTT ADDRESS
1 242.03 ms 10.10.14.1
2 242.17 ms 10.10.10.229
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Poi facciamo uno scan di tutte le porte tcp.
Bash:
Starting Nmap 7.80 ( https://nmap.org ) at 2022-06-13 23:00 CEST
Nmap scan report for spectra.htb (10.10.10.229)
Host is up (0.11s latency).
Not shown: 41968 closed ports, 23564 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql
Nmap done: 1 IP address (1 host up) scanned in 45.09 seconds
E infine facciamo uno scan udp con la flag
-sU
per capire se ci sono servizi che ascoltano su udp.
Bash:
Nmap 7.80 scan initiated Mon Jun 13 23:04:27 2022 as: nmap -T5 -sU -o nmap/udp.log 10.10.10.229
Warning: 10.10.10.229 giving up on port because retransmission cap hit (2).
Nmap scan report for spectra.htb (10.10.10.229)
Host is up (0.10s latency).
All 1000 scanned ports on spectra.htb (10.10.10.229) are closed (699) or open|filtered (301)
Nmap done at Mon Jun 13 23:17:51 2022 -- 1 IP address (1 host up) scanned in 803.81 seconds
Andando sul sito hostato nel server.
Ci sono 2 pagine.
- Software Issue Tracker
- Test
Nella cartella test c'è un backup di wp-config
E da questo file possiamo ottenere delle credenziali per mysql
user: devtest
passwd: devteam01
Provando ad entrare in mysql nel database di wordpress mi dice che le credenziali sono errate.
Provando ad entrare con ssh mi da credenziali errate quindi ho provato ad andare nell'altra cartella.
Ho scoperto che Software Issue Tracker è un sito wordpress.
L'hostname è
spectra.htb
Guardando il post chiamato Hello Word! ho scoperto che l'username è administrator.
Exploitation
Ho provato a loggarmi con la password che abbiamo trovato in precedenza e siamo dentro wordpress.
Possiamo modificare un tema e mettere php reverse shell e cosi otteniamo una shell.
PrivEsc
Bash:
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Automatic login at boot"
author "[email protected]"
# After boot-complete starts, the login prompt is visible and is accepting
# input.
start on started boot-complete
script
passwd=
# Read password from file. The file may optionally end with a newline.
for dir in /mnt/stateful_partition/etc/autologin /etc/autologin; do
if [ -e "${dir}/passwd" ]; then
passwd="$(cat "${dir}/passwd")"
break
fi
done
if [ -z "${passwd}" ]; then
exit 0
fi
# Inject keys into the login prompt.
#
# For this to work, you must have already created an account on the device.
# Otherwise, no login prompt appears at boot and the injected keys do the
# wrong thing.
/usr/local/sbin/inject-keys.py -s "${passwd}" -k enter
Andando nella cartella /etc/autologin ho trovato il file passwd
Codice:
SummerHereWeCome!!
Questa password è la stessa dell'utente katie.
Ma quando ho provando ad usare su mi da un errore di libreria quindi bisogna usare ssh per entrare come katie.
E adesso siamo dentro e abbiamo una user.
Vedendo i permessi di katie può eseguire initctl come root.
Poi usando
id
ho scoperto che katie fa parte del gruppo developers che ha accesso a dei file .confI file .conf sono usati da initctl per caricare dei servizi quindi modificando un file .conf possiamo eseguire codice.
Iniziamo modificando
/etc/init/test.conf
, cancelliamo tutto e inseriamo un comando per far diventare bash un suidPoi facciamo partire il servizio test con
sudo /sbin/initctl start test
e otteniamo una shell da root.E abbiamo finito la box.