###Learn how change your identity
I love spending part of my free time writing for my blog and reading a book. During the weekend, I like do this in a quite place, drinking my favourite coffee and tasting tarts or cakes.
Few weeks ago I was studying in a coffee shop and everything seemed fine. The place was pretty nice and quite, the coffee amazing. Except one thing: the use of wifi connectivity was time limited. Every 25 minutes wifi connection dropped down: to continue to surf the web there were two options: compile a registration form providing all your personal details, or spoof the airport MAC address.
Spoof a MAC address is really easy in Mac OSX and in all Unix/Linux based systems. However, running the same commands several times per day can get everyone bored in short time. So I decided to write a little script for spoofing the wifi interface in OSX Yosemite and make all the process automatic and invisible to the user. The script is very easy and it is fundamentally based on the ifconfig command.
MAC spoofing entails changing a computer’s identity. Technically speaking, it is a technique for masking the MAC address of the network interface. Indeed, each network interface is uniquely identified by a factory-assigned hard-coded address called Media Access Control (MAC). This address cannot be changed. However, there are several tools for Windows or Unix based systems, which can make the operating system believe that the NIC has the MAC address of a user’s choosing.
Every spoofing software use a foundamental command: ifconfig. Looking in the man page, providing the ether option (an alias for lladdr), is possible to change the MAC address.
It is worth to note that in OSX there are some limitations to overcome in order to make the script well working:
-
not all the combination to build a mac addresses can be used. Indeed there are some digits reserved that can have a limited range of values (e.g the first or the last bytes related, depending by the card manufacturer). The script should generate a new MAC address until it can be used.
-
every virtual hardware change need be detected and the wifi interface should automatically reconnect to the wifi network
-
I want the script is executed automatically at login time
-
I want the possibility to set a special MAC address to use
-
I want disable the automatic execution, if necessary
##MAC spoofing on OSX Yosemite: yospoof.sh Below you can see the bash script I wrote to spoof the wifi network card on my Macbook Pro (download).
It is very easy to understand. As first thing it parses the options provided through the command line. Indeed is possible to use a custom MAC address using -m as option. In case no address is provided, the script will generate a new MAC randomly and it will try to spoof the mac. The process is repeated again up to 5 times in case the MAC address generated is not valid.
In order to perform the spoof operation correctly, is necessary previously to disconnect the interface from any network and then, after the spoof, detect hardware changes. As last thing, the script disables and re-enables the airport interface in order to reconnect automatically to the network.
Below the results after a script excecution (use -v for verbose mode):
##Execute the script at login time: Automator As last thing, you can make airspoof.sh automatically run on each login time. Simply open Automator, select Run AppleScript, and past the code below:
After the field customization (script_path, username and password), save the script as yospoof.app or any other name you like.
Then open Control Panel and add the app in Login Items:
##Avoid to store password in plaintext As noted by Rudy Baum in his comment, Automator has a weak. it stores the whole script as plaintext. In some situations, store your system password could be a serious security risk. To address this further complication, there are 3 options you can follow:
1.Don’t save at all the password in the script. Just use the script below
In this way you’ll be prompted for a password each time.
2.If you are the only user on your mac and you’re using FileVault encryption, restrict access permission of spoof.app as much as possible. ie with chmod:
In this way you’re just protecting yourself from bad guys’eyes that could look in the script and find root password.
3.Use a specific tool, ie except
##Further Information MAC spoofing, Wikipedia.org
do shell script in AppleScript, Technical Note TN2065: do shell script in AppleScript