-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAC_Address_Modifier.py
59 lines (44 loc) · 1.94 KB
/
MAC_Address_Modifier.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
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import subprocess
import optparse
from pyfiglet import Figlet
def modify_mac(interface, new_mac):
print("[*] Modifying MAC_Address of " + interface + " to " + new_mac + "...\n")
subprocess.call(['ifconfig', interface, 'down'])
subprocess.call(['ifconfig', interface, 'hw', 'ether', new_mac])
subprocess.call(['ifconfig', interface, 'up'])
print("\n[*] Restarting Network Services...\n")
subprocess.call(['service', 'network-manager', 'restart'])
print("\n[+] MAC_Address of " + interface + " has been successfully changed to " + new_mac + "\n")
print("\n[+] Done")
def get_arguments():
parser = optparse.OptionParser(usage='usage %prog [options] arguments')
parser.add_option("-i", "--interface", dest="interface", help="Enter Interface Name")
parser.add_option("-m", "--new-mac", dest="new_mac", help="Enter new MAC Address")
parser.add_option("-s", action='store_true', help="Show Current MAC_Address(s)")
(options, arguments) = parser.parse_args()
if options.s:
current_macs()
exit(0)
elif not options.interface:
print("\n[-] Please specify Network Interface for the MAC to be changed! Use -h, --help, for more info!\n")
exit(0)
elif not options.new_mac:
print("\n[-] Please specify New MAC_Address to change to! Use -h, --help, for more info!\n")
exit(0)
else:
return options
def current_macs():
print("\n[+] Current MAC_Address(s) of Network Interface(s) is/are follows: \n")
subprocess.call("ip link | awk \'{print $2}\'", shell=True)
print("\n[+] Done\n")
def text_render():
print("\n\n----------------------MAC_Modifier Script made by----------------------\n")
f = Figlet(font='slant')
print(f.renderText('shIVam') + "\t\t\t\t\tv1.0\n\n\n")
def main():
text_render()
options = get_arguments()
modify_mac(options.interface, options.new_mac)
if __name__ == '__main__':
main()