Advertisement
infodox

HideMAC v1.2

Dec 2nd, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.37 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # HideMAC - 0x4641494c - v1.2
  3. # By infodox - credit to Trip from Hak5 for the getmac function, as mine did not work!
  4. # Credits to Mario Scondo for randomMAC 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: randommac()
  18. def randomMAC():
  19.     mac = [ 0x00,
  20.       random.randint(0x00, 0xff),
  21.       random.randint(0x00, 0xff),
  22.       random.randint(0x00, 0xff),
  23.       random.randint(0x00, 0xff),
  24.       random.randint(0x00, 0xff) ]
  25.     return ':'.join(map(lambda x: "%02x" % x, mac))
  26.     return newmac
  27.  
  28. # Function: getmac(iface)
  29. def getmac(iface):
  30.     data = commands.getoutput("ifconfig " + iface)
  31.     words = data.split()
  32.     found = 0
  33.     for x in words:
  34.         #print x
  35.         if found != 0:
  36.             mac = x
  37.             break
  38.         if x == "HWaddr":
  39.             found = 1
  40.     if len(mac) == 0:
  41.         mac = 'Mac not found'
  42.     mac = mac[:17]
  43.     print mac
  44.  
  45. # Function: check()
  46. def check():
  47.     if os.path.isfile("/usr/local/bin/macchanger") == True:
  48.         print("MAC Changer is installed, using it...")
  49.         macchanger_changemac(iface)
  50.     else:
  51.         print("MAC Changer is not installed, using ifconfig method!")
  52.         ifconfig_changemac(iface)
  53.  
  54. # Function: macchanger_changemac(iface)
  55. def macchanger_changemac(iface):
  56.     print("[+] Changing your MAC address to something totally random...") # More statuses
  57.     os.popen("macchanger --random " + iface) # CHANGES MAC ADDRESS!!!!!!!
  58.  
  59. # Function: ifconfig_changemac(iface)
  60. def ifconfig_changemac(iface):
  61.     print("[+] Changing your MAC address to something totally random...") # More statuses
  62.     os.popen("ifconfig " + iface + " hw ether " + randomMAC())
  63.  
  64. # Main part!!!
  65. print("Welcome to HideMAC - 0x4641494c - v1.2 by infodox")
  66. print("This code is still under development - I have a lot of work to do!")
  67. print("Have fun...")
  68. amiroot()
  69. iface = raw_input("what interface are you changing: ") # Sets the interface to fuck with...
  70. print("[*] Your Current MAC address is: ")
  71. getmac(iface)
  72. os.popen("ifconfig " + iface + " down") # Puts interface down :(
  73. check()
  74. os.popen("ifconfig " + iface + " up") # Puts interface back up :)
  75. print("[*] Your New MAC address is: ")
  76. getmac(iface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement