Nov-04-2018, 12:14 AM
(This post was last modified: Nov-04-2018, 12:33 AM by ichabod801.)
root@:~# python
Python 2.7.15+ (default, Aug 31 2018, 11:56:52)
[GCC 8.2.0] on linux2
Linux 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux
Python 2.7.15+ (default, Aug 31 2018, 11:56:52)
[GCC 8.2.0] on linux2
Linux 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux
#!/usr/bin/env python 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") return parser.parse_args() def change_mac(interface, new_mac): print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call(["ifconfig", interface, "down"]) subprocess.call(["ifconfig", interface, "hw", "ether", new_mac]) subprocess.call(["ifconfig", interface, "up"]) (options, arguments) = get_arguments() change_mac(options.interface, options.new_mac)
Output:Traceback (most recent call last):
File "/root/PycharmProjects/mac_changer/mac_changer.py", line 22, in <module>
change_mac(options.interface, options.new_mac)
File "/root/PycharmProjects/mac_changer/mac_changer.py", line 15, in change_mac
print("[+] Changing MAC address for " + interface + " to " + new_mac)
TypeError: can only concatenate str (not "NoneType") to str
Process finished with exit code 1