Last active
November 21, 2020 08:18
-
-
Save 2hanX/fff619aa45cbf00ce230267cd5c8a5ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import subprocess | |
from random import choice, randint | |
interface = input("Enter your network interface: ").strip() | |
choice_num = input("Enter your new mac address[0]/random mac[1]: ").strip() | |
if choice_num == 0: | |
new_mac = input("new mac: ").strip() | |
else choice_num == 1: | |
new_mac = mac_random() | |
else: | |
new_mac = mac_random() | |
def changeMac(interface, new_mac): | |
subprocess.call(['ifconfig ' + str(interface) + ' down'], shell=True) | |
subprocess.call(['ifconfig ' + str(interface) + | |
" hw ether " + str(new_mac) + ' '], shell=True) | |
subprocess.call(['ifconfig ' + str(interface) + ' up'], shell=True) | |
def mac_random(): | |
cisco = ["00", "40", "96"] | |
dell = ["00", "14", "22"] | |
mac_address = choice([cisco, dell]) | |
for i in range(3): | |
one = choice(str(randint(0, 9))) | |
two = choice(str(randint(1, 8))) | |
three = str(one + two) | |
mac_address.append(three) | |
return ":".join(mac_address) | |
def currentMac(): | |
output = subprocess.check_output(['ifconfig ' + 'wlan0'], shell=True) | |
current_mac = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", str(output)) | |
print(f"The old mac address: {current_mac}") | |
def main(): | |
currentMac() | |
changeMac(interface, new_mac) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment