Discussione Spectra - HackTheBox walkthrough [easy]

monnezzza

Utente Silver
11 Marzo 2021
119
23
52
86
Introduzione
ip = 10.10.10.229
Enumerazione
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
1655154648963.png


Nella cartella test c'è un backup di wp-config

1655154885626.png

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
1655155612070.png


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.

1655155968152.png


Possiamo modificare un tema e mettere php reverse shell e cosi otteniamo una shell.


1655156634046.png


PrivEsc
Cercando nella cartella /opt ho trovato un file config

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.

1655199946520.png


Vedendo i permessi di katie può eseguire initctl come root.
1655200313810.png


Poi usando id ho scoperto che katie fa parte del gruppo developers che ha accesso a dei file .conf
I file .conf sono usati da initctl per caricare dei servizi quindi modificando un file .conf possiamo eseguire codice.
1655200966981.png

Iniziamo modificando /etc/init/test.conf, cancelliamo tutto e inseriamo un comando per far diventare bash un suid
1655203624860.png


Poi facciamo partire il servizio test con sudo /sbin/initctl start test e otteniamo una shell da root.

1655203461601.png

E abbiamo finito la box.
 

Allegati

  • 1655201527216.png
    1655201527216.png
    56.5 KB · Visualizzazioni: 7
  • 1655201609139.png
    1655201609139.png
    60.7 KB · Visualizzazioni: 7
  • 1655201904657.png
    1655201904657.png
    31.3 KB · Visualizzazioni: 6
  • 1655203414278.png
    1655203414278.png
    10.1 KB · Visualizzazioni: 6
  • Mi piace
  • Incredibile
Reazioni: 0xbro e Conti