Solved How could I change the identity of Tor7.0 by Qt5?
-
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 64bitsFollowing 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 textHashedControlPassword 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 messageWhole 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/".
-
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
-
@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
-
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
-
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.