Mac Address code in Python - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

Mac Address code in Python


daniels2

Recommended Posts

התחלתי לכתוב קודים בפייטון אבל רציתי להגיע עם זה יותר לרמה של פיתוח כלי איסוף מידע מאשר פיתוח רגיל, הקוד שלי לשינוי 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  address")
    return opt.parse_args()


def change_MAC(interface, mac):

    print("[+] Changing the  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)

 

קישור לתוכן
שתף באתרים אחרים

ארכיון

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

×
  • צור חדש...