Forum Thread: Bash-Script to Get MAC Address Vendor Names

Hi.

I have written a little script that some of you might find usefull.

It uses grep to search the file /var/lib/ieee-data/oui.txt for the vendor names of one or multiple MAC addresses provided.

It can be started with the addresses as parameters or without parameters to copy/paste a multiline list of addresses (as provided by e.g. btscanner or airodump) into it (it stops reading after 0.5secs of no input).

It will automatically remove the : and spaces and cut the address after the 6th character. It will provide a list with all the results of grep.

This is my first "bigger" skript (my others were only 5-liners or so), so if you find any errors, please feel free to report them or even correct them. I appreciate it.

Now, have fun.

#!/bin/bash
printf "############ GrepOUI ############\n########## By 94erBrom ##########\n\n"
if -n "$@" ;
then
for var in "$@"
do
text=$var
text="${text//:/}"
text="${text// /}"
text="${text:0:6}"
grep $text /var/lib/ieee-data/oui.txt;
done
fi

if -z "$@" ;
then printf "GrepOUI has started with no parameters.Please enter MAC Addresses via Copy/Paste\n";
IFS= read -d '' -n 1 textlist
while IFS= read -d '' -n 1 -t 0.5 c
do
textlist+=$c
done

printf "\nYour input is being processed. Please wait...\n\n"
sleep .5
printf "MAC-Vendor-ID \t\t\tVendor\n"
sleep .5
for i in $textlist;
do
text=$i
text="${text//:/}"
text="${text// /}"
text="${text:0:6}"
grep $text /var/lib/ieee-data/oui.txt;
done
fi

1 Response

Share Your Thoughts

  • Hot
  • Active