From f8f3500fdaec0045b69816e71ca40c1047a134fd Mon Sep 17 00:00:00 2001 From: HexR <108182977+daoq@users.noreply.github.com> Date: Fri, 22 Dec 2023 21:47:49 +0100 Subject: [PATCH] Add files via upload --- main.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..832fb6d --- /dev/null +++ b/main.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include + +#ifdef __linux__ +int main() { + const char* filePath = "sublime_text"; + std::fstream file(filePath, std::ios::in | std::ios::out | std::ios::binary); + + std::vector srPtr = { 0x80, 0x78, 0x05, 0x00, 0x0F, 0x94, 0xC1 }; + std::vector rpPtr = { 0xC6, 0x40, 0x05, 0x01, 0x48, 0x85, 0xC9 }; + + const size_t chunkSize = 1024 * 1024; + std::vector chunk(chunkSize); + + size_t fileSize = 0; + + file.seekg(0, std::ios::end); + fileSize = file.tellg(); + file.seekg(0, std::ios::beg); + + while (file.read(reinterpret_cast(chunk.data()), chunkSize)) { + auto it = std::search(chunk.begin(), chunk.end(), srPtr.begin(), srPtr.end()); + while (it != chunk.end()) { + std::copy(rpPtr.begin(), rpPtr.end(), it); + it = std::search(it + srPtr.size(), chunk.end(), srPtr.begin(), srPtr.end()); + } + file.seekp(-static_cast(chunkSize), std::ios::cur); + file.write(reinterpret_cast(chunk.data()), chunk.size()); + + file.seekp(0, std::ios::end); + } + file.close(); + if (system(("sudo chmod 755 " + std::string(filePath)).c_str()) != 0) { + return 1; + } + if (system(("sudo chown root " + std::string(filePath)).c_str()) != 0) { + return 1; + } + if (system(("sudo chgrp root " + std::string(filePath)).c_str()) != 0) { + return 1; + } + std::cout << "cracked successfully" << std::endl; + return 0; +} +#else +int main() { + const char* filePath = "sublime_text.exe"; + std::fstream file("sublime_text.exe", std::ios::in | std::ios::out | std::ios::binary); + file.seekg(0, std::ios::end); + std::streamsize fileSize = file.tellg(); + file.seekg(0, std::ios::beg); + + std::vector content(fileSize); + file.read(reinterpret_cast(content.data()), fileSize); + + std::vector srPtr = { 0x80, 0x78, 0x05, 0x00, 0x0F, 0x94, 0xC1 }; + std::vector rpPtr = { 0xC6, 0x40, 0x05, 0x01, 0x48, 0x85, 0xC9 }; + + auto it = std::search(content.begin(), content.end(), srPtr.begin(), srPtr.end()); + while (it != content.end()) { + std::copy(rpPtr.begin(), rpPtr.end(), it); + it = std::search(it + srPtr.size(), content.end(), srPtr.begin(), srPtr.end()); + } + file.seekp(0, std::ios::beg); + file.write(reinterpret_cast(content.data()), fileSize); + + std::cout << "cracked successfully" << std::endl; + file.close(); + return 0; +} +#endif \ No newline at end of file