katana.units.crypto.xor — XOR Operation

XOR decoder

You can supply a key argument to use for the XOR operation. With the current implementation, if the key is not provided, this unit will attempt to bruteforce the XOR with a single-byte range (1-255).

class katana.units.crypto.xor.Unit(*args, **kwargs)

Bases: katana.units.crypto.CryptoUnit

BLOCKED_GROUPS = ['crypto']

These are tags for groups to not recurse into. Recursing into other crypto units would be silly.

GROUPS = ['crypto', 'xor']

These are “tags” for a unit. Considering it is a Crypto unit, “crypto” is included, and the name of the unit itself, “xor”.

PRIORITY = 70

Priority works with 0 being the highest priority, and 100 being the lowest priority. 50 is the default priorty. This unit has a lower priority.

RECURSE_SELF = False

Do not recurse into self.

evaluate(case: Any) → None

Evaluate the target. Perform the XOR operation with the provided key argument. If no key is provided, it will bruteforce a single-byte XOR within the range of 1-255.

Parameters:case – A case returned by enumerate. For this unit, the enumerate function is not used.
Returns:None. This function should not return any data.
katana.units.crypto.xor.xor(data, key)

Perform an XOR operation across the provided data with a given key.

Parameters:
  • data – A byte string to use as the data for the XOR operation.
  • key – The key to use the for the XOR operation.
Returns:

The result of the XOR operation as a byte string.