Crate cart

source ·
Expand description

The CaRT file format is used to store/transfer malware and it’s associated metadata.

It neuters the malware so it cannot be executed and encrypts it so anti-virus software cannot flag the CaRT file as malware.

The functions, structs, and constants in the root of the package prefixed with cart are all exported to build a c library.

#include "cart.h"
#include <string.h>

int main(char** argv, int argn) {
    // A file to encode
    char* input_file = "./cart.h";
    char* metadata_json = "{\"hello\": \"world\"}";
    char* carted_file = "./cart.h.cart";
    char* output_file = "./cart_copy.h";

    // Encode file
    if(CART_NO_ERROR != cart_pack_file_default(input_file, carted_file, metadata_json)) {
        return 1;
    }

    // Decode file
    CartUnpackResult result = cart_unpack_file(carted_file, output_file);
    if(result.error != CART_NO_ERROR) {
        return 2;
    }

    cart_free_unpack_result(result);
}

An interfaces more suitable for calling from rust is in the cart module.

Modules

Structs

A struct returned from encoding functions that may return a buffer.
A struct returned from decoding functions that may return a buffer.

Constants

Error code when a string argument could not be parsed
Error code when input json could not be parsed
Error code when an unexpected null argument was passed
Error code when an input file could not be opened
Error code when an output file could not be opened
Error code when an error occurs processing the input data
Error code set when a call completes without errors

Functions

Release any resources behind a CartPackResult struct.
Release any resources behind a CartUnpackResult struct.
Read header metadata only from a buffer of cart data.
Open the cart file at the given path and read out its metadata.
Read header metadata only from a cart file object.
Test if the given buffer contains cart data.
Test if the file at a given path contains cart data.
Test if the given file object contains cart data.
Cart encode a buffer.
Cart encode a file from disk into a new file.
Cart encode between open libc file handles.
Decode cart data from a buffer.
Decode a cart encoded file into a new file.
Decode cart data from an open libc file into another.