Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "md5.hpp"
- #include <string>
- #define MIN char(32)
- #define MAX char(126)
- std::size_t first_not_max(
- std::string& guess)
- {
- std::size_t index = 0;
- for (char i : guess) {
- if (i < MAX) {
- break;
- }
- index++;
- }
- return index;
- }
- void increment_guess(
- std::string& guess)
- {
- std::size_t index = first_not_max(guess);
- if (index < guess.size()) {
- guess[index]++;
- if (index) {
- memset(&guess[0], MIN, index);
- }
- } else {
- guess.assign(guess.size()+1, MIN);
- }
- }
- int main() {
- std::cout << "Enter MD5 to attempt to crack: ";
- std::string hash;
- std::getline(std::cin, hash);
- std::cout << std::endl << "Attempting brute force..." << std::endl << std::endl;
- std::string guess;
- guess += MIN;
- while (true) {
- if (md5(guess) == hash) {
- break;
- }
- increment_guess(guess);
- if (guess.size() > 3) {
- break;
- }
- }
- std::cout << "Result: " << guess << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement