Last active
March 22, 2016 00:16
-
-
Save deliciouskek/8562bad00bcbfbee3a4f to your computer and use it in GitHub Desktop.
MAC FINDER UBERTOOTH
This file contains 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 | |
#requires perl | |
#requires manuf.txt available from wireshark | |
#requires last 4 octets of mac address available from Ubertooth-scan | |
#use responsibly and don't use for any unauthorized purposes | |
#based in part on code from http://stackoverflow.com/questions/36119396/bash-script-passes-variable-that-is-a-hex-number-to-a-perl-regex-search-to-match?noredirect=1#comment59878958_36119396 | |
read -p "Enter Third and Fourth and Fifth and Sixth Octet Here (AB:CD:EF:12) " STR | |
octet6=$(echo $STR | cut -c 1-11) | |
octet5=$(echo $STR | cut -c 1-8) | |
octet4=$(echo $STR | cut -c 1-5) | |
octet=$(echo $STR | cut -c 1-2) | |
#Makes sure the manuf.txt file only contains ":" notation | |
sed -i 's/-/:/ig' manuf.txt | |
#third and fourth and fifth octet | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}(?=((\s)|(\/)))/ig' -- -octet=$octet5 manuf.txt | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet(?=((\s)|(\/)))/ig' -- -octet=$octet5 manuf.txt | |
#third and fourth octet | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}(?=((\s)|(\/)))/ig' -- -octet=$octet4 manuf.txt | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet(?=((\s)|(\/)))/ig' -- -octet=$octet4 manuf.txt | |
#Third octet. Kind of pointless bc it might generate hundreds or thousands of matches | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}(?=((\s)|(\/)))/ig' -- -octet=$octet manuf.txt | |
perl -nse 'print if /[0-9A-F]{2}[:][0-9A-F]{2}[:]$octet(?=((\s)|(\/)))/ig' -- -octet=$octet manuf.txt | |
#Trim things up and make them look neat and tidy | |
sed -i -E 's/^([0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}).*/\1/g' matches.txt | |
sed -i -E 's/^([0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2})\s.*/\1/ig' matches.txt | |
#Replace everything after the third octet with the rest of the Mac address for 6 octetc strings | |
sed -i -E 's/^([0-9A-F]{2}[:][0-9A-F]{2}[:])[0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}/\1'$octet6'/g' matches.txt | |
#Replace everything after the third octet with the rest of the Mac address for 3 octetc strings | |
sed -i -E 's/^([0-9A-F]{2}:[0-9A-F]{2}):[0-9A-F]{2}$/\1:'$octet6'/g' matches.txt | |
#Remove repeated strings | |
sed -i '$!N; /^\(.*\)\n\1$/!P; D' matches.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment