Created
April 20, 2021 12:49
-
-
Save 3isenHeiM/cadf05f8e24eec0d347fa2a916a68ff9 to your computer and use it in GitHub Desktop.
Get the SMB version from a tcpdump capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: rewardone / 3isenHeiM | |
# Description: | |
# Requires root or enough permissions to use tcpdump | |
# Will listen for the first 8 packets of a null login | |
# and grab the SMB Version | |
# Notes: | |
# Will sometimes not capture or will print multiple | |
# lines. May need to run a second time for success. | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
echo "Usage: sudo $0 RHOST {RPORT}" | |
exit 1 | |
fi | |
# Check Usage | |
if [ -z $1 ]; then echo "Usage: sudo $0 RHOST {RPORT}" && exit; else rhost=$1; fi | |
#Set port | |
if [ ! -z $2 ]; then rport=$2; else rport=139; fi | |
tcpdump -s0 -n -i tun0 src $rhost and port $rport -A -c 10 2>/dev/null | grep -i "samba\|s.a.m" | tr -d '.' | grep -oP 'UnixSamba.*[0-9a-z]' | tr -d '\n' & echo -n "$rhost: " & | |
echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null | |
echo "" && sleep .1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment