Skip to content

Instantly share code, notes, and snippets.

@manugarri
Created June 7, 2014 19:25
Show Gist options
  • Save manugarri/122f17a64ce884d04f92 to your computer and use it in GitHub Desktop.
Save manugarri/122f17a64ce884d04f92 to your computer and use it in GitHub Desktop.
Change mac address
#!/usr/bin/env python
#Totally copied from http://www.reddit.com/r/Python/comments/27gumv/share_your_helper_scripts/
import os, random
def random_mac():
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
return ':'.join(map(lambda x: "%02x" % x, mac))
if __name__ == '__main__':
mac = random_mac()
print "Switching en0 to %s..." % mac
os.system("sudo ifconfig en0 ether %s" % mac)
os.system("ifconfig en0 | grep ether")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment