59 lines
2.2 KiB
PowerShell
59 lines
2.2 KiB
PowerShell
# Find any DBA/admin secrets usable on 10.206.0.14; never print values.
|
|
$ErrorActionPreference = "Continue"
|
|
Write-Output "=== candidate secret files ==="
|
|
$paths = @(
|
|
"E:\wwwroot\ops\admin-secrets.env",
|
|
"E:\wwwroot\ops\*root*",
|
|
"E:\wwwroot\ops\*admin*",
|
|
"C:\yutongda\secure\*",
|
|
"C:\yutongda\config\*mysql*",
|
|
"C:\yutongda\config\*db*",
|
|
"C:\yutongda\config\*postgres*",
|
|
"C:\yutongda\config\*pgsql*"
|
|
)
|
|
foreach ($p in $paths) {
|
|
Get-ChildItem $p -EA SilentlyContinue | ForEach-Object { $_.FullName }
|
|
}
|
|
|
|
Write-Output "=== key names in env-like files ==="
|
|
$files = @(
|
|
"E:\wwwroot\ops\admin-secrets.env",
|
|
"C:\yutongda\secure\e2e-business-20260826-205407.env",
|
|
"C:\yutongda\config\minio.env"
|
|
)
|
|
Get-ChildItem "C:\yutongda\secure" -File -EA SilentlyContinue | ForEach-Object { $files += $_.FullName }
|
|
Get-ChildItem "E:\wwwroot\ops" -File -EA SilentlyContinue | Where-Object { $_.Extension -match '\.(env|json|txt)$' } | ForEach-Object { $files += $_.FullName }
|
|
|
|
foreach ($f in ($files | Select-Object -Unique)) {
|
|
if (-not (Test-Path $f)) { continue }
|
|
Write-Output ("FILE=" + $f)
|
|
if ($f -match '\.json$') {
|
|
try {
|
|
$j = Get-Content $f -Raw | ConvertFrom-Json
|
|
foreach ($p in $j.PSObject.Properties) {
|
|
$len = if ($p.Value -is [string]) { $p.Value.Length } else { "-" }
|
|
Write-Output (" key=" + $p.Name + " len=" + $len)
|
|
}
|
|
} catch { Write-Output " json_parse_fail" }
|
|
} else {
|
|
Get-Content $f -EA SilentlyContinue | ForEach-Object {
|
|
if ($_ -match '^\s*#' -or $_ -notmatch '=') { return }
|
|
$k = ($_ -split '=',2)[0].Trim()
|
|
$v = ($_ -split '=',2)[1]
|
|
if ($k -match '(?i)pass|secret|pwd|token|key') {
|
|
Write-Output (" key=" + $k + " len=" + $v.Trim().Length)
|
|
} else {
|
|
Write-Output (" key=" + $k + " val=" + $v.Trim())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Output "=== sql ready? ==="
|
|
Get-ChildItem "E:\wwwroot\ops\sql" -EA SilentlyContinue | ForEach-Object { $_.Name + " " + $_.Length }
|
|
|
|
Write-Output "=== ssh to 10.206.0.14? ==="
|
|
ssh -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new ytd_extdev_0903@10.206.0.14 "echo ssh_ok & hostname" 2>&1 | Select-Object -First 5
|
|
|
|
Write-Output "DONE"
|