Hunting (Shares)
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
On this page
TL;DR
Staff drop scripts, configs, and password spreadsheets on file shares. Hunting shares is the same keyword search as Hunting (Windows), run across every share your account can read. Listing and connecting to shares is in SMB.
Every tool here returns many false positives. Expect to review the matches by hand.
What to search for
Use the keywords and extensions from Hunting (Windows), plus these share-specific leads:
- Interesting filenames:
config,user,passw,cred,initial. - Extensions:
.ini,.cfg,.env,.xlsx,.ps1,.bat. - The domain prefix:
INLANEFREIGHT\finds files that name a domain account. - Local language: a German company writes
Benutzer, notUser.
Pick shares by who uses them. An IT share holds scripts and deployment files. A Photos share
holds photos. Search the likely shares first, because a full scan of large shares takes hours.
From Windows
Start with a plain search of one share:
Get-ChildItem -Recurse -Include *.ini,*.cfg,*.ps1,*.bat \\DC01\IT | Select-String -Pattern "passw"Snaffler finds every readable share in the domain and flags interesting files. Run it on a domain-joined host as a domain user:
Snaffler.exe -s # -s print results to stdout as they are foundSnaffler.exe -s -o snaffler.log # -o also write results to a fileSnaffler.exe -s -u # -u pull AD usernames and search for them in filesSnaffler.exe -s -n DC01,FS01 # -n skip computer discovery, search only these hostsSnaffler.exe -s -i \\DC01\IT # -i skip host and share discovery, search only this pathEach hit carries a rating: Black, Red, Yellow, or Green. Read Black and Red first.
PowerHuntShares maps share permissions and writes an HTML report with CSV files beside it:
Set-ExecutionPolicy -Scope Process BypassImport-Module .\PowerHuntShares.psm1Invoke-HuntSMBShares -Threads 100 -OutputDirectory C:\Users\PublicIt does not need a domain-joined host. From a host outside the domain, start PowerShell with domain credentials and name the DC:
runas /netonly /user:INLANEFREIGHT\<user> powershell.exe # /netonly use these creds for network access onlyInvoke-HuntSMBShares -Threads 100 -OutputDirectory C:\Users\Public -DomainController <dc-ip> -Credential INLANEFREIGHT\<user>From Linux
NetExec searches one share by name and content:
nxc smb $TARGET -u <user> -p <pass> --spider IT --content --pattern passw # --content also search file contentsnxc smb $TARGET -u <user> -p <pass> --spider IT --content --regex 'passw(or)?d' # --regex in place of --patternnxc smb $TARGET -u <user> -p <pass> --spider IT --pattern passw --depth 3 --exclude-dirs Archive # limit depth, skip foldersThe spider_plus module from SMB indexes every readable file instead.
MANSPIDER searches every share on a host, a range, or a target file, and downloads the matches. Run it from the Docker image to skip the dependency setup:
docker run --rm -v ./manspider:/root/.manspider blacklanternsecurity/manspider \ $TARGET -c passw -u <user> -p <pass> # -c search file contents by regexdocker run --rm -v ./manspider:/root/.manspider blacklanternsecurity/manspider \ $TARGET -c passw -e xlsx docx pdf -u <user> -p <pass> # -e only these extensionsdocker run --rm -v ./manspider:/root/.manspider blacklanternsecurity/manspider \ $TARGET -f passw cred -d <domain> -u <user> -H <hash> # -f match filenames, -H pass the hashMatches land in ./manspider/loot on the attack host.
A credential found on a share often works on other hosts, so test every one with Spraying and Defaults.