PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Randomize Mac Address In Linux With Python Script

Go down

Randomize Mac Address In Linux With Python Script Empty Randomize Mac Address In Linux With Python Script

Post by jamied_uk 5th May 2017, 18:12



Kali has macchanger installed already but for Mint 18 you will need to install

Code:
sudo apt install -y macchanger



Tested in Kali Linux but fails inside virtual box im still working on this, check below for updates!.

Code:
#!/usr/bin/env python
# (c) J~Net 2017
# python fastmac_all.py wlan0

import random
import pwd
import os
import sys
import re

if len(sys.argv)<2:
    os.system("clear")
    os.system("ifconfig")
    adaptor=raw_input("Choose Adapter & Press Enter To Continue. ");
    
else:
    adaptor=sys.argv[1]

def randomMAC():
    return [ 0x00, 0x16, 0x3e,
        random.randint(0x00, 0x7f),
        random.randint(0x00, 0xff),
        random.randint(0x00, 0xff) ]

def MACprettyprint(mac):
    return ':'.join(map(lambda x: "%02x" % x, mac))

if __name__ == '__main__':
    newmac = (MACprettyprint(randomMAC()))
   # raw_input("Press Enter To Start Mac Changer...");
    os.system("sudo ifconfig " + adaptor + " down")
    combined = ' '.join([newmac,adaptor])
    os.system("sudo macchanger -m " + combined + "")
    os.system("sudo service network-manager restart")
    os.system("sudo ifconfig " + adaptor + " up")

I have made this so if you forget to put adapter (eth0 or wlan0) you will be shown a list and asked which adapter you want to change mac address on!

If used inside virtual box you will need to restart to get internet access back but on an actual machine (native) it will work 100% fine with no loss of internet!

Download Link
app.box.com/s/fq9hajmwab91se71rhivr2hvd7uhg6hs
https://app.box.com/s/fq9hajmwab91se71rhivr2hvd7uhg6hs


Last edited by jamied_uk on 6th May 2017, 01:18; edited 5 times in total
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Randomize Mac Address In Linux With Python Script Empty Re: Randomize Mac Address In Linux With Python Script

Post by jamied_uk 5th May 2017, 20:07

Bashrc Function


edit bashrc

Code:
sudo .bashrc

Add


Code:
function Mac(){
python ~/Documents/Scripts/MacChanger/fastmac_all.py $1
}

Code:
make sure path is correct above is an example!


now you can close terminal or reload source

Code:
source ~/.bashrc





and run like:

Code:
Mac wlan0
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum