Created
February 4, 2016 13:32
-
-
Save vijinho/048a8d65bb26f2399439 to your computer and use it in GitHub Desktop.
PHP to parse mac address vendor db of wireshark at https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf
This file contains hidden or 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
<?php | |
// script to parse mac address db at | |
// https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf | |
$data = file('vendors.txt'); | |
foreach ($data as $line) { | |
if (preg_match("/^#.*/", $line)) { | |
continue; | |
} elseif (preg_match("/([A-F0-9]+:[A-F0-9]+:[A-F0-9]+)\s+[^#]+#\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+:[A-F0-9]+:[A-F0-9]+:[A-F0-9]+:[A-F0-9]+:[A-F0-9]+)[^s]+\s+[^#]+#\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+:[A-F0-9]+:[A-F0-9]+)\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+)\s+(.+)/i", $line, $matches)) { | |
// print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+)[^\s]+\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+-[A-F0-9]+)[^\s]+\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} elseif (preg_match("/([A-F0-9]+-[A-F0-9]+-[A-F0-9]+)[^\s]+\s+(.+)/i", $line, $matches)) { | |
//print_r($matches); | |
} else { | |
continue; | |
} | |
print_r($matches); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment