covertutils package

Subpackages

Submodules

covertutils.exceptions module

All exception of covertutils package are provided centrically in this module.

exception covertutils.exceptions.InvalidChunkException[source]

Bases: exceptions.Exception

Exception thrown when the chunks are invalid

exception covertutils.exceptions.NoFunctionAvailableException[source]

Bases: exceptions.Exception

This Exception is raised when the received stream does not have a corresponding function.

exception covertutils.exceptions.StegoDataExtractionException[source]

Bases: exceptions.Exception

This Exception is thrown whenever data extraction from a Data is not possible

exception covertutils.exceptions.StegoDataInjectionException[source]

Bases: exceptions.Exception

This Exception is thrown whenever given data cannot be properly injected in Data

exception covertutils.exceptions.StegoSchemeParseException[source]

Bases: exceptions.Exception

This Exception is thrown whenever the StegoScheme syntax gets violated

exception covertutils.exceptions.StreamAdditionException[source]

Bases: exceptions.Exception

This Exception is thrown if any issue happens in stream addition.

exception covertutils.exceptions.StreamAlreadyExistsException[source]

Bases: covertutils.exceptions.StreamAdditionException

This Exception is thrown if an existing stream is tried to be re-added.

exception covertutils.exceptions.StreamDeletionException[source]

Bases: exceptions.Exception

This Exception is thrown if the deletion of a stream is not possible.

exception covertutils.exceptions.TemplateNotFoundException[source]

Bases: exceptions.Exception

This Exception is thrown when the template passed as argument is not available in the covertutils.datamanipulation.stegoinjector.StegoInjector configuration string

covertutils.helpers module

exception covertutils.helpers.CovertUtilsException[source]

Bases: exceptions.Exception

General Exception for raising in helper functions

covertutils.helpers.copydoc(fromfunc, sep='\n')[source]

Decorator: Copy the docstring of fromfunc

covertutils.helpers.defaultArgMerging(defaults, kwargs)[source]
covertutils.helpers.isprintable(s)[source]
covertutils.helpers.permutate(list_, number_set)[source]
covertutils.helpers.str_similar(a, b)[source]
covertutils.helpers.sxor(s1, s2)[source]
covertutils.helpers.xor_str(s1, s2)[source]

covertutils.payloads module

This module provides the CommonStages dict which contains functions properly implemented for use alogn with covertutils.handlers.FunctionDictHandler and subclasses.

The payloads.CommonStages contents are arranged by feature as follows:

CommonStages['shell']               # Contains another dict with keys every usable instance of the `shell` feature.
CommonStages['shell']['function']       # Contains the actual pointer to the `shell` function. This function executes its argument directly to the Operating System's shell and returns the Standard Output.
CommonStages['shell']['marshal']        # Contains a serialized representation of `shell` function using the `python marshal` build-in module.

marshal stages are suitable for use with covertutils.handlers.StageableHandler. They can be remotely deployed to an existing agent and called via a specified stream.

>>> from covertutils.payloads import CommonStages
>>>
>>> CommonStages['shell']['function']("echo 1")
'1\n'
>>> CommonStages['shell']['marshal']
'c\x01\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s&\x00\x00\x00d\x01\x00d\x02\x00l\x00\x00m\x01\x00}\x01\x00\x01|\x01\x00|\x00\x00\x83\x01\x00j\x02\x00\x83\x00\x00}\x02\x00|\x02\x00S(\x03\x00\x00\x00Ni\xff\xff\xff\xff(\x01\x00\x00\x00t\x05\x00\x00\x00popen(\x03\x00\x00\x00t\x02\x00\x00\x00osR\x00\x00\x00\x00t\x04\x00\x00\x00read(\x03\x00\x00\x00t\x07\x00\x00\x00messageR\x00\x00\x00\x00t\x06\x00\x00\x00result(\x00\x00\x00\x00(\x00\x00\x00\x00s\x15\x00\x00\x00covertutils/Stages.pyt\x0e\x00\x00\x00__system_shell\x04\x00\x00\x00s\x06\x00\x00\x00\x00\x01\x10\x01\x12\x01'

Module contents

The covertutils module provides ready plug-n-play tools for Remote Code Execution Agent programming. Features like chunking, encryption, data identification are all handled transparently by its classes. The SimpleOrchestrator handles all data manipulation, and the Handlers.BaseHandler derivative classes handle the agent’s and handler’s actions and responses.

The module does not provide networking functionalities. All networking has to be wrapped by two functions (a sender and a receiver functions) and Handlers will use those for raw_data.