-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
OUI_Search.cmd
61 lines (44 loc) · 1.72 KB
/
OUI_Search.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@echo off
rem =====
rem For more information on ScriptTiger and more ScriptTiger scripts visit the following URL:
rem https://scripttiger.github.io/
rem Or visit the following URL for the latest information on this ScriptTiger script:
rem https://github.com/ScriptTiger/MAC-Address-Lookup
rem =====
rem Set SIMPLE to 0 to use master.txt and 1 to use simplified.txt
set SIMPLE=0
rem Set OUI lookup table file path and adjust the search format
if %SIMPLE%==0 (
set MASTER=%~dp0master.txt
if not "%~1"=="" set SEARCH=%~1&set FORMAT="tokens=3 delims={}"&goto MAC_Search
) else (
set MASTER=%~dp0simplified.txt
if not "%~1"=="" set SEARCH=%~1&set FORMAT="tokens=2 delims={}"&goto MAC_Search
)
rem Interactive mode prompt
:Choice
rem Exit if not in interactive mode
if not "%~1"=="" exit /b
set FORMAT="tokens=*"
choice /m "Reverse search by company keywords?"
if %ERRORLEVEL%==1 goto Company_Search
:MAC_Input
set /p SEARCH=MAC address: || exit /b
rem Get rid of extra characters before searching
:MAC_Search
set SEARCH=%SEARCH::=%
set SEARCH=%SEARCH:-=%
rem Search the MA-S block entries
for /f %FORMAT% %%0 in ('findstr /l /i "{%SEARCH:~,9%}{" %MASTER%') do echo %%0&goto Choice
rem Search the MA-M block entries
for /f %FORMAT% %%0 in ('findstr /l /i "{%SEARCH:~,7%}{" %MASTER%') do echo %%0&goto Choice
rem Search the MA-L block entries
for /f %FORMAT% %%0 in ('findstr /l /i "{%SEARCH:~,6%}{" %MASTER%') do echo %%0&goto Choice
rem Return a response if no results found
echo Unregistered OUI
goto Choice
rem Search by company information and not strictly by mac address
:Company_Search
set /p SEARCH=Company keywords: || exit /b
findstr /r /i "%SEARCH%" %MASTER% | more
goto Choice