1 /* 2 * (C) 2006 Jack Lloyd (lloyd@randombit.net) 3 */ 4 5 #ifndef VNC_CRACKER_H__ 6 #define VNC_CRACKER_H__ 7 8 #include <exception> 9 #include <string> 10 #include <vector> 11 #include <fstream> 12 13 #include <openssl/des.h> 14 15 class Exception : public std::exception 16 { 17 public: what()18 const char* what() const throw() { return msg.c_str(); } Exception(const std::string & m)19 Exception(const std::string& m) : msg(m) {} ~Exception()20 virtual ~Exception() throw() {} 21 private: 22 const std::string msg; 23 }; 24 25 class TrialPassword 26 { 27 public: password()28 std::string password() const { return pass; } key_schedule()29 DES_key_schedule key_schedule() const { return ks; } 30 31 TrialPassword(const std::string&); 32 private: 33 DES_key_schedule ks; 34 std::string pass; 35 }; 36 37 class ChallengeResponse 38 { 39 public: 40 bool is_solved() const; 41 std::string solution_is() const; 42 std::string to_string() const; 43 44 void test(const TrialPassword&); 45 46 ChallengeResponse(const std::string&); 47 private: 48 std::vector<unsigned char> challenge, response; 49 std::string solution, string_rep; 50 }; 51 52 class Report 53 { 54 public: 55 virtual void solution(const ChallengeResponse&, const std::string&) = 0; ~Report()56 virtual ~Report() {} 57 }; 58 59 class ChallengeResponses 60 { 61 public: 62 int count() const; 63 bool all_solved() const; 64 65 void test(const TrialPassword&, Report&); 66 ChallengeResponses(const std::string&); 67 private: 68 std::vector<ChallengeResponse> crpairs; 69 }; 70 71 class Wordlist 72 { 73 public: 74 bool has_more() const; 75 TrialPassword next(); 76 77 Wordlist(const std::string&); 78 private: 79 std::string next_line(); 80 81 std::ifstream in; 82 std::string last; 83 }; 84 85 #endif 86