Home > other >  Winrar blasting source
Winrar blasting source

Time:10-04


# include "baobo. HPP
"
using namespace std;


Int main (int arg c, char * * argv) {

If (arg c <3) {return baobo: : showhelp (); }
String commd=argv [1].
If (commd=="c" | | commd=="create") {return baobo: : createpassfile (argv, arg c, 2); }
Else if (commd=="b" | | commd=="baopo") {return baobo: : baoporarfile (argv, arg c, 2); }
Return baobo: : showhelp ();
}



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
/* baobo HPP */

# pragma once

# include "util. HPP
"# include "MyConsole. HPP
"
# include
# include
# include
# include
# include
# include

using namespace std;
The namespace baobo {
The class passdic {
Const string dic="` 1234567890 -=~! @ # $% ^ & * () _ + qwertyuiop \ \ [] asdfghjkl; 'ZXCVBNM,./QWERTYUIOP {} | ASDFGHJKL: \ "ZXCVBNM <>?" ;
Public:
Bool newpassfile (string filepath, int minlen, int maxlen) {
if (! (minlen <=maxlen)) {return false. }
If (ofs. Is_open ()) {ofs. Close (); }
Ofs. Open (filepath);
if (! Ofs. Is_open () {return false. }
For (int I=minlen; I <=maxlen; I++) {
Cbuff. The clear ();
Writeoutfile (I);
}

Ofs. Close ();
return true;
}
Bool usingpassfile (string) filepath {
If (ofs. Is_open ()) {ofs. Close (); }
If (ifs) is_open ()) {ifs. Close (); }
Using the namespace filesystem;
The path p (filepath);
if (! The exists (p)) {return false. }
The logpath=p.p arent_path ();
Logpath. Append (p.f ilename (). The string (), append (" log "));
if (! The exists (logpath)) {
Ofs. Open (logpath);
Ofs. Write (" 0 \ n ", 2);
Ofs. Close ();
}
The ifs. Open (logpath);
The string line;
Getline (ifs, line);
The ifs. Close ();
Prevline=line. The size () <=0? 0: atoi (line c_str ());
The ifs. Open (p);
if (! Ifsshiftline (prevline)) {closepassfile (); return false; }
return true;
}
Bool next (string & string) {
Char buff [2048].
if (! The ifs. Getline (buff, 2048)) {return false. }
String. The clear ();
String. Append (buff);
Prevline +=1;
return true;
}

Bool closepassfile () {
if (! The ifs. Is_open () {return false. }
Ofs. Open (logpath);
Assert (ofs. Is_open ());
Auto && line=to_string (prevline);
Line. Append (" \ n ");
Ofs. Write (line. C_str (), the line. The size ());
Ofs. Close ();
The ifs. Close ();
return true;
}
Private:
Ifstream ifs.
Int prevline;
Filesystem: : path logpath;
Private:
Ofstream ofs.
The vector cbuff;
Void writeoutfile (int len) {
If (len <=0) {
The string result;
For (auto & v: cbuff) {
Result. The push_back (dic [v]);
}
Result. The push_back (' \ n ');
Ofs. Write (result. C_str (), the result, the size ());
Cbuff. Pop_back ();
return;
}
For (int I=0; I Cbuff. Push_back (I);
Writeoutfile (len - 1);
}
If (cbuff. The size ()> 0) {cbuff. Pop_back (); }
}

Private:
Bool ifsshiftline (int shiftline) {
int i=0;
Char buff [1024].
While (I If (I return true;
}

};


Void writeOneLinetoFile (string filepath, string line) {
Ofstream ofs.
Ofs. Open (filepath);
Assert (ofs. Is_open ());
Line. Append (" \ n ");
Ofs Ofs. Close ();
}


Int showhelp () {
Cout <"arg erro!" Cout <"c | create 'filepath' 'minlen' 'maxlen'" Cout <"b | baopo 'rarfilepath' 'passfilepath'" return 1;
}

Int createpassfile (char * * argv, int arg c, int beg) {
If (arg c - beg + 1 <3) {return showhelp (); }
String filepath=argv [beg];
String minlen=argv [beg + 1];
String maxlen=argv [beg + 2];
Int ni=atoi (minlen c_str ());
Int mx=atoi (maxlen c_str ());
Baobo: : passdic dic.
Auto r=dic. Newpassfile (filepath, ni, mx);
Return r? 0:1;
}

Int baoporarfile (char * * argv, int arg c, int beg) {
If (arg c - beg + 1 <3) {return showhelp (); }
Using the namespace filesystem;
String STR=argv [beg];
The path rar (STR);
if (! The exists (rar)) {
Cout <"rar file '" return 1;
}
STR. The clear ();
STR. Append (argv [beg + 1]).
The path pass (STR);
if (! The exists (pass)) {
Cout <"pass the file '" return 1;
}
String rarcmd="rar t - p";
Baobo: : passdic dic.
if (! Dic. Usingpassfile (pass. The string ())) {
Cout <"pass the file '" return 2;
}
Util... MyConsole console (" input ");
String p;
While (dic) next (p)) {
String CMD.
CMD. Append (rarcmd). Append (rar) string ());
Cout <"using pass:"

  • Related