# Sensitive Files on SMB Shares

- **URL:** https://hackindex.io/index.php/services/smb/vulnerability-discovery/sensitive-files-on-smb-shares
- **Path:** SMB > Vulnerability Discovery
- **Up:** [Vulnerability Discovery](https://hackindex.io/index.php/services/smb/vulnerability-discovery.md)
- **Published:** 2026-03-06
- **Updated:** 2026-03-06

Once a share is readable, the next question is whether it contains anything that changes your path fast. Sensitive SMB content often turns a simple share exposure into credential theft, key recovery, database access, or access to internal systems without needing another vulnerability. SMBMap supports recursive review and pattern-based file hunting, and `smbclient` supports recursive listing and direct retrieval when you need to pull specific files.

Start with a recursive listing on the shares you can access. Shares labelled IT, Backup, Shared, Scripts, Config, or Software are worth prioritizing over generic ones. Writable shares matter less here than readable ones with content.

## Finding SMB Sensitive Files

High-value file types to prioritize:

- `.kdbx` KeePass databases and `.ppk`/`.pem` private keys
- `.rdp` connection files with saved credentials
- `.ps1`, `.bat`, `.cmd` scripts with hardcoded passwords
- `web.config`, `.env`, `.ini` files with connection strings
- `.vhd`, `.vhdx` disk images and `.sql` database dumps

If a share returns errors on listing, another account may have access to it, so note it and move on.

```bash
smbmap -H $TARGET_IP -u "$USER" -p "$PASSWORD" -r
smbmap -H $TARGET_IP -r
```

If you need direct inspection with `smbclient`, enumerate the share and pull only what matters. Anonymous access (`-N`) works on misconfigured shares and is worth trying even when you hold credentials. Some shares have guest-only permissions configured separately from authenticated access. Check both authenticated and unauthenticated listings to catch mismatches between intended and actual permissions.

```bash
smbclient //$TARGET_IP/Shared -U "$USER%$PASSWORD" -c "recurse; ls"
smbclient //$TARGET_IP/Public -N -c "recurse; ls"
```

Search for names that regularly change the next move. The pattern covers the most common high-value extensions: password managers (.kdbx), private keys (.pem, .ppk), remote desktop connection files (.rdp), virtual disk images (.vhd, .vhdx), archived backups (.bak, .zip, .7z), database dumps (.sql, .mdb, .accdb), and scripts (.ps1, .bat, .cmd) that may contain hardcoded credentials or network paths. XML, INI, and TXT files frequently hold connection strings, API tokens, or deployment configuration. SMBMap prints matches with the full share path, so you can retrieve them directly without re-browsing the tree.

```bash
smbmap -H $TARGET_IP -u "$USER" -p "$PASSWORD" -A "(?i)(pass|cred|secret|config|kdbx|key|pem|ppk|rdp|vhd|vhdx|bak|zip|7z|sql|mdb|accdb|ps1|bat|cmd|xml|ini|txt)$"
smbmap -H $TARGET_IP -A "(?i)(pass|cred|secret|config|kdbx|key|pem|ppk|rdp|vhd|vhdx|bak|zip|7z|sql|mdb|accdb|ps1|bat|cmd|xml|ini|txt)$"
```

If you find a likely target, pull it for offline review. Use `get` for individual files and inspect locally. Encrypted archives confirm something worth protecting was there even if you cannot open them immediately. Note the full path and revisit after gaining a higher-privilege session if needed.

```bash
smbclient //$TARGET_IP/Shared -U "$USER%$PASSWORD" -c "get config.xml"
smbclient //$TARGET_IP/Public -N -c "get backup.zip"
```

What matters is not file count. It is whether the share gives you configuration files, scripts, backups, exported databases, password manager files, keys, certificates, or connection profiles that support credential reuse, VPN access, database access, or trusted script review.

If SMBMap returns no pattern matches but you know the share is accessible, try lowercasing the pattern or removing the case-insensitive flag. Some SMB server configurations handle filename case differently. On large or heavily loaded shares, recursive listing may time out. Narrow the scope by specifying a subdirectory path with `-r`, or browse the subtree directly using `smbclient`. PowerShell scripts and batch files on accessible shares are especially useful when they contain credentials, paths to other systems, or logic that reveals how the environment is structured.

## References

- [SMBMap](https://github.com/ShawnDEvans/smbmap) - Recursive share review and file pattern handling
- [smbclient man page](https://www.samba.org/samba/samba/docs/man/manpages/smbclient.1.html) - Recursive listing and file retrieval
