c++ qt авторизация facebook + friend adder 2019 - однопоточный.

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by mail156, 29 May 2019.

  1. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
    c++ qt авторизация facebook + friend adder 2019 - однопоточный.
    создан в qt creator https://qt.io

    fb.pro

    Code:
    #-------------------------------------------------
    #
    # Project created by QtCreator 2016-02-29T00:54:09
    #
    #-------------------------------------------------
    
    QT       += core gui webkit webkitwidgets network
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = fb
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp \
        methods.cpp
    
    HEADERS  += mainwindow.h \
        methods.h
    
    FORMS    += mainwindow.ui
    
    CONFIG += c++11
    mainwindow.h
    Code:
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    public slots:
        void update();
    };
    
    #endif // MAINWINDOW_H
    
    methods.h
    Code:
    #ifndef METHODS_H
    #define METHODS_H
    
    #include <QString>
    #include <QWebFrame>
    #include <QWebView>
    #include <QList>
    #include <QNetworkCookie>
    
    class methods
    {
    public:
        methods();
    public slots:
        static void auth(QString login,QString pass,QWebFrame * frame);
        static void buttonPress(QWebView * webView,int x, int y);
        static void CookieJar();
        static void CookieLoad(QWebView * webView);
        static void CookieSave(QWebView * webView);
        QList<QNetworkCookie> cookiesForUrl(const QUrl &url);
        bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url);
        static void findFriendsClick(QWebFrame * frame);
        static QString readFile();
    
    };
    
    #endif // METHODS_H
    
    mainWindow.cpp
    Code:
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "methods.h"
    #include <QTimer>
    #include <QMouseEvent>
    #include <QNetworkCookieJar>
    #include <QFile>
    #include <QIODevice>
    #include <QNetworkCookie>
    #include <QNetworkCookieJar>
    
    QString login;
    QString pass;
    QString page = "load";
    
    int addFriendIter = 0;
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        methods::CookieLoad(ui->webView);
    
        ui->webView->load(QUrl("https://facebook.com/"));
    
        QStringList login_and_pass = methods::readFile().split(',');
        login = login_and_pass[0];
        pass = login_and_pass[1];
    
        QTimer *timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(update()));
        timer->start(3500);
    }
    
    void MainWindow::update(){
        QPoint mousePos = ui->webView->mapFromGlobal(QCursor::pos());
            qDebug() << mousePos;
            //qDebug() << ui->webView->url();
    
            if (page == "load") {
                methods::auth(login,pass,ui->webView->page()->currentFrame());
                page = "cookieSave";
            } else if (page == "cookieSave"){
                methods::CookieSave(ui->webView);
                qDebug() << "cookieSave";
                page = "friendListLoad";
            } else if (page == "friendListLoad"){
                ui->webView->load(QUrl("https://www.facebook.com/?sk=ff"));
                qDebug() << "friendListLoad";
                page = "friendListLoaded";
            } else if (page == "friendListLoaded") {
                methods::findFriendsClick(ui->webView->page()->currentFrame());
                qDebug() << "friendListLoaded";
                addFriendIter++;
                  if (addFriendIter<5) {
                    page = "friendListLoad";
                  } else {
                      page = "exit";
                  }
            } else if (page == "exit") {
                QApplication::quit();
                qDebug() << "exit";
            }
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    methods.cpp
    Code:
    #include "methods.h"
    #include <QWebView>
    #include <QWebFrame>
    #include <QWebElement>
    #include <QWebElementCollection>
    #include <QMouseEvent>
    #include "QCoreApplication"
    #include "QWebView"
    #include "QSettings"
    #include <QNetworkCookieJar>
    #include <QList>
    #include <QUrl>
    
    methods::methods()
    {
    
    }
    
    void methods::auth(QString login,QString pass,QWebFrame * frame) {
    
        QWebElementCollection collection = frame->findAllElements("input");
        foreach (QWebElement element, collection)
        {
            //qDebug() << element.attribute("name");
            if (element.attribute("name") == "email") element.setAttribute("value",login);
            if (element.attribute("name") == "pass") element.setAttribute("value",pass);
        }
    
        QWebElementCollection collection1 = frame->findAllElements("label");
        int i =0;
        foreach (QWebElement element, collection1)
        {
            if (element.toPlainText() == "") {
               element.evaluateJavaScript("this.click()");
            }
        }
    }
    
    void methods::findFriendsClick(QWebFrame * frame) {
    
        QWebElementCollection collection1 = frame->findAllElements("button");
        int i =0;
        foreach (QWebElement element, collection1)
        {
            int i = 0;
            qDebug() << element.toPlainText();
    
            if (element.toPlainText() == "Добавить" && i==0) {
                   element.evaluateJavaScript("this.click()");
                    qDebug() << element.toPlainText();
                    i++;
                    break;
            }
        }
    
    }
    
    void methods::buttonPress(QWebView * webView,int x,int y){
        QMouseEvent event0(QEvent::MouseButtonRelease, QPointF(x,y), Qt::LeftButton,Qt::LeftButton, Qt::NoModifier);
        QCoreApplication::sendEvent(webView, &event0);
    }
    
    void methods::CookieLoad(QWebView * webView){
        QFile file("cookies.bin");
        if (file.open(QIODevice::ReadOnly))
        {
            QNetworkCookieJar *cookiejar = new QNetworkCookieJar();
    
            quint64 size;
            while (!file.atEnd())
            {
                file.read(reinterpret_cast<char *>(&size), sizeof(size));
                cookiejar->setCookiesFromUrl(QNetworkCookie::parseCookies(file.read(size)), QUrl("https://facebook.com"));
            }
    
            webView->page()->networkAccessManager()->setCookieJar(cookiejar);
        }
        file.close();
    }
    
    void methods::CookieSave(QWebView * webView){
        QFile file("cookies.bin");
        if (file.open(QIODevice::WriteOnly))
        {
            quint64 size;
    
            auto cookies = webView->page()->networkAccessManager()->cookieJar()->cookiesForUrl(QUrl("https://facebook.com/"));
            for (auto &cookie : cookies)
            {
                auto data = cookie.toRawForm();
                size = data.size();
                file.write(reinterpret_cast<char *>(&size), sizeof(size));
                file.write(data);
            }
        }
        file.close();
    }
    
    QString methods::readFile() {
    
        QFile* file = new QFile();
        file->setFileName("login_and_pass.txt");
    
        file->open(QIODevice::ReadWrite);
    
        QString strFile1(file->readAll());
        file->close();
    
        return strFile1;
    }
    
    mainWindow.ui
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>1135</width>
        <height>541</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralWidget">
       <widget class="QWebView" name="webView">
        <property name="geometry">
         <rect>
          <x>20</x>
          <y>10</y>
          <width>1101</width>
          <height>461</height>
         </rect>
        </property>
        <property name="url">
         <url>
          <string>about:blank</string>
         </url>
        </property>
       </widget>
      </widget>
      <widget class="QMenuBar" name="menuBar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>1135</width>
         <height>22</height>
        </rect>
       </property>
      </widget>
      <widget class="QToolBar" name="mainToolBar">
       <property name="windowTitle">
        <string>Facebook</string>
       </property>
       <attribute name="toolBarArea">
        <enum>TopToolBarArea</enum>
       </attribute>
       <attribute name="toolBarBreak">
        <bool>false</bool>
       </attribute>
      </widget>
      <widget class="QStatusBar" name="statusBar"/>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <customwidgets>
      <customwidget>
       <class>QWebView</class>
       <extends>QWidget</extends>
       <header>QtWebKitWidgets/QWebView</header>
      </customwidget>
     </customwidgets>
     <resources/>
     <connections/>
    </ui>
    
    main.cpp
    Code:
    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    
    еще нужно создать файл login_and_pass.txt в папке с exe (windows) или bin (linux) файлах.
    в нем в первую строчку пишется login,pass через запятую.
     
    #1 mail156, 29 May 2019
    Last edited: 29 May 2019
  2. DartPhoenix

    DartPhoenix Well-Known Member

    Joined:
    15 Sep 2013
    Messages:
    251
    Likes Received:
    3,953
    Reputations:
    5
    Ох ушь мне этот веб...

    if (element.toPlainText() == "Добавить" && i==0)
     
    mail156 likes this.
  3. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
    Здесь используются файлы cookie,
    так что при последующем входе в программу,
    не нужно заново авторизовываться.
     
  4. man474019

    man474019 Member

    Joined:
    31 Jul 2015
    Messages:
    250
    Likes Received:
    71
    Reputations:
    1
    can you share .exe ?
     
    mail156 likes this.
  5. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
    #5 mail156, 30 May 2019
    Last edited: 30 May 2019
  6. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
  7. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
    Этим софтом в 2019 году реально делать на автоматизме по 10 друзей на аккаунт в сутки.
     
  8. mail156

    mail156 Active Member

    Joined:
    28 Sep 2018
    Messages:
    193
    Likes Received:
    122
    Reputations:
    0
    Данный софт, нет смысла делать многопоточный, так как на рассылку 10 приглашений в друзья (а больше не нужно так как будет бан аккаунта), нужно около 1 минуты. А значит, теоретически, можно добавить в софт прокси и очистку cookies и сброс кэша эмулированного браузера, тем самым в сутки можно иметь 1 минута = 1 аккаунт, 24 часа = 1440 минут, т.е. в данный софт можно было бы загрузить 1440 аккаунтов, которые работали бы 24 часа в сутки, 365 дней в году с VPS-сервера, работающего в Нидерландах на https://tilaa.nl . Это все теория, непроверенная на практике.
     
  9. westruk

    westruk New Member

    Joined:
    26 Sep 2018
    Messages:
    3
    Likes Received:
    3
    Reputations:
    0
    можно и больше делать, главное в софте по фб грамотная эмуляция поведения реального человека и хорошие прокси.
     
    mail156 likes this.
Loading...