add: elements of strings are now 1 byte, string encryption for Windows APIs, fix: nullptr
This commit is contained in:
24
src/api.c
24
src/api.c
@@ -53,7 +53,13 @@ void api_callrawaddr() {
|
|||||||
#endif
|
#endif
|
||||||
void api_VirtualAlloc(void) {
|
void api_VirtualAlloc(void) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fVirtualAlloc pVirtualAlloc = GetApi(L"kernel32.dll", "VirtualAlloc");
|
char api[] = "[nwyzfqFqqth";
|
||||||
|
fVirtualAlloc pVirtualAlloc = GetApi(L"kernel32.dll", PCAESAR_DECRYPT(api));
|
||||||
|
if (pVirtualAlloc == NULL) {
|
||||||
|
state->STACK_IDX -= 4;
|
||||||
|
state->registers->eax = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
long long arg0 = state->STACK[state->STACK_IDX--];
|
long long arg0 = state->STACK[state->STACK_IDX--];
|
||||||
long long arg1 = state->STACK[state->STACK_IDX--];
|
long long arg1 = state->STACK[state->STACK_IDX--];
|
||||||
long long arg2 = state->STACK[state->STACK_IDX--];
|
long long arg2 = state->STACK[state->STACK_IDX--];
|
||||||
@@ -71,7 +77,13 @@ void api_VirtualAlloc(void) {
|
|||||||
#endif
|
#endif
|
||||||
void api_VirtualFree(void) {
|
void api_VirtualFree(void) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fVirtualFree pVirtualFree = GetApi(L"kernel32.dll", "VirtualFree");
|
char api[] = "[nwyzfqKwjj";
|
||||||
|
fVirtualFree pVirtualFree = GetApi(L"kernel32.dll", PCAESAR_DECRYPT(api));
|
||||||
|
if (pVirtualFree == NULL) {
|
||||||
|
state->STACK_IDX -= 3;
|
||||||
|
state->registers->eax = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
long long arg0 = state->STACK[state->STACK_IDX--];
|
long long arg0 = state->STACK[state->STACK_IDX--];
|
||||||
long long arg1 = state->STACK[state->STACK_IDX--];
|
long long arg1 = state->STACK[state->STACK_IDX--];
|
||||||
long long arg2 = state->STACK[state->STACK_IDX--];
|
long long arg2 = state->STACK[state->STACK_IDX--];
|
||||||
@@ -88,7 +100,13 @@ void api_VirtualFree(void) {
|
|||||||
#endif
|
#endif
|
||||||
void api_GetAsyncKeyState(void) {
|
void api_GetAsyncKeyState(void) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fGetAsyncKeyState pGetAsyncKeyState = GetApi(L"user32.dll", "GetAsyncKeyState");
|
char api[] = "LjyFx~shPj~Xyfyj";
|
||||||
|
fGetAsyncKeyState pGetAsyncKeyState = GetApi(L"user32.dll", PCAESAR_DECRYPT(api));
|
||||||
|
if (pGetAsyncKeyState == NULL) {
|
||||||
|
state->STACK_IDX -= 1;
|
||||||
|
state->registers->eax = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
long long arg0 = state->STACK[state->STACK_IDX--];
|
long long arg0 = state->STACK[state->STACK_IDX--];
|
||||||
state->registers->eax = (long long)pGetAsyncKeyState((int)arg0);
|
state->registers->eax = (long long)pGetAsyncKeyState((int)arg0);
|
||||||
#else
|
#else
|
||||||
|
|||||||
52
src/libc.c
52
src/libc.c
@@ -39,19 +39,43 @@ fHeapReAlloc pHeapReAlloc = NULL;
|
|||||||
#define IS_NUM(c) ((c >= '0' && c <= '9') ? (1) : (0))
|
#define IS_NUM(c) ((c >= '0' && c <= '9') ? (1) : (0))
|
||||||
#define IS_SPACE(c) (c == ' ')
|
#define IS_SPACE(c) (c == ' ')
|
||||||
|
|
||||||
|
int strlen__(char const* str)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
return 1;
|
||||||
|
for (int i = 0; str[i] != '\0'; i += 1) {
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
char* PCAESAR_DECRYPT(char* in) {
|
||||||
|
for (int i = 0; i < strlen__(in); i++) {
|
||||||
|
in[i] -= KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* malloc_(size_t _Size) {
|
void* malloc_(size_t _Size) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
return malloc(_Size);
|
return malloc(_Size);
|
||||||
#else
|
#else
|
||||||
if (_crt_heap_ == 0) {
|
if (_crt_heap_ == 0) {
|
||||||
if (pHeapCreate == NULL) {
|
if (pHeapCreate == NULL) {
|
||||||
pHeapCreate = GetApi(L"KERNEL32.DLL", "HeapCreate");
|
char api[] = "MjfuHwjfyj";
|
||||||
|
pHeapCreate = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
_crt_heap_ = pHeapCreate(0, 0, 0);
|
_crt_heap_ = pHeapCreate(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHeapAlloc == NULL) {
|
if (pHeapAlloc == NULL) {
|
||||||
pHeapAlloc = GetApi(L"KERNEL32.DLL", "HeapAlloc");
|
char api[] = "MjfuFqqth";
|
||||||
|
pHeapAlloc = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
return pHeapAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Size);
|
return pHeapAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Size);
|
||||||
#endif
|
#endif
|
||||||
@@ -63,7 +87,8 @@ void free_(void* _Block) {
|
|||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
if (pHeapFree == NULL) {
|
if (pHeapFree == NULL) {
|
||||||
pHeapFree = GetApi(L"KERNEL32.DLL", "HeapFree");
|
char api[] = "MjfuKwjj";
|
||||||
|
pHeapFree = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
pHeapFree(_crt_heap_, 0, _Block);
|
pHeapFree(_crt_heap_, 0, _Block);
|
||||||
return;
|
return;
|
||||||
@@ -76,35 +101,26 @@ void* realloc_(void* _Block, size_t _Size) {
|
|||||||
#else
|
#else
|
||||||
if (_crt_heap_ == 0) {
|
if (_crt_heap_ == 0) {
|
||||||
if (pHeapCreate == NULL) {
|
if (pHeapCreate == NULL) {
|
||||||
pHeapCreate = GetApi(L"KERNEL32.DLL", "HeapCreate");
|
char api[] = "MjfuHwjfyj";
|
||||||
|
pHeapCreate = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
_crt_heap_ = pHeapCreate(0, 0, 0);
|
_crt_heap_ = pHeapCreate(0, 0, 0);
|
||||||
}
|
}
|
||||||
if (_Block == NULL) {
|
if (_Block == NULL) {
|
||||||
if (pHeapAlloc == NULL) {
|
if (pHeapAlloc == NULL) {
|
||||||
pHeapAlloc = GetApi(L"KERNEL32.DLL", "HeapAlloc");
|
char api[] = "MjfuFqqth";
|
||||||
|
pHeapAlloc = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
return pHeapAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Size);
|
return pHeapAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Size);
|
||||||
}
|
}
|
||||||
if (pHeapReAlloc == NULL) {
|
if (pHeapReAlloc == NULL) {
|
||||||
pHeapReAlloc = GetApi(L"KERNEL32.DLL", "HeapReAlloc");
|
char api[] = "MjfuWjFqqth";
|
||||||
|
pHeapReAlloc = GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
}
|
}
|
||||||
return pHeapReAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Block, _Size);
|
return pHeapReAlloc(_crt_heap_, HEAP_ZERO_MEMORY, _Block, _Size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int strlen__(char const* str)
|
|
||||||
{
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
return 1;
|
|
||||||
for (int i = 0; str[i] != '\0'; i += 1) {
|
|
||||||
len += 1;
|
|
||||||
}
|
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* strcpy__(char* dest, char const* src)
|
char* strcpy__(char* dest, char const* src)
|
||||||
{
|
{
|
||||||
int len = strlen__(src);
|
int len = strlen__(src);
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
extern HANDLE _crt_heap_;
|
extern HANDLE _crt_heap_;
|
||||||
|
|
||||||
|
#define KEY 5
|
||||||
|
|
||||||
|
char* PCAESAR_DECRYPT(char* in);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* malloc_(size_t _Size);
|
void* malloc_(size_t _Size);
|
||||||
|
|||||||
18
src/pasm.c
18
src/pasm.c
@@ -30,12 +30,18 @@ int dprintf(int stream, const char * format, ...) {
|
|||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
if (pGetStdHandle == NULL)
|
if (pGetStdHandle == NULL) {
|
||||||
pGetStdHandle = (fGetStdHandle)GetApi(L"KERNEL32.DLL", "GetStdHandle");
|
char api[] = "LjyXyiMfsiqj";
|
||||||
if (pwvsprintfA == NULL)
|
pGetStdHandle = (fGetStdHandle)GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
pwvsprintfA = (fwvsprintfA)GetApi(L"USER32.dll", "wvsprintfA");
|
}
|
||||||
if (pWriteFile == NULL)
|
if (pwvsprintfA == NULL) {
|
||||||
pWriteFile = (fWriteFile)GetApi(L"KERNEL32.DLL", "WriteFile");
|
char api[] = "|{xuwnsykF";
|
||||||
|
pwvsprintfA = (fwvsprintfA)GetApi(L"USER32.dll", PCAESAR_DECRYPT(api));
|
||||||
|
}
|
||||||
|
if (pWriteFile == NULL) {
|
||||||
|
char api[] = "\\wnyjKnqj";
|
||||||
|
pWriteFile = (fWriteFile)GetApi(L"KERNEL32.DLL", PCAESAR_DECRYPT(api));
|
||||||
|
}
|
||||||
|
|
||||||
switch (stream) {
|
switch (stream) {
|
||||||
case 1: // stdout
|
case 1: // stdout
|
||||||
|
|||||||
Reference in New Issue
Block a user