Permalink
Browse files

add hashO

  • Loading branch information...
1 parent 9d08d89 commit 59d63ca82813597ca3bd045edc11c1884774ada9 @zhanlangsir committed Apr 20, 2013
Showing with 55 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +8 −0 src/core/captchainfo.h
  3. +3 −0 src/core/qqlogincore.cpp
  4. +41 −2 src/mainwindow.cpp
  5. +1 −0 src/mainwindow.h
View
@@ -2,3 +2,5 @@
*~
build/
.clang_complete
+tags
+cscope.*
View
@@ -29,6 +29,13 @@ class CaptchaInfo
void setSkey(QString skey)
{ skey_ = skey; }
+ QString ptwebqq() const
+ { return ptwebqq_; }
+ void setPtwebqq(const QString &ptwebqq)
+ {
+ ptwebqq_ = ptwebqq;
+ }
+
QString cookie() const
{ return cookie_; }
void setCookie(QString cookie)
@@ -52,6 +59,7 @@ class CaptchaInfo
QString vfwebqq_;
QString psessionid_;
+ QString ptwebqq_;
QString skey_;
QString cookie_;
int index_;
View
@@ -95,7 +95,10 @@ void QQLoginCore::login(QString id, QString pwd, ContactStatus status)
QString value = result.mid(value_idx+1, fin_value_idx - value_idx - 1);
if (key == "ptwebqq")
+ {
ptwebqq = value;
+ CaptchaInfo::instance()->setPtwebqq(ptwebqq);
+ }
if (key == "skey")
CaptchaInfo::instance()->setSkey(value);
View
@@ -230,15 +230,54 @@ void MainWindow::closeEvent(QCloseEvent *)
}
}
+QString MainWindow::hashO(const QString &uin, const QString &ptwebqq)
+{
+ QString a;
+ a.append(ptwebqq);
+ a.append("password error");
+
+ QString s;
+ while ( true )
+ {
+ if ( s.length() < a.length() )
+ {
+ s.append(uin);
+ if ( s.length() == a.length() )
+ break;
+ }
+ else
+ {
+ s.truncate(a.length());
+ break;
+ }
+ }
+
+ QString j;
+ for ( int i = 0; i < s.length(); ++i )
+ {
+ j.append(s[i].toLatin1() ^ a[i].toLatin1());
+ }
+
+ QString key = "0123456789ABCDEF";
+
+ s[0] = 0;
+ for ( int i = 0; i < a.length(); ++i )
+ {
+ s[2*i] = key[j[i].toLatin1() >> 4 & 15];
+ s[2*i+1] = key[j[i].toLatin1() & 15];
+ }
+ return s;
+}
+
void MainWindow::getFriendList()
{
QString get_friendlist_url = "/api/get_user_friends2";
- QString msg_content = "r={\"h\":\"hello\",\"vfwebqq\":\"" + CaptchaInfo::instance()->vfwebqq() + "\"}";
+ QString msg_content = "r={\"h\":\"hello\",\"hash\":\"" + hashO(CurrLoginAccount::id(), CaptchaInfo::instance()->ptwebqq())+ "\",\"vfwebqq\":\"" + CaptchaInfo::instance()->vfwebqq() + "\"}";
QHttpRequestHeader header("POST", get_friendlist_url);
header.addValue("Host", "s.web2.qq.com");
setDefaultHeaderValue(header);
- header.addValue("Referer", "http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=1");
+ header.addValue("Referer", "http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3");
header.addValue("Cookie", CaptchaInfo::instance()->cookie());
header.setContentType("application/x-www-form-urlencoded");
header.setContentLength(msg_content.length());
View
@@ -79,6 +79,7 @@ private slots:
void setupLoginStatus();
QString getStatusByIndex(int idx) const;
void initHotkey();
+ QString hashO(const QString &uin, const QString &ptwebqq);
private:
Ui::MainWindow *ui;

0 comments on commit 59d63ca

Please sign in to comment.