Function to Change Mac on Win XP in Python

Questions about programming languages and debugging
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1610
Joined: 28 Aug 2005, 16:00
15

Function to Change Mac on Win XP in Python

Post by maboroshi »

Here is a function to change your mac address in Python

Code: Select all



def changemac():
    networkcard = OpenKey(
    HKEY_LOCAL_MACHINE,
    r"SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001",
    0, KEY_WRITE)
    mykey = "NetworkAddress"
    theend = raw_input("Please Enter The Mac Address to change to")
    try:
        value = SetValueEx(networkcard, mykey, 0, REG_SZ, theend)
        print "Mac Successfully Changed to \n\n" + theend)
        print "\n\n You now need to run \n http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272 \n\n")
        print "Or reboot your computer Easiest Choice\n\n")
    except:
        print "Failed Setting Mac")
    CloseKey(networkcard)

Cheers Maboroshi

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11567
Joined: 06 Apr 2005, 16:00
16
Location: The zone.
Contact:

Post by bad_brain »

sweet! :D
umm...is this registry key already existing including the original MAC?
or is is a new key? in the first case it might be useful to have the opportunity to save the original MAC to a textfile before changing it...just a suggestion.. :)

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1610
Joined: 28 Aug 2005, 16:00
15

Thats an idea

Post by maboroshi »

Thats an idea but would take all the fun out of it

hehe :D

I'll see what I can do ;)

Post Reply