forked from canerdianeh/ekahau-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathismac.py
executable file
·32 lines (27 loc) · 866 Bytes
/
ismac.py
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
#!/usr/bin/python3
import re
for sourceString in ['aa:bb:cc:dd:ee:ff', "AA-BB-CC-DD-EE-FF", "aaaa.bbbb.cccc", "This. is-not a : hex string"]:
print("\n\nSource String: "+sourceString)
isMac=False
delimiter=""
# Let's Check to see if this is at least vaguely hexadecimal
if '.' in sourceString:
macMatch=re.match(r"^([0-9A-Fa-f]{4}[.]){2}([0-9A-Fa-f]{4})$", sourceString)
if macMatch:
isMac=True
delimiter = '.'
print(macMatch.group())
if ':' in sourceString:
macMatch=re.match(r"^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$", sourceString)
if macMatch:
isMac=True
delimiter = ':'
print(macMatch.group())
if '-' in sourceString:
macMatch=re.match(r"^([0-9A-Fa-f]{2}[-]){5}([0-9A-Fa-f]{2})$", sourceString)
if macMatch:
isMac=True
delimiter = '-'
print(macMatch.group())
print (isMac)
print("Delimiter: " + delimiter)