Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various optimizations #118

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions runner/include/ConfigTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class ConfigTask {
static const char *DISTRIBUTION_MODE;
static const char *HEX_DICT;
static const char *DICT1_KEYSPACE;
static const char *MASK_INCREMENT_MIN;
static const char *MASK_INCREMENT_MAX;
static const char *SLOW_CANDIDATES;
};

#endif // CONFIGTASK_HPP
2 changes: 1 addition & 1 deletion runner/include/TaskBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TaskBase {
unsigned long long computed_hashes_; /**< Already computed hashes */
unsigned long long
total_hashes_; /**< Total number or hashes to compute in the task */

unsigned long long computed_hashes_increment_; /**< Already computed hashes in increment mode */
nlohmann::json status_info_; /**< Hashcat status info in json format */

std::string
Expand Down
11 changes: 11 additions & 0 deletions runner/src/AttackCrackingBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ void AttackCrackingBase::addSpecificArguments() {
if (config_.find(ConfigTask::HC_KEYSPACE, value) && value != "0")
addArgument("--limit=" + value);

if (config_.find(ConfigTask::MASK_INCREMENT_MIN, value) && value != "0")
{
addArgument("--increment");
addArgument("--increment-min=" + value);
}
if (config_.find(ConfigTask::MASK_INCREMENT_MAX, value) && value != "0")
addArgument("--increment-max=" + value);

if (config_.find(ConfigTask::SLOW_CANDIDATES, value) && value != "0")
addArgument("--slow-candidates");

findAndAddOptional(ConfigTask::GENERATE_RANDOM_RULES, "--generate-rules");
findAndAddOptional(ConfigTask::HWMON_TEMP_ABORT, "--hwmon-temp-abort");

Expand Down
6 changes: 6 additions & 0 deletions runner/src/ConfigTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const char *ConfigTask::OPTIMIZED = "optimized";
const char *ConfigTask::DISTRIBUTION_MODE = "distribution_mode";
const char *ConfigTask::HEX_DICT = "hex_dict";
const char *ConfigTask::DICT1_KEYSPACE = "dict1_keyspace";
const char *ConfigTask::MASK_INCREMENT_MIN = "mask_increment_min";
const char *ConfigTask::MASK_INCREMENT_MAX = "mask_increment_max";
const char *ConfigTask::SLOW_CANDIDATES = "slow_candidates";
/* Private */

void ConfigTask::convertLineToOption(std::string& line) {
Expand Down Expand Up @@ -79,6 +82,9 @@ void ConfigTask::initSupported() {
supported_.push_back(ConfigTask::DISTRIBUTION_MODE);
supported_.push_back(ConfigTask::HEX_DICT);
supported_.push_back(ConfigTask::DICT1_KEYSPACE);
supported_.push_back(ConfigTask::MASK_INCREMENT_MIN);
supported_.push_back(ConfigTask::MASK_INCREMENT_MAX);
supported_.push_back(ConfigTask::SLOW_CANDIDATES);
}

bool ConfigTask::isSupported(const std::string& key) {
Expand Down
4 changes: 2 additions & 2 deletions runner/src/TaskBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ TaskBase::TaskBase(Directory &directory, ConfigTask &task_config,
const std::string &output_file,
const std::string &workunit_name)
: task_config_(task_config), host_config_(host_config),
directory_(directory), computed_hashes_(0), total_hashes_(0),
directory_(directory), computed_hashes_(0), total_hashes_(0), computed_hashes_increment_(0),
output_file_(output_file), workunit_name_(workunit_name) {}

TaskBase::TaskBase(Directory &directory, ConfigTask &task_config,
ConfigHost &host_config, const std::string &output_file,
const std::string &workunit_name)
: task_config_(task_config), host_config_(host_config),
directory_(directory), computed_hashes_(0), total_hashes_(0),
directory_(directory), computed_hashes_(0), total_hashes_(0), computed_hashes_increment_(0),
output_file_(output_file), workunit_name_(workunit_name) {}

double TaskBase::fractionDone() {
Expand Down
43 changes: 40 additions & 3 deletions runner/src/TaskNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,48 @@ bool TaskNormal::parseHashcatStatus(const std::string &progress_line) {
return false;
}

std::string trash;

/** When this is the first parsed line */
if (total_hashes_ == 0) {
setTotalHashesFromProgress(current_progress, total_hashes, salt_count);
std::string keyspace_val;
// Total hash count in increment mode is passed in MASK_HC_KEYSPACE
if (task_config_.find(ConfigTask::MASK_INCREMENT_MIN, trash) && task_config_.find(ConfigTask::MASK_HC_KEYSPACE, keyspace_val))
{
setTotalHashesFromProgress(current_progress, std::stoull(keyspace_val), salt_count);
}
else
{
setTotalHashesFromProgress(current_progress, total_hashes, salt_count);
}
}

saveParsedProgress(current_progress);

// Mask finished in increment mode - reset computed hash count
if((current_progress == total_hashes) && (total_hashes != 0) && (task_config_.find(ConfigTask::MASK_INCREMENT_MIN, trash)))
{
computed_hashes_increment_ = 0;
}

return true;
}

void TaskNormal::saveParsedProgress(uint64_t currentProgress) {
uint64_t difference_since_last_actualization;

std::string trash;
// Increment mode
if(task_config_.find(ConfigTask::MASK_INCREMENT_MIN, trash))
{
difference_since_last_actualization = currentProgress - start_index_ - computed_hashes_increment_;
computed_hashes_increment_ += difference_since_last_actualization;
}
else
{
difference_since_last_actualization = currentProgress - start_index_ - computed_hashes_;
}

uint64_t difference_since_last_actualization =
currentProgress - start_index_ - computed_hashes_;
Logging::debugPrint(Logging::Detail::CustomOutput,
"Computed_hashes_index: " +
RunnerUtils::toString(currentProgress));
Expand All @@ -59,6 +88,14 @@ void TaskNormal::saveParsedProgress(uint64_t currentProgress) {

void TaskNormal::setTotalHashesFromProgress(uint64_t current, uint64_t max,
uint64_t salt_count) {
std::string trash;
// Increment mode - no skip, total hash count from config must be multiplied by salt count
if(task_config_.find(ConfigTask::MASK_INCREMENT_MIN, trash))
{
start_index_ = 0;
total_hashes_ = max * salt_count;
return;
}

std::string keyspace_val;
uint64_t limit = 0;
Expand Down
14 changes: 14 additions & 0 deletions server/sql/10_create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ CREATE TABLE IF NOT EXISTS `fc_workunit` (
`boinc_host_id` bigint(20) unsigned NOT NULL,
`start_index` bigint(20) unsigned NOT NULL,
`start_index_2` bigint(20) unsigned NOT NULL,
`rule_count` bigint(20) unsigned NOT NULL,
`split_pos` bigint(20) unsigned NOT NULL,
`hc_keyspace` bigint(20) unsigned NOT NULL,
`progress` double NOT NULL DEFAULT '0',
`speed` bigint(20) unsigned NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -206,6 +208,9 @@ CREATE TABLE IF NOT EXISTS `fc_mask` (
`current_index` bigint(20) unsigned NOT NULL,
`keyspace` bigint(20) unsigned NOT NULL,
`hc_keyspace` bigint(20) unsigned NOT NULL,
`increment_min` int(11) unsigned NOT NULL DEFAULT '0',
`increment_max` int(11) unsigned NOT NULL DEFAULT '0',
`merged` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

Expand Down Expand Up @@ -320,6 +325,7 @@ CREATE TABLE IF NOT EXISTS `fc_job` (
`charset3` varchar(4096) COLLATE utf8_bin DEFAULT NULL,
`charset4` varchar(4096) COLLATE utf8_bin DEFAULT NULL,
`rules` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`rules_id` bigint(20) unsigned DEFAULT NULL,
`rule_left` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`rule_right` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`markov_hcstat` varchar(255) COLLATE utf8_bin DEFAULT NULL,
Expand All @@ -332,7 +338,12 @@ CREATE TABLE IF NOT EXISTS `fc_job` (
`min_elem_in_chain` int(10) unsigned NOT NULL DEFAULT '1',
`max_elem_in_chain` int(10) unsigned NOT NULL DEFAULT '8',
`generate_random_rules` int(10) unsigned NOT NULL DEFAULT '0',
`split_dict_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`split_dict_index` bigint(20) unsigned NOT NULL DEFAULT '0',
`split_dict_pos` bigint(20) unsigned NOT NULL DEFAULT '0',
`split_rule_index` bigint(20) unsigned NOT NULL DEFAULT '0',
`optimized` tinyint(1) NOT NULL DEFAULT '1',
`slow_candidates` tinyint(1) NOT NULL DEFAULT '0',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`kill` int(11) NOT NULL DEFAULT '0',
`batch_id` int(11),
Expand Down Expand Up @@ -487,6 +498,9 @@ CREATE TABLE IF NOT EXISTS `fc_settings` (
`ramp_down_coefficient` decimal(5,2) NOT NULL DEFAULT '0.25',
`verify_hash_format` tinyint(1) unsigned NOT NULL DEFAULT '1',
`auto_add_hosts_to_running_jobs` tinyint(1) unsigned NOT NULL DEFAULT '0',
`skip_benchmark` tinyint(1) unsigned NOT NULL DEFAULT '0',
`merge_masks` tinyint(1) unsigned NOT NULL DEFAULT '0',
`update_hashes` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Expand Down
38 changes: 19 additions & 19 deletions server/sql/30_insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- Insert default settings row
--

INSERT INTO `fc_settings` (`default_seconds_per_workunit`, `workunit_timeout_factor`, `hwmon_temp_abort`, `bench_all`, `distribution_coefficient_alpha`, `t_pmin`, `ramp_up_workunits`, `ramp_down_coefficient`, `verify_hash_format`, `auto_add_hosts_to_running_jobs`) VALUES
(3600, 48, 90, 0, 0.1, 20, 0, 0.25, 1, 0);
INSERT INTO `fc_settings` (`default_seconds_per_workunit`, `workunit_timeout_factor`, `hwmon_temp_abort`, `bench_all`, `distribution_coefficient_alpha`, `t_pmin`, `ramp_up_workunits`, `ramp_down_coefficient`, `verify_hash_format`, `auto_add_hosts_to_running_jobs`, `skip_benchmark`, `merge_masks`, `update_hashes`) VALUES
(3600, 48, 90, 0, 0.1, 20, 0, 0.25, 1, 0, 0, 1, 1);


--
Expand Down Expand Up @@ -6583,15 +6583,15 @@ INSERT INTO `fc_hcstats` (`id`, `name`, `path`, `time`, `deleted`) VALUES
-- Insert default masks
--

INSERT INTO `fc_mask` (`id`, `job_id`, `mask`, `current_index`, `keyspace`, `hc_keyspace`) VALUES
(1, 4, '?l', 0, 26, 1),
(2, 4, '?l?l', 0, 676, 26),
(3, 4, '?l?l?l', 0, 17576, 676),
(4, 4, '?l?l?l?l', 0, 456976, 17576),
(5, 4, '?l?l?l?l?l', 0, 11881376, 456976),
(6, 4, '?l?l?l?l?l?l', 0, 308915776, 456976),
(7, 4, '?l?l?l?l?l?l?l', 0, 8031810176, 456976),
(8, 4, '?l?l?l?l?l?l?l?l', 0, 208827064576, 11881376);
INSERT INTO `fc_mask` (`id`, `job_id`, `mask`, `current_index`, `keyspace`, `hc_keyspace`, `increment_min`, `increment_max`) VALUES
(1, 4, '?l', 0, 26, 1, 0, 0),
(2, 4, '?l?l', 0, 676, 26, 0, 0),
(3, 4, '?l?l?l', 0, 17576, 676, 0, 0),
(4, 4, '?l?l?l?l', 0, 456976, 17576, 0, 0),
(5, 4, '?l?l?l?l?l', 0, 11881376, 456976, 0, 0),
(6, 4, '?l?l?l?l?l?l', 0, 308915776, 456976, 0, 0),
(7, 4, '?l?l?l?l?l?l?l', 0, 8031810176, 456976, 0, 0),
(8, 4, '?l?l?l?l?l?l?l?l', 0, 208827064576, 11881376, 0, 0);


--
Expand Down Expand Up @@ -6625,14 +6625,14 @@ INSERT INTO `fc_bin` (`name`) VALUES
-- Insert default BENCH_ALL job and sample jobs
--

INSERT INTO `fc_job` (`id`, `attack`, `attack_mode`, `attack_submode`, `distribution_mode`, `hash_type`, `status`, `keyspace`, `hc_keyspace`, `indexes_verified`, `current_index`, `current_index_2`, `time`, `name`, `comment`, `time_start`, `time_end`, `workunit_sum_time`, `seconds_per_workunit`, `charset1`, `charset2`, `charset3`, `charset4`, `rules`, `rule_left`, `rule_right`, `markov_hcstat`, `markov_threshold`, `grammar_id`, `min_password_len`, `max_password_len`, `min_elem_in_chain`, `max_elem_in_chain`, `optimized`, `deleted`, `hash_list_id`) VALUES
(1, 'mask', 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, NOW(), 'BENCH_ALL', 'This is default job for benchmarking all hosts.', NULL, NULL, 0, 3600, '', '', '', '', NULL, '', '', NULL, 0, NULL, 0, 0, 0, 0, 1, 1, 1),
(2, 'dictionary', 0, 0, 0, 0, 0, 92431, 92431, 0, 0, 0, '2018-08-18 12:00:00', 'sample-dict-md5-quick', 'Default hashcat MD5 hash list', NULL, NULL, 0, 120, '', '', '', '', NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 2),
(3, 'dictionary', 0, 0, 0, 3200, 0, 226082, 226081, 0, 0, 0, '2018-08-18 12:00:00', 'sample-dict-bcrypt', '', NULL, NULL, 0, 60, '', '', '', '', NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 3),
(4, 'mask', 3, 0, 0, 18000, 0, 217180147158, 13270583, 0, 0, 0, '2018-08-18 12:00:00', 'sample-mask-sha3', '', NULL, NULL, 0, 60, '', '', '', '', NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 4),
(5, 'combinator', 1, 0, 0, 3200, 0, 397000, 1000, 0, 0, 0, '2018-08-18 12:00:00', 'sample-combinator-bcrypt', '', NULL, NULL, 0, 60, '', '', '', '', NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 5),
(6, 'pcfg', 9, 0, 0, 1700, 0, 1096, 1096, 0, 0, 0, '2018-08-18 12:00:00', 'sample-pcfg-sha512', '', NULL, NULL, 0, 60, '', '', '', '', NULL, '', '', '', 0, 3, 0, 0, 0, 0, 1, 0, 6),
(7, 'prince', 8, 0, 0, 0, 0, 2306859, 2306859, 0, 0, 0, '2018-08-18 12:00:00', 'sample-prince-md5', '', NULL, NULL, 0, 120, '', '', '', '', NULL, '', '', '', 0, NULL, 1, 8, 1, 8, 1, 0, 7);
INSERT INTO `fc_job` (`id`, `attack`, `attack_mode`, `attack_submode`, `distribution_mode`, `hash_type`, `status`, `keyspace`, `hc_keyspace`, `indexes_verified`, `current_index`, `current_index_2`, `time`, `name`, `comment`, `time_start`, `time_end`, `workunit_sum_time`, `seconds_per_workunit`, `charset1`, `charset2`, `charset3`, `charset4`, `rules`, `rules_id`, `rule_left`, `rule_right`, `markov_hcstat`, `markov_threshold`, `grammar_id`, `min_password_len`, `max_password_len`, `min_elem_in_chain`, `max_elem_in_chain`, `optimized`, `slow_candidates`, `deleted`, `hash_list_id`) VALUES
(1, 'mask', 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, NOW(), 'BENCH_ALL', 'This is default job for benchmarking all hosts.', NULL, NULL, 0, 3600, '', '', '', '', NULL, NULL, '', '', NULL, 0, NULL, 0, 0, 0, 0, 1, 0, 1, 1),
(2, 'dictionary', 0, 0, 0, 0, 0, 92431, 92431, 0, 0, 0, '2018-08-18 12:00:00', 'sample-dict-md5-quick', 'Default hashcat MD5 hash list', NULL, NULL, 0, 120, '', '', '', '', NULL, NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 0, 2),
(3, 'dictionary', 0, 0, 0, 3200, 0, 226082, 226081, 0, 0, 0, '2018-08-18 12:00:00', 'sample-dict-bcrypt', '', NULL, NULL, 0, 60, '', '', '', '', NULL, NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 0, 3),
(4, 'mask', 3, 0, 0, 18000, 0, 217180147158, 13270583, 0, 0, 0, '2018-08-18 12:00:00', 'sample-mask-sha3', '', NULL, NULL, 0, 60, '', '', '', '', NULL, NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 0, 4),
(5, 'combinator', 1, 0, 0, 3200, 0, 397000, 1000, 0, 0, 0, '2018-08-18 12:00:00', 'sample-combinator-bcrypt', '', NULL, NULL, 0, 60, '', '', '', '', NULL, NULL, '', '', '', 0, NULL, 0, 0, 0, 0, 1, 0, 0, 5),
(6, 'pcfg', 9, 0, 0, 1700, 0, 1096, 1096, 0, 0, 0, '2018-08-18 12:00:00', 'sample-pcfg-sha512', '', NULL, NULL, 0, 60, '', '', '', '', NULL, NULL, '', '', '', 0, 3, 0, 0, 0, 0, 1, 0, 0, 6),
(7, 'prince', 8, 0, 0, 0, 0, 2306859, 2306859, 0, 0, 0, '2018-08-18 12:00:00', 'sample-prince-md5', '', NULL, NULL, 0, 120, '', '', '', '', NULL, NULL, '', '', '', 0, NULL, 1, 8, 1, 8, 1, 0, 0, 7);

--
-- Insert default job dictionaries
Expand Down
2 changes: 1 addition & 1 deletion server/src/headers/AttackModes/AttackMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class AttackMode {

virtual PtrMask GetWorkunitMask() const;

virtual PtrMask FindCurrentMask(std::vector<PtrMask> &masks, bool useRealKeyspace) const;
virtual PtrMask FindCurrentMask(std::vector<PtrMask> &masks, bool useRealKeyspace, bool findLongest = false) const;

uint64_t getPasswordCountToProcess() const;

Expand Down
3 changes: 3 additions & 0 deletions server/src/headers/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace Config {
extern std::string tableNameJobDictionary;
extern std::string tableNameHash;
extern std::string tableNamePcfgGrammar;
extern std::string tableNameRule;

/** Path to dictionaries/markov/rules */
extern std::string dictDir;
Expand All @@ -72,6 +73,7 @@ namespace Config {
extern std::string inTemplateFileHybridMaskDict;
extern std::string inTemplateFileRule;
extern std::string inTemplateFileRuleAlt;
extern std::string inTemplateFileRuleSplit;
extern std::string inTemplateFilePrince;
extern std::string inTemplateFilePrinceRules;
extern std::string inTemplateFilePcfg;
Expand All @@ -89,6 +91,7 @@ namespace Config {
extern char * inTemplatePathHybridMaskDict;
extern char * inTemplatePathRule;
extern char * inTemplatePathRuleAlt;
extern char * inTemplatePathRuleSplit;
extern char * inTemplatePathPrince;
extern char * inTemplatePathPrinceRules;
extern char * inTemplatePathPcfg;
Expand Down
28 changes: 28 additions & 0 deletions server/src/headers/Database/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ class CJob {
*/
uint64_t getEndIndex() const;

/**
* @brief Create new mask
* @param newMask [in] New mask string
* @param newKeyspace [in] New real keyspace
* @param newHcKeyspace [in] New hashcat keyspace
* @param incrementMin [in] New increment min size
* @param incrementMax [in] New increment max size
* @return ID of the new fc_mask entry
*/
uint64_t createMask(std::string newMask, uint64_t newKeyspace, uint64_t newHcKeyspace, uint64_t incrementMin, uint64_t incrementMax);

private:

CSqlLoader * m_sqlLoader; /**< SqlLoader for database updating */
Expand All @@ -119,6 +130,7 @@ class CJob {
std::string m_name;
uint64_t m_secondsPerWorkunit;
std::string m_rules;
uint64_t m_rules_id;
std::string m_ruleLeft;
std::string m_ruleRight;
std::string m_charset1;
Expand All @@ -136,7 +148,12 @@ class CJob {
uint32_t m_minElemInChain;
uint32_t m_maxElemInChain;
uint32_t m_generateRandomRules;
uint64_t m_splitDictId;
uint64_t m_splitDictIndex;
uint64_t m_splitDictPos;
uint64_t m_splitRuleIndex;
bool m_optimized;
bool m_slowCandidates;
bool m_killFlag;

/**
Expand Down Expand Up @@ -176,6 +193,7 @@ class CJob {
const std::string & getName() const;
uint64_t getSecondsPerWorkunit() const;
const std::string & getRules() const;
uint64_t getRulesId() const;
const std::string & getRuleLeft() const;
const std::string & getRuleRight() const;
const std::string & getCharset1() const;
Expand All @@ -192,7 +210,17 @@ class CJob {
uint32_t getMinElemInChain() const;
uint32_t getMaxElemInChain() const;
uint32_t getRandomRulesCount() const;

void createRuleSplit(uint64_t dictId, uint64_t dictIndex, uint64_t dictPos, uint64_t ruleIndex);
void removeRuleSplit();
void updateRuleIndex(uint64_t newRuleIndex);
uint64_t getSplitDictId() const;
uint64_t getSplitDictIndex() const;
uint64_t getSplitDictPos() const;
uint64_t getSplitRuleIndex() const;

bool getOptimizedFlag() const;
bool getSlowCandidatesFlag() const;
bool getKillFlag() const;

void setGrammar(const std::string & grammar);
Expand Down
22 changes: 22 additions & 0 deletions server/src/headers/Database/Mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class CMask {
uint64_t m_currentIndex;
uint64_t m_hcKeyspace;
uint64_t m_keyspace;
uint64_t m_incrementMin;
uint64_t m_incrementMax;
uint64_t m_merged;

public:

Expand All @@ -79,6 +82,25 @@ class CMask {
uint64_t getCurrentIndex() const;
uint64_t getHcKeyspace() const;
uint64_t getKeyspace() const;
uint64_t getIncrementMin() const;
uint64_t getIncrementMax() const;
bool isMerged() const;

void setMerged();

/**
* @brief Get mask length (number of characters in candidate passwords created from the mask)
* @return Mask length - '?d?d' has length 2, 'X?d?l' length 3 etc.
*/
uint64_t getLength() const;

/**
* @brief Compare 2 masks
* @param otherMask [in] Other mask to compare to
* @param length [in] Length from the start that should be compared
* @return True if masks are identical in specified range, False otherwise
*/
bool compare(PtrMask otherMask, uint64_t length) const;
};

#endif //WORKGENERATOR_MASK_H
Loading