angryip / ipscan

Angry IP Scanner - fast and friendly network scanner
angryip.org
GNU General Public License v2.0
4.09k stars 715 forks source link

Add IEEE MA-M and MA-S assignments to Company Identification #290

Open shmorgan opened 3 years ago

shmorgan commented 3 years ago

It is possible to add the other two list of MAC Address assignments to the identified MAC address list?

It looks like the program only imports the MA-L list, but not the MA-M and MA-S lists. Can these be added?

Fix the import script to grab all three lists MA-L,MA-M, MA-S and create the MAC Table. Adjust code to handle MAC Identifications that are longer than three bytes.

Location were these can be downloaded. https://standards.ieee.org/products-services/regauth/index.html

shmorgan commented 3 years ago

Here is an updated update-mac-vendors.sh script to pull all the MAC addresses and sort them by MAC address:

I based the script on the original script in the git repository.

The results is a vendors.csv file.

!/bin/bash

This scripts downloads and optimizes IEEE MAC vendor list

SED_APP='sed' if [ "$(uname)" = "Darwin" ]; then

Mac users: bundled sed doesn't have -r

brew install gnu-sed SED_APP='gsed' fi

curl 'http://standards-oui.ieee.org/oui/oui.csv' |\ fgrep 'MA-L' | cut -d',' -f2-3 | $SED_APP -r ' s/\r//g; s/ (base 16)\t\t// s/,? ?(Inc).?$//I s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A\/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig s/(.+)// s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig s/ (Registration Authority| MobilityCommunication)// s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/ s/\"// ' | sort \

mac-vendors-MA-L.csv

curl 'http://standards-oui.ieee.org/oui28/mam.csv' |\ fgrep 'MA-M' | cut -d',' -f2-3 | $SED_APP -r ' s/\r//g; s/ (base 16)\t\t// s/,? ?(Inc).?$//I s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A\/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig s/(.+)// s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig s/ (Registration Authority| MobilityCommunication)// s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/ s/\"// ' | sort \

mac-vendors-MA-M.csv

curl 'http://standards-oui.ieee.org/oui36/oui36.csv' |\ fgrep 'MA-S' | cut -d',' -f2-3 | $SED_APP -r ' s/\r//g; s/ (base 16)\t\t// s/,? ?(Inc).?$//I s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A\/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig s/(.+)// s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig s/ (Registration Authority| MobilityCommunication)// s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/ s/\"// ' | sort \

mac-vendors-MA-S.csv

cat mac-vendors-MA-L.csv mac-vendors-MA-M.csv mac-vendors-MA-S.csv | sort >mac-vendors.csv

wc -l mac-vendors-MA-L.csv wc -l mac-vendors-MA-M.csv wc -l mac-vendors-MA-S.csv wc -l mac-vendors.csv

ghost commented 3 years ago

@shmorgan : Looks interesting, maybe you want to learn how to use GitHub Flavored MarkDown (GFM), or simply MarkDown, to format and encapsulate scripts in comments here on GitHub. As an example, I can post your script from above, encapsulated in a MarkDown fenced code box with syntax highlighting for #!/bin/bash :

#!/bin/bash

# This scripts downloads and optimizes IEEE MAC vendor list
SED_APP='sed'
if [ "$(uname)" = "Darwin" ]; then

# Mac users: bundled sed doesn't have -r
brew install gnu-sed
SED_APP='gsed'
fi

curl 'http://standards-oui.ieee.org/oui/oui.csv' |
fgrep 'MA-L' | cut -d',' -f2-3 | $SED_APP -r '
s/\r//g; s/ (base 16)\t\t//
s/,? ?(Inc).?$//I
s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig
s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig
s/(.+)//
s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig
s/ (Registration Authority| MobilityCommunication)//
s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/
s/"//
' | sort \

> mac-vendors-MA-L.csv

curl 'http://standards-oui.ieee.org/oui28/mam.csv' |
fgrep 'MA-M' | cut -d',' -f2-3 | $SED_APP -r '
s/\r//g; s/ (base 16)\t\t//
s/,? ?(Inc).?$//I
s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig
s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig
s/(.+)//
s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig
s/ (Registration Authority| MobilityCommunication)//
s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/
s/"//
' | sort \

> mac-vendors-MA-M.csv

curl 'http://standards-oui.ieee.org/oui36/oui36.csv' |
fgrep 'MA-S' | cut -d',' -f2-3 | $SED_APP -r '
s/\r//g; s/ (base 16)\t\t//
s/,? ?(Inc).?$//I
s/(,|, | )(Ltd|CO,.LTD|Limited|GmbH|LLC|A/S|AB|AS|SAS|AG|KG|PLC|SRL|OY|Oy|BV|Nederland BV|SAN VE TIC).?$//Ig
s/(,|, | )(Co|Corp|Corporation|Company|Incorporated).?$//Ig
s/(.+)//
s/ (Electronics?|Technology|Technologies|Telecommunication|Communications?|Corporation|Systems|Solutions|International|Industry|Industries|Networks?|Holdings?|Device$) ?//Ig
s/ (Registration Authority| MobilityCommunication)//
s/SAMSUNG ELECTRO[- ]MECHANICS/Samsung/
s/"//
' | sort \

> mac-vendors-MA-S.csv

cat mac-vendors-MA-L.csv mac-vendors-MA-M.csv mac-vendors-MA-S.csv | sort >mac-vendors.csv

wc -l mac-vendors-MA-L.csv
wc -l mac-vendors-MA-M.csv
wc -l mac-vendors-MA-S.csv
wc -l mac-vendors.csv

Please note: I am not familiar with the contents in this script, so I am unable to tell if any of the lines are broken or not (simply copy-pasted or quoted from the comment above).

shmorgan commented 3 years ago

Thank you, I was just sharing an example of a script I threw together to pull the 3 files now needed to get all the MAC address ranges. Our company just purchased a range in the MA-S range, thus our interest in getting that MAC address range added to the scanner. Also everyone I know used this script to scan their networks.

shmorgan commented 3 years ago

Oh, and If you can point to to the section of code that processes this input, I would be happy to take a look at what might be needed for the different length MAC addresses.

angryziber commented 3 years ago

@shmorgan The code that reads mac-vendors.txt is in src/net/azib/ipscan/fetchers/MACVendorFetcher.java, of course currently it assumes only 6-character-long prefixes.

That's interesting, actually I didn't know that shorter MAC ranger can also be assigned.