Jump to content

Change Mac Address


Recommended Posts


This is for mac address spoofing.
Before a mod gives me the ban hammer for posting code such as this, id like to explain I recently had a necessity for it.
A lot of places use mac addresses to identify devices/machines and control internet permissions.
I myself love the xfinity wifi hotspots placed all around where I live as I can connect to them and save data usage instead of tethering my phone.
BUT! They use a captive portal with a webpage interface in javascript and (not too much to my surprise), wifey says some of her crap wont open that page.
I explained she can disable wifi on the device, use computer and spoof to the mac address of what she wants to use. Then sign into the portal as she would normally with computer.
Once connected, shut the computer down and enable wifi for that device again. Once enabled shes got net access. edit: Wife looked at me like I was speaking latin.....lol

;
;
; Function:  Set_Mac()
;
; Parameter(s):  $s_Desired_Mac        =    Need I really explain?
;                $s_Target_Net_Adapter =    Network adapter name (one can use the adapter index as well but thats less "user friendly"
;                $b_Toggle_Device      =    For my wife cuz it needs full automation for her to stop bothering me
;
; Author(s):     KingOfNothing credz to google & autoitscript.com members
;
;
;=====================================================================




Opt('MustDeclareVars', 0) ;cause its late in the morning and im just gonna trust this should still fly
#include <WinApi.au3>


$MacAddressRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007"
;                                                   ^^^ After making this I read online that this should be some "CurrentControlSet"
;                                                       key instead. However, I watched registry while changing things in adapter properties
;                                                       to see that key, which works fine on my 3 test machines....

;easy example
Set_Mac("Wireless Network Connection","",true)
;msgbox(0,"",Get_Mac())




Func Set_Mac($s_Targeted_Adapter, $s_Desired_Mac = "D20000000000",  $b_Toggle_Device = true )
Local $sMac, $s_Tmp, $val, $sVar = ""

$sMac = Get_Mac()
while stringlen($s_Desired_Mac)< 12 and stringlen($s_Desired_Mac)> 0   ;this will append zeros if mac length is too short
   $s_Desired_Mac = $s_Desired_Mac & "0"
wend

if stringlen($s_Desired_Mac)> 12 then  ;likewise if too many characters entered to function, then we should truincate some
$s_Desired_Mac = StringLeft ($s_Desired_Mac,12)
endif

;this creates a random mac address with very little actual thought behind it.
;Im sure theres some formal means to devising a valid mac address but this simple crap suits my needs atm....
if $s_Desired_Mac = "" then
      For $i = 1 To 10
        $sVar=  Chr(Random(48, 57, 1)) ;0-9
         $s_Tmp = $s_Tmp & $sVar
      Next
$s_Desired_Mac = "D2" & $s_Tmp
$s_Desired_Mac = StringUpper($s_Desired_Mac)
endif

$val = RegWrite($MacAddressRegKey, "NetworkAddress", "REG_SZ", $s_Desired_Mac)
if $val =0 then
   MsgBox(0,"Mac Address Changer ","Could not write to registry as needed to change your mac address!" & @CRLF & "Please restart this program with administrator rights!")
   Exit
endif



;in order to benifit from changing the registry, one must disable/re-enable the adapter.
;This cmd line query to wmic prevents the need to do so in device manager manually
if $b_Toggle_Device = true then
ShellExecuteWait  ("C:\Windows\System32\wbem\wmic.exe", "path win32_networkadapter where  NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call disable" ,"",$SHEX_OPEN,@SW_HIDE)
ShellExecuteWait  ("C:\Windows\System32\wbem\wmic.exe","path win32_networkadapter where  NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call enable" ,"",$SHEX_OPEN,@SW_HIDE)
endif
;Would be smart to catch the return of the function there in some varible for error handling, but its too late for me to give a crap atm....

MsgBox(0,"Mac Address Changer", "Old Mac = " & $sMac & @crlf & "New Mac = " &   $s_Desired_Mac)
clipput($s_Desired_Mac)
endfunc


Func Get_Mac()
Local $xRet
$xRet= RegRead($MacAddressRegKey, "NetworkAddress")
return $xRet
EndFunc

 

Sorry bout the messy penmenship. Aint looked at the tidy thing yet....🧐

Edited by KingOfNothing
Link to comment
Share on other sites

  • 4 weeks later...

This is very cool. Thank you for the script. It will help me with something I want to make for security reasons. In case anyone cares, I will explain my concern. 

The other day, I searched for Merrell replacement soles for my shoes. My sister started getting ads for Merrell replacement soles on her cell phone. The only thing we have in common is we share wifi, nothing else. So, I found an article on this (https://www.technologyreview.com/s/538731/how-ads-follow-you-from-phone-to-desktop-to-tablet/). Basically, there are companies that predict which devices belong to the same user with information such as IP address, MAC address, etc. One way to combat this tracking is spoofing your MAC address. I was thinking of making something that changes my MAC address every 30 seconds. This might throw off the companies trying to target me. I guess a VPN would help, too.

On a side note, my sister and her husband went to a restaurant yesterday and paid in cash. This morning, he got an ad on his phone naming the restaurant and asked how they liked the restaurant. I guess they used his GPS location to tell they ate there. But I don't know how a company could get this information. It's getting scary out there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...