Advertisement
Guest User

Untitled

a guest
Jul 4th, 2010
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.84 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. # MAC address OUI checker
  3. # Thijs (Thice) Bosschert
  4. # http://www.thice.nl
  5. # v0.4 25-06-2010
  6.  
  7. $ouifile = "/usr/local/etc/aircrack-ng/airodump-ng-oui.txt";
  8.  
  9. # Check if argument has been given
  10. if (!$ARGV[0]) {
  11.         fatal_error();
  12. }
  13.  
  14. # Removing seperators from MAC address and uppercase chars
  15. foreach $argnum (0 .. $#ARGV) {
  16.  
  17. my $OUI = uc($ARGV[$argnum]);
  18. $OUI =~ s/[^0-9A-F]//g;
  19.  
  20. # Get OUI from MAC
  21. if ($OUI =~ /^([0-9A-F]{6})/) {
  22.         $OUI = $1;
  23.         print "Checking OUI: ".$OUI."\n";
  24. } else {
  25.         fatal_error();
  26. }
  27.  
  28. # Open OUI file from aircrack-ng
  29. open(my $fh, "<", $ouifile) || die "  Error: Can not access OUI file: $ouifile";
  30. while (<$fh>) {
  31.         ($checkoui,$company) = split(/\(hex\)/,$_);
  32.         $checkoui =~ s/[-|\s]//g;
  33.         # Check if OUI can be found in the list
  34.         if ($OUI eq $checkoui) {
  35.                 $company =~ s/\t//g;
  36.                 chomp($company);
  37.                 # Output found OUI
  38.                 print "Found OUI: ".$OUI." - ".$company."\n\n";
  39.                # exit;
  40.         }
  41. }
  42. close($fh);
  43.  
  44. # Show if OUI was not found
  45. #print "  Could not find OUI: ".$OUI."\n\n";
  46.  
  47. # Error messages
  48. sub fatal_error {
  49.  
  50.         print "  Error: No MAC address or OUI specified or could not recognize it.\n";
  51.         if ($0 =~ /^\/bin\/(.*)/) {
  52.                 print "  Usage: $1 \n";
  53.         } else {
  54.                 print "  Usage: perl $0 \n";
  55.         }
  56.         print "  MAC can be submitted as:\n".
  57.                 "                001122334455\n".
  58.                 "                00:11:22:33:44:55\n".
  59.                 "                00-11-22-33-44-55\n".
  60.                 "        OUI can be submitted as:\n".
  61.                 "                001122\n".
  62.                 "                00:11:22\n".
  63.                 "                00-11-22\n\n";
  64.         exit;
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement