Advertisement
infodox

HideMAC v1.5

Dec 6th, 2011
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.43 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # HideMAC 1.5
  3. # Package mantained by infodox and Dark_Lightening
  4. # www.infodox.co.cc
  5. # blog.infodox.co.cc
  6. # http://twitter.com/info_dox
  7. # Credit to Trip from Hak5 for the getmac function, as mine did not work!
  8. # This version is a more cleaned up one, with a lot fo the Python2 code ported to Python3...
  9. # Also the ifconfig methods MAC address randomization engine has been improved!
  10. import os
  11. import commands
  12. import sys
  13. import random
  14.  
  15. # Function: Banner()
  16. # Does fuck all, just puts out an epic banner!
  17. def banner():
  18.     print(".##..##..######..#####...######..##...##...####....####...........##..##....##............######.")
  19.     print(".##..##....##....##..##..##......###.###..##..##..##..##..........##..##...###............##.....")
  20.     print(".######....##....##..##..####....##.#.##..######..##..............##..##....##.............####..")
  21.     print(".##..##....##....##..##..##......##...##..##..##..##..##...........####.....##......##........##.")
  22.     print(".##..##..######..#####...######..##...##..##..##...####.............##....######....##....#####..")
  23.     print("..................................By.Infodox.and.DARK_LIGHTNING..................................")
  24.     print("                   This code is still under development. It still needs work.                    ")
  25.     print("      Email any bugs you find in this code to infodox [at] compsoc [dot] nuigalway [dot] ie      ")
  26.  
  27. # Function: amiroot()
  28. def amiroot():
  29.     if os.geteuid() != 0:
  30.         print("[-] You are not root... Sudo may be of some assistance!")
  31.         sys.exit(1)
  32.     else:
  33.         pass
  34.  
  35. # Function: get_ifaces() This works in 3
  36. def get_ifaces():
  37.         airmon = os.popen("airmon-ng")
  38.         ifacelst = airmon.readlines()
  39.         li=0
  40.         for line in ifacelst:
  41.                 line = line.replace("Interface\tChipset\t\tDriver","")
  42.                 line = line.strip()
  43.                 inum = li + 1
  44.                 if line:
  45.                         line = line.split("\t\t")
  46.                         print (line[0])
  47.                         ifaces = line[0]
  48.                         return ifaces
  49.  
  50. # Function: randommac() as does this
  51. def randomMAC():
  52.     mac = [random.randint(0x00, 0xff) ,
  53.        random.randint(0x00, 0xff) ,
  54.        random.randint(0x00, 0xff) ,
  55.        random.randint(0x00, 0xff) ,
  56.        random.randint(0x00, 0xff) ,
  57.        random.randint(0x00, 0xff)]
  58.     return (':'.join(map(lambda x: "%02x" % x, mac)))
  59.     return (newmac)
  60.  
  61. # Function: getmac(iface)
  62. def getmac(iface):
  63.     data = commands.getoutput("ifconfig " + iface)
  64.     words = data.split()
  65.     found = 0
  66.     for x in words:
  67.         #print x
  68.         if found != 0:
  69.             mac = x
  70.             break
  71.         if x == "HWaddr":
  72.             found = 1
  73.     if len(mac) == 0:
  74.         mac = 'Mac not found'
  75.     mac = mac[:17]
  76.     print mac
  77.  
  78. # Function: check()
  79. def check():
  80.     if os.path.isfile("/usr/local/bin/macchanger") == True:
  81.         print("[*] MAC Changer is installed, using it...")
  82.         macchanger_changemac(iface)
  83.     else:
  84.         print("[*] MAC Changer is not installed, using ifconfig method!")
  85.         ifconfig_changemac(iface)
  86.  
  87. # Function: check() works
  88. def check():
  89.     if os.path.isfile("/usr/local/bin/macchanger") == True:
  90.         print("MAC Changer is installed, using it...")
  91.         macchanger_changemac(iface)
  92.     else:
  93.         print("MAC Changer is not installed, using ifconfig method!")
  94.         ifconfig_changemac(iface)
  95.  
  96. # Function: macchanger_changemac(iface)
  97. def macchanger_changemac(iface):
  98.     print("[+] Changing your MAC address to something totally random...") # More statuses
  99.     os.popen("macchanger --random " + iface) # CHANGES MAC ADDRESS!!!!!!!
  100.  
  101. # Function: ifconfig_changemac(iface)
  102. def ifconfig_changemac(iface):
  103.     print("[+] Changing your MAC address to something totally random...") # More statuses
  104.     os.popen("ifconfig " + iface + " hw ether " + randomMAC())
  105.  
  106. banner()
  107. amiroot()
  108. print("========== Currently Available Interfaces ==========")
  109. get_ifaces()
  110. print("====================================================")
  111. iface = raw_input("what interface are you changing (eg: wlan0): ") # Sets the interface to fuck with...
  112. print("[*] Your Current MAC address is: ")
  113. getmac(iface)
  114. os.popen("ifconfig " + iface + " down") # Puts interface down :(
  115. check()
  116. os.popen("ifconfig " + iface + " up") # Puts interface back up :)
  117. print("[*] Your New MAC address is: ")
  118. getmac(iface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement