MCEELoginSkip/MinecraftEducationEdition/MinecraftEducationEdition.c

263 lines
5.9 KiB
C
Raw Normal View History

2020-07-28 08:55:30 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <psapi.h>
#include <TlHelp32.h>
int* pointer_path;
int num_ptr;
2020-11-15 01:02:44 +00:00
uintptr_t GetProcessBaseAddress(HANDLE process) // from stackoverflow
2020-07-28 08:55:30 +00:00
{
DWORD_PTR baseAddress = 0;
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS,TRUE,process);
HMODULE* moduleArray;
LPBYTE moduleArrayBytes;
DWORD bytesRequired;
if (processHandle)
{
if (EnumProcessModules(processHandle, NULL, 0, &bytesRequired))
{
if (bytesRequired)
{
moduleArrayBytes = (LPBYTE)LocalAlloc(LPTR, bytesRequired);
if (moduleArrayBytes)
{
int moduleCount;
moduleCount = bytesRequired / sizeof(HMODULE);
2020-11-15 01:02:44 +00:00
moduleArray = (uintptr_t*)moduleArrayBytes;
2020-07-29 06:07:46 +00:00
2020-07-28 08:55:30 +00:00
if (EnumProcessModules(processHandle, moduleArray, bytesRequired, &bytesRequired))
{
baseAddress = moduleArray[0];
}
LocalFree(moduleArrayBytes);
}
}
}
CloseHandle(processHandle);
}
return baseAddress;
}
int main(int argc, char* argv[])
{
HWND hWnd = NULL;
FILE* ptr_file;
char MEE_POINTER_FILE[0x2048];
2020-11-15 01:02:44 +00:00
int LOGIN_STEP_VALUE = -1;
char* tmp;
2020-07-28 08:55:30 +00:00
#ifdef _WIN64
printf_s("!!! x64 Version can ONLY be used for the 64 Bit Versions of the game!\n");
#else
printf_s("!!! x86 Version can ONLY be used for the 32 Bit Versions of the game!\n");
#endif
2020-11-15 01:02:44 +00:00
strncpy_s(MEE_POINTER_FILE, 0x2048, "mee.ptr", 0x2048);
if(argc > 1)
2020-07-28 08:55:30 +00:00
{
2020-11-15 01:02:44 +00:00
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "--help") == 0)
{
printf_s("--ptr <mee.ptr file>\n");
printf_s("--lstep <custom login step value>\n");
return;
}
if(strcmp(argv[i],"--ptr") == 0)
strncpy_s(MEE_POINTER_FILE, 0x2048, argv[i+1], 0x2048);
if (strcmp(argv[i], "--lstep") == 0)
LOGIN_STEP_VALUE = strtol(argv[i + 1], &tmp, 10);
}
printf_s("MEE.PTR FILE : %s\nLOGIN STEP VALUE: %i\n", MEE_POINTER_FILE, LOGIN_STEP_VALUE);
2020-07-28 08:55:30 +00:00
}
// Read text file
printf_s("Loading %s\n", MEE_POINTER_FILE);
if ((access(MEE_POINTER_FILE, 0)) != -1)
{
fopen_s(&ptr_file, MEE_POINTER_FILE, "r");
fseek(ptr_file, 0, SEEK_END);
int sz = ftell(ptr_file)+1;
fseek(ptr_file, 0, SEEK_SET);
char* file_contents = (char*)malloc(sz);
memset(file_contents, 0x00, sz);
fread(file_contents, sz, 1, ptr_file);
char* work_buf = (char*)malloc(sz);
memcpy_s(work_buf, sz, file_contents, sz);
num_ptr = 0;
char* next_token1 = NULL;
char* token = strtok_s(work_buf, " > ", &next_token1);
// Count number of ptrs
while (token != NULL) {
token = strtok_s(NULL, " > ",&next_token1);
num_ptr += 1;
}
pointer_path = (int*)malloc(num_ptr * sizeof(int));
work_buf = (char*)malloc(sz);
memcpy_s(work_buf, sz, file_contents, sz);
char* next_token2 = NULL;
char* ptrs = strtok_s(work_buf, " > ",&next_token2);
pointer_path[0] = (int)strtol(ptrs, &tmp, 16);
// Use ptr
for(int i = 1; i < num_ptr; i++){
ptrs = strtok_s(NULL, " > ", &next_token2);
pointer_path[i] = (int)strtol(ptrs, &tmp, 16);
}
fclose(ptr_file);
printf_s("Loaded %s!\n", MEE_POINTER_FILE);
}
else
{
printf_s("Failed, using default pointer path (MCEE 1.12.60 UWP x64)\n");
num_ptr = 8;
pointer_path = (int*)malloc(num_ptr * sizeof(int));
2020-07-28 09:19:01 +00:00
pointer_path[0] = 0x2594A58;
pointer_path[1] = 0x60;
pointer_path[2] = 0x138;
pointer_path[3] = 0x58;
pointer_path[4] = 0x480;
pointer_path[5] = 0x10;
pointer_path[6] = 0xA8;
2020-07-28 08:55:30 +00:00
pointer_path[7] = 0x0;
}
printf_s("\nPointer Path: ");
for (int i = 0; i < num_ptr; i++)
{
printf_s("%x", pointer_path[i]);
if (i != num_ptr - 1)
{
printf_s(" > ");
}
}
printf_s("\n");
// Hack the universe.
printf_s("\n\nPlease open Minecraft Education Edition\n");
while (hWnd == NULL)
{
hWnd = FindWindow(0, L"Minecraft: Education Edition");
}
printf_s("MCEE Window Handle: %x\n", hWnd);
DWORD proc_id;
GetWindowThreadProcessId(hWnd, &proc_id);
printf_s("MCEE Process ID: %x\n", proc_id);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, proc_id);
printf_s("MCEE Process Handle: %x\n", hProcess);
2020-11-15 01:02:44 +00:00
uintptr_t baseAddress = (uintptr_t)GetProcessBaseAddress(proc_id);
2020-07-28 08:55:30 +00:00
printf_s("MCEE Base Addr: %llx\n", baseAddress);
if (!hProcess)
{
MessageBox(NULL, L"Cannot open process!\r\nTry \"Run as administrator\"", L"Error!", MB_OK + MB_ICONERROR);
}
else
{
2020-11-15 01:02:44 +00:00
printf_s("Waiting for game to initalize....\n");
read_ptr_path:
2020-07-28 08:55:30 +00:00
// Read first ptr
2020-11-15 01:02:44 +00:00
"weird compiler shiz right here..";
uintptr_t cur_ptr = baseAddress + pointer_path[0];
uintptr_t ptr = 0;
uintptr_t new_ptr = 0;
2020-07-28 08:55:30 +00:00
while (ptr == 0)
{
2020-11-15 01:02:44 +00:00
ReadProcessMemory(hProcess, cur_ptr, &ptr, sizeof(uintptr_t), 0);
2020-07-28 08:55:30 +00:00
}
for (int i = 1; i < num_ptr-1; i++) // Follow path...
{
2020-07-29 06:07:46 +00:00
2020-07-28 08:55:30 +00:00
cur_ptr = ptr + pointer_path[i];
2020-11-15 01:02:44 +00:00
ReadProcessMemory(hProcess, cur_ptr, &new_ptr, sizeof(uintptr_t), 0);
2020-07-28 08:55:30 +00:00
if (new_ptr == 0) {
i -= 1;
2020-11-15 01:02:44 +00:00
goto read_ptr_path;
2020-07-28 08:55:30 +00:00
}
else
{
ptr = new_ptr;
2020-11-15 01:02:44 +00:00
2020-07-28 08:55:30 +00:00
}
}
// Wait for 0x1
2020-11-15 01:02:44 +00:00
int login_step_value = 0;
ReadProcessMemory(hProcess, (void*)ptr, &login_step_value, sizeof(int), 0);
2020-07-28 08:55:30 +00:00
2020-11-15 01:02:44 +00:00
if (login_step_value != 0x0)
2020-07-28 08:55:30 +00:00
{
2020-11-15 01:02:44 +00:00
if (LOGIN_STEP_VALUE != -1)
2020-07-28 08:55:30 +00:00
{
2020-11-15 01:02:44 +00:00
printf_s("Trying login stage %i", LOGIN_STEP_VALUE);
WriteProcessMemory(hProcess, (void*)ptr, &LOGIN_STEP_VALUE, sizeof(int), 0);
goto finish;
}
2020-07-28 08:55:30 +00:00
2020-11-15 01:02:44 +00:00
printf_s("Trying login stage 6...\n"); // Backwards Comp (1.9 and lower)
int login_step_value = 6;
WriteProcessMemory(hProcess, (void*)ptr, &login_step_value, sizeof(int), 0);
2020-07-28 08:55:30 +00:00
2020-11-15 01:02:44 +00:00
Sleep(1 * 500);
printf_s("Trying login stage 8...\n");
login_step_value = 8;
WriteProcessMemory(hProcess, (void*)ptr, &login_step_value, sizeof(int), 0);
2020-07-28 08:55:30 +00:00
}
2020-11-15 01:02:44 +00:00
else
{
goto read_ptr_path;
}
finish:
2020-07-28 08:55:30 +00:00
CloseHandle(hProcess);
printf_s("\nBlessed Be!\n");
return 0;
}
}