Advertisement
Guest User

Untitled

a guest
May 29th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #define __USE_GNU
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7.  
  8. #define OUIFile "/usr/local/share/wireshark/manuf"
  9.  
  10. FILE *ouiFile;
  11. unsigned long ouiFSize;
  12.  
  13. void main(int argc, char *argv[]){
  14.     if (argc < 2 || argc > 2){
  15.         printf("\nUsage: %s <MAC ADDRESS>\n\n",argv[0]);
  16.         exit(1);
  17.     }
  18.     if ( access("./manuf", F_OK) != -1){
  19.         printf("USING ./manuf\n");
  20.         ouiFile=fopen("./manuf","r");
  21.     }
  22.     else if ( access(OUIFile, F_OK) != -1){
  23.         printf("USING OUIFile\n");
  24.         ouiFile=fopen(OUIFile,"r");
  25.     }
  26.     else {
  27.         printf("File not found D:\n");
  28.         exit(1);
  29.     }
  30.  
  31.  
  32.     fseek(ouiFile, 0, SEEK_END);
  33.     ouiFSize = ftell(ouiFile);
  34.     rewind(ouiFile);
  35.     printf("File Size: %li\n",ouiFSize);
  36.  
  37.     char fileBuf[ouiFSize];
  38.     fread(fileBuf,1,ouiFSize,ouiFile);
  39.     fileBuf[ouiFSize] = 0;//Get rid of the EOF
  40.  
  41.     char *match = strcasestr(fileBuf,argv[1]);
  42.     if ( match != NULL ){
  43.         char *end = strpbrk(match, "\n");
  44.         char *ouiOut = malloc(128);
  45.         strncpy(ouiOut, match, end - match);
  46.         printf("\n\n%s\n",ouiOut);
  47.     }
  48.     else {
  49.         printf("No match found :(\n");
  50.     }
  51.  
  52.  
  53. //char *ouiOut; Why dosent that work?
  54. // you also need to add a check for full MAC and Only the OUI (lowercase only), mabey add a probability and best match scenarios also
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement