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. VS Code WebApi系列——2、jwt结合数据库校验

    Knowledge should be shared free. 我们都知道WebApi最重要的作用就是为外部服务提供相应的数据接口和服务,所以一般WebApi都会连接后台数据库,那么最重要的一件事就 ...

  2. excel筛选重复项代码

    Sub test()'updateby Extendoffice 20151030    Dim xRng As Range    Dim xTxt As String    On Error Res ...

  3. WeChair项目Beta冲刺(7/10)

    团队项目进行情况 1.昨日进展    Beta冲刺第七天 昨日进展: 前后端并行开发,项目按照计划有条不絮进行 2.今日安排 前端:扫码占座功能和预约功能并行开发 后端:扫码占座后端逻辑开发,编码预约 ...

  4. jni不通过线程c回调java的函数

    整个工程的项目如下: 1.项目的思路是在activity中启动MyService这个服务,在服务中调用 JniScsManger类中的本地方法startNativeScsService,在 start ...

  5. java中值传递

    最近学基础的时候,老师讲了值传递和引用传递,这个问题一直不太明白,上网查了很多资料,按照自己的理解整理了一遍,发现之前不太明白的地方基本上想明白了,如有不正确的地方,欢迎指正,谢谢. 首先要说明的是j ...

  6. mysql经典面试必须知道的

    http://www.cnblogs.com/wangshouchang/p/6930443.html 在华三的时候就问道了数据集的事务的四种特性,事务的隔离级别,事务的存储过程等

  7. 实现客户端与服务端之间传输json数据

    步骤:创建数据库,并创建表.利用myeclipse创建新工程,利用JDBC实现java操纵数据库.实现客户端类,服务端类.具体实现:创建数据表create table usertable( usern ...

  8. Security 10:权限管理

    SQL Server 用于管理权限的TSQL命令有:GRANT用于授予权限,REVOKE 用于移除授予的权限,而DENY用于防止安全主体通过GRANT获得权限.但是,SQL Server的权限管理不是 ...

  9. vscode 配置 c++ 环境

    vscode 配置 c++ 环境 参考的这篇bloghttps://blog.csdn.net/bat67/article/details/81268581 1.安装编译器.这里安装 codebloc ...

  10. git bash中提示 bash:node: command not found

    昨天小伙伴私信,git bash以及windows 的cmd命令行下均无法运行node npm. 究其原因是环境变量的问题.解决步骤: 1>在"此电脑"中右击,选择" ...