1#ifndef BKCRACK_ARGUMENTS_HPP
2#define BKCRACK_ARGUMENTS_HPP
11#include <unordered_map>
22 explicit Error(
const std::string& description);
108 std::size_t
maxLength{std::numeric_limits<std::size_t>::max()};
117 std::optional<std::vector<std::vector<std::uint8_t>>>
mask;
138 const char** m_current;
139 const char**
const m_end;
141 std::unordered_map<char, std::bitset<256>> m_charsets;
142 std::unordered_map<char, std::string> m_rawCharsets;
146 auto resolveCharset(
const std::string& rawCharset) -> std::bitset<256>;
148 std::optional<std::string> m_rawBruteforce;
149 std::optional<std::string> m_rawMask;
151 auto finished() const ->
bool;
153 void parseArgument();
188 auto readString(
const std::string& description) -> std::string;
189 auto readOption(
const std::string& description) -> Option;
190 auto readInt(
const std::string& description) -> int;
191 auto readSize(
const std::string& description) -> std::size_t;
192 auto readHex(
const std::string& description) -> std::vector<std::uint8_t>;
193 auto readKey(
const std::string& description) -> std::uint32_t;
194 auto readRawCharset(
const std::string& description) -> std::string;
Error(const std::string &description)
Constructor.
std::optional< std::string > infoArchive
Zip archive about which to display information.
Definition Arguments.hpp:129
std::optional< std::string > cipherFile
File containing the ciphertext.
Definition Arguments.hpp:35
Arguments(int argc, const char *argv[])
Constructor parsing command line arguments.
std::optional< std::string > decipheredFile
File to write the deciphered text corresponding to cipherFile.
Definition Arguments.hpp:69
std::optional< std::string > plainFile
File containing the known plaintext.
Definition Arguments.hpp:39
std::string recoveryStart
Starting point for password recovery.
Definition Arguments.hpp:120
std::optional< std::size_t > plainIndex
Index of the zip entry containing plaintext.
Definition Arguments.hpp:40
bool version
Tell whether version information is needed or not.
Definition Arguments.hpp:132
std::optional< std::string > decryptedArchive
File to write an unencrypted copy of the encrypted archive.
Definition Arguments.hpp:75
std::optional< Keys > keys
Internal password representation.
Definition Arguments.hpp:66
bool keepHeader
Tell whether to keep the encryption header or discard it when writing the deciphered text.
Definition Arguments.hpp:72
std::optional< std::vector< std::vector< std::uint8_t > > > mask
Mask for password recovery, alternative to bruteforce and length.
Definition Arguments.hpp:117
std::optional< std::string > password
Password from which to derive the internal password representation.
Definition Arguments.hpp:63
int attackStart
Starting point of the attack on Z values remaining after reduction.
Definition Arguments.hpp:60
int jobs
Number of threads to use for parallelized operations.
Definition Arguments.hpp:123
std::optional< ChangePassword > changePassword
Arguments needed to change an archive's password.
Definition Arguments.hpp:84
bool exhaustive
Tell whether to try all candidates (keys or passwords) exhaustively or stop after the first success.
Definition Arguments.hpp:126
bool ignoreCheckByte
Tell not to use the check byte derived from ciphertext entry metadata as known plaintext.
Definition Arguments.hpp:57
std::optional< ChangeKeys > changeKeys
Arguments needed to change an archive's internal password representation.
Definition Arguments.hpp:96
int offset
Plaintext offset relative to ciphertext without encryption header (may be negative)
Definition Arguments.hpp:50
std::optional< std::string > plainArchive
Zip archive containing plainFile.
Definition Arguments.hpp:41
std::map< int, std::uint8_t > extraPlaintext
Definition Arguments.hpp:54
std::size_t plainFilePrefix
Maximum number of bytes of plaintext to read from plainFile.
Definition Arguments.hpp:47
auto loadData() const -> Data
Load the data needed for an attack based on parsed arguments.
std::optional< std::vector< std::uint8_t > > bruteforce
Characters to generate password candidates.
Definition Arguments.hpp:99
std::optional< std::size_t > cipherIndex
Index of the zip entry containing ciphertext.
Definition Arguments.hpp:36
bool help
Tell whether help message is needed or not.
Definition Arguments.hpp:135
std::optional< std::string > cipherArchive
Zip archive containing cipherFile.
Definition Arguments.hpp:37
std::optional< LengthInterval > length
Range of password lengths to try during password recovery.
Definition Arguments.hpp:114
BaseError(const std::string &type, const std::string &description)
Constructor.
Keys defining the cipher state.
Definition Keys.hpp:10
Arguments needed to change an archive's internal password representation.
Definition Arguments.hpp:91
Keys newKeys
Internal password representation chosen to generate the new archive.
Definition Arguments.hpp:93
std::string unlockedArchive
File to write the new encrypted archive.
Definition Arguments.hpp:92
Arguments needed to change an archive's password.
Definition Arguments.hpp:79
std::string unlockedArchive
File to write the new encrypted archive.
Definition Arguments.hpp:80
std::string newPassword
Password chosen to generate the new archive.
Definition Arguments.hpp:81
Range of password lengths to try during password recovery.
Definition Arguments.hpp:103
std::size_t maxLength
Greatest password length to try (inclusive)
Definition Arguments.hpp:108
std::size_t minLength
Smallest password length to try (inclusive)
Definition Arguments.hpp:105
auto operator&(const LengthInterval &other) const -> LengthInterval
Compute the intersection between this interval and the given other interval.
Structure to hold the data needed for an attack.
Definition Data.hpp:10
Useful types, constants and utility functions.