Skip to content

Commit c10dc73

Browse files
authored
Merge branch 'master' into update_Android_Intents__1_2___how_they_work__security__an_20251016_131954
2 parents 1286411 + 552cc55 commit c10dc73

File tree

41 files changed

+2171
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2171
-258
lines changed

.github/workflows/build_master.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,28 @@ jobs:
8282
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
8383
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
8484
85-
# Copy the .gz version to the searchindex repo
85+
# XOR encrypt the compressed file
86+
KEY='Prevent_Online_AVs_From_Flagging_HackTricks_Search_Gzip_As_Malicious_394h7gt8rf9u3rf9g'
87+
cat > /tmp/xor_encrypt.py << 'EOF'
88+
import sys
89+
key = sys.argv[1]
90+
input_file = sys.argv[2]
91+
output_file = sys.argv[3]
92+
with open(input_file, 'rb') as f:
93+
data = f.read()
94+
key_bytes = key.encode('utf-8')
95+
encrypted = bytearray(len(data))
96+
for i in range(len(data)):
97+
encrypted[i] = data[i] ^ key_bytes[i % len(key_bytes)]
98+
with open(output_file, 'wb') as f:
99+
f.write(encrypted)
100+
print(f"Encrypted: {len(data)} bytes")
101+
EOF
102+
python3 /tmp/xor_encrypt.py "$KEY" "${ASSET}.gz" "${ASSET}.gz.enc"
103+
104+
# Copy the encrypted .gz version to the searchindex repo
86105
cd /tmp/searchindex-repo
87-
cp "${GITHUB_WORKSPACE}/${ASSET}.gz" "${FILENAME}.gz"
106+
cp "${GITHUB_WORKSPACE}/${ASSET}.gz.enc" "${FILENAME}.gz"
88107
89108
# Stage the updated file
90109
git add "${FILENAME}.gz"

.github/workflows/translate_all.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,27 @@ jobs:
163163
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
164164
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
165165
166-
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
167-
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
166+
# XOR encrypt the compressed file
167+
KEY='Prevent_Online_AVs_From_Flagging_HackTricks_Search_Gzip_As_Malicious_394h7gt8rf9u3rf9g'
168+
cat > /tmp/xor_encrypt.py << 'EOF'
169+
import sys
170+
key = sys.argv[1]
171+
input_file = sys.argv[2]
172+
output_file = sys.argv[3]
173+
with open(input_file, 'rb') as f:
174+
data = f.read()
175+
key_bytes = key.encode('utf-8')
176+
encrypted = bytearray(len(data))
177+
for i in range(len(data)):
178+
encrypted[i] = data[i] ^ key_bytes[i % len(key_bytes)]
179+
with open(output_file, 'wb') as f:
180+
f.write(encrypted)
181+
print(f"Encrypted: {len(data)} bytes")
182+
EOF
183+
python3 /tmp/xor_encrypt.py "$KEY" "${ASSET}.gz" "${ASSET}.gz.enc"
184+
185+
# Copy ONLY the encrypted .gz version to the searchindex repo (no uncompressed .js)
186+
cp "${ASSET}.gz.enc" "/tmp/searchindex-repo/${FILENAME}.gz"
168187
169188
# Commit and push with retry logic
170189
cd /tmp/searchindex-repo
@@ -203,8 +222,8 @@ jobs:
203222
git config user.name "GitHub Actions"
204223
git config user.email "github-actions@github.com"
205224
206-
# Re-copy ONLY the .gz version (no uncompressed .js)
207-
cp "${ASSET}.gz" "${FILENAME}.gz"
225+
# Re-copy ONLY the encrypted .gz version (no uncompressed .js)
226+
cp "${ASSET}.gz.enc" "${FILENAME}.gz"
208227
209228
git add "${FILENAME}.gz"
210229
git commit -m "Update ${FILENAME}.gz from hacktricks-cloud build"

src/README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,6 @@ https://www.youtube.com/watch?v=Zq2JycGDCPM
163163

164164
---
165165

