CaRT Neutering Format Library

1.2.3 · active · verified Thu Apr 16

Compressed and RC4 Transport (CaRT) is a file format and an associated Python library used to 'neuter' files for secure distribution, particularly in the malware analysis community. It encrypts and compresses files, optionally embedding metadata, to prevent execution and detection by antivirus software. The library provides functionalities for packing and unpacking CaRT files and currently supports format version 1. It is actively maintained by Cybercentre Canada, with the latest stable release being 1.2.3.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to pack a simple text file into the CaRT format and then unpack it using the synchronous API. The library handles compression and default ARC4 encryption.

import os
from cart.pack import pack_file
from cart.unpack import unpack_file

# Create a dummy file to pack
original_file = 'test_original.txt'
with open(original_file, 'w') as f:
    f.write('This is a test file for CaRT neutering.')

# Pack the file
cart_file = 'test_original.cart'
pack_file(original_file, cart_file)
print(f"File packed: {original_file} -> {cart_file}")

# Unpack the file
unpacked_file = 'test_unpacked.txt'
unpack_file(cart_file, unpacked_file)
print(f"File unpacked: {cart_file} -> {unpacked_file}")

# Verify content (optional)
with open(unpacked_file, 'r') as f:
    content = f.read()
    print(f"Unpacked content: {content}")

# Clean up
os.remove(original_file)
os.remove(cart_file)
os.remove(unpacked_file)

view raw JSON →