GoodiesHQ

PassPattern.h

Feb 24th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #ifndef _PASSPATTERN_H
  2. #define _PASSPATTERN_H
  3.  
  4. #include <unordered_map>
  5. #include <algorithm>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <vector>
  9. #include <string>
  10.  
  11. /*
  12.  * A simple program that will take a list of plaintext passwords and print out a list of patterns. Fun for analyzing
  13.  * the most common patterns for which you should generate rainbowtables in order to crack the most amount of common
  14.  * passwords.
  15.  */
  16.  
  17. class PassPattern {
  18. private:
  19.     // Private struct and comparator for holding and sorting patterns/counts respectively.
  20.     // Figured they'd be slightly faster than std::pair...
  21.     struct pattern;
  22.     struct patternSorter;
  23. public:
  24.     PassPattern() = default;                            // default constructor
  25.     PassPattern(const std::string&);                    // accept file as a string ref parameter
  26.     std::vector<pattern> parse();                       // actually parse the data and return a sorted vector of pattern structs
  27.     std::string filename();                             // gets the fname variable
  28.     void write(                                         // writes the data to a text file
  29.         const std::string&,
  30.         const std::vector<pattern> &,
  31.         char
  32.     );
  33. private:
  34.     inline char getCharType(char);                      // retrieve a character type
  35.     inline void setCharType(const std::string&, char);  // set each item in a string to a respective char in the charmap
  36.     inline bool exists(const std::string&);             // checks if a file exists or not...
  37.     std::vector <pattern> patterns;                     // vector of pattern strings and their number of occurances
  38.     std::unordered_map<char, char> charmap;             // map of characters... each printable character maps to another
  39.     std::string fname{};                                // file name
  40.  };
  41.  
  42. #endif
Advertisement
Add Comment
Please, Sign In to add comment