forked from avinashkranjan/Pentesting-and-Hacking-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Automatic_MAC_Address_changer.py
43 lines (29 loc) Β· 1.38 KB
/
Automatic_MAC_Address_changer.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
import subprocess
import optparse
def get_arguments():
parser = optparse.OptionParser()
parser.add_option("-i", "--interface", dest="interface", help="Interface to change its MAC address")
parser.add_option("-m", "--mac", dest="new_mac", help="New MAC address")
(options, arguments)= parser.parse_args()
if not options.interface:
parser.error("[.] Please specify an interface, use --help for more info.")
elif not options.new_mac:
parser.error("[.] Please specify an new MAC, use --help for more info.")
return options
def change_mac(interface, new_mac):
print("[+] Changing MAC address for " + interface + "to new MAC " + new_mac)
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])
#interface = input("interface (wlan0, wlan8 etc) >")
#new_mac=input("new mac of ur choice >")
options=get_arguments()
change_mac(options.interface, options.new_mac)
'''
subprocess.call("ifconfig"+interface +"down", shell=True)
# in windows its equivalent is ipconfig
subprocess.call("ifconfig"+ interface+" hw ether"+new_mac, shell=True)
#changing the mac to 00:11:22:44:55:99(my choice id)
subprocess.call("ifconfig"+interface +"up", shell=True)
# the above approach can allow a user to hack our program, so we r gonna restrict that
'''