Results 1 to 1 of 1

Thread: [SOLVED] Could not change MAC. & Setup Macchanger auto spoofing/randomization in Kali

  1. #1
    Junior Member
    Join Date
    Apr 2017
    Posts
    1

    Lightbulb [SOLVED] Could not change MAC. & Setup Macchanger auto spoofing/randomization in Kali

    Here's a simple solution to getting your mac address to either randomize or use a custom address upon rebooting or making a new wireless connections in Kali Linux. I decided to post this after having an issue with macchanger which I couldn't find a working solution for in the forum.

    After the latest system update, macchanger stoped working entirely. It would not change the MAC address for either wlan0 or eth0 and every attempt would return "[ERROR] Could not change MAC: interface up or insufficient permissions: Device or resource busy"

    # service NetworkManager stop
    # ifconfig wlan0 down
    # macchanger -r wlan0
    # ifconfig wlan0 up
    # service NetworkManager start
    This would return the error message and would not allow the address to change. I tried several other recommended methods with no success and finally decided to try to just reinstall macchanger which ultimately fixed the error.

    TO FIX THE ISSUE DO THE FOLLOWING:

    Remove macchanger
    # apt-get remove macchanger -y
    This command will also force the removal of fern-wifi-cracker & kali-linux-full...
    So install them all again.

    # apt-get install macchanger fern-wifi-cracker kali-linux-full -y
    After the install is complete the error message is no more. Now to set up automatic MAC spoofing/randomization. This is the same method that I use in Fedora & Redhat.

    First create a new startup service:

    # nano /etc/systemd/system/macspoof@.service
    Insert the following text into the new file:

    [Unit]
    Description=macchanger on %I
    Wants=network-pre.target
    Before=network-pre.target
    After=sys-subsystem-net-devices-%i.device

    [Service]
    ExecStart=/usr/bin/macchanger -r %I
    Type=oneshot

    [Install]
    WantedBy=multi-user.target
    Enable the new service and modify the interface name ('wlan0') to match your setup:

    # systemctl enable macspoof@wlan0.service
    MACCHANGER WILL NOW RANDOMIZE YOUR MAC AT REBOOT
    IF YOU WISH TO HAVE MACCHANGER RANDOMIZE YOUR MAC WITH EACH NEW CONNECTION
    DO THE FOLLOWING:

    # nano /etc/NetworkManager/dispatcher.d/random_mac.sh
    Enter the following text into the file be sure to modify 'wlan0' to match your interface name:

    #!/bin/sh

    IF=$1
    STATUS=$2
    MACCHANGER=/usr/bin/macchanger
    WLANIFACE="wlan0"

    if [ -z "$IF" ]; then
    echo "$0: called with no interface" 1>&2
    exit 1;
    fi
    if [ ! -x $MACCHANGER ]; then
    echo "$0: can’t call $MACCHANGER" 1>&2
    exit 1;
    fi

    if [ "$IF" = "$WLANIFACE" ] && [ "$STATUS" = "down" ]; then
    /usr/sbin/ip link set $IF down
    $MACCHANGER -r $IF
    /usr/sbin/ip link set $IF up
    fi
    Now make the file executable:

    # chmod +x /etc/NetworkManager/dispatcher.d/random_mac.sh
    OPTIONAL: Every time you disconnect and reconnect to the same access point the DHCP server will give you a fresh IP address from the table. If you are constantly disconnecting and reconnection this can fill the table and in effect crash some routers. If you would like to prevent this, you can use an univocal DHCP identifier for the wireless card, instead of its MAC address.

    Create or edit the following file:

    # nano /etc/dhcp/dhcpclient.conf
    Edit or create the dhcp-client-identifier to any value you choose other than the default 'hardware':

    send dhcp-client-identifier = "kali_wifi_card";
    THATS IT. ENJOY YOUR NEW RANDOM MAC ADDRESS.
    Last edited by GoBlack; 2017-04-20 at 07:48 PM.

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
  •