Advertisement
luxaeterna101

oui_lookup.pl

Feb 16th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.51 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # MAC address OUI checker
  3. # Thijs (Thice) Bosschert
  4. # http://www.thice.nl
  5. # v0.1 24-06-2010
  6. # Revised by Lux Æterna on 12-10-2016 to work with Kali 2.0
  7.  
  8. # Print header
  9. print "\n  MAC address OUI checker v0.1\n".
  10.       "  by Thijs (Thice) Bosschert\n\n";
  11.  
  12. # Check if argument has been given
  13. if (!$ARGV[0]) {
  14.   &error;
  15. }
  16.  
  17. # Removing seperators from MAC address and uppercase chars
  18. $ARGV[0] =~ s/[:|\s|-]//g;
  19. $ARGV[0] =~ y/a-z/A-Z/;
  20.  
  21. # Get OUI from MAC
  22. if ($ARGV[0] =~ /^([0-9a-f]{6})/i) {
  23.   $OUI = $1;
  24.   print "  Checking OUI: ".$OUI."\n";
  25. } else {
  26.   &error;
  27. }
  28.  
  29. # Open OUI file from aircrack-ng
  30. open(FILE,"/var/lib/ieee-data/oui.txt");
  31.   while (<FILE>) {
  32.     ($checkoui,$company) = split(/\(hex\)/,$_);
  33.     $checkoui =~ s/[-|\s]//g;
  34.     # Check if OUI can be found in the list
  35.     if ($OUI eq $checkoui) {
  36.       $company =~ s/\t//g;
  37.       # Output found OUI
  38.       print "  Found OUI: ".$OUI." - ".$company."\n\n";
  39.       exit;
  40.     }
  41.   }
  42. close(FILE);
  43.  
  44. # Show if OUI was not found
  45. print "  Could not find OUI: ".$OUI."\n\n";
  46.  
  47. # Error messages
  48. sub error {
  49.   print "  Error: No MAC address or OUI specified or could not recognize it.\n".
  50.         "    Usage: perl OUI_lookup.pl <MAC/OUI>\n".
  51.         "    MAC can be submitted as:\n".
  52.         "       001122334455\n".
  53.         "       00:11:22:33:44:55\n".
  54.         "       00-11-22-33-44-55\n".
  55.         "    OUI can be submitted as:\n".
  56.         "       001122\n".
  57.         "       00:11:22\n".
  58.         "       00-11-22\n\n";
  59.   exit;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement