-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacChanger.py
45 lines (28 loc) · 1.35 KB
/
MacChanger.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
38
39
40
41
42
43
44
45
import subprocess
import optparse
import re
def get_user_input(): ## ---> Kullanıcıdan input alma yeri
parse_object = optparse.OptionParser()
parse_object.add_option("-i","--interface", dest = "interface", help = "Interface to help")
parse_object.add_option("-m","--mac", dest = "mac_adress", help = "New Mac Adress")
#print(parse_object.parse_args())
return parse_object.parse_args()
def Mac_changer(user_interface, user_mac_adress): ## ---> Programın çalıştığı yer.
subprocess.call(["ifconfig", user_interface, "down"])
subprocess.call(["ifconfig", user_interface, "hw", "ether", user_mac_adress])
subprocess.call(["ifconfig", user_interface, "up"])
def control_new_mac(interface): ## ----> Input kontrolü
ifconfig = subprocess.check_output(["ifconfig",interface])
new_mac = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",str(ifconfig)) ## ---> str -> Python3 uyumluluğu
if new_mac:
return new_mac.group(0)
else:
return None
print("Mac is Changing")
(user_input,arguments) = get_user_input()
Mac_changer(user_input.interface, user_input.mac_adress)
final_mac = control_new_mac(str(user_input.interface)) ## ---> str -> Python3 uyumluluğu
if final_mac == user_input.mac_adress:
print("Succsess")
else:
print("Error")