From 2338e7215a8e760e0096a4b548125b4e8bb7bc0a Mon Sep 17 00:00:00 2001 From: CPunch Date: Sun, 17 Apr 2022 01:12:01 -0500 Subject: [PATCH] Added CONTRIBUTING.md --- CONTRIBUTING.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 15 +++++---------- lib/NOTES.md | 1 + 3 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..eea6b7e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,44 @@ +# CONTRIBUTING to Laika +HEAD: https://github.com/CPunch/Laika/tree/main + +## Directories explained +- `/cmake-modules` holds helper functions for CMake. +- `/lib` is a shared static library between the bot, shell & CNC. LibSodium is also vendor'd here. +- `/cnc` is the Command aNd Control server. (Currently only targets Linux) +- `/bot` is the bot client to be ran on the target machine. (Targets both Linux and Windows) +- `/shell` is the main shell to connect to the CNC server with to issue commands. (Currently only targets Linux) +- `/tools` holds tools for generating keypairs, etc. + +## Tasks and TODOs +Looking for some simple tasks that need to get done for that sweet 'contributor' cred? Check here! + +- Implement `lib/win/winpersist.c` +- Fix address sanitizer for CMake DEBUG builds + +## Lib: Error Handling +Error handling in Laika is done via the 'lerror.h' header library. It's a small and simple error handling solution written for laika, however can be stripped and used as a simple error handling library. Error handling in Laika is used similarly to other languages, implementing a try & catch block and is achieved using setjmp(). The LAIKA_ERROR(...) is used to throw errors. + +Example: +```C +LAIKA_TRY + printf("Ran first\n"); + LAIKA_ERROR("Debug message here\n"); + printf("You'll never see this\n"); +LAIKA_CATCH + printf("Ran second!\n"); +LAIKA_TRYEND + +printf("Ran last!\n"); +``` + +Some minor inconveniences include: +- `return` or other control-flow statements that leave the current scope cannot be used in the LAIKA_TRY or LAIKA_CATCH scopes. +- max of 32 depth, avoid using recursively. +- not thread safe. + +## Lib: Task Service +Tasks can be scheduled on a delta-period (call X function every approximate N seconds). laikaT_pollTasks() is used to check & run any currently queued tasks. This is useful for sending keep-alive packets, polling shell pipes, or other repeatably scheduled tasks. Most laikaT_pollTasks() calls are done in the peerHandler for each client/server. + +## Bot: Platform-specific backends + +`bot/win` and `bot/lin` include code for platform-specific code that can't be quickly "ifdef"d away. These mainly include stuff like persistence or opening pseudo-ttys. \ No newline at end of file diff --git a/README.md b/README.md index 8ff4b31..2329f34 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,6 @@ My hope is that this becomes complete enough to be accurate to real RAT sources I could add some padding to each packet to make it look pseudo-HTTP-like, however I haven't given much thought to this. -## Directories explained - -- `/cmake-modules` holds helper functions for CMake. -- `/lib` is a shared static library between the bot, shell & CNC. LibSodium is also vendor'd here. -- `/cnc` is the Command aNd Control server. (Currently only targets Linux) -- `/bot` is the bot client to be ran on the target machine. (Targets both Linux and Windows) -- `/shell` is the main shell to connect to the CNC server with to issue commands. (Currently only targets Linux) -- `/tools` holds tools for generating keypairs, etc. - ## CMake Definitions | Definition | Description | Example | @@ -79,6 +70,10 @@ $ rm -rf bin build &&\ Output binaries are put in the `./bin` folder +## Looking to contribute? + +Read `CONTRIBUTING.md` + # Ansible-Playbook -To setup a test VPS for a Laika CNC, check out [this ansible playbook](https://github.com/CPunch/Laika-Playbook). \ No newline at end of file +To setup a test VPS for a Laika CNC, check out [this ansible playbook](https://github.com/CPunch/Laika-Playbook). diff --git a/lib/NOTES.md b/lib/NOTES.md index e5d2495..a22ddfa 100644 --- a/lib/NOTES.md +++ b/lib/NOTES.md @@ -3,5 +3,6 @@ There are some unused features and boilerplate. The unused files include: - ltunnel.c - lbox.h - lvm.h +- lvm.c These files can be safely removed from the library. \ No newline at end of file