$ErrorActionPreference = "Continue" $mysql = "C:\yutongda\tools\mysql-8.0.39-winx64\bin\mysql.exe" $dbCred = Get-Content "C:\yutongda\secure\application-database-credentials.json" -Raw | ConvertFrom-Json $pgpass = (Get-Content "C:\yutongda\secure\pgpass.txt" -Raw).Trim() Write-Output "=== try mysql root candidates (result only) ===" $candidates = @( @{u='root'; p=$dbCred.mysql_password; tag='same_as_jeecg'}, @{u='root'; p='root'; tag='root_root'}, @{u='root'; p=$pgpass; tag='pgpass_as_mysql'}, @{u='admin'; p=$dbCred.mysql_password; tag='admin_jeecgpass'} ) foreach ($c in $candidates) { $out = & $mysql -h 10.206.0.14 -P 3306 -u $c.u "-p$($c.p)" --connect-timeout=5 -e "SELECT CURRENT_USER(), @@hostname;" 2>&1 $text = ($out | ForEach-Object { "$_" }) -join " " if ($text -match 'CURRENT_USER|localhost|root@') { Write-Output "HIT tag=$($c.tag)" } else { $brief = if ($text -match 'Access denied') { 'Access denied' } elseif ($text -match 'ERROR') { 'ERROR' } else { 'fail' } Write-Output "miss tag=$($c.tag) $brief" } } Write-Output "=== try pg roles ===" $psql = "C:\yutongda\tools\pgsql\bin\psql.exe" $pgUsers = @('postgres','ytd_runtime','admin') $pgPasses = @($pgpass, $dbCred.postgres_password) foreach ($u in $pgUsers) { foreach ($p in $pgPasses) { $env:PGPASSWORD = $p $env:PGCONNECT_TIMEOUT = "5" $out = & $psql -h 10.206.0.14 -p 5432 -U $u -d postgres -tAc "SELECT current_user||','||rolsuper FROM pg_roles WHERE rolname=current_user" 2>&1 $text = ($out | ForEach-Object { "$_" }) -join " " if ($text -match 't$' -or $text -match ',t') { Write-Output "PG_HIT user=$u super" } elseif ($text -match 'inquiry_robot|,f') { Write-Output "PG_HIT user=$u nonsuper=$text" } else { if ($text -match 'password authentication failed') { Write-Output "pg_miss user=$u badpass" } elseif ($text -match 'does not exist') { Write-Output "pg_miss user=$u noexist" } else { Write-Output "pg_miss user=$u other" } } } } Write-Output "=== admin-login-recovery ===" cmd /c "dir /s /b C:\yutongda\secure\admin-login-recovery 2>nul" Write-Output "TRY_DONE"