Author Topic: Command-line app that spoofs a random MAC address  (Read 693 times)

0 Members and 1 Guest are viewing this topic.

Offline CompulsiveCoding

  • /dev/null
  • *
  • Posts: 5
  • Cookies: 0
    • View Profile
    • Ohmnitica
Command-line app that spoofs a random MAC address
« on: July 28, 2015, 05:04:26 am »
That was a very brief description of what I have in mind.

My goal is to create a command-line application -- written in C or something -- that sets the computer's  MAC address to one that is randomly generated. I'm thinking about adding an option that would save the machine's original MAC address to a *.txt file so that the user can switch back if they want to, later.

I realize this is a fairly simple application. However I think that this will be good practice for learning about MAC addresses (and how to spoof them!), as well as give me the opportunity to do something with the C language, which I had begun learning a few days ago.

If any of you have advice or input -- that is if you think I should make a change to my idea, use a different language, or simply criticize the mere notion of something so daft -- by all means DM me or click reply! :-)
Quote from: Kevin Mitnick
My primary goal of hacking was the intellectual curiosity, the seduction of adventure.

Offline gray-fox

  • Knight
  • **
  • Posts: 208
  • Cookies: 52
    • View Profile
Re: Command-line app that spoofs a random MAC address
« Reply #1 on: July 28, 2015, 05:46:38 am »
Well if you want to do this for learning purposes sure why not, even tho making it in C sounds bit odd choice when this is so easily done in short shell script and ofc. there's GNU macchanger , which already does what you descriped and much more.

edit: Just quick example why I said this can be easily done in short shell script; in bash it could be something like this:
Code: [Select]
#generate random macaddress
macdres=$(dd if=/dev/urandom bs=1024 count=1 2> /dev/null|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/00:\2:\3:\4:\5:\6/')
#backup real macaddress, wlan0 works as  example
if [ ! -f ~/mac_backup.txt ]; then
    ifconfig wlan0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > ~/mac_backup.txt
fi
#restore backup
if [ $1 = "--restore" ]; then
    macdres=$(cat ~/mac_backup.txt)
fi
#randomize (or restore) macaddress
ifconfig wlan0 down
ifconfig wlan0 hw ether $macdres
ifconfig wlan0 up
« Last Edit: July 28, 2015, 06:28:55 am by gray-fox »