{"id":329,"date":"2012-09-30T10:42:00","date_gmt":"2012-09-30T10:42:00","guid":{"rendered":""},"modified":"2017-02-07T14:10:22","modified_gmt":"2017-02-07T14:10:22","slug":"mutating-your-mac-address","status":"publish","type":"post","link":"https:\/\/perfectionatic.org\/?p=329","title":{"rendered":"Mutating your MAC address"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div dir=\"ltr\" style=\"text-align: left;\">Recently I was at an airport that offered free WiFi for the first 15 minutes, afterwards the system asked you pay. I knew that they must be checking identity via <a href=\"http:\/\/en.wikipedia.org\/wiki\/MAC_address\">MAC address<\/a>, so I wrote this little nifty python script that changes it to some random value each time you call it. This would only work on Linux (or maybe a MAC) OS.<br \/>\nI am not suggesting that you violate any laws, I put this up for educational purposes. Use it at your own risk.<br \/>\nFor obtaining the MAC address through python, I used <a href=\"http:\/\/stackoverflow.com\/users\/210613\/synthesizerpatel\">synthesizerpatel<\/a>&#8216;s <a href=\"http:\/\/stackoverflow.com\/questions\/159137\/getting-mac-address\">code snippet<\/a>. Alternatively the MAC address could have been obtained via a system call ifconfig using &#8220;subprocess.Popen&#8221;, as described in <a href=\"http:\/\/jimmyg.org\/blog\/2009\/working-with-python-subprocess.html\">here<\/a>.<\/p>\n<\/div>\n<pre style=\"background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"><code> #!\/usr\/bin\/python  \n   \n import fcntl, socket, struct, random  \n from subprocess import call  \n   \n def getHwAddr(ifname):  \n   s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  \n   info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15]))  \n   return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]  \n   \n   \n a=getHwAddr('wlan0')  \n i=random.randint(2,5)  \n b=a[:3*i]+hex((int(a.split(':')[i])+random.randint(1,255))%255)[2:].zfill(2)+a[(i+1)*3-1:]  \n   \n print \"Changing from \"+a+\" to \"+b  \n call([\"sudo ifconfig wlan0 down\"],shell=True)  \n call([\"sudo ifconfig wlan0 hw ether \"+b],shell=True)  \n call([\"sudo ifconfig wlan0 up\"],shell=True)  \n   \n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was at an airport that offered free WiFi for the first 15 minutes, afterwards the system asked you pay. I knew that they must be checking identity via MAC address, so I wrote this little nifty python script that changes it to some random value each time you call it. This would only [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88,89,85],"tags":[76],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-ifconfig","category-mac-address","category-python","tag-linux"],"_links":{"self":[{"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/posts\/329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329"}],"version-history":[{"count":3,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":334,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions\/334"}],"wp:attachment":[{"href":"https:\/\/perfectionatic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/perfectionatic.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}