ksjsb/tools/frida_attach_captcha_stable.ps1
2026-07-30 20:25:56 +08:00

37 lines
1.3 KiB
PowerShell

param(
[string]$Package = 'com.kuaishou.nebula',
[string]$Script = 'out\probe_captcha_flow.js',
[int]$WarmupSeconds = 3
)
$ErrorActionPreference = 'Stop'
$scriptPath = (Resolve-Path $Script).Path
$outDir = (Resolve-Path 'out').Path
$pidText = (adb shell pidof $Package 2>$null)
$pidText = if ($pidText) { $pidText.Trim() } else { '' }
if (-not $pidText) {
adb shell monkey -p $Package 1 | Out-Null
Start-Sleep -Seconds $WarmupSeconds
$pidText = (adb shell pidof $Package 2>$null)
$pidText = if ($pidText) { $pidText.Trim() } else { '' }
}
if (-not $pidText) {
throw "package process not found: $Package"
}
$targetPid = ($pidText -split '\s+')[0]
$ts = Get-Date -Format 'yyyyMMdd_HHmmss'
$log = Join-Path $outDir ("probe_captcha_{0}_{1}.log" -f $ts, $targetPid)
$cmd = "frida -U -p $targetPid -l `"$scriptPath`" 2>&1 | Tee-Object `"$log`""
$runner = Start-Process powershell -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-Command',$cmd) -WindowStyle Hidden -PassThru
Start-Sleep -Seconds 5
$runner.Id | Set-Content (Join-Path $outDir 'probe_captcha_runner_latest.txt')
$log | Set-Content (Join-Path $outDir 'probe_captcha_log_latest.txt')
Write-Host "ATTACH package=$Package pid=$targetPid runner=$($runner.Id)"
Write-Host "LOG $log"
Get-Content $log -Tail 40 | ForEach-Object { $_ -replace '(1\d{2})\d{4}(\d{4})','$1****$2' }