-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can post without 4chan pass using captcha; can post threads
- Loading branch information
1 parent
3cb40d8
commit 74cf1c0
Showing
10 changed files
with
238 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "captcha.h" | ||
#include <QDebug> | ||
|
||
Captcha::Captcha() | ||
{ | ||
|
||
} | ||
|
||
Captcha::~Captcha(){ | ||
|
||
} | ||
|
||
void Captcha::getCaptcha(){ | ||
qDebug() << "getting captcha from " + urlChallenge; | ||
loaded = true; | ||
replyChallenge = nc.jsonManager->get(requestChallenge); | ||
QObject::connect(replyChallenge,&QNetworkReply::finished,this,&Captcha::loadCaptcha); | ||
} | ||
|
||
void Captcha::loadCaptcha(){ | ||
qDebug() << "got captcha"; | ||
if(!replyChallenge){ | ||
emit fail(); | ||
return; | ||
} | ||
else if(replyChallenge->error()) { | ||
qDebug().noquote() << "loading post error:" << replyChallenge->errorString(); | ||
replyChallenge->deleteLater(); | ||
return; | ||
} | ||
QByteArray rep = replyChallenge->readAll(); | ||
replyChallenge->deleteLater(); | ||
if(rep.isEmpty()) return; | ||
QString replyString(rep); | ||
qDebug() << replyString; | ||
int start = replyString.indexOf("{\n challenge : "); | ||
if(start == -1) return; | ||
int end = replyString.indexOf("'",start+19); | ||
if(end == -1) return; | ||
qDebug() << start << " " << end; | ||
challenge = replyString.mid(start+19,end-start-19); | ||
qDebug() << challenge; | ||
getImage(challenge); | ||
} | ||
|
||
void Captcha::getImage(QString challenge){ | ||
qDebug() << "getting image"; | ||
if(challenge.isEmpty()) return; | ||
replyImage = nc.jsonManager->get(QNetworkRequest(QUrl(urlImageBase+challenge))); | ||
connect(replyImage,&QNetworkReply::finished,this,&Captcha::loadImage); | ||
} | ||
|
||
void Captcha::loadImage(){ | ||
qDebug() << "got image"; | ||
if(!replyImage){ | ||
emit fail(); | ||
return; | ||
} | ||
else if(replyImage->error()) { | ||
qDebug().noquote() << "loading post error:" << replyImage->errorString(); | ||
replyImage->deleteLater(); | ||
return; | ||
} | ||
QByteArray rep = replyImage->readAll(); | ||
replyImage->deleteLater(); | ||
if(rep.isEmpty()) return; | ||
QPixmap challengeImage; | ||
challengeImage.loadFromData(rep); | ||
emit challengeInfo(challenge,challengeImage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef CAPTCHA_H | ||
#define CAPTCHA_H | ||
#include "netcontroller.h" | ||
#include <QObject> | ||
#include <QNetworkReply> | ||
#include <QThread> | ||
#include <QPixmap> | ||
#include <QTimer> | ||
|
||
class Captcha : public QObject | ||
{ | ||
Q_OBJECT | ||
int timeout = 120; | ||
QString siteKey = "6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc"; | ||
QString server = "https://www.google.com/recaptcha/api"; | ||
QString lang = "en"; | ||
QString urlChallenge = server+"/challenge?k="+siteKey+"&lang="+lang; | ||
QString urlImageBase = server+"/image?c="; | ||
QNetworkRequest requestChallenge = QNetworkRequest(QUrl(urlChallenge)); | ||
public: | ||
explicit Captcha(); | ||
virtual ~Captcha(); | ||
QString challenge; | ||
QString response; | ||
QTimer timer; | ||
bool loaded; | ||
void getCaptcha(); | ||
void getImage(QString challenge); | ||
private: | ||
QNetworkReply *replyChallenge; | ||
QNetworkReply *replyImage; | ||
signals: | ||
void challengeInfo(QString &challenge, QPixmap &challengeImage); | ||
void timeOut(); | ||
void success(); | ||
void fail(); | ||
public slots: | ||
void loadCaptcha(); | ||
void loadImage(); | ||
}; | ||
|
||
#endif // CAPTCHA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.