# Continuous Route Investigator - local-only IPv4 ICMP TTL probe param([string]$Target='8.8.8.8',[ValidateSet(30,60,120,300)][int]$DurationSeconds=120,[ValidateRange(4,30)][int]$MaxHops=20,[ValidateRange(200,2000)][int]$TimeoutMs=500) $ErrorActionPreference='Stop' $ip=[System.Net.Dns]::GetHostAddresses($Target) | Where-Object { $_.AddressFamily -eq 'InterNetwork' } | Select-Object -First 1 if(-not $ip){throw 'No IPv4 address found'} $ping=[System.Net.NetworkInformation.Ping]::new() $rows=[System.Collections.Generic.List[object]]::new() $start=[DateTime]::UtcNow $end=$start.AddSeconds($DurationSeconds) $sweep=0 Write-Host ('Probing '+$Target+' ('+$ip+') for '+$DurationSeconds+' seconds...') try { while([DateTime]::UtcNow -lt $end){ $sweep++ for($ttl=1;$ttl -le $MaxHops -and [DateTime]::UtcNow -lt $end;$ttl++){ $at=[DateTime]::UtcNow $status='ProbeError';$router='';$ms=$null try{ $reply=$ping.Send($ip.ToString(),$TimeoutMs,[byte[]]::new(32),[System.Net.NetworkInformation.PingOptions]::new($ttl,$true)) $status=$reply.Status.ToString() if($reply.Address){$router=$reply.Address.ToString()} if($status -eq 'Success' -or $status -eq 'TtlExpired'){$ms=[int]$reply.RoundtripTime} }catch{} $rows.Add([pscustomobject]@{sweep=$sweep;time=$at.ToString('o');ttl=$ttl;ip=$router;status=$status;ms=$ms}) if($status -eq 'Success'){break} } Start-Sleep -Milliseconds 200 } }finally{$ping.Dispose()} $report=[ordered]@{schema='bap-route-v1';target=$Target;resolvedIp=$ip.ToString();startedUtc=$start.ToString('o');endedUtc=([DateTime]::UtcNow).ToString('o');durationSeconds=$DurationSeconds;maxHops=$MaxHops;timeoutMs=$TimeoutMs;probes=@($rows.ToArray())} $file=Join-Path (Get-Location) ('burnafterpinging-route-'+[DateTime]::UtcNow.ToString('yyyyMMdd-HHmmss')+'.json') $report | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $file -Encoding UTF8 Write-Host ('Saved '+$rows.Count+' probes: '+$file)