Skip to content

Commit

Permalink
Support for non-root user added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hack Hunt committed Jun 21, 2020
1 parent 9dc9bf5 commit 7d4fdd9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
### Supports Platform: Linux, Debain

### How to use:
- Convert the file into executable.
- Convert the setup.sh into executable
> **chmod 755 setup.sh**
- Run setup.sh
> **./setup.sh**

- Convert the mac_changer into executable.
> **chmod u+x mac_changer**
- Run the Executable.
> **./mac_changer**
Expand Down
Binary file modified mac_changer
Binary file not shown.
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo apt install net-tools -y
16 changes: 8 additions & 8 deletions source_code/mac_changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

def mac_change(interface, mac):
print(colored("[+] Changing interface (" + interface + ") to down state", 'yellow'))
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["sudo","ifconfig", interface, "down"])

print(colored("[+] Changing MAC Address for " + interface + " to " + colored(mac, 'white'), 'yellow'))
subprocess.call(["ifconfig", interface, "hw", "ether", mac])
subprocess.call(["sudo","ifconfig", interface, "hw", "ether", mac])

print(colored("[+] Changing interface (" + interface + ") to up state\n", 'yellow'))
subprocess.call(["ifconfig", interface, "up"])
subprocess.call(["sudo","ifconfig", interface, "up"])


def get_current_mac(interface):
result = subprocess.check_output(["ifconfig", interface])
result = subprocess.check_output(["sudo","ifconfig", interface])
mac_add = re.search("\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", str(result))

if mac_add:
Expand Down Expand Up @@ -61,7 +61,7 @@ def get_cmd_line_arguments():
parser = argparse.ArgumentParser(prog="MAC Changer",
usage="%(prog)s [options]\n\t[-i | --interface] interface_name\n\t[-m | --mac] mac_address",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=""">>> | MAC Changer v1.0 by Hack Hunt | <<<
description=""">>> | MAC Changer v1.1 by Hack Hunt | <<<
---------------------------------""",
epilog="*** If -m or --mac is not specified MAC will be generated randomly")

Expand All @@ -88,7 +88,7 @@ def main():
mac = args.mac

try:
subprocess.check_call(['ifconfig', interface], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.check_call(['sudo','ifconfig', interface], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
print(colored("\n[-] Error! Interface (" + interface + ") not found!\n", 'red'))
sys.exit()
Expand All @@ -106,7 +106,7 @@ def main():
else:
print(colored("\n[-] Please enter a valid MAC Address\n", 'red'))
else:
print(original_mac)
print(colored("\n[-] MAC Address not found for the Interface (" + interface + ").\n", 'red'))


main()
main()

0 comments on commit 7d4fdd9

Please sign in to comment.