Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 657 Bytes

SMB.md

File metadata and controls

19 lines (15 loc) · 657 Bytes

Enumerating SMB shares

https://book.hacktricks.xyz/network-services-pentesting/pentesting-smb#manually-enumerate-windows-shares-and-connect-to-them

#!/bin/bash

ip='<TARGET-IP-HERE>'
shares=('C$' 'D$' 'ADMIN$' 'IPC$' 'PRINT$' 'FAX$' 'SYSVOL' 'NETLOGON')

for share in ${shares[*]}; do
    output=$(smbclient -U '%' -N \\\\$ip\\$share -c '') 

    if [[ -z $output ]]; then 
        echo "[+] creating a null session is possible for $share" # no output if command goes through, thus assuming that a session was created
    else
        echo $output # echo error message (e.g. NT_STATUS_ACCESS_DENIED or NT_STATUS_BAD_NETWORK_NAME)
    fi
done