Skip to content

Commit

Permalink
Implement mask-based password recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
kimci86 committed Aug 10, 2024
1 parent 3f284fa commit e691b94
Show file tree
Hide file tree
Showing 4 changed files with 482 additions and 8 deletions.
3 changes: 3 additions & 0 deletions include/password.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ auto recoverPassword(const Keys& keys, const std::vector<std::uint8_t>& charset,
std::size_t maxLength, std::string& start, int jobs, bool exhaustive, Progress& progress)
-> std::vector<std::string>;

auto recoverPassword(const Keys& keys, const std::vector<std::vector<std::uint8_t>>& mask, std::string& start, int jobs,
bool exhaustive, Progress& progress) -> std::vector<std::string>;

#endif // BKCRACK_PASSWORD_HPP
25 changes: 17 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,30 @@ try
}

// recover password
if (args.bruteforce)
if (args.bruteforce || args.mask)
{
std::cout << "[" << put_time << "] Recovering password" << std::endl;

auto passwords = std::vector<std::string>{};

const auto [state, restart] = [&]() -> std::pair<Progress::State, std::string>
{
const auto& charset = *args.bruteforce;
const auto& [minLength, maxLength] = args.length.value_or(Arguments::LengthInterval{});
auto start = args.recoveryStart;
auto progress = ConsoleProgress{std::cout};
const auto sigintHandler = SigintHandler{progress.state};
passwords = recoverPassword(keysvec.front(), charset, minLength, maxLength, start, args.jobs,
args.exhaustive, progress);
auto start = args.recoveryStart;
auto progress = ConsoleProgress{std::cout};
const auto sigintHandler = SigintHandler{progress.state};

if (args.bruteforce)
{
const auto& charset = *args.bruteforce;
const auto& [minLength, maxLength] = args.length.value_or(Arguments::LengthInterval{});
passwords = recoverPassword(keysvec.front(), charset, minLength, maxLength, start, args.jobs,
args.exhaustive, progress);
}
else
{
passwords = recoverPassword(keysvec.front(), *args.mask, start, args.jobs, args.exhaustive, progress);
}

return {progress.state, start};
}();

Expand Down
Loading

0 comments on commit e691b94

Please sign in to comment.