Skip to content

Instantly share code, notes, and snippets.

@evilr00t
Created March 28, 2017 14:55
Show Gist options
  • Save evilr00t/b0ea482796948a69ba38fb9c519c514e to your computer and use it in GitHub Desktop.
Save evilr00t/b0ea482796948a69ba38fb9c519c514e to your computer and use it in GitHub Desktop.
Generate unique mac address using bash & python
# evilroot at Karols-MacBook-Pro.local in ~ [15:53:05]
→ python - << EOF
import random
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
print ':'.join(map(lambda x: "%02x" % x, mac))
EOF
00:16:3e:76:e0:78
# evilroot at Karols-MacBook-Pro.local in ~ [15:53:06]
→ function new_mac() {
function> python - << EOF
import random
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
print ':'.join(map(lambda x: "%02x" % x, mac))
EOF
function> }
# evilroot at Karols-MacBook-Pro.local in ~ [15:54:28]
→ alias nma=new_mac
# evilroot at Karols-MacBook-Pro.local in ~ [15:54:31]
→ nma
00:16:3e:7d:32:bf
# evilroot at Karols-MacBook-Pro.local in ~ [15:54:32]
→ nma
00:16:3e:60:75:96
# evilroot at Karols-MacBook-Pro.local in ~ [15:54:34]
→ nma
00:16:3e:57:f5:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment