Skip to content

Commit a06174c

Browse files
authored
Merge pull request #1540 from HackTricks-wiki/update_ShareHound__An_OpenGraph_Collector_for_Network_Sha_20251030_182759
ShareHound An OpenGraph Collector for Network Shares
2 parents 7298a06 + d6c9251 commit a06174c

File tree

1 file changed

+70
-1
lines changed
  • src/network-services-pentesting/pentesting-smb

1 file changed

+70
-1
lines changed

src/network-services-pentesting/pentesting-smb/README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,74 @@ Specially interesting from shares are the files called **`Registry.xml`** as the
365365
> You should **check** the **scripts** inside of it as you might **find** sensitive info such as **passwords**. Also, don’t trust automated share listings: even if a share looks read-only, the underlying NTFS ACLs may allow writes. Always test with smbclient by uploading a small file to `\\<dc>\\SYSVOL\\<domain>\\scripts\\`.
366366
> If writable, you can [poison logon scripts for RCE at user logon](../../windows-hardening/active-directory-methodology/acl-persistence-abuse/README.md#sysvolnetlogon-logon-script-poisoning).
367367
368+
### ShareHound – OpenGraph collector for SMB shares (BloodHound)
369+
370+
[ShareHound](https://github.com/p0dalirius/sharehound) discovers domain SMB shares, traverses them, extracts ACLs, and emits an OpenGraph JSON file for BloodHound CE/Enterprise.
371+
372+
- Baseline collection:
373+
1) LDAP: enumerate computer objects, read `dNSHostName`
374+
2) DNS: resolve each host
375+
3) SMB: list shares on reachable hosts
376+
4) Crawl shares (BFS/DFS), enumerate files/folders, capture permissions
377+
378+
ShareQL-driven traversal
379+
- [ShareQL](https://github.com/p0dalirius/shareql) is a first-match-wins DSL to allow/deny traversal by host/share/path and set per-rule max depth. Focus on interesting shares and cap recursion.
380+
381+
Example ShareQL rules
382+
```text
383+
# Only crawl shares with name containing "backup", up to depth 2
384+
allow host * share * path * depth 0
385+
allow host * share *backup* path * depth 2
386+
deny host * share * path *
387+
```
388+
389+
Usage
390+
```bash
391+
sharehound -ai "10.0.100.201" -au "user" -ap "Test123!" -ns "10.0.100.201" \
392+
-rf "rules/skip_common_shares.shareql" -rf "rules/max_depth_2.shareql"
393+
```
394+
- Provide AD creds via `-ad`/`-au`/`-ap` (or use `-ad` with `-au`/`-ap`). Use `-r`/`-rf` for inline rules or files.
395+
- Output: JSON OpenGraph; import in BloodHound to query hosts/shares/files and effective rights.
396+
- Tip: Limit max depth to 1–2 unless your filters are very restrictive.
397+
398+
BloodHound attack-surface queries
399+
- Principals with write-like access on shares
400+
```cypher
401+
MATCH x=(p)-[r:CanWriteDacl|CanWriteOwner|CanDsWriteProperty|CanDsWriteExtendedProperties]->(s:NetworkShareSMB)
402+
RETURN x
403+
```
404+
405+
- Principals with FULL_CONTROL on shares
406+
<details>
407+
<summary>Cypher: principals with FULL_CONTROL on shares</summary>
408+
409+
```cypher
410+
MATCH (p:Principal)-[r]->(s:NetworkShareSMB)
411+
WHERE (p)-[:CanDelete]->(s)
412+
AND (p)-[:CanDsControlAccess]->(s)
413+
AND (p)-[:CanDsCreateChild]->(s)
414+
AND (p)-[:CanDsDeleteChild]->(s)
415+
AND (p)-[:CanDsDeleteTree]->(s)
416+
AND (p)-[:CanDsListContents]->(s)
417+
AND (p)-[:CanDsListObject]->(s)
418+
AND (p)-[:CanDsReadProperty]->(s)
419+
AND (p)-[:CanDsWriteExtendedProperties]->(s)
420+
AND (p)-[:CanDsWriteProperty]->(s)
421+
AND (p)-[:CanReadControl]->(s)
422+
AND (p)-[:CanWriteDacl]->(s)
423+
AND (p)-[:CanWriteOwner]->(s)
424+
RETURN p,r,s
425+
```
426+
427+
</details>
428+
429+
- Hunt sensitive files by extension (e.g., VMDKs)
430+
```cypher
431+
MATCH p=(h:NetworkShareHost)-[:HasNetworkShare]->(s:NetworkShareSMB)-[:Contains*0..]->(f:File)
432+
WHERE toLower(f.extension) = toLower(".vmdk")
433+
RETURN p
434+
```
435+
368436
## Read Registry
369437

370438
You may be able to **read the registry** using some discovered credentials. Impacket **`reg.py`** allows you to try:
@@ -618,6 +686,7 @@ Entry_6:
618686

619687
- [NetExec (CME) wiki – Kerberos usage](https://www.netexec.wiki/)
620688
- [Pentesting Kerberos (88) – client setup and troubleshooting](../pentesting-kerberos-88/README.md)
621-
- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html)
689+
- [ShareHound (collector)](https://github.com/p0dalirius/sharehound)
690+
- [ShareQL (DSL)](https://github.com/p0dalirius/shareql)
622691

623692
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)