Advertisement
infodox

HideMAC v1.4

Dec 3rd, 2011
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # HideMAC 1.4....
  3. # By infodox - credit to Trip from Hak5 for the getmac function, as mine did not work!
  4. # This version includes a quick "get interface names" function...
  5. import os
  6. import commands
  7. import sys
  8. import random
  9. # Function: amiroot()
  10. def amiroot():
  11.     if os.geteuid() != 0:
  12.         print("[-] sorry, you need to run this as root")
  13.         sys.exit(1)
  14.     else:
  15.         pass
  16.  
  17. # Function: get_ifaces()
  18. def get_ifaces():
  19.     airmon = os.popen("airmon-ng")
  20.     ifacelst = airmon.readlines()
  21.     li=0
  22.     for line in ifacelst:
  23.         line = line.replace("Interface\tChipset\t\tDriver","")
  24.         line = line.strip()
  25.         inum = li + 1
  26.         if line:
  27.             line = line.split("\t\t")
  28.             print(line[0])
  29.             ifaces = line[0]
  30.             return ifaces
  31.  
  32. # Function: randommac()
  33. def randomMAC():
  34.     mac = [ 0x00,
  35.       random.randint(0x00, 0xff),
  36.       random.randint(0x00, 0xff),
  37.       random.randint(0x00, 0xff),
  38.       random.randint(0x00, 0xff),
  39.       random.randint(0x00, 0xff) ]
  40.     return ':'.join(map(lambda x: "%02x" % x, mac))
  41.     return newmac
  42.  
  43. # Function: getmac(iface)
  44. def getmac(iface):
  45.     data = commands.getoutput("ifconfig " + iface)
  46.     words = data.split()
  47.     found = 0
  48.     for x in words:
  49.         #print x
  50.         if found != 0:
  51.             mac = x
  52.             break
  53.         if x == "HWaddr":
  54.             found = 1
  55.     if len(mac) == 0:
  56.         mac = 'Mac not found'
  57.     mac = mac[:17]
  58.     print(mac)
  59.  
  60. # Function: check()
  61. def check():
  62.     if os.path.isfile("/usr/local/bin/macchanger") == True:
  63.         print("MAC Changer is installed, using it...")
  64.         macchanger_changemac(iface)
  65.     else:
  66.         print("MAC Changer is not installed, using ifconfig method!")
  67.         ifconfig_changemac(iface)
  68.  
  69. # Function: macchanger_changemac(iface)
  70. def macchanger_changemac(iface):
  71.     print("[+] Changing your MAC address to something totally random...") # More statuses
  72.     os.popen("macchanger --random " + iface) # CHANGES MAC ADDRESS!!!!!!!
  73.  
  74. # Function: ifconfig_changemac(iface)
  75. def ifconfig_changemac(iface):
  76.     print("[+] Changing your MAC address to something totally random...") # More statuses
  77.     os.popen("ifconfig " + iface + " hw ether " + randomMAC())
  78.  
  79. # Main part!!!
  80. print("Welcome to HideMAC v1.4 by infodox")
  81. print("This code is still under development - I have a lot of work to do!")
  82. print("Have fun...")
  83. amiroot()
  84. print(" ")
  85. print("Currently Available Interfaces are...")
  86. get_ifaces()
  87. iface = raw_input("what interface are you changing (eg: wlan0): ") # Sets the interface to fuck with...
  88. print("[*] Your Current MAC address is: ")
  89. getmac(iface)
  90. os.popen("ifconfig " + iface + " down") # Puts interface down :(
  91. check()
  92. os.popen("ifconfig " + iface + " up") # Puts interface back up :)
  93. print("[*] Your New MAC address is: ")
  94. getmac(iface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement