1 /* 2 * (C) 2006 Jack Lloyd (lloyd@randombit.net) 3 */ 4 5 #include "vnccrack.h" 6 Wordlist(const std::string & file)7Wordlist::Wordlist(const std::string& file) : in(file.c_str()) 8 { 9 if(!in) 10 throw Exception("Couldn't open wordlist " + file); 11 } 12 has_more() const13bool Wordlist::has_more() const 14 { 15 return in.good() && !in.eof(); 16 } 17 next_line()18std::string Wordlist::next_line() 19 { 20 if(!has_more()) 21 return ""; 22 23 std::string next; 24 std::getline(in, next); 25 26 if(next.length() > 8) 27 next = next.substr(0, 8); /* truncate to 8 chars, VNC's limit */ 28 return next; 29 } 30 next()31TrialPassword Wordlist::next() 32 { 33 std::string line = next_line(); 34 35 while(line == last) 36 line = next_line(); 37 38 last = line; 39 return TrialPassword(line); 40 } 41