{"id":205,"date":"2010-04-02T14:01:49","date_gmt":"2010-04-02T20:01:49","guid":{"rendered":"http:\/\/hackarandas.com\/blog\/?p=205"},"modified":"2010-04-02T14:04:09","modified_gmt":"2010-04-02T20:04:09","slug":"fast-mac-address-changer-in-linux","status":"publish","type":"post","link":"https:\/\/hackarandas.com\/blog\/2010\/04\/02\/fast-mac-address-changer-in-linux\/","title":{"rendered":"Fast MAC Address Changer in Linux"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/hackarandas.com\/blog\/wp-content\/uploads\/2010\/03\/APtext3RWBCol-150x150.jpg\" style=\"margin: 10px 10px 0pt 0pt; float: left; width: 120px; height: 134px;\" title=\"Fractal\" alt=\"\" \/> When you are making a pentest sometimes you need to be sneaky and have some tricks in your arsenal to cloak yourself in the network. But some sysadmins are skillfull in their incident response and, sometimes (not many in my experience) they found you and try to block your access creating some ACLs for the IP you are using, maybe for your MAC Address.<\/p>\n<p>This script runs on linux and helps you changing your MAC Address in a blink of an eye, this is how it works: you invoke the command and automatically see if you are root, if not it sudo itself to get the needed priviledges, generates a new random mac and installs it in the interface.<\/p>\n<pre lang=\"c\">-=:)> changemacrandom.sh <interface> <\/pre>\n<p>For example:<\/p>\n<pre lang=\"c\">\r\n-=:)> changemacrandom.sh eth0\r\nOnly root can do that! sudoing...\r\neth0      Link encap:Ethernet  HWaddr 00:15:c5:3d:e9:82  \r\nInterface eth0 has new mac:\r\neth0      Link encap:Ethernet  HWaddr 70:e7:84:ca:b2:c5  \r\nRestart dhcp client to get a new IP. <\/pre>\n<p>The code is really simple:<\/p>\n<pre lang=\"bash\">\r\n#!\/bin\/bash\r\n# Script by Adrian Puente Z. apuente _AT_ hackarandas _dot_ com\r\n# Powered by Hackarandas www.hackarandas.com\r\n# Licensed by GNU GPLv3\r\n# http:\/\/www.gnu.org\/licenses\/gpl-3.0.txt\r\n\r\n\r\n[ $# -eq 0 ] && echo  \"Sintax: `basename $0` <interface>\" && exit 0\r\n\r\n[ `id -u` -ne 0 ] && echo \"Only root can do that! sudoing...\" \r\nif [ \"$EUID\" != 0 ]; then sudo `which $0` $1; exit; fi\r\n\r\nINT=$1\r\n\r\nfunction gennewmac\r\n{\r\nhexdump  \/dev\/urandom | head -3 |\\\r\n\t cut -d' ' -f2 | while read -n 2 i\r\n\t\t\t do echo -n $i:\r\n\t\t\t done | sed 's\/::\/:\/g;s\/:$\/\/g'\r\n}\r\n\r\nif  ifconfig ${INT} 2> \/dev\/null 2>&1 | head -1 \r\nthen\r\n\tNEWMAC=`gennewmac`\r\n\tsleep 3\r\n\tif  ifconfig ${INT} down hw ether ${NEWMAC} 2>\/dev\/null\r\n\tthen\r\n\t\techo Interface ${INT} has new mac: \r\n\t\tifconfig ${INT} 2> \/dev\/null 2>&1 | head -1\r\n\t\tifconfig ${INT} up\r\n\t\techo Restart dhcp client to get a new IP.\r\n\telse\r\n\t\techo \"Error changing MAC to ${NEWMAC}!\"\r\n\t\techo \"Try again with the same command.\"\r\n\t\texit 1\r\n\tfi\r\nelse\r\n\techo \"Interface ${INT} doesn't exists!\"\r\n\texit 1\r\nfi\r\nexit 0 <\/pre>\n<p>You can <a href=\"http:\/\/hackarandas.com\/hacking-projects\/changemacrandom.sh.gz\">download the script<\/a> or <a href=\"http:\/\/hackarandas.com\/hacking-projects\/\">check other projects<\/a> i&#8217;ve made.<\/p>\n<p>So that&#8217;s it. Leave your comments please and happy hacking!<\/p>\n<p><em>Adri\u00c3\u00a1n Puente Z.<\/em><\/p>\n<p><a href=\"http:\/\/www.technorati.com\/tag\/hackarandas\" rel=\"tag\">hackarandas<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/hacker\" rel=\"tag\">hacker<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/mac+changer\" rel=\"tag\">mac changer<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/Adrian+Puente+Z.\" rel=\"tag\">Adrian Puente Z.<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/Linux\" rel=\"tag\">Linux<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/backtrack\" rel=\"tag\">backtrack<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/pentest\" rel=\"tag\">pentest<\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>When you are making a pentest sometimes you need to be sneaky and have some tricks in your arsenal to cloak yourself in the network. But some sysadmins are skillfull in their incident response and, sometimes (not many in my &hellip; <a href=\"https:\/\/hackarandas.com\/blog\/2010\/04\/02\/fast-mac-address-changer-in-linux\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,8,4],"tags":[30,29,23,80,24],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry","category-code","category-hacking","category-security","tag-backtrack","tag-bash","tag-hackarandas","tag-hacking","tag-pentest"],"_links":{"self":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":9,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/205\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}