166-
### [Venacus](https://venacus.com/?utm_medium=link&utm_source=hacktricks&utm_campaign=spons)
167-
168-
<figure><img src="images/venacus-logo.svg" alt="venacus logo"><figcaption></figcaption></figure>
169-
170-
[**Venacus**](https://venacus.com/?utm_medium=link&utm_source=hacktricks&utm_campaign=spons) is a data breach (leak) search engine. \
171-
We provide random string search (like google) over all types of data leaks big and small --not only the big ones-- over data from multiple sources. \
172-
People search, AI search, organization search, API (OpenAPI) access, theHarvester integration, all features a pentester needs.\
173-
**HackTricks continues to be a great learning platform for us all and we're proud to be sponsoring it!**
174-
175-
{{#ref}}
176-
https://venacus.com/?utm_medium=link&utm_source=hacktricks&utm_campaign=spons
177-
{{#endref}}
178-
179-
---
180-
181166
### [CyberHelmets](https://cyberhelmets.com/courses/?ref=hacktricks)
182167

183168
<figure><img src="images/cyberhelmets-logo.png" alt="cyberhelmets logo"><figcaption></figcaption></figure>

src/SUMMARY.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
- [PDF File analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md)
6969
- [PNG tricks](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md)
7070
- [Structural File Format Exploit Detection](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/structural-file-format-exploit-detection.md)
71+
- [Svg Font Glyph Analysis And Web Drm Deobfuscation](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/svg-font-glyph-analysis-and-web-drm-deobfuscation.md)
7172
- [Video and Audio file analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md)
7273
- [ZIPs tricks](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md)
7374
- [Windows Artifacts](generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md)
@@ -268,6 +269,7 @@
268269
- [SeDebug + SeImpersonate copy token](windows-hardening/windows-local-privilege-escalation/sedebug-+-seimpersonate-copy-token.md)
269270
- [SeImpersonate from High To System](windows-hardening/windows-local-privilege-escalation/seimpersonate-from-high-to-system.md)
270271
- [Semanagevolume Perform Volume Maintenance Tasks](windows-hardening/windows-local-privilege-escalation/semanagevolume-perform-volume-maintenance-tasks.md)
272+
- [Service Triggers](windows-hardening/windows-local-privilege-escalation/service-triggers.md)
271273
- [Windows C Payloads](windows-hardening/windows-local-privilege-escalation/windows-c-payloads.md)
272274
- [Active Directory Methodology](windows-hardening/active-directory-methodology/README.md)
273275
- [Abusing Active Directory ACLs/ACEs](windows-hardening/active-directory-methodology/acl-persistence-abuse/README.md)
@@ -478,6 +480,7 @@
478480
- [disable_functions bypass - PHP 4 >= 4.2.0, PHP 5 pcntl_exec](network-services-pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-4-greater-than-4.2.0-php-5-pcntl_exec.md)
479481
- [Php Rce Abusing Object Creation New Usd Get A Usd Get B](network-services-pentesting/pentesting-web/php-tricks-esp/php-rce-abusing-object-creation-new-usd_get-a-usd_get-b.md)
480482
- [PHP SSRF](network-services-pentesting/pentesting-web/php-tricks-esp/php-ssrf.md)
483+
- [Perl Tricks](network-services-pentesting/pentesting-web/perl-tricks.md)
481484
- [PrestaShop](network-services-pentesting/pentesting-web/prestashop.md)
482485
- [Python](network-services-pentesting/pentesting-web/python.md)
483486
- [Rocket Chat](network-services-pentesting/pentesting-web/rocket-chat.md)
@@ -488,6 +491,7 @@
488491
- [Spring Actuators](network-services-pentesting/pentesting-web/spring-actuators.md)
489492
- [Symfony](network-services-pentesting/pentesting-web/symphony.md)
490493
- [Tomcat](network-services-pentesting/pentesting-web/tomcat/README.md)
494+
- [Telerik Ui Aspnet Ajax Unsafe Reflection Webresource Axd](network-services-pentesting/pentesting-web/telerik-ui-aspnet-ajax-unsafe-reflection-webresource-axd.md)
491495
- [Uncovering CloudFlare](network-services-pentesting/pentesting-web/uncovering-cloudflare.md)
492496
- [Vuejs](network-services-pentesting/pentesting-web/vuejs.md)
493497
- [VMWare (ESX, VCenter...)](network-services-pentesting/pentesting-web/vmware-esx-vcenter....md)
@@ -587,7 +591,6 @@
587591

588592
# 🕸️ Pentesting Web
589593

590-
- [Less Code Injection Ssrf](pentesting-web/less-code-injection-ssrf.md)
591594
- [Web Vulnerabilities Methodology](pentesting-web/web-vulnerabilities-methodology.md)
592595
- [Reflecting Techniques - PoCs and Polygloths CheatSheet](pentesting-web/pocs-and-polygloths-cheatsheet/README.md)
593596
- [Web Vulns List](pentesting-web/pocs-and-polygloths-cheatsheet/web-vulns-list.md)
@@ -668,6 +671,7 @@
668671
- [LDAP Injection](pentesting-web/ldap-injection.md)
669672
- [Login Bypass](pentesting-web/login-bypass/README.md)
670673
- [Login bypass List](pentesting-web/login-bypass/sql-login-bypass.md)
674+
- [Mass Assignment Cwe 915](pentesting-web/mass-assignment-cwe-915.md)
671675
- [NoSQL injection](pentesting-web/nosql-injection.md)
672676
- [OAuth to Account takeover](pentesting-web/oauth-to-account-takeover.md)
673677
- [Open Redirect](pentesting-web/open-redirect.md)
@@ -755,6 +759,7 @@
755759
- [JavaScript Execution XS Leak](pentesting-web/xs-search/javascript-execution-xs-leak.md)
756760
- [CSS Injection](pentesting-web/xs-search/css-injection/README.md)
757761
- [CSS Injection Code](pentesting-web/xs-search/css-injection/css-injection-code.md)
762+
- [LESS Code Injection](pentesting-web/xs-search/css-injection/less-code-injection.md)
758763
- [Iframe Traps](pentesting-web/iframe-traps.md)
759764

760765
# ⛈️ Cloud Security
@@ -855,6 +860,7 @@
855860
- [WWW2Exec - GOT/PLT](binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md)
856861
- [WWW2Exec - \_\_malloc_hook & \_\_free_hook](binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md)
857862
- [Common Exploiting Problems](binary-exploitation/common-exploiting-problems.md)
863+
- [Ksmbd Streams Xattr Oob Write Cve 2025 37947](binary-exploitation/linux-kernel-exploitation/ksmbd-streams_xattr-oob-write-cve-2025-37947.md)
858864
- [Linux kernel exploitation - toctou](binary-exploitation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md)
859865
- [PS5 compromission](binary-exploitation/freebsd-ptrace-rfi-vm_map-prot_exec-bypass-ps5.md)
860866
- [Windows Exploiting (Basic Guide - OSCP lvl)](binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# ksmbd streams_xattr OOB write → local LPE (CVE-2025-37947)
2+
3+
{{#include ../../banners/hacktricks-training.md}}
4+
5+
This page documents a deterministic out-of-bounds write in ksmbd streams handling that enables a reliable Linux kernel privilege escalation on Ubuntu 22.04 LTS (5.15.0-153-generic), bypassing KASLR, SMEP, and SMAP using standard kernel heap primitives (msg_msg + pipe_buffer).
6+
7+
- Affected component: fs/ksmbd/vfs.c — ksmbd_vfs_stream_write()
8+
- Primitive: page-overflow OOB write past a 0x10000-byte kvmalloc() buffer
9+
- Preconditions: ksmbd running with an authenticated, writable share using vfs streams_xattr
10+
11+
Example smb.conf
12+
13+
```ini
14+
[share]
15+
path = /share
16+
vfs objects = streams_xattr
17+
writeable = yes
18+
```
19+
20+
Root cause (allocation clamped, memcpy at unclamped offset)
21+
- The function computes size = *pos + count, clamps size to XATTR_SIZE_MAX (0x10000) when exceeded, and recomputes count = (*pos + count) - 0x10000, but still performs memcpy(&stream_buf[*pos], buf, count) into a 0x10000-byte buffer. If *pos ≥ 0x10000 the destination pointer is already outside the allocation, producing an OOB write of count bytes.
22+
23+
<details>
24+
<summary>Vulnerable function snippet (ksmbd_vfs_stream_write)</summary>
25+
26+
```c
27+
// https://elixir.bootlin.com/linux/v5.15/source/fs/ksmbd/vfs.c#L411
28+
static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, size_t count)
29+
{
30+
char *stream_buf = NULL, *wbuf;
31+
size_t size;
32+
...
33+
size = *pos + count;
34+
if (size > XATTR_SIZE_MAX) { // [1] clamp allocation, but...
35+
size = XATTR_SIZE_MAX;
36+
count = (*pos + count) - XATTR_SIZE_MAX; // [1.1] ...recompute count
37+
}
38+
wbuf = kvmalloc(size, GFP_KERNEL | __GFP_ZERO); // [2] alloc 0x10000
39+
stream_buf = wbuf;
40+
memcpy(&stream_buf[*pos], buf, count); // [3] OOB when *pos >= 0x10000
41+
...
42+
kvfree(stream_buf);
43+
return err;
44+
}
45+
```
46+
47+
</details>
48+
49+
Offset steering and OOB length
50+
- Example: set file offset (pos) to 0x10018 and original length (count) to 8. After clamping, count' = (0x10018 + 8) - 0x10000 = 0x20, but memcpy writes 32 bytes starting at stream_buf[0x10018], i.e., 0x18 bytes beyond the 16-page allocation.
51+
52+
Triggering the bug via SMB streams write
53+
- Use the same authenticated SMB connection to open a file on the share and issue a write to a named stream (streams_xattr). Set file_offset ≥ 0x10000 with a small length to generate a deterministic OOB write of controllable size.
54+
- libsmb2 can be used to authenticate and craft such writes over SMB2/3.
55+
56+
Minimal reachability (concept)
57+
```c
58+
// Pseudocode: send SMB streams write with pos=0x0000010018ULL, len=8
59+
smb2_session_login(...);
60+
smb2_open("\\\\host\\share\\file:stream", ...);
61+
smb2_pwrite(fd, payload, 8, 0x0000010018ULL); // yields 32-byte OOB
62+
```
63+
64+
Allocator behavior and why page shaping is required
65+
- kvmalloc(0x10000, GFP_KERNEL|__GFP_ZERO) requests an order-4 (16 contiguous pages) allocation from the buddy allocator when size > KMALLOC_MAX_CACHE_SIZE. This is not a SLUB cache object.
66+
- memcpy occurs immediately after allocation; post-allocation spraying is ineffective. You must pre-groom physical memory so that a chosen target lies immediately after the allocated 16-page block.
67+
- On Ubuntu, GFP_KERNEL often pulls from the Unmovable migrate type in zone Normal. Exhaust order-3 and order-4 freelists to force the allocator to split an order-5 block into an adjacent order-4 + order-3 pair, then park an order-3 slab (kmalloc-cg-4k) directly after the stream buffer.
68+
69+
Practical page shaping strategy
70+
- Spray ~1000–2000 msg_msg objects of ~4096 bytes (fits kmalloc-cg-4k) to populate order-3 slabs.
71+
- Receive some messages to punch holes and encourage adjacency.
72+
- Trigger the ksmbd OOB repeatedly until the order-4 stream buffer lands immediately before a msg_msg slab. Use eBPF tracing to confirm addresses and alignment if available.
73+
74+
Useful observability
75+
```bash
76+
# Check per-order freelists and migrate types
77+
sudo cat /proc/pagetypeinfo | sed -n '/Node 0, zone Normal/,/Node/p'
78+
# Example tracer (see reference repo) to log kvmalloc addresses/sizes
79+
sudo ./bpf-tracer.sh
80+
```
81+
82+
Exploitation plan (msg_msg + pipe_buffer), adapted from CVE-2021-22555
83+
1) Spray many System V msg_msg primary/secondary messages (4KiB-sized to fit kmalloc-cg-4k).
84+
2) Trigger ksmbd OOB to corrupt a primary message’s next pointer so that two primaries share one secondary.
85+
3) Detect the corrupted pair by tagging queues and scanning with msgrcv(MSG_COPY) to find mismatched tags.
86+
4) Free the real secondary to create a UAF; reclaim it with controlled data via UNIX sockets (craft a fake msg_msg).
87+
5) Leak kernel heap pointers by abusing m_ts over-read in copy_msg to obtain mlist.next/mlist.prev (SMAP bypass).
88+
6) With an sk_buff spray, rebuild a consistent fake msg_msg with valid links and free it normally to stabilize state.
89+
7) Reclaim the UAF with struct pipe_buffer objects; leak anon_pipe_buf_ops to compute kernel base (defeat KASLR).
90+
8) Spray a fake pipe_buf_operations with release pointing to a stack pivot/ROP gadget; close pipes to execute and gain root.
91+
92+
Bypasses and notes
93+
- KASLR: leak anon_pipe_buf_ops, compute base (kbase_addr) and gadget addresses.
94+
- SMEP/SMAP: execute ROP in kernel context via pipe_buf_operations->release flow; avoid userspace derefs until after disable/prepare_kernel_cred/commit_creds chain.
95+
- Hardened usercopy: not applicable to this page overflow primitive; corruption targets are non-usercopy fields.
96+
97+
Reliability
98+
- High once adjacency is achieved; occasional misses or panics (<10%). Tuning spray/free counts improves stability. Overwriting two LSBs of a pointer to induce specific collisions was reported as effective (e.g., write 0x0000_0000_0000_0500 pattern into the overlap).
99+
100+
Key parameters to tune
101+
- Number of msg_msg sprays and hole pattern
102+
- OOB offset (pos) and resulting OOB length (count')
103+
- Number of UNIX socket, sk_buff, and pipe_buffer sprays during each stage
104+
105+
Mitigations and reachability
106+
- Fix: clamp both allocation and destination/length or bound memcpy against the allocated size; upstream patches track as CVE-2025-37947.
107+
- Remote exploitation would additionally require a reliable infoleak and remote heap grooming; this write-up focuses on local LPE.
108+
109+
References PoC and tooling
110+
- libsmb2 for SMB auth and streams writes
111+
- eBPF tracer script to log kvmalloc addresses and histogram allocations (e.g., grep 4048 out-4096.txt)
112+
- Minimal reachability PoC and full local exploit are publicly available (see References)
113+
114+
## References
115+
- [ksmbd - Exploiting CVE-2025-37947 (3/3) — Doyensec](https://blog.doyensec.com/2025/10/08/ksmbd-3.html)
116+
- [libsmb2](https://github.com/sahlberg/libsmb2)
117+
- [KSMBD-CVE-2025-37947: proof-of-concept.c](https://github.com/doyensec/KSMBD-CVE-2025-37947/blob/main/proof-of-concept.c)
118+
- [KSMBD-CVE-2025-37947: CVE-2025-37947.c (full exploit)](https://github.com/doyensec/KSMBD-CVE-2025-37947/blob/main/CVE-2025-37947.c)
119+
- [bpf-tracer.sh](https://github.com/doyensec/KSMBD-CVE-2025-37947/blob/main/bpf-tracer.sh)
120+
121+
{{#include ../../banners/hacktricks-training.md}}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,15 @@ Audit hotspots (for reviewers)
205205
Notes for exploitation research
206206
- The disclosed behavior is a reliable kernel crash primitive; turning it into privilege escalation typically needs an additional controllable overlap (object lifetime or write-what-where influence) beyond the scope of this summary. Treat any PoC as potentially destabilizing and run only in emulators/VMs.
207207

208+
### See also
209+
210+
{{#ref}}
211+
ksmbd-streams_xattr-oob-write-cve-2025-37947.md
212+
{{#endref}}
213+
208214
## References
209215
- [Race Against Time in the Kernel’s Clockwork (StreyPaws)](https://streypaws.github.io/posts/Race-Against-Time-in-the-Kernel-Clockwork/)
210216
- [Android security bulletin – September 2025](https://source.android.com/docs/security/bulletin/2025-09-01)
211217
- [Android common kernel patch commit 157f357d50b5…](https://android.googlesource.com/kernel/common/+/157f357d50b5038e5eaad0b2b438f923ac40afeb%5E%21/#F0)
212218

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

src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pdf-file-analysis.md
3535
{{#endref}}
3636

3737

38+
{{#ref}}
39+
svg-font-glyph-analysis-and-web-drm-deobfuscation.md
40+
{{#endref}}
41+
42+
3843
{{#ref}}
3944
structural-file-format-exploit-detection.md
4045
{{#endref}}

0 commit comments

Comments
 (0)