Results 1 to 3 of 3

Thread: RNMacchange - A script that changes your MAC Address to a random one automatically

  1. #1
    Join Date

    Post RNMacchange - A script that changes your MAC Address to a random one automatically

    Randomnetmacchange (RNMacchange for short) is my first simple tiny bash script
    The Features are
    • Spoof the host's MAC Address at set intervals
    • Stops changing the MAC Address when connected to an Ethernet or WiFi connection
    • Stops/starts switching function based on whether you are connected to a network, not an Internet connection which allows compatibility to networks that do not have Internet

    In other words the program changes your MAC Address when its not connected to a network but stops when it is while still having a spoofed MAC Address. I created this script because i found that i couldn't find any built in easy to setup features in Kali Linux that does this so i thought i could make and share this to people (mostly newbies) that may be interested in finding something that does that.
    And yes, i know the features are small but this was written up in a day that being said it is also my first script I've attempted in creating. I am going to provide some small updates in the future to make this script more powerful.

    This helps with anonymity as it changes and doesn't reveal your actual MAC Address so you can't be physically tracked and also helps people not spy on what your doing based on your MAC Address, please note that this is script will not COMPLETELY make you anonymous it only stops people from taking advantage of your MAC Address meaning that there is still other methods available of tracking you but this just eliminates a big one.

    I am going to point out 1 issue with the script, there isn't a function for the user to stop it changing the MAC Address when you not connected to a network this is an issue because this makes it not viable for situations were you need to specifically change your MAC Address to another in-order to connect to a network that has MAC Address Filtering enabled, there will be an update to fix this.

    I am accepting feedback on the script and suggestions to changes.

    Installing the script
    #! /bin/bash -x
     while [ 1 ] 
     sleep 10
     if ifconfig wlan0 | grep "inet" >> /dev/null; then 
     ##just some filler to not get the unexpected 'else' token message
     echo "connected"
     if ifconfig eth0 \ grep "inet" >> /dev/null; then 
     ##just some filler to not get the unexpected 'else' token message
     echo "connected"
     ## The echos could perhaps be used injunction with other applications (grep)
     echo "not connected, macchange in effect"
    #Turns off the interfaces so we can do some macchange magic
    ifconfig eth0 down
    ifconfig wlan0 down
    #Changes the mac address on eth0 to a random one
     macchanger -r eth0
     ifconfig eth0 up
     macchanger -r wlan0
     ifconfig wlan0 up
    ## waits 50 seconds before changing the mac address, you could change this to something less or more depending on your preference
     sleep 50
    ##closes the if loops and done also closes the do statement
    IMPORTANT NOTES: Change wlan0 and eth0 to your interfaces names, wlan0 being wifi and eth0 being ethernet cable, you can check the names by running this in terminal 'ifconfig' without quotes (Ignore the interface name called 'lo' its not needed for MAC Address changing.

    This requires an program called 'macchanger' to download do in terminal 'apt-get install macchanger' or 'pacman -S macchanger' Or 'yum install macchanger' depending what package manager you use

    Step One, In the terminal do 'yourtexteditor /bin/randomnetmacchange' without the quotes.

    Step Two, Copy and paste the code into your text editor then save.

    Step Three, In the terminal do 'sudo chmod 7 /bin/randomnetmacchange', if you have an error relating to unknown command remove sudo (not the program) and try again.

    Step Four, You now need to configure systemd to auto run this script at startup to do this do in terminal 'yourtexteditor /etc/systemd/system/randomnetmacchange.service''

    Step Five, Now copy the code below and paste it then save it.
    Description=Changes mac address in minute intervals if not connected to a network
    There now we have configured it to be a service that starts at boot one last step!

    Step Six, Now to enable the service and reboot your computer In terminal do 'systemctl enable randomnetmacchanger.service && reboot'.
    Done now the script will run at boot and change your MACAdress
    Uninstalling the script
    1. Remove the files that you've created during the installing process using the rm command
    2. Run the command to disable the RNMacchanger service: 'systemctl disable randomnetmacchanger.service'
    3. Done!
    I recommend you guys sharing and starting up threads about scripts and programs you've made thats what Linux is about after all!

  2. #2
    Join Date
    To Spicewolf

    Note that settings made thru macchanger will be overwritten by Network Manager unless the same address is loaded thru Network Manager drop down menus.

    Suggest you read the thread netmanmac found in these forums.

    That being said, there is a new version of Network Manager which MTeams has not seen which handles clone mac addresses differently.

    Musket Teams
    Last edited by mmusket33; 2016-08-08 at 04:06.

  3. #3
    Join Date
    Is this used in rolling 2016.2 x64? My wifi cards have some random MACs when at boot. And MACs keep changing while using airodump.

Similar Threads

  1. Updated Guide: How to make random MAC address at each boot
    By bluedangerforyou in forum How-To Archive
    Replies: 2
    Last Post: 2017-07-28, 23:51
  2. Kali assigns random mac address to wlan0
    By trojan_cow in forum TroubleShooting Archive
    Replies: 0
    Last Post: 2017-06-15, 18:44
  3. How to make mac address random at each boot up
    By Defaultzero in forum How-To Archive
    Replies: 19
    Last Post: 2016-12-16, 13:22
  4. Replies: 0
    Last Post: 2014-02-10, 17:53

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts