Jump to content

Mac clone script


yabasoya

Recommended Posts

I have a list of 20 'authorized' macs (will add more as I come across them). I was looking to write a script that runs on startup to query the file of macs and randomly pick one to clone it to wlan1.

Can someone help me write a script to do this or at least point me in the right direction?

Thanks.

Link to comment
Share on other sites

A bash script like this will should use a random mac (please test as i have not)

#!/bin/bash

sleep 20 #Wait 20 seconds - Use if you need to wait for other things to load first
max=$(wc -l /sd/mac.list) #Count the macs in list (i assume each mac is on a seperate line and only contains MAC?)
num=$(( ( RANDOM % $max )  + 1 )) #Get number between 1 - number of macs in file.
mac=$(tail -n $num /sd/mac.list| head -n 1) # get random mac

macchanger -m $mac #Change to random mac address :)

Good Luck, let us know how you go!

Edited by markcoker
Link to comment
Share on other sites

It just needed a wlan1 on the last line and an extra set of parenthesis on line 4. Without them it was assigning '20 /sd/mac.list' to max, not just '20'

#!/bin/bash

sleep 20 #Wait 20 seconds - Use if you need to wait for other things to load first
max=($(wc -l /sd/mac.list)) #Count the macs in list (i assume each mac is on a seperate line and only contains MAC?)
num=$(( ( RANDOM % $max )  + 1 )) #Get number between 1 - number of macs in file.
mac=$(tail -n $num /sd/mac.list| head -n 1) # get random mac

macchanger -m $mac wlan1 #Change to random mac address :)
Thanks for the help! It works in a shh terminal on the pineapple. I just need to test it on a dip switch next. Edited by yabasoya
Link to comment
Share on other sites

goodstuff,

totally missed the mistake on line 4 :)

TIP: if your wanting to test your dip setup you could run /usr/bin/dip-handler which ive found handy to test correct dipsetup.

1. So you first just use web interface Configuration > Boot Modes (or edit mk5.db with a db editor of your choice) to edit dip settings & save.

2. Change your dips correct to the settings you want to test.

3. Finally run /usr/bin/dip-handler and those settings will run.

Hope it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...