עבור לתוכן

Mac Address code in Python

Featured Replies

פורסם

התחלתי לכתוב קודים בפייטון אבל רציתי להגיע עם זה יותר לרמה של פיתוח כלי איסוף מידע מאשר פיתוח רגיל, הקוד שלי לשינוי mac address, אשמח לקבל עצות לשיפור הקוד.

 

import subprocess
import optparse

def get_arg():
    opt = optparse.OptionParser()
    opt.add_option("-i", "--interface", dest="interface", help="This sets the interface")
    opt.add_option("-m", "--mac", dest="mac", help="This sets the MAC address")
    return opt.parse_args()


def change_MAC(interface, mac):

    print("[+] Changing the MAC address for", interface, "for MAC", mac)
    subprocess.call(["ifconfig", interface, "down"])
    subprocess.call(["ifconfig", interface, "hw", "ether", mac])
    subprocess.call(["ifconfig", interface, "up"])


(options, arg) = get_arg()
change_MAC(options.interface, options.mac)

 

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים