From 947a53f71ec085ab60f1d4ff95de328db2360f64 Mon Sep 17 00:00:00 2001 From: Ashhar Farooqui Date: Thu, 27 Oct 2022 22:02:46 +0530 Subject: [PATCH] Added new python program files --- Python/Password-Generator.py | 12 +++++++++ Python/macchanger.py | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Python/Password-Generator.py create mode 100644 Python/macchanger.py diff --git a/Python/Password-Generator.py b/Python/Password-Generator.py new file mode 100644 index 0000000..72afd52 --- /dev/null +++ b/Python/Password-Generator.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + + +import random + +s = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?" + +passlen = 8 + +p = "".join(random.sample(s,passlen)) + +print(p) diff --git a/Python/macchanger.py b/Python/macchanger.py new file mode 100644 index 0000000..a45ae96 --- /dev/null +++ b/Python/macchanger.py @@ -0,0 +1,50 @@ + +#importing modules +import subprocess +import optparse +import re + +#function for handling user input(arguments) +def getting_arguments(): + parser = optparse.OptionParser() + parser.add_option("-i", "--interface", dest="interface", help="enter the interface") + parser.add_option("-m", "--mac", dest="new_mac", help="enter new mac") + (options, arguments) = parser.parse_args() + if not options.interface: + parser.error("[-] Interface not specified, use --help for more information.") + elif not options.new_mac: + parser.error("[-] Mac address not specified, use --help for more information.") + return options + + +#function for changing MAC address +def changing_mac(interface, new_mac): + print("[+] Changing MAC address for " + interface + " to " + new_mac) + subprocess.call(["ifconfig", interface, "down"]) + subprocess.call(["ifconfig", interface, "hw", "ether", new_mac]) + subprocess.call(["ifconfig", interface, "up"]) + + +#function for getting search results +def get_current_mac(interface): + ifconfig_result = subprocess.check_output(["ifconfig", options.interface]) + + mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result) + if mac_address_search_result: + return mac_address_search_result.group(0) + else: + print("[-] Could not read Mac Address.") + + +options = getting_arguments() +current_mac = get_current_mac(options.interface) +print("Current MAC = " + str(current_mac)) + +changing_mac(options.interface, options.new_mac) + +#verifying whether MAC has changed or not +current_mac = get_current_mac(options.interface) +if current_mac == options.new_mac: + print("[+] MAC Address was successfully changed to " + current_mac) +else: + print("[-] MAC address did not get changed.")