master
John Lauer rust/verbs/assets/import-scan.ps1 (embedded by import.rs, missed by the rust/ push's extension filter; pup-bridge#118) 9feb6ee 1mo ago
$ErrorActionPreference='SilentlyContinue'
$local = $env:LOCALAPPDATA
$browsers = @(
  @{ id='chrome'; name='Google Chrome'; root=(Join-Path $local 'Google\Chrome\User Data') },
  @{ id='edge';   name='Microsoft Edge'; root=(Join-Path $local 'Microsoft\Edge\User Data') },
  @{ id='brave';  name='Brave';          root=(Join-Path $local 'BraveSoftware\Brave-Browser\User Data') }
)
$out = @()
foreach($b in $browsers){
  if(-not (Test-Path $b.root)){ continue }
  $abe=$false
  $lsPath = Join-Path $b.root 'Local State'
  if(Test-Path $lsPath){ try { $ls = Get-Content -Raw -LiteralPath $lsPath | ConvertFrom-Json; if($ls.os_crypt.app_bound_encrypted_key){ $abe=$true } } catch {} }
  $profs = @()
  $d = Get-Item -LiteralPath (Join-Path $b.root 'Default') -ErrorAction SilentlyContinue; if($d){ $profs += $d }
  $profs += (Get-ChildItem -LiteralPath $b.root -Directory -Filter 'Profile *' -ErrorAction SilentlyContinue)
  foreach($pf in $profs){
    if(-not $pf){ continue }
    $prefPath = Join-Path $pf.FullName 'Preferences'
    if(-not (Test-Path $prefPath)){ continue }
    $pname=$pf.Name; $emails=@()
    try { $pref = Get-Content -Raw -LiteralPath $prefPath | ConvertFrom-Json; if($pref.profile.name){ $pname = $pref.profile.name }; if($pref.account_info){ foreach($a in $pref.account_info){ if($a.email){ $emails += $a.email } } } } catch {}
    $ldPath = Join-Path $pf.FullName 'Login Data'
    $ldBytes=0; if(Test-Path $ldPath){ $ldBytes = (Get-Item -LiteralPath $ldPath).Length }
    if($ldBytes -gt 0){ $out += [pscustomobject]@{ browser=$b.id; browserName=$b.name; profileDir=$pf.Name; profileName=$pname; accounts=@($emails); loginDataBytes=$ldBytes; abe=$abe } }
  }
}
@{ profiles = @($out) } | ConvertTo-Json -Compress -Depth 6