commit 7fd793faa3ae07d731da41013b91e96a9409fc99 Author: kiritow <1362050620@qq.com> Date: Thu Sep 21 09:02:07 2017 +0800 Initial Commit diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..5c89aa0 --- /dev/null +++ b/Readme.md @@ -0,0 +1,3 @@ +# AutoNewQustLogin + +QUST无感知版本的自动登录程序 \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..dc40b02 --- /dev/null +++ b/main.cpp @@ -0,0 +1,170 @@ +#include +#include +#include +#include + +#include +using namespace std; + +#include "user_info.hpp" + +const string curl_bin="C:\\curl "; + +int system(const std::string& str) +{ + //cout<<"SystemExec: "< ans.txt 2> curl.txt"; + + system(ostr.str()); + + ifstream ifs("ans.txt"); + string temp,ans; + while(getline(ifs,temp)) ans.append(temp); + + return (ans.find("baidu")!=string::npos); +} + +static unsigned char hexchars[] = "0123456789ABCDEF"; +char* basic_url_encode(char const *s, int len, int *new_length) +{ + register unsigned char c; + unsigned char *to, *start; + unsigned char const *from, *end; + + from = (unsigned char *)s; + end = (unsigned char *)s + len; + start = to = (unsigned char *) calloc(1, 3*len+1); + + while (from < end) + { + c = *from++; + + if (c == ' ') + { + *to++ = '+'; + } + else if ((c < '0' && c != '-' && c != '.') || + (c < 'A' && c > '9') || + (c > 'Z' && c < 'a' && c != '_') || + (c > 'z')) + { + to[0] = '%'; + to[1] = hexchars[c >> 4]; + to[2] = hexchars[c & 15]; + to += 3; + } + else + { + *to++ = c; + } + } + *to = 0; + if (new_length) + { + *new_length = to - start; + } + return (char *) start; +} + +string URLEncode(const string& url_to_encode) +{ + char* ptr=basic_url_encode(url_to_encode.c_str(),url_to_encode.size(),nullptr); + string new_url(ptr); + free(ptr); + return new_url; +} + +string QURLEncode(const string& url_to_encode) +{ + string s=URLEncode(url_to_encode); + string ans; + int sz=s.size(); + for(int i=0;i %2526) + ans.append("%25"); + } + else ans.push_back(s[i]); + } + return ans; +} + +bool try_qust_with(const string& login_url,const string& uname,const string& passwd) +{ + ostringstream ostr; + ostr< login.txt 2> curl.txt"; + + system(ostr.str()); + + ifstream ifs("login.txt"); + string temp,ans; + while(getline(ifs,temp)) ans.append(temp); + + return (ans.find("success")!=string::npos); +} + +void qust_login() +{ + cout<<"ڲ..."<