Metadata-Version: 2.4
Name: configextractor-py
Version: 1.1.15
Summary: A library for extracting malware configurations across multiple frameworks
Author: cccs-rs
Maintainer: cccs-rs
License: MIT License
        
        Copyright (c) 2024 Crown Copyright, Government of Canada (Canadian Centre for Cyber Security / Communications Security Establishment)
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Repository, https://github.com/CybercentreCanada/configextractor-py
Project-URL: Issues, https://github.com/CybercentreCanada/configextractor-py/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: cart
Requires-Dist: click
Requires-Dist: maco>=1.2.12
Requires-Dist: mwcfg
Requires-Dist: mwcp
Requires-Dist: setuptools
Dynamic: license-file

# ConfigExtractor

[![Latest Stable Release](https://img.shields.io/pypi/v/configextractor-py)](https://pypi.org/project/configextractor-py/)
[![License](https://img.shields.io/github/license/CybercentreCanada/configextractor-py)](./LICENSE.md)

Maintainer: @cccs-rs

Python Library for performing configuration extraction across multiple extraction frameworks (ie. Maco, MWCP, etc.). This tool is actively used in the [Assemblyline](https://cybercentrecanada.github.io/assemblyline4_docs/) project as a [service](https://github.com/CybercentreCanada/assemblyline-service-configextractor).

The code found in this repository contains a command line interface that acts as
a wrapper for popular malware configuration data decoders from:

- [Maco](https://github.com/CybercentreCanada/Maco) [MIT license]
- [MWCP](https://github.com/Defense-Cyber-Crime-Center/DC3-MWCP) [MIT license]
- [CAPE Sandbox](https://github.com/kevoreilly/CAPEv2/) [GPL license] via [CAPE-parsers fork](https://github.com/cccs-rs/CAPE-parsers/tree/assemblyline) [MIT License]
  - many thanks to [@kevoreilly](https://github.com/kevoreilly) and the CAPESandbox community for releasing so many open source parsers.
- ~~MWCFG : https://github.com/c3rb3ru5d3d53c/mwcfg [BSD 3-Clause License]~~
  - [Pending support from malduck with structured output](https://github.com/CERT-Polska/malduck/pull/101)

## Installation Guide

### Running in a Container

```bash
docker container run \
  -v /path/to/parsers:/mnt/parsers \
  -v /path/to/samples:/mnt/samples \
  cccs/assemblyline-service-configextractor \
  "cx -p /mnt/parsers -s /mnt/samples"
```

## Usage

### Command-line

You can use `configextractor` or `cx` to make use of the CLI:

```
Usage: cx [OPTIONS] PARSERS_PATH SAMPLE_PATH

Options:
  --block_list TEXT  Comma-delimited list of parsers to ignore
  --help             Show this message and exit.
```

### Python

```python
from configextractor.main import ConfigExtractor
import logging

# Create a logger to track ongoings
logger = logging.getLogger()
logger.handlers = [logging.StreamHandler()]
logger.setLevel('DEBUG')

# Instantiate instance of class with path(s) to extractors
# Attaching a logger will allow some insight into what's going on if parser detection is the issue
cx = ConfigExtractor(["/path/to/extractors/"], logger=logger)

# List all parsers actively detected and loaded into instance
# cx.parsers.keys() lists all the relative module paths to the parsers
# The value of each key is an Extractor object containing details for running the extractor (ie. venv location, YARA rule, etc.)
print([cx.get_details(p)['name'] for p in cx.parsers.values()])

# Run all loaded parsers against sample
results = cx.run_parsers('/path/to/sample')

# Output raw results to stdout, each should be organized by the parsers that generated an output
print(results)
```

## Adding a new Parser Framework

1. Inherit from the base `Framework` class and implement class accordingly
2. Add new framework to the ConfigExtractor class' `FRAMEWORK_LIBRARY_MAPPING`
