-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacRandomizer.py
37 lines (29 loc) · 1.26 KB
/
macRandomizer.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
32
33
34
35
36
37
#!/usr/bin/env python
import subprocess
import random
import time
def get_current_mac_address():
mac_address = str(subprocess.check_output("ifconfig " + interface, shell=True)).partition("ether")[2][1:18]
return mac_address
interface = input("interface > ")
new_random_mac = "%02x:%02x:%02x:%02x:%02x:%02x" % (random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255))
print("Changing MAC address for " + interface + " interface to " + new_random_mac)
previous = get_current_mac_address()
print("Previous MAC Address: " + previous)
#Change MAC address
subprocess.call("ifconfig " + interface + " down", shell=True)
time.sleep(5)
subprocess.call("ifconfig " + interface + " hw ether " + new_random_mac, shell=True)
time.sleep(5)
subprocess.call("ifconfig " + interface + " up", shell=True)
after = get_current_mac_address()
print("After MAC Address: " + after)
if (previous == after):
print("[-] MAC Address Change Failed")
else:
print("[+] MAC Address Change Successful")