Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How could I change the identity of Tor7.0 by Qt5?
Qt 6.11 is out! See what's new in the release blog

How could I change the identity of Tor7.0 by Qt5?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by tham
    #1

    Do anyone try to do that with Qt?I search through internet but cannot find anyone tried it with Qt.

    Qt version : Qt5.6.2 vc2015 32bits
    os : win10 64bits

    Following are my solution, but it do not work

    Step 1 : Add HashedControlPassword in the file torrc

    Go to "your_location\Tor Browser\Browser\TorBrowser\Data\Tor"
    Open torrc by text editor
    Add following text

    HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4E

    Step 2 : start tor browser, make sure it is connected

    Step 3 : Use QTcpSocket and QUdpSocket to ask tor to renew the identity

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow),
        socket_(new socket_type(this))
    {
        ui->setupUi(this);
    
        connect(socket_, &QUdpSocket::readyRead, this, &MainWindow::read_tor_msg);
        connect(socket_, static_cast<void(socket_type::*)(QAbstractSocket::SocketError)>(&socket_type::error),
                this, &MainWindow::error);
        connect(socket_, &socket_type::connected, [this]()
        {
            qDebug()<<"socket is connected";
            if(ui->lineEditMessage->text().isEmpty()){
                qDebug()<<"send msg:"<<"AUTHENTICATE \"16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4E\"\r\n";
                socket_->write("AUTHENTICATE \"16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4E\"\r\n");
            }else{
                qDebug()<<"send msg:"<<ui->lineEditMessage->text().toLatin1();
                socket_->write(ui->lineEditMessage->text().toLatin1());
            }
        });
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::error(QAbstractSocket::SocketError error)
    {
        qDebug()<<__func__<<":"<<error;
    }
    
    void MainWindow::read_tor_msg()
    {
        static size_t count = 0;
        qDebug()<<"read tor msg:"<<count++<<"="<<socket_->readAll();
    }
    
    void MainWindow::on_pushButtonSendMsg_clicked()
    {
        socket_->abort();
        socket_->connectToHost(ui->lineEditHost->text(), ui->spinBoxPort->value());
    }
    

    Step 4 : results?

    If I connect with TCP socket, it always reply me "QAbstractSocket::RemoteHostClosedError"
    If I connect with UDP socket, it always give me empty message

    Whole project are place at mega, depend on Qt5.6.2 only. I am 100% sure the host and port are correct, because I have used it as proxy to test my ip address on "http://ipaddress.com/".

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by Eddy
      #2

      Hi tham,

      I stumbled on this tutorial on using Qt with Tor and remembered your question here in the Qt forum.

      I haven't looked in it myself, but maybe you can get some information out of it that is usefull.

      hope it helps

      Qt Certified Specialist
      www.edalsolutions.be

      thamT 1 Reply Last reply
      3
      • EddyE Eddy

        Hi tham,

        I stumbled on this tutorial on using Qt with Tor and remembered your question here in the Qt forum.

        I haven't looked in it myself, but maybe you can get some information out of it that is usefull.

        hope it helps

        thamT Offline
        thamT Offline
        tham
        wrote on last edited by
        #3

        @Eddy Thanks for the link, but this tutorial cannot solve my problem, it is too old, today Tor need another solution to renew the ip address

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          @tham

          today Tor need another solution to renew the ip address
          

          Maybe you migth ask at the Tor developers/ users more details on how to do it, let's say in a pure C++ way.

          Hope it helps

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • thamT Offline
            thamT Offline
            tham
            wrote on last edited by
            #5

            The problem is solved, the problem is the password, I should enter the actual password but not the hashed codes, how silly I was.

            For more details, please read this post. QTcpSocket works too.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved