Bug #8538 » update_ethercodes.sh
1 |
#!/bin/bash
|
---|---|
2 |
# update_ethercodes.sh
|
3 |
# This script downloads the currect mac address data from the IEEE and parses it for nmap and arpwatch.
|
4 |
# nmap-mac-prefixes is for nmap.
|
5 |
# ethercodes.dat is arpwatch.
|
6 |
|
7 |
# Download the current data
|
8 |
|
9 |
wget http://standards.ieee.org/regauth/oui/oui.txt |
10 |
|
11 |
# Divide the data into Manufacturer and Address files
|
12 |
cat oui.txt | grep '(base 16)' | cut -f3 > mac.manufacturer |
13 |
cat oui.txt | grep '(base 16)' | cut -f1 -d' ' > mac.address |
14 |
|
15 |
# Paste them back together for nmap data
|
16 |
paste mac.address mac.manufacturer > nmap-mac-prefixes |
17 |
|
18 |
# Parse the address data for arpwatch
|
19 |
cat mac.address | perl -pe 's/^(([^0].)|0(.))(([^0].)|0(.))(([^0].)|0(.))/\2\3:\5\6:\8\9/' > tmp.address |
20 |
cat tmp.address | tr [A-Z] [a-z] > mac.address |
21 |
|
22 |
# Paste the parsed data into the arpwatch file
|
23 |
paste mac.address mac.manufacturer > ethercodes.dat |
24 |
|
25 |
# Clean up intermediary files
|
26 |
rm tmp.address
|
27 |
rm mac.address
|
28 |
rm mac.manufacturer
|
29 |
rm oui.txt
|
30 |
|