├── .gitignore ├── LICENSE ├── README.md └── source ├── MacOrg.pro ├── OUI.qrc ├── main.cpp ├── orgadd.cpp ├── orgadd.h └── oui.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | qrc_*.cpp 24 | ui_*.h 25 | Makefile* 26 | *build-* 27 | 28 | # QtCreator 29 | 30 | *.autosave 31 | 32 | # QtCtreator Qml 33 | *.qmlproject.user 34 | *.qmlproject.user.* 35 | 36 | # QtCtreator CMake 37 | CMakeLists.txt.user 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Bill Brown 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MacOrg 2 | 3 | MAC Address Organization Auto-Detection 4 | 5 | Dragging the result file of "arp -a" to the MacOrg.exe,You will find the Organization. 6 | 7 | Windows 7 & VS2013 & QT 5.7 Static 8 | 9 | 10 | ## Usage 11 | 12 | ``` 13 | C:\Users\Gaearrow> arp -a > arp-all.txt 14 | 15 | C:\Users\Gaearrow> MacOrg.exe arp-all.txt 16 | 17 | Oui Version = Generated: Tue, 23 May 2017 09:15:05 18 | 19 | Successfully add ORG to [C:/Users/Gaearrow/arp-all-org.txt] 20 | ``` 21 | 22 | ### arp-all.txt 23 | 24 | ``` 25 | Interface: 192.168.102.135 --- 0xe 26 | 27 | Internet Address Physical Address Type 28 | 29 | 192.168.102.2 00-50-56-f3-b8-2d dynamic 30 | 31 | 192.168.102.3 90-7F-61-c3-b8-2d dynamic 32 | 33 | 192.168.102.4 9C-8E-99-00-00-16 dynamic 34 | 35 | 192.168.102.5 00-F8-71-00-00-fc dynamic 36 | 37 | 239.255.255.250 01-00-5e-7f-ff-fa static 38 | 39 | 255.255.255.255 ff-ff-ff-ff-ff-ff static 40 | ``` 41 | 42 | 43 | ### arp-all-org.txt 44 | 45 | ``` 46 | Interface: 192.168.102.135 --- 0xe 47 | 48 | Internet Address Physical Address Type ORG 49 | 50 | 192.168.102.2 00-50-56-f3-b8-2d dynamic VMware, Inc. 51 | 52 | 192.168.102.3 90-7F-61-c3-b8-2d dynamic Chicony Electronics Co., Ltd. 53 | 54 | 192.168.102.4 9C-8E-99-00-00-16 dynamic Hewlett Packard 55 | 56 | 192.168.102.5 00-F8-71-00-00-fc dynamic DGS Denmark A/S 57 | 58 | 239.255.255.250 01-00-5e-7f-ff-fa static Not Found 59 | 60 | 255.255.255.255 ff-ff-ff-ff-ff-ff static Not Found 61 | ``` -------------------------------------------------------------------------------- /source/MacOrg.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-04-15T15:37:00 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core 8 | 9 | QT -= gui 10 | 11 | TARGET = MacOrg 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | 18 | SOURCES += main.cpp \ 19 | orgadd.cpp 20 | 21 | RESOURCES += \ 22 | OUI.qrc 23 | 24 | HEADERS += \ 25 | orgadd.h 26 | -------------------------------------------------------------------------------- /source/OUI.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | oui.txt 4 | 5 | 6 | -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "orgadd.h" 4 | 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QCoreApplication a(argc, argv); 9 | if (argc != 2){ 10 | printf("Usage: %s arp-all.txt \n", argv[0]); 11 | return 0; 12 | } 13 | 14 | orgadd oa(argv[1]); 15 | return a.exec(); 16 | } 17 | -------------------------------------------------------------------------------- /source/orgadd.cpp: -------------------------------------------------------------------------------- 1 | #include "orgadd.h" 2 | 3 | orgadd::orgadd(char *parpall) 4 | { 5 | //Load oui.txt 6 | loadoui(); 7 | 8 | //Open&Create File 9 | QFile SrcFile(parpall); 10 | if(!SrcFile.open(QIODevice::ReadOnly|QIODevice::Text)){ 11 | printf("%s\n","Can't Open Arp-All File!"); 12 | system("pause"); 13 | return; 14 | } 15 | QFile DstFile(SrcFile.fileName().split('.')[0].append("-org.txt")); 16 | if(!DstFile.open(QIODevice::WriteOnly|QIODevice::Text)){ 17 | printf("%s\n","Can't Create Result File!"); 18 | system("pause"); 19 | return; 20 | } 21 | QTextStream in(&SrcFile); 22 | QTextStream out(&DstFile); 23 | 24 | //Init 25 | char *ip = new char[100]; //Maybe IPv6 26 | char *mac = new char[100]; 27 | char *macllc = new char[10]; 28 | 29 | /* arp-all.txt 30 | * 31 | * Interface: 192.168.102.135 --- 0xe 32 | * Internet Address Physical Address Type 33 | * 192.168.102.2 00-50-56-f3-b8-2d dynamic 34 | * 192.168.102.255 ff-ff-ff-ff-ff-ff static 35 | * 255.255.255.255 ff-ff-ff-ff-ff-ff static 36 | */ 37 | while (!in.atEnd()) { 38 | //Read line 39 | QString line = in.readLine(); 40 | //Process line(line); 41 | if(line.contains("Interface:")){ 42 | out << line << endl; 43 | continue; 44 | } 45 | if(line.contains("Internet Address") && line.contains("Physical Address")){ 46 | line.append(" ORG"); 47 | out << line << endl; 48 | continue; 49 | } 50 | if(line.contains("static") || line.contains("dynamic")){ 51 | sscanf(line.toLocal8Bit().constData(),"%s%s", ip, mac); 52 | sscanf(mac,"%8s",macllc); 53 | QString ml(macllc); 54 | int start = orglib.indexOf(ml.toUpper(),Qt::CaseInsensitive); 55 | if (start < 0){ 56 | line.append(" Not Found"); 57 | out << line << endl; 58 | continue; 59 | } 60 | start = start + 18; 61 | int end = start; 62 | QString Dstline; 63 | while(orglib.mid(end,1).compare("\n")) 64 | { 65 | Dstline.append(orglib.mid(end,1)); 66 | end++; 67 | } 68 | line.append(" "); 69 | line.append(Dstline); 70 | out << line << endl; 71 | continue; 72 | } 73 | 74 | } 75 | printf("Successfully add ORG to [%s]\n",DstFile.fileName().toLocal8Bit().constData()); 76 | 77 | delete(ip); 78 | delete(mac); 79 | delete(macllc); 80 | SrcFile.close(); 81 | DstFile.close(); 82 | 83 | } 84 | 85 | //Load oui.txt 86 | //Download URL: http://standards-oui.ieee.org/oui/oui.txt 87 | void orgadd::loadoui() 88 | { 89 | //Open oui.txt 90 | QFile OuiFile(":/lib/oui.txt"); 91 | if(!OuiFile.open(QIODevice::ReadOnly|QIODevice::Text)){ 92 | printf("%s\n","Can't Open oui.txt"); 93 | system("pause"); 94 | return; 95 | } 96 | //Format Check & Output Oui Version 97 | QString OuiVer = OuiFile.readLine(); 98 | if(!OuiVer.contains("Generated:")){ 99 | printf("%s\n","oui.txt Format Error!"); 100 | system("pause"); 101 | return; 102 | }else{ 103 | printf("Oui Version =%s\n",OuiVer.toLocal8Bit().constData()); 104 | } 105 | //Load oui.txt 106 | orglib = OuiFile.readAll(); 107 | OuiFile.close(); 108 | } 109 | -------------------------------------------------------------------------------- /source/orgadd.h: -------------------------------------------------------------------------------- 1 | #ifndef ORGADD_H 2 | #define ORGADD_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | #define MAX_SIZE_PACKET 1024*10 16 | 17 | 18 | class orgadd 19 | { 20 | public: 21 | 22 | orgadd(char* parpall); 23 | 24 | 25 | 26 | private: 27 | 28 | void loadoui(); 29 | QString orglib; 30 | 31 | }; 32 | 33 | #endif // ORGADD_H 34 | --------------------------------------------------------------------------------