mirror of
https://github.com/CPunch/Laika.git
synced 2025-09-26 20:00:08 +00:00
misc. refactoring, updated comments and minor documentation
This commit is contained in:
@@ -25,10 +25,11 @@ enum {
|
||||
2 main APIs are exposed here, laikaB_unlock() & laikaB_lock(). Both of which are inlined to make it more painful
|
||||
for the reverse engineer to quickly dump boxes from memory, forcing them to set breakpoints across the executable.
|
||||
Each box has its own VM, with it's own deobfuscation routine. This makes static analysis a painful route for string
|
||||
dumping. Some predefined boxes are made for you to use.
|
||||
dumping. These apis, while can be used directly, are abstracted through macros with the pre-built boxes.
|
||||
|
||||
Use LAIKA_BOX_STARTVAR & LAIKA_BOX_ENDVAR for quick and dirty usage. The data macros in `lboxconfig.h` are passed
|
||||
to these, which are generated by VMBoxGen (`tools/vmboxgen`).
|
||||
Use LAIKA_BOX_SKID_START & LAIKA_BOX_SKID_END for quick and dirty usage. The data macros in `lboxconfig.h` are passed
|
||||
to these, which are generated by VMBoxGen (`tools/vmboxgen`). This will be extended in the future with more boxes and such,
|
||||
however for the time being only LAIKA_BOX_SKID_* is implemented.
|
||||
*/
|
||||
|
||||
struct sLaikaB_box {
|
||||
@@ -62,7 +63,7 @@ struct sLaikaB_box {
|
||||
|
||||
/* ==============================================[[ Laika Boxes ]]=============================================== */
|
||||
|
||||
/* BOX_SKID decodes null-terminated strings using a provided xor _key. aptly named lol [SEE tools/vmtest/src/main.c] */
|
||||
/* 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: \
|
||||
@@ -110,7 +111,7 @@ LAIKA_FORCEINLINE void* laikaB_lock(struct sLaikaB_box *box) {
|
||||
sodium_memzero(box->unlockedData, LAIKA_BOX_HEAPSIZE);
|
||||
sodium_memzero(box->scratch, LAIKA_BOX_SCRATCH_SIZE);
|
||||
}
|
||||
|
||||
/* include KEY_* & DATA_* macros for each obfuscated string */
|
||||
#include "lboxconfig.h"
|
||||
|
||||
#endif
|
@@ -21,13 +21,13 @@ typedef enum {
|
||||
} OSTYPE;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define LAIKA_OSTYPE OS_WIN
|
||||
# define LAIKA_OSTYPE OS_WIN
|
||||
#else
|
||||
#ifdef __linux__
|
||||
#define LAIKA_OSTYPE OS_LIN
|
||||
#else
|
||||
#define LAIKA_OSTYPE OS_UNKNWN
|
||||
#endif
|
||||
# ifdef __linux__
|
||||
# define LAIKA_OSTYPE OS_LIN
|
||||
# else
|
||||
# define LAIKA_OSTYPE OS_UNKNWN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct sLaika_peer;
|
||||
@@ -39,7 +39,6 @@ struct sLaika_peerPacketInfo {
|
||||
bool variadic;
|
||||
};
|
||||
|
||||
|
||||
#define LAIKA_CREATE_PACKET_INFO(ID, HANDLER, SIZE, ISVARIADIC) [ID] = {.handler = HANDLER, .size = SIZE, .variadic = ISVARIADIC}
|
||||
|
||||
struct sLaika_peer {
|
||||
|
@@ -4,49 +4,49 @@
|
||||
/* socket/winsock headers */
|
||||
#ifdef _WIN32
|
||||
/* windows */
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
# include <ws2tcpip.h>
|
||||
# pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
typedef char buffer_t;
|
||||
#define PollFD WSAPOLLFD
|
||||
#define poll WSAPoll
|
||||
#define LN_ERRNO WSAGetLastError()
|
||||
#define LN_EWOULD WSAEWOULDBLOCK
|
||||
#define LN_MSG_NOSIGNAL 0
|
||||
#define SOCKETINVALID(x) (x == INVALID_SOCKET)
|
||||
#define SOCKETERROR(x) (x == SOCKET_ERROR)
|
||||
typedef char buffer_t;
|
||||
# define PollFD WSAPOLLFD
|
||||
# define poll WSAPoll
|
||||
# define LN_ERRNO WSAGetLastError()
|
||||
# define LN_EWOULD WSAEWOULDBLOCK
|
||||
# define LN_MSG_NOSIGNAL 0
|
||||
# define SOCKETINVALID(x) (x == INVALID_SOCKET)
|
||||
# define SOCKETERROR(x) (x == SOCKET_ERROR)
|
||||
#else
|
||||
/* posix platform */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <poll.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/epoll.h>
|
||||
/* max events for epoll() */
|
||||
#define MAX_EPOLL_EVENTS 128
|
||||
#define LAIKA_USE_EPOLL
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <poll.h>
|
||||
# ifdef __linux__
|
||||
# include <sys/epoll.h>
|
||||
/* max events for epoll() */
|
||||
# define MAX_EPOLL_EVENTS 128
|
||||
# define LAIKA_USE_EPOLL
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
|
||||
typedef int SOCKET;
|
||||
typedef void buffer_t;
|
||||
#define PollFD struct pollfd
|
||||
#define LN_ERRNO errno
|
||||
#define LN_EWOULD EWOULDBLOCK
|
||||
#define LN_MSG_NOSIGNAL MSG_NOSIGNAL
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKETINVALID(x) (x < 0)
|
||||
#define SOCKETERROR(x) (x == -1)
|
||||
typedef int SOCKET;
|
||||
typedef void buffer_t;
|
||||
# define PollFD struct pollfd
|
||||
# define LN_ERRNO errno
|
||||
# define LN_EWOULD EWOULDBLOCK
|
||||
# define LN_MSG_NOSIGNAL MSG_NOSIGNAL
|
||||
# define INVALID_SOCKET -1
|
||||
# define SOCKETINVALID(x) (x < 0)
|
||||
# define SOCKETERROR(x) (x == -1)
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
|
@@ -1,34 +0,0 @@
|
||||
#ifndef SHELLTUNNEL_H
|
||||
#define SHELLTUNNEL_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "lmem.h"
|
||||
#include "lsocket.h"
|
||||
#include "lpeer.h"
|
||||
#include "lpolllist.h"
|
||||
|
||||
struct sLaika_tunnel;
|
||||
struct sLaika_tunnelConnection {
|
||||
struct sLaika_socket sock;
|
||||
struct sLaika_tunnel *tunnel;
|
||||
struct sLaika_tunnelConnection *next;
|
||||
uint16_t id;
|
||||
};
|
||||
|
||||
struct sLaika_tunnel {
|
||||
struct sLaika_tunnelConnection *connectionHead;
|
||||
struct sLaika_peer *peer;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
struct sLaika_tunnel *laikaT_newTunnel(struct sLaika_peer *peer, uint16_t port);
|
||||
void laikaT_freeTunnel(struct sLaika_tunnel *tunnel);
|
||||
|
||||
struct sLaika_tunnelConnection *laikaT_newConnection(struct sLaika_tunnel *tunnel, uint16_t id);
|
||||
void laikaT_freeConnection(struct sLaika_tunnelConnection *connection);
|
||||
|
||||
void laikaT_forwardData(struct sLaika_tunnelConnection *connection, struct sLaika_pollList *pList, void *data, size_t sz);
|
||||
struct sLaika_tunnelConnection *laikaT_getConnection(struct sLaika_tunnel *tunnel, uint16_t id);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user