Project

General

Profile

Bug #8538 » update_ethercodes_v2.sh

THIS ONE INSTEAD - revised to accommodate new nmap field layout - ROB VANHOOREN, 05/25/2018 09:39 AM

 
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
#old nmap format 
14
#cat oui.txt | grep '(base 16)' | cut -f1 -d' ' > mac.address 
15
#new nmap format
16
cat oui.txt | grep '(base 16)' | cut -f3 -d' ' > mac.address
17

    
18
# Paste them back together for nmap data 
19
paste mac.address mac.manufacturer > nmap-mac-prefixes
20

    
21
# Parse the address data for arpwatch
22
cat mac.address | perl -pe 's/^(([^0].)|0(.))(([^0].)|0(.))(([^0].)|0(.))/\2\3:\5\6:\8\9/' > tmp.address 
23
cat tmp.address | tr [A-Z] [a-z] > mac.address
24

    
25
# Paste the parsed data into the arpwatch file
26
paste mac.address mac.manufacturer > ethercodes.dat
27

    
28
# Clean up intermediary files
29
rm tmp.address
30
rm mac.address
31
rm mac.manufacturer
32
rm oui.txt
33

    
(2-2/2)