44448480de
- qmt_relogin.py: 发现/外科杀/启动/凭证登录/桥应答判定(退出码0/3/4/5/6) - 凭证安全: DPAPI加密摄取(ingest333)+运行时env注入,明文零落盘 - ui_act框架: console session UI自动化(activate/credtype/zoom/closewin/launch等op) +wintree/uiadump/childtree窗口透明三件套 - 机制定论: 勾「记住密码+自动登录」后强杀重启=完整登录+实例自启+桥活 (未勾=半启动窗像主界面但实例不拉); 07:50 schtask A案上线 - 坑: SecureString=UTF-16LE; session0跑UI自动化死; cwd空串WinError123
35 lines
1.6 KiB
PowerShell
35 lines
1.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
# Ingest the plaintext password from Desktop 333.txt into a DPAPI-encrypted
|
|
# blob (current-user + machine scope). Password never leaves this machine and
|
|
# is never printed. On success the plaintext file is deleted.
|
|
$src = 'C:\Users\Administrator\Desktop\333.txt'
|
|
$credDir = 'C:\sanguo_bigqmt\creds'
|
|
$encPath = Join-Path $credDir 'qmt_login.enc'
|
|
|
|
New-Item -ItemType Directory -Force -Path $credDir | Out-Null
|
|
$pw = (Get-Content -Raw -LiteralPath $src).Trim()
|
|
if (-not $pw) { throw '333.txt is empty' }
|
|
|
|
$cred = @{ user = '66639661'; password = $pw } | ConvertTo-Json -Compress
|
|
$sec = ConvertTo-SecureString -String $cred -AsPlainText -Force
|
|
$enc = ConvertFrom-SecureString -SecureString $sec
|
|
Set-Content -LiteralPath $encPath -Value $enc -Encoding ASCII
|
|
|
|
# Lock the directory down on top of DPAPI (belt and suspenders).
|
|
icacls $credDir /inheritance:r | Out-Null
|
|
icacls $credDir /grant 'Administrator:F' | Out-Null
|
|
icacls $encPath /grant 'Administrator:F' | Out-Null
|
|
|
|
# Round-trip verify before destroying the plaintext source.
|
|
$enc2 = (Get-Content -Raw -LiteralPath $encPath).Trim()
|
|
$sec2 = ConvertTo-SecureString -String $enc2
|
|
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec2)
|
|
$plain = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
|
|
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr)
|
|
$j = $plain | ConvertFrom-Json
|
|
if ([string]$j.user -ne '66639661' -or [string]$j.password -ne $pw) { throw 'round-trip mismatch' }
|
|
Write-Output ('INGEST_OK encbytes=' + (Get-Item -LiteralPath $encPath).Length + ' pwdlen=' + $pw.Length)
|
|
|
|
Remove-Item -LiteralPath $src -Force
|
|
Write-Output '333_DELETED'
|