Update any-desk-reset-trial.bat
This commit is contained in:
+31
-18
@@ -109,24 +109,37 @@ if exist "%AnyDesk2%" start "" "%AnyDesk2%"
|
|||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:randomize_mac
|
:randomize_mac
|
||||||
echo [*] Randomizing NIC MAC address...
|
echo [*] Randomizing MAC on internet-facing adapter(s)...
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
set "PS1=%temp%\ad_mac_%RANDOM%.ps1"
|
||||||
"$ErrorActionPreference='Stop';" ^
|
> "%PS1%" echo $ErrorActionPreference = 'Continue'
|
||||||
"$a = Get-NetAdapter -Physical | Where-Object { $_.Status -eq 'Up' } | Select-Object -First 1;" ^
|
>>"%PS1%" echo $base = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}'
|
||||||
"if (-not $a) { $a = Get-NetAdapter -Physical | Select-Object -First 1 };" ^
|
>>"%PS1%" echo $excl = 'Hyper-V','VMware','VirtualBox','Virtual Adapter','Loopback','TAP','TUN','WAN Miniport','Bluetooth','Npcap','WireGuard','OpenVPN','Wintun','WSL','Docker','Pseudo-Interface'
|
||||||
"if (-not $a) { Write-Host '[!] No physical adapter found.'; exit 1 };" ^
|
>>"%PS1%" echo $gwIfs = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' -ErrorAction SilentlyContinue ^| Sort-Object RouteMetric ^| Select-Object -ExpandProperty ifIndex -Unique)
|
||||||
"$first = '{0:X2}' -f ((Get-Random -Minimum 0 -Maximum 64) * 4 -bor 2);" ^
|
>>"%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') }
|
||||||
"$rest = -join (1..5 | ForEach-Object { '{0:X2}' -f (Get-Random -Minimum 0 -Maximum 256) });" ^
|
>>"%PS1%" echo $cands = $cands ^| Where-Object { $desc = $_.InterfaceDescription; -not ($excl ^| Where-Object { $desc -like "*$_*" }) }
|
||||||
"$mac = $first + $rest;" ^
|
>>"%PS1%" echo $cands = $cands ^| Where-Object { $gwIfs -contains $_.ifIndex }
|
||||||
"Write-Host ('[+] Adapter: ' + $a.Name + ' New MAC: ' + ($mac -replace '(..)(?!$)','$1-'));" ^
|
>>"%PS1%" echo if (-not $cands) { Write-Host '[!] No internet-facing physical adapter found (Wi-Fi/Ethernet with default gateway). Skipping MAC change.'; exit 0 }
|
||||||
"$base = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}';" ^
|
>>"%PS1%" echo foreach ($a in $cands) {
|
||||||
"$key = Get-ChildItem $base -ErrorAction SilentlyContinue | Where-Object { (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue).NetCfgInstanceId -eq $a.InterfaceGuid } | Select-Object -First 1;" ^
|
>>"%PS1%" echo Write-Host ('[+] Target adapter: ' + $a.Name + ' (' + $a.InterfaceDescription + ') current MAC: ' + $a.MacAddress)
|
||||||
"if (-not $key) { Write-Host '[!] Registry key for adapter not found.'; exit 1 };" ^
|
>>"%PS1%" echo $first = '{0:X2}' -f ((Get-Random -Minimum 0 -Maximum 64) * 4 -bor 2)
|
||||||
"Set-ItemProperty -Path $key.PSPath -Name NetworkAddress -Value $mac -Type String;" ^
|
>>"%PS1%" echo $rest = -join (1..5 ^| ForEach-Object { '{0:X2}' -f (Get-Random -Minimum 0 -Maximum 256) })
|
||||||
"Disable-NetAdapter -Name $a.Name -Confirm:$false;" ^
|
>>"%PS1%" echo $mac = $first + $rest
|
||||||
"Start-Sleep -Seconds 2;" ^
|
>>"%PS1%" echo $pretty = ($mac -replace '(..)(?!$)','$1-')
|
||||||
"Enable-NetAdapter -Name $a.Name -Confirm:$false;" ^
|
>>"%PS1%" echo Write-Host ('[+] New MAC: ' + $pretty)
|
||||||
"Start-Sleep -Seconds 3;"
|
>>"%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
|
exit /b
|
||||||
|
|
||||||
:stop_any
|
:stop_any
|
||||||
|
|||||||
Reference in New Issue
Block a user