Randomize Mac Address In Linux With Python Script
Page 1 of 1 • Share •
Randomize Mac Address In Linux With Python Script
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
Re: Randomize Mac Address In Linux With Python Script
Bashrc Function
edit bashrc
Add
now you can close terminal or reload source
and run like:
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

» Problem with brackets[?] in css selector in Selenium-python
» Script for an email address that is already registered in the database
» Linux Based Stable Solution for VoIP Business!!
» Getting error when i run selenium script in Eclipse, please help
» Linux based VoIP Switch with Integrated Billing only $2/port
» Script for an email address that is already registered in the database
» Linux Based Stable Solution for VoIP Business!!
» Getting error when i run selenium script in Eclipse, please help
» Linux based VoIP Switch with Integrated Billing only $2/port
Permissions in this forum:
You cannot reply to topics in this forum