From c71b15d90a6f89ea06c10e7449dee53b1d85a5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=93=99=F0=9D=93=BE=F0=9D=93=B5=F0=9D=93=B2?= =?UTF-8?q?=F0=9D=93=B8?= Date: Mon, 20 Apr 2026 14:10:46 -0400 Subject: [PATCH] Update any-desk-reset-trial.bat --- any-desk-reset-trial.bat | 49 +++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/any-desk-reset-trial.bat b/any-desk-reset-trial.bat index a904d3b..0196e16 100644 --- a/any-desk-reset-trial.bat +++ b/any-desk-reset-trial.bat @@ -109,24 +109,37 @@ if exist "%AnyDesk2%" start "" "%AnyDesk2%" exit /b :randomize_mac -echo [*] Randomizing NIC MAC address... -powershell -NoProfile -ExecutionPolicy Bypass -Command ^ - "$ErrorActionPreference='Stop';" ^ - "$a = Get-NetAdapter -Physical | Where-Object { $_.Status -eq 'Up' } | Select-Object -First 1;" ^ - "if (-not $a) { $a = Get-NetAdapter -Physical | Select-Object -First 1 };" ^ - "if (-not $a) { Write-Host '[!] No physical adapter found.'; exit 1 };" ^ - "$first = '{0:X2}' -f ((Get-Random -Minimum 0 -Maximum 64) * 4 -bor 2);" ^ - "$rest = -join (1..5 | ForEach-Object { '{0:X2}' -f (Get-Random -Minimum 0 -Maximum 256) });" ^ - "$mac = $first + $rest;" ^ - "Write-Host ('[+] Adapter: ' + $a.Name + ' New MAC: ' + ($mac -replace '(..)(?!$)','$1-'));" ^ - "$base = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}';" ^ - "$key = Get-ChildItem $base -ErrorAction SilentlyContinue | Where-Object { (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue).NetCfgInstanceId -eq $a.InterfaceGuid } | Select-Object -First 1;" ^ - "if (-not $key) { Write-Host '[!] Registry key for adapter not found.'; exit 1 };" ^ - "Set-ItemProperty -Path $key.PSPath -Name NetworkAddress -Value $mac -Type String;" ^ - "Disable-NetAdapter -Name $a.Name -Confirm:$false;" ^ - "Start-Sleep -Seconds 2;" ^ - "Enable-NetAdapter -Name $a.Name -Confirm:$false;" ^ - "Start-Sleep -Seconds 3;" +echo [*] Randomizing MAC on internet-facing adapter(s)... +set "PS1=%temp%\ad_mac_%RANDOM%.ps1" +> "%PS1%" echo $ErrorActionPreference = 'Continue' +>>"%PS1%" echo $base = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}' +>>"%PS1%" echo $excl = 'Hyper-V','VMware','VirtualBox','Virtual Adapter','Loopback','TAP','TUN','WAN Miniport','Bluetooth','Npcap','WireGuard','OpenVPN','Wintun','WSL','Docker','Pseudo-Interface' +>>"%PS1%" echo $gwIfs = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue ^| Sort-Object RouteMetric ^| Select-Object -ExpandProperty ifIndex -Unique) +>>"%PS1%" echo $cands = Get-NetAdapter -Physical ^| Where-Object { $_.Status -eq 'Up' -and $_.HardwareInterface -eq $true -and ($_.MediaType -eq '802.3' -or $_.MediaType -eq 'Native 802.11') } +>>"%PS1%" echo $cands = $cands ^| Where-Object { $desc = $_.InterfaceDescription; -not ($excl ^| Where-Object { $desc -like "*$_*" }) } +>>"%PS1%" echo $cands = $cands ^| Where-Object { $gwIfs -contains $_.ifIndex } +>>"%PS1%" echo if (-not $cands) { Write-Host '[!] No internet-facing physical adapter found (Wi-Fi/Ethernet with default gateway). Skipping MAC change.'; exit 0 } +>>"%PS1%" echo foreach ($a in $cands) { +>>"%PS1%" echo Write-Host ('[+] Target adapter: ' + $a.Name + ' (' + $a.InterfaceDescription + ') current MAC: ' + $a.MacAddress) +>>"%PS1%" echo $first = '{0:X2}' -f ((Get-Random -Minimum 0 -Maximum 64) * 4 -bor 2) +>>"%PS1%" echo $rest = -join (1..5 ^| ForEach-Object { '{0:X2}' -f (Get-Random -Minimum 0 -Maximum 256) }) +>>"%PS1%" echo $mac = $first + $rest +>>"%PS1%" echo $pretty = ($mac -replace '(..)(?!$)','$1-') +>>"%PS1%" echo Write-Host ('[+] New MAC: ' + $pretty) +>>"%PS1%" echo $key = Get-ChildItem $base -ErrorAction SilentlyContinue ^| Where-Object { (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue).NetCfgInstanceId -eq $a.InterfaceGuid } ^| Select-Object -First 1 +>>"%PS1%" echo if (-not $key) { Write-Host '[!] Registry key not found for adapter, skipping.'; continue } +>>"%PS1%" echo try { Set-ItemProperty -Path $key.PSPath -Name NetworkAddress -Value $mac -Type String -ErrorAction Stop } catch { Write-Host ('[!] Failed to set NetworkAddress: ' + $_.Exception.Message); continue } +>>"%PS1%" echo Write-Host '[*] Disabling adapter...' +>>"%PS1%" echo Disable-NetAdapter -Name $a.Name -Confirm:$false -ErrorAction SilentlyContinue +>>"%PS1%" echo Start-Sleep -Seconds 2 +>>"%PS1%" echo Write-Host '[*] Enabling adapter...' +>>"%PS1%" echo Enable-NetAdapter -Name $a.Name -Confirm:$false -ErrorAction SilentlyContinue +>>"%PS1%" echo Start-Sleep -Seconds 3 +>>"%PS1%" echo $now = (Get-NetAdapter -Name $a.Name -ErrorAction SilentlyContinue).MacAddress +>>"%PS1%" echo if ($now -and ($now -replace '[:-]','') -ieq $mac) { Write-Host ('[OK] MAC applied: ' + $now) } else { Write-Host ('[!] Driver did not accept new MAC. Current: ' + $now + ' (update NIC driver or use a dedicated MAC changer)') } +>>"%PS1%" echo } +powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%" +del /f /q "%PS1%" >NUL 2>&1 exit /b :stop_any