#include <Windows.h>
#include "auth.hpp"
#include <string>
#include "skStr.h"
#include <windows.h>
#include <jni.h>
#include <thread>
#include <utils.hpp>
#include <set>
#include <vector>
#include <psapi.h>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <memory>
#include <utility>
#include <cstdio>
#include <random>
#include <openssl/sha.h>
#include <windows.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#include <openssl/aes.h>
#include <filesystem>
#include <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/filters.h>
#include <cryptopp/files.h>
#include <cryptopp/hex.h>
#include <locale>
#pragma comment(lib, "psapi.lib")
#define RESET "\033[0m"
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN "\033[36m"
#define WHITE "\033[37m"
std::string tm_to_readable_time(tm ctx);
static std::time_t string_to_timet(std::string timestamp);
static std::tm timet_to_tm(time_t timestamp);
const std::string compilation_date = (std::string)skCrypt(DATE);
const std::string compilation_time = (std::string)skCrypt(TIME);
using namespace KeyAuth;
using namespace CryptoPP;
auto name = skCrypt("");
auto ownerid = skCrypt("");
auto secret = skCrypt(""); // Тут свое вставьте
auto version = skCrypt("1.0");
auto url = skCrypt("https://keyauth.win/api/1.2/"); // change if you're self-hosting
api KeyAuthApp(name.decrypt(), ownerid.decrypt(), secret.decrypt(), version.decrypt(), url.decrypt());
std::wstring stringToWstring(const std::string& str)
{
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
return wstrTo;
}
std::string toLowerCase(const std::string& input) {
std::string result = input;
for (char& c : result) {
c = std::tolower(c);
}
return result;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char buffer[128];
GetWindowTextA(hwnd, buffer, sizeof(buffer));
std::string help = buffer;
std::transform(help.begin(), help.end(), help.begin(), ::tolower);
if (toLowerCase(std::string(help)).find(skCrypt("injector")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("decompiler")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("recaf")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("deobfuscator")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("debugger")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("fiddler")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("bytecode")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("hacker")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("v8.3")) != std::string::npos
toLowerCase(std::string(help)).find(skCrypt("inject")) != std::string::npos)
{
std::cout << "SOSI HUI";
KeyAuthApp.ban();
exit(0);
}
return TRUE;
}
void CheckDllsRepeatedly(DWORD processID)
{
while (true)
{
EnumWindows(EnumWindowsProc, 0);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
}
constexpr int NUM_THREADS = 4;
int current = 0;
int total = 0;
std::string calculateSHA256(const std::string& filePath) {
std::ifstream file(filePath, std::ios::binary);
if (!file.is_open()) {
return ""; // Handle file open failure
}
SHA256_CTX sha256;
SHA256_Init(&sha256);
char buffer[1024];
while (file.read(buffer, sizeof(buffer))) {
SHA256_Update(&sha256, buffer, file.gcount());
}
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_Final(hash, &sha256);
std::string fileHash;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
char buf[3];
snprintf(buf, sizeof(buf), "%02x", hash[i]);
fileHash += buf;
}
return fileHash;
}
void processFiles(const std::vector<std::string>& files, int threadID, std::vector<std::string>& fileHashes, HANDLE hConsole) {
for (size_t i = threadID; i < files.size(); i += NUM_THREADS) {
std::string filePath = files[i];
std::string fileHash = calculateSHA256(filePath);
if (!fileHash.empty()) {
fileHashes[i] = fileHash;
}
current++;
if (current % 100 == 0 current+5 > total) {
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
COORD cursorPosition;
cursorPosition = csbi.dwCursorPosition;
// Move the cursor to the beginning of the line
cursorPosition.X = 0;
SetConsoleCursorPosition(hConsole, cursorPosition);
if ((float)current / (float)total * 100 > 99) {
std::cout << "Stage #7: " << 100 << "%" << " " << std::endl;
}
else {
std::cout << "Stage #7: " << (float)current / (float)total * 100 << "%" << " " << std::endl;
}
SetConsoleCursorPosition(hConsole, cursorPosition);
}
}
}
int countFilesInTree(const std::string& folderPath) {
int fileCount = 0;
for (const auto& entry : std::filesystem::recursive_directory_iterator(folderPath)) {
if (std::filesystem::is_regular_file(entry)) {
fileCount++;
}
}
return fileCount;
}
std::string folderPath = skCrypt("C:\\werwedc\\classesDev").decrypt();
std::string folderPath2 = skCrypt("C:\\werwedc\\natives").decrypt();
void encryptFile(const std::string& fileName, const byte* key)
{
std::ifstream inputFile(fileName, std::ios::binary | std::ios::ate);
if (!inputFile.is_open()) {
std::cerr << "Error opening file: " << fileName << std::endl;
return;
}
size_t fileSize = static_cast<size_t>(inputFile.tellg());
inputFile.seekg(0, std::ios::beg);
std::vector<byte> fileContent(fileSize);
inputFile.read(reinterpret_cast<char*>(fileContent.data()), fileSize);
inputFile.close();
byte iv[AES::BLOCKSIZE];
memset(iv, 0x00, AES::BLOCKSIZE);
CBC_Mode<AES>::Encryption encryption(key, AES::DEFAULT_KEYLENGTH, iv);
ArraySource(fileContent.data(), fileContent.size(), true,
new StreamTransformationFilter(encryption,
new FileSink(fileName.c_str(), std::ios::binary), StreamTransformationFilter::PKCS_PADDING
)
);
}
void decryptData(const byte* encryptedData, size_t dataSize, const byte* key, byte*& decryptedData, size_t& decryptedSize)
{
byte iv[AES::BLOCKSIZE];
memset(iv, 0x00, AES::BLOCKSIZE);
CBC_Mode<AES>::Decryption decryption(key, AES::DEFAULT_KEYLENGTH, iv);
decryptedSize = dataSize;
decryptedData = new byte[decryptedSize];
ArraySource(encryptedData, dataSize, true,
new StreamTransformationFilter(decryption,
new ArraySink(decryptedData, decryptedSize)
)
);
// Remove PKCS7 padding
size_t paddingSize = static_cast<size_t>(decryptedData[decryptedSize - 1]);
if (paddingSize <= decryptedSize) {
decryptedSize -= paddingSize;
}
else {
// Invalid padding, handle accordingly (e.g., throw an exception or log an error)
std::cerr << "Invalid padding size!" << std::endl;
// Optionally, you might want to return or handle the error in another way
}
}
void writeBytesToFile(const byte* data, size_t dataSize, const std::string& fileName) {
std::ofstream outputFile(fileName, std::ios::binary | std::ios::trunc);
if (!outputFile.is_open()) {
std::cerr << "Error opening output file: " << fileName << std::endl;
return;
}
// Write the data to the file
outputFile.write(reinterpret_cast<const char*>(data), dataSize);
outputFile.close();
}
int main()
{
std::locale::global(std::locale("en_US.utf8"));
std::wcout.imbue(std::locale());
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
std::wcout <<
L"░██╗░░░░░░░██╗███████╗██████╗░░██╗░░░░░░░██╗███████╗██████╗░░█████╗░" << std::endl <<
L"░██║░░██╗░░██║██╔════╝██╔══██╗░██║░░██╗░░██║██╔════╝██╔══██╗██╔══██╗" << std::endl <<
L"░╚██╗████╗██╔╝█████╗░░██████╔╝░╚██╗████╗██╔╝█████╗░░██║░░██║██║░░╚═╝" << std::endl <<
L"░░████╔═████║░██╔══╝░░██╔══██╗░░████╔═████║░██╔══╝░░██║░░██║██║░░██╗" << std::endl <<
L"░░╚██╔╝░╚██╔╝░███████╗██║░░██║░░╚██╔╝░╚██╔╝░███████╗██████╔╝╚█████╔╝" << std::endl <<
L"░░░╚═╝░░░╚═╝░░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚══════╝╚═════╝░░╚════╝░" << std::endl;
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN);
const std::string folderPathE = skCrypt("C:\\werwedc\\classesDev").decrypt();
std::string shlapa = skCrypt("").decrypt(); // ключ придумайте
const unsigned char* key = reinterpret_cast<const unsigned char*>(shlapa.c_str());
/*for (const auto& entry : std::filesystem::recursive_directory_iterator("C:\\werwedc\\classesDev\\ua\\werwedc"))
{
if (std::filesystem::is_regular_file(entry))
{
if (entry.path().string().find(".class") == std::string::npos) {
continue;
}
const std::string inputFileName = entry.path().string();
// Encrypt the file
encryptFile(inputFileName, key);
std::cout << "encrypted: " << inputFileName << std::endl;
}
}*/
KeyAuthApp.init();
std::cout << "Stage #2" << std::endl;
std::string consoleTitle = (std::string)skCrypt("Loader - Built at: ") + compilation_date + " " + compilation_time;
SetConsoleTitleA(consoleTitle.c_str());
std::cout << "Stage #3" << std::endl;
if (KeyAuthApp.checkblack()) {
abort();
}
std::cout << "Stage #4" << std::endl;
if (!KeyAuthApp.data.success)
{
std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
Sleep(1500);
exit(0);
}
if (std::filesystem::exists("test.json"))
{
if (!CheckIfJsonKeyExists("test.json", "username"))
{
std::string key = ReadFromJson("test.json", "license");
KeyAuthApp.license(key);
if (!KeyAuthApp.data.success)
{
std::remove("test.json");
std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
Sleep(1500);
exit(0);
}
std::cout << skCrypt("Successfully Automatically Logged In\n");
}
else
{
std::string username = ReadFromJson("test.json", "username");
std::string password = ReadFromJson("test.json", "password");
KeyAuthApp.login(username, password);
if (!KeyAuthApp.data.success)
{
std::remove("test.json");
std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
Sleep(1500);
exit(0);
}
std::cout << skCrypt("Successfully Automatically Logged In\n");
}
}
else
{
std::string key;
std::cout << skCrypt("\n Enter license: ");
std::cin >> key;
KeyAuthApp.license(key);
if (!KeyAuthApp.data.success)
{
std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
Sleep(1500);
exit(0);
}
WriteToJson("test.json", "license", key, false, "", "");
std::cout << skCrypt("Successfully Created File For Auto Login");
}
std::cout << "Stage #5" << std::endl;
for (int i = 0; i < KeyAuthApp.data.subscriptions.size(); i++) {
auto sub = KeyAuthApp.data.subscriptions.at(i);
std::cout << skCrypt("Client till: ") << tm_to_readable_time(timet_to_tm(string_to_timet(sub.expiry)));
}
DWORD processID = GetCurrentProcessId();
std::thread t234234(CheckDllsRepeatedly, processID);
std::cout << "Stage #6" << std::endl;
std::vector<std::string> files;
for (const auto& entry : std::filesystem::recursive_directory_iterator(folderPath)) {
if (std::filesystem::is_regular_file(entry)) {
files.push_back(entry.path().string());
}
}
for (const auto& entry : std::filesystem::recursive_directory_iterator(folderPath2)) {
if (std::filesystem::is_regular_file(entry)) {
files.push_back(entry.path().string());
}
}
for (const auto& entry : std::filesystem::recursive_directory_iterator(skCrypt("C:\\jdk-17.0.2").decrypt())) {
if (std::filesystem::is_regular_file(entry)) {
files.push_back(entry.path().string());
}
}
total = files.size();
std::vector<std::string> fileHashes(files.size());
std::vector<std::thread> threads;
for (int i = 0; i < NUM_THREADS; i++) {
threads.emplace_back(processFiles, std::ref(files), i, std::ref(fileHashes), hConsole);
}
for (std::thread& thread : threads) {
thread.join();
}
SHA256_CTX combinedSha256;
SHA256_Init(&combinedSha256);
for (size_t i = 0; i < files.size(); i++) {
if (!fileHashes[i].empty()) {
SHA256_Update(&combinedSha256, fileHashes[i].c_str(), fileHashes[i].length());
}
}
unsigned char combinedHash[SHA256_DIGEST_LENGTH];
SHA256_Final(combinedHash, &combinedSha256);
std::string combinedHashString;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
char buf[3];
snprintf(buf, sizeof(buf), "%02x", combinedHash[i]);
combinedHashString += buf;
}
std::cout << std::endl << "Stage #8" << std::endl;
if (combinedHashString != skCrypt("").decrypt()) {
KeyAuthApp.ban();
abort();
exit(0);
}
//std::cout << "Stage #9" << std::endl;
//std::cout << combinedHashString;
int mem = 1024;
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN);
std::cout << std::endl << "Enter the amount of memory(in megabytes)" << std::endl;
std::cin >> mem;
std::string memS = "-Xmx" + mem;
memS = memS + "m";
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN);
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs vm_args;
JavaVMOption* options = new JavaVMOption[4];
options[0].optionString = const_cast<char*>("-Djava.class.path=C:\\werwedc\\classesDev");
options[1].optionString = const_cast<char*>("-Djava.library.path=C:\\werwedc\\natives");
// options[2].optionString = const_cast<char*>("-verbose:jni");
options[3].optionString = const_cast<char*>(memS.c_str());
options[2].optionString = const_cast<char*>("-Xverify:none");
vm_args.version = JNI_VERSION_10;
vm_args.nOptions = 3;
vm_args.options = options;
vm_args.ignoreUnrecognized = false;
jint ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
jclass loader = env->FindClass("java/lang/ClassLoader");
jmethodID getClassLoaderId = env->GetStaticMethodID(loader, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
jobject classLoader = env->CallStaticObjectMethod(loader, getClassLoaderId);
std::cout << "Stage #10" << std::endl;
//Define Utility
std::string filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\utility\\Utility.class").decrypt();
FILE* file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
rewind(file);
byte* byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
byte* decryptedData;
size_t decryptedSize;
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
jclass defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define Custom Button
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\ui\\CustomButton.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define Module
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\modules\\Module.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define setting
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\modules\\settings\\Setting.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define Manager
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\config\\Manager.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define Config Updater
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\config\\ConfigUpdater.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
//Define
filePath = skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc\\config\\Config.class").decrypt();
file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
for (const auto& entry : std::filesystem::recursive_directory_iterator(skCrypt("C:\\werwedc\\classesDev\\ua\\werwedc").decrypt())) {
if (std::filesystem::is_regular_file(entry)) {
//для дефайна ебучего класса
const std::filesystem::path& path = entry.path();
// Convert to string with backslashes
std::string filePath = path.string();
if (filePath.find(".class") == std::string::npos) {
continue;
}
//filePath = "C:\\werwedc\\testDefine\\" + filePath;
//std::cout << filePath << std::endl;
FILE* file = fopen(filePath.c_str(), "rb");
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
rewind(file);
byte* byteBuffer = (byte*)malloc(fileSize);
fread(byteBuffer, 1, fileSize, file);
fclose(file);
// Decrypt data
byte* decryptedData;
size_t decryptedSize;
decryptData(byteBuffer, fileSize, key, decryptedData, decryptedSize);
jclass defined = env->DefineClass(NULL, classLoader, (jbyte*)decryptedData, decryptedSize);
/*if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}*/
}
}
std::cout << "Stage #11" << std::endl;
jclass StartClass = env->FindClass(skCrypt("Start").decrypt());
std::cout << "Stage #12" << std::endl;
if (StartClass != nullptr) {
jmethodID mid = env->GetStaticMethodID(StartClass, "main", "([Ljava/lang/String;)V");
if (mid != nullptr) {
jobjectArray args = env->NewObjectArray(1, env->FindClass("java/lang/String"), NULL);
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
env->CallStaticVoidMethod(StartClass, mid, args);
}
}
std::cout << skCrypt("\n\n Closing in five seconds...");
Sleep(5000);
exit(0);
}
std::string tm_to_readable_time(tm ctx) {
char buffer[80];
strftime(buffer, sizeof(buffer), "%a %m/%d/%y %H:%M:%S %Z", &ctx);
return std::string(buffer);
}
static std::time_t string_to_timet(std::string timestamp) {
auto cv = strtol(timestamp.c_str(), NULL, 10); // long
return (time_t)cv;
}
static std::tm timet_to_tm(time_t timestamp) {
std::tm context;
localtime_s(&context, ×tamp);
return context;
}