katana.units.crypto.railfence — Railfence Cipher

Railfence Cipher decoder

This takes arguments rails and offset which you can set, but they will be bruteforce within the range of 2-10 and 0-10 respectively.

This unit inherits from the katana.unit.NotEnglishAndPrintableUnit class, as we can expect the data to still be printable characters (letters, numbers and punctuation) but not readable English. It also inherits from the katana.units.crypto.CryptoUnit class to ensure it is not a viable URL or potentially useful file.

The code for this is shamelessly stolen from https://github.com/tothi/railfence

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

Bases: katana.unit.NotEnglishAndPrintableUnit, 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', 'railfence']

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

PRIORITY = 60

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

RECURSE_SELF = False

This unit does not recurse into itself. That would be silly.

enumerate()

Yield cases for evaluation given the target and manager configuration. This allows units with multiple possible evaluations (such as password guesser’s) to take advantage of the parallelism of Katana without further coding. By default, this method yields a single None value which will be passed as case in the Unit.evaluate method below. You must yield at least one value before returning, or evaluate will never run.

evaluate(case: Any) → None

Evaluate the target. This simply attemptes to decrypt the target with the Railfence cipher, using the rails and offset values returned by enumerate`.

Parameters:case – A case returned by enumerate. In this case, it is a tuple containing a rail value and offset value to be used for the Railfence cipher operations.
Returns:None
katana.units.crypto.railfence.decryptFence(cipher, rails, offset=0)

Stolen from https://github.com/tothi/railfence.

This is a convenience function to decrypt data with the Railfence cipher.

Parameters:
  • cipher – The ciphertext as a string.
  • rails – The integer number of rails to use in the Railfence cipher operations.
  • offset – The integer offset number to use in the Railfence cipher operations.
katana.units.crypto.railfence.encryptFence(plain, rails, offset=0)

Stolen from https://github.com/tothi/railfence.

This is a convenience function to encrypt data with the Railfence cipher.

Parameters:
  • plain – The plaintext as a string.
  • rails – The integer number of rails to use in the Railfence cipher operations.
  • offset – The integer offset number to use in the Railfence cipher operations.