Python Ethical Hacking - MAC Address & How to Change
MAC ADDRESS
WHY CHANGE THE MAC ADDRESS 1.Increase anonymity 2.Impersonate other devices 3.Bypass filters ? Change the MAC Address manually. ifconfig ifconfig eth0 down ifconfig eth0 hw ether 00:11:22:33:44:55 ifconfig eth0 up ifconfig ? MAC_CHANGER USING A PYTHON MODULE TO EXECUTE SYSTEM COMMANDS
Refer to the Python Documentation:?https://docs.python.org/3/library/subprocess.html Simple sample: #!/usr/bin/env python import subprocess subprocess.call("ifconfig",shell=True) ? The Python script to change the MAC Address: #!/usr/bin/env python import subprocess subprocess.call("ifconfig eth0 down",shell=True) subprocess.call("ifconfig eth0 hw ether 00:11:22:33:44:66",shell=True) subprocess.call("ifconfig eth0 up",shell=True) ?It works. ? The updated Python script to change the MAC address using variables. #!/usr/bin/env python import subprocess interface = "eth0" new_mac = "00:11:22:33:44:77" print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call("ifconfig " + interface + " down",shell=True) subprocess.call("ifconfig " + interface + " hw ether " + new_mac,shell=True) subprocess.call("ifconfig " + interface + " up",shell=True) Run the script successfully. ? The updated Python script using the user‘s input. #!/usr/bin/env python import subprocess interface = input("interface > ") new_mac = input("new MAC > ") print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call("ifconfig " + interface + " down",shell=True) ?Run the new scripts successfully. ? Enhance the security of the Python script by changing the use of the call function. #!/usr/bin/env python import subprocess interface = raw_input("interface > ") new_mac = raw_input("new MAC > ") print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call(["ifconfig",interface,"down"]) subprocess.call(["ifconfig","hw","ether",new_mac]) subprocess.call(["ifconfig","up"]) ?Run the script successfully and more secure. ? Update the Python script to handle command-line arguments. Use the module Parser:?https://docs.python.org/2/library/optparse.html #!/usr/bin/env python import subprocess import optparse parser = optparse.OptionParser() parser.add_option("-i","--interface",dest="interface",help="Interface to change its MAC address") parser.parse_args() interface = raw_input("interface > ") new_mac = raw_input("new MAC > ") print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call(["ifconfig","up"]) Initializing the variables based on the command arguments. #!/usr/bin/env python import subprocess import optparse parser = optparse.OptionParser() parser.add_option("-i",help="Interface to change its MAC address") parser.add_option("-m","--mac",dest="new_mac",help="New MAC address") (options,arguments) = parser.parse_args() interface = options.interface new_mac = options.new_mac print("[+] Changing MAC address for " + interface + " to " + new_mac) subprocess.call(["ifconfig","up"]) ? Execute the following commands. python mac_changer.py --interface eth0 --mac 00:11:22:33:44:55 or python mac_changer.py -i eth0 -m 00:11:22:33:44:55 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 删除pythonlist中的项目
- python-熊猫在特定级别向多索引添加行
- 无法在OSX El Capitan(opencv3.1.0)上的python2.7中导入cv2
- python – 为什么NamedTemporaryFile().write(没有中间变量
- Python 寻找最大连续子串和寻找最长数字串的简单示例
- 如何为Django Admin创建复杂的Django模型验证?
- python – PySpark 2:KMeans输入数据不直接缓存
- 在Mac OS系统上安装Python的Pillow库的教程
- Python Berkeley DB / Sqlite
- api接口是什么?会调用api之后,你会发现这可能就是学习的乐