Random Mac Address Generator, + macchanger + monitor mode

Discussion in 'Linux' started by mindhack, May 9, 2009.

  1. mindhack

    mindhack

    Joined:
    Apr 25, 2009
    Messages:
    35
    Likes Received:
    0
    Location:
    Sequim, Wa
    This bash script will assign a random mac address to wlan0, and start monitor mode on mon0. You will need the aircrack-ng and macchanger packages to use this script. To use it with a system other than the acer aspire one, you will need to modify the interfaces.

    You can remove the lines with airmon-ng and mon0, if you don't want to install te aircrack-ng package or put it into monitor mode.

    Open a txt editor, paste this code in, save it as rndmac.sh.
    Open a terminal, and chmod a+x rndmac.sh

    To run it use
    sudo ./rndmac.sh

    Edited to fix minor issue.

    Code:
    #!/bin/bash
    #Published by
    #[url]http://www.mindhack.us[/url]
    
    Brand="00:00:05
    00:21:78
    00:23:BA
    00:23:BB
    00:23:BC
    00:23:BD
    00:23:BE
    00:23:BF
    00:23:C0
    00:23:C1
    00:23:C2
    00:23:C3
    00:23:C4
    00:23:C5
    00:23:C6
    00:13:C8"
    
    Mac="0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    A
    B
    C
    D
    E
    F"
    
    
    brand=($Brand)
    mac=($Mac)
    
    num_brand=${#brand[*]}
    num_mac=${#mac[*]}
    
    newmac="${brand[$((RANDOM%num_brand))]}:"${mac[$((RANDOM%num_mac))]}"${mac[$((RANDOM%num_mac))]}:"${mac[$((RANDOM%num_mac))]}"${mac[$((RANDOM%num_mac))]}:"${mac[$((RANDOM%num_mac))]}"${mac[$((RANDOM%num_mac))]}"
    
    ifconfig wlan0 down
    macchanger -m $newmac wlan0
    ifconfig wlan0 up
    airmon-ng start wlan0
    ifconfig mon0 down
    macchanger -m $newmac mon0
    ifconfig mon0 up
    
    echo "Your new randomly generated mac address is $newmac"
    echo "and monitor mode has been started on mon0"
    echo "http://www.mindhack.us"
    
    exit
    
    
     
    mindhack, May 9, 2009
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.