Python Ethical Hacking - MAC Address & How to Change(1)
MAC ADDRESS
- Media Access Control
- Permanent
- Physical
- Unique
- Assigned by manufacturer
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 ::::: ifconfig eth0 up ifconfig
MAC_CHANGER USING A PYTHON MODULE TO EXECUTE SYSTEM COMMANDS
- The subprocess module contains a number of functions.
- These functions allow us to execute system commands.
- Commands depend on the OS which executes the script.
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)
subprocess.call("ifconfig " + interface + " hw ether " + new_mac, shell=True)
subprocess.call("ifconfig " + interface + " up", 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", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "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", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])
Initializing the variables based on the command arguments.
#!/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.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", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])
Execute the following commands.
python mac_changer.py --interface eth0 --mac ::::: or python mac_changer.py -i eth0 -m :::::
Python Ethical Hacking - MAC Address & How to Change(1)的更多相关文章
- Python Ethical Hacking - MAC Address & How to Change(3)
SIMPLE ALGORITHM Goal -> Check if MAC address was changed. Steps: 1. Execute and read ifconfig. ...
- Python Ethical Hacking - MAC Address & How to Change(2)
FUNCTIONS Set of instructions to carry out a task. Can take input, and return a result. Make the cod ...
- Python Ethical Hacking - ARP Spoofing
Typical Network ARP Spoofing Why ARP Spoofing is possible: 1. Clients accept responses even if they ...
- Python Ethical Hacking - NETWORK_SCANNER(1)
NETWORK_SCANNER Discover all devices on the network. Display their IP address. Display their MAC add ...
- Python Ethical Hacking - NETWORK_SCANNER(2)
DICTIONARIES Similar to lists but use key instead of an index. LISTS List of values/elements, all ca ...
- Python Ethical Hacking - BeEF Framework(1)
Browser Exploitation Framework. Allows us to launch a number of attacks on a hooked target. Targets ...
- Python Ethical Hacking - WEB PENETRATION TESTING(1)
WHAT IS A WEBSITE Computer with OS and some servers. Apache, MySQL ...etc. Cotains web application. ...
- Python Ethical Hacking - BACKDOORS(8)
Cross-platform hacking All programs we wrote are pure python programs They do not rely on OS-specifi ...
- Python Ethical Hacking - BACKDOORS(7)
Handling Errors: If the client or server crashes, the connection will be lost. Backdoor crashes if: ...
随机推荐
- ca33a_demo_c++_新旧代码的兼容char数组与vector_string相互转换
/*ca33a_demo_c++33_CppPrimer_新旧代码的兼容_txwtech旧代码:数组和c风格字符串新代码:vector和string相互转换:c风格字符串<- ->stri ...
- Maven发展历史
1.1 Maven是什么 Maven是一个项目管理和综合工具. Maven提供了开发人员构建一个完整的生命周期框架.开发者团队可以自动完成项目的基础工具建设, Maven使用标准的目录结构和默认构建生 ...
- android面试详解
前台就是和用户交互的进程 可见进程例如一个activity被一个透明的对话框覆盖,该activity就是可见进程 服务:service进程 后台一个activity按了home按键就是从前台退回到后台 ...
- MongoDB入门三
MongoDB字段问题 增删查改操作 删除一列操作db.RiderReaTimePositon.update({},{$unset:{'CreateTime':''}},false,true)db. ...
- Java工具类——日期相关的类
前言 在日常的开发工作当中,我们经常需要用到日期相关的类(包括日期类已经处理日期的类),所以,我就专门整理了一篇关于日期相关的类,希望可以帮助到大家. 正文 一.日期类介绍 在 Java 里面,操作日 ...
- npm安装加速
1.通过config命令 npm config set registry https://registry.npm.taobao.org npm info underscore (如果上面配置正确这个 ...
- linux下安装jdk并设置环境变量
首先去官网下载jdk安装包 我这里下载的是jdk7,因为jdk8之后做了很大的改动,所以现在常用的还是jdk7.下载地址:www.oracle.com/technetwork/cn/java/ja ...
- windows 下搭建 MQTT 服务
1.首先搭建起MQTT服务 1.1安装mosquitto,mosquitto是开源的MQTT代理服务器,它的Windows安装包地址:https://mosquitto.org/download/ 1 ...
- 《算法笔记》6.6小节 问题 A: 任务调度
这道题我一开始看到的时候,想到的是拓补排序,可是这么菜又这么懒的我怎么可能用呢,既然出现在优先队列里面,那么久一定和他有关了 可是并没有使用优先队列 思路: 对于这道题,我们肯定是对他们定义优先级,然 ...
- hive 时间戳函数之unix_timestamp,from_unixtime
一. 日期>>>>时间戳 1.unix_timestamp() 获取当前时间戳 例如:select unix_timestamp() -- 2.unix_timestamp(s ...