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)的更多相关文章

  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. ...

  2. 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 ...

  3. Python Ethical Hacking - ARP Spoofing

    Typical Network ARP Spoofing Why ARP Spoofing is possible: 1. Clients accept responses even if they ...

  4. Python Ethical Hacking - NETWORK_SCANNER(1)

    NETWORK_SCANNER Discover all devices on the network. Display their IP address. Display their MAC add ...

  5. Python Ethical Hacking - NETWORK_SCANNER(2)

    DICTIONARIES Similar to lists but use key instead of an index. LISTS List of values/elements, all ca ...

  6. Python Ethical Hacking - BeEF Framework(1)

    Browser Exploitation Framework. Allows us to launch a number of attacks on a hooked target. Targets ...

  7. Python Ethical Hacking - WEB PENETRATION TESTING(1)

    WHAT IS A WEBSITE Computer with OS and some servers. Apache, MySQL ...etc. Cotains web application. ...

  8. Python Ethical Hacking - BACKDOORS(8)

    Cross-platform hacking All programs we wrote are pure python programs They do not rely on OS-specifi ...

  9. Python Ethical Hacking - BACKDOORS(7)

    Handling Errors: If the client or server crashes, the connection will be lost. Backdoor crashes if: ...

随机推荐

  1. C++ 进阶 模板和STL

    C++提高编程 本阶段主要针对C++泛型编程和STL技术做详细讲解,探讨C++更深层的使用 1 模板 1.1 模板的概念 模板就是建立通用的模具,大大提高复用性 模板的特点: 模板不可以直接使用,它只 ...

  2. 笨办法学python - 专业程序员的养成完整版PDF免费下载_百度云盘

    笨办法学python - 专业程序员的养成完整版PDF免费下载_百度云盘 提取码:xaln  怎样阅读本书 由于本书结构独特,你必须在学习时遵守几条规则 录入所有代码,禁止复制粘贴 一字不差地录入代码 ...

  3. Typescript的interface、class和abstract class

    interface,class,和abstract class这3个概念,既有联系,又有区别,本文尝试着结合官方文档来阐述这三者之间的关系. 1. Declaration Merging Declar ...

  4. Spring中的JDBC API

    1 JdbcTemplate的诞生 JDBC作为Java平台访问关系数据库的标准API,其成功是有目共睹的.为了避免在JDBC API在使用中的种种尴尬局面(几乎程式一样的代码,繁琐的异常处理),Sp ...

  5. @PathVariable @RequestParam@RequestBody

    @PathVariable 当使用@RequestMapping URI template 样式映射时, 即 someUrl/{paramId}, 这时的paramId可通过 @Pathvariabl ...

  6. Git执行"git rebase -i HEAD~xxx"报错:git rebase fatal: Needed a single revision invalid upstream –i

    一.问题"git rebase -i HEAD~xxx"是修改git 历史记录的一个很有用的命令. 但是有时在执行该命令时会出现以下错误:$ git rebase –i HEAD~ ...

  7. ElasticSearch中的sort排序和filedData作用

    默认情况下,ElasticSearch 会根据算分进行排序: 可以使用 sort API 指定排序的规则: POST /kibana_sample_data_ecommerce/_search { & ...

  8. DataFrame索引和切片

    import numpy as np import pandas as pd from pandas import DataFrame, Seriesdf = DataFrame(data=np.ra ...

  9. yqq命令

    用 apt-get install 安装时 ,会有一个提问,问是否继续,需要输入 yes.使用 yqq 的话,就没有这个提问了,自动 yes . 例如下面的更新和安装nginx: apt-get -y ...

  10. day19__第三次作业

    一.break 与 continue 的区别 答:break 是结束全部循环,continue 是结束当前循环,开始进行下一循环 二.函数传递参数时,所用的内存地址一样吗? 答:一样 name = ' ...