Last active
February 15, 2019 19:38
-
-
Save cgimenes/f948ddb46b94d0e069c5cd274140cd90 to your computer and use it in GitHub Desktop.
Will listen for the first 7 packets of a null login and grab the SMB Version. by rewardone
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 | |
#Description: | |
# Requires root or enough permissions to use tcpdump | |
# Will listen for the first 7 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 [ -z $1 ]; then echo "Usage: ./smbver.sh RHOST {RPORT}" && exit; else rhost=$1; fi | |
if [ ! -z $2 ]; then rport=$2; else rport=139; fi | |
if [ ! -z $3 ]; then intf=$3; else intf='eth0'; fi | |
tcpdump -s0 -n -i $intf src $rhost and port $rport -A -c 7 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 | |
sleep 0.5 && echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment