小程序源代码 下载: https://download.csdn.net/download/nn_84/88846445?spm=1001.2014.3001.5501
请下载 Qt 5.12.12
server.pro :
QT += gui network
CONFIG += c++11 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
mythread.cpp
server.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS +=
mythread.h
server.h
mythread.h :
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include
#include
#include
#include
class myThread : public QThread
{
Q_OBJECT
public:
myThread(qintptr ID,QObject *parent = 0);
qintptr sockethandle;
QTcpSocket *socket;
void run();
QProcess *process;
public slots:
void readyRead();
void disconnected();
void fun();
};
#endif // MYTHREAD_H
server.h :
#ifndef SERVER_H
#define SERVER_H
#include
#include "mythread.h"
class Server : public QTcpServer
{
public:
Server();
void startServer();
protected:
void incomingConnection(qintptr handle);
};
#endif // SERVER_H
mythread.cpp :
#include "mythread.h"
myThread::myThread(qintptr ID,QObject *parent):QThread(parent)
{
sockethandle = ID;
process = new QProcess(this);
connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(fun()));
}
void myThread::run()
{
qDebug() setSocketDescriptor(sockethandle);
connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
connect(socket,SIGNAL(disconnected()),this,SLOT(disconnected()));
exec();
}
void myThread::readyRead()
{
QByteArray data = socket->readAll();
qDebug() start("bash");
process->write(data);
}
void myThread::disconnected()
{
socket->deleteLater();
exit(0);
}
void myThread::fun()
{
socket->write(process->readAllStandardOutput().data());
}
server.cpp :
#include "server.h"
Server::Server()
{
}
void Server::incomingConnection(qintptr handle)
{
myThread *thread = new myThread(handle);
thread->start();
}
void Server::startServer()
{
if(this->l服务器托管网isten(QHostAddress::Any,1984)){qDebug()
main.cpp :
#服务器托管网include
#include "server.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Server ser;
ser.startServer();
return a.exec();
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: 微软警告:APT29间谍攻击猖狂;思科关键漏洞允许黑客远程接管统一通信系统;Jenkins漏洞远程代码执行攻击| 安全周报0126
1. 微软警告:针对全球组织的APT29间谍攻击正在扩大 注:APT29是一个与俄罗斯情报机构有关的黑客组织,也被称为Cozy Bear、The Dukes或Office Monkeys。该组织以针对政府机构、外交实体、智库、国防承包商、能源、航服务器托管网空…