# Sharada Audio local web-interface finder, version 2. # Reads local web pages only; no login or device changes. param([string]$MacAddress) $ErrorActionPreference = 'Stop' $targetMac = '' if ($MacAddress) { if ($MacAddress -notmatch '^([0-9A-Fa-f]{12}|([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2})$') { throw 'Enter a valid MAC, or omit -MacAddress to search automatically.' } $targetMac = ($MacAddress -replace '[:-]', '').ToUpperInvariant() } Write-Host 'Sharada Audio - finding possible regenerator settings pages.' Write-Host 'No settings will be changed. Please allow a minute or two.' function Find-KnownMac { if (-not $targetMac) { return } Get-NetNeighbor -AddressFamily IPv4 -ErrorAction SilentlyContinue | Where-Object { ($_.LinkLayerAddress -replace '[:-]', '').ToUpperInvariant() -eq $targetMac } | Select-Object IPAddress,InterfaceAlias -Unique } $found = @(Find-KnownMac) if ($found.Count) { foreach ($device in $found) { Write-Host "MAC match: http://$($device.IPAddress)/" -ForegroundColor Green } return } $upIndexes = @(Get-NetAdapter -Physical | Where-Object Status -eq 'Up' | Select-Object -ExpandProperty ifIndex) $addresses = @(Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceIndex -in $upIndexes -and $_.IPAddress -notlike '169.254.*' -and $_.IPAddress -ne '127.0.0.1' }) $targets = New-Object 'System.Collections.Generic.HashSet[string]' foreach ($address in $addresses) { $prefix = $address.PrefixLength if ($prefix -lt 22 -or $prefix -gt 30) { Write-Warning "Skipping $($address.IPAddress)/${prefix}: only common /22 through /30 networks are scanned." continue } $o = $address.IPAddress.Split('.') [long]$number = [long]$o[0]*16777216 + [long]$o[1]*65536 + [long]$o[2]*256 + [long]$o[3] [long]$size = [math]::Pow(2,32-$prefix) [long]$network = [math]::Floor($number/$size)*$size Write-Host "Checking $($address.InterfaceAlias) ($($address.IPAddress)/$prefix)..." for ([long]$n=$network+1; $n -lt $network+$size-1; $n++) { $ip = '{0}.{1}.{2}.{3}' -f (($n -shr 24) -band 255),(($n -shr 16) -band 255),(($n -shr 8) -band 255),($n -band 255) if ($ip -ne $address.IPAddress) { $null = $targets.Add($ip) } } } Add-Type -AssemblyName System.Net.Http $handler = New-Object System.Net.Http.HttpClientHandler $handler.UseProxy = $false $handler.UseCookies = $false $handler.AllowAutoRedirect = $false $handler.AutomaticDecompression = [System.Net.DecompressionMethods]::GZip -bor [System.Net.DecompressionMethods]::Deflate $client = New-Object System.Net.Http.HttpClient($handler) $client.Timeout = [TimeSpan]::FromSeconds(2) $client.MaxResponseContentBufferSize = 131072 $candidates = @() $ips = @($targets) try { for ($start=0; $start -lt $ips.Count; $start+=32) { $pending = @() for ($j=$start; $j -lt [math]::Min($start+32,$ips.Count); $j++) { $pending += [pscustomobject]@{ IP=$ips[$j]; Task=$client.GetAsync("http://$($ips[$j])/") } } foreach ($item in $pending) { $response = $null try { $response = $item.Task.GetAwaiter().GetResult() $html = $response.Content.ReadAsStringAsync().GetAwaiter().GetResult() # A family fingerprint is only a possible match, not a unique identity. if ($html -match '(?i)SE106\s*Pro|Sharada\s*Audio' -or ($html -match '(?i)\bg_product\s*=\s*0\s*;' -and $html -match '(?i)mercurycom\.com\.cn')) { $candidates += $item.IP } } catch { # Unresponsive hosts and non-web devices are normal. } finally { if ($response) { $response.Dispose() } } } } } finally { $client.Dispose(); $handler.Dispose() } if ($targetMac) { $found = @(Find-KnownMac) foreach ($device in $found) { Write-Host "MAC match: http://$($device.IPAddress)/" -ForegroundColor Green } if (-not $found.Count) { Write-Warning 'The specified MAC address was not found.' } } elseif ($candidates.Count) { foreach ($ip in ($candidates | Select-Object -Unique)) { Write-Host "Possible regenerator settings page: http://$ip/" -ForegroundColor Green } Write-Host 'Open the address in your browser. Confirm it is your regenerator before signing in or changing settings.' Write-Host 'Similar devices may also appear. If there is more than one result, send the list to Sharada Audio.' } else { Write-Warning 'No recognisable regenerator web page was found. This does not prove the unit is offline.' } Write-Host 'Check power, use the same home network, avoid guest Wi-Fi and disconnect a VPN for the test.' Write-Host 'An address outside your home network, a separate VLAN, or different login-page software may prevent discovery.' Write-Host 'Contact Sharada Audio if no result appears or you are unsure which device was found.'