Random MAC and IP Generator Function

Download | Vote Up (1) | Vote Down (0)
#!/usr/bin/python

import random

def mac_gen():
 hexa = [0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"]
 a = 1
 b = 0
 spoof_mac = ""
 while a != 7:
  while b != 2:
   rnd = random.randint(0, 15)
   spoof_mac = str(spoof_mac) + str(hexa[rnd])
   b = b + 1
  if a != 6:
   spoof_mac = str(spoof_mac) + ":"
  a = a + 1
  b = 0
 return str(spoof_mac)

def ip_gen():
 i = 1
 spoof_ip = ""
 while i != 5:
  rnd = random.randint(0, 255)
  spoof_ip = str(spoof_ip) + str(rnd)
  if i != 4:
   spoof_ip = str(spoof_ip) + "."
  i = i + 1
 return str(spoof_ip)
 

print "\nRandom Mac Adress\n"
print mac_gen()
print "\nRandom IP Adress\n"
print ip_gen() 

St0rn


Be the first to give feedback !

Please login to comment !