Código PHP:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget::setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::MSWindowsFixedSizeDialogHint);
LoadXml();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::LoadXml()
{
QFile file("./Applications.xml");
file.open(QIODevice::ReadOnly | QIODevice::Text);
if(file.error())
{
ui->cmbApp->addItem("Error");
return;
}
QXmlStreamReader xml(&file);
AppInfo appinfo;
OffsetData offset;
if(xml.hasError())
{
ui->cmbApp->addItem("Error");
return;
}
while(!xml.atEnd())
{
if(xml.readNext() == xml.StartDocument)
{
continue;
}
if(xml.name() == "App")
{
if(xml.isStartElement())
{
appinfo.Offsets.clear();
appinfo.Name.clear();
appinfo.Args.clear();
appinfo.Suspended = false;
//ui->cmbApp->addItem(xml.attributes().value("Name").toString());
appinfo.Name = xml.attributes().value("Name").toString();
appinfo.Args = xml.attributes().value("Args").toString();
appinfo.Suspended = (xml.attributes().value("Suspend") == "true");
ui->cmbApp->addItem(appinfo.Name);
}
else if(xml.isEndElement())
{
Apps.append(appinfo);
}
}
else if(xml.name() == "Binary" && xml.isStartElement())
{
offset.Data.clear();
offset.Offset = 0;
offset.AllAccess = false;
offset.Offset = xml.attributes().value("Offset").toString().toInt(NULL, 16);
offset.AllAccess = (xml.attributes().value("AllAccess") == "true");
qint16 repeat = xml.attributes().value("Repeat").toString().toInt(NULL, 16);
if(repeat == 0)
{
repeat = 1;
}
QStringList bytes = xml.readElementText().split(' ');
for(qint16 i = 0; i < repeat; i++)
{
foreach(QString byte, bytes)
{
offset.Data.append(byte.toInt(NULL, 16));
}
}
appinfo.Offsets.append(offset);
}
else if(xml.name() == "String" && xml.isStartElement())
{
offset.Data.clear();
offset.Offset = 0;
offset.AllAccess = false;
offset.Offset = xml.attributes().value("Offset").toString().toInt(NULL, 16);
offset.AllAccess = (xml.attributes().value("AllAccess") == "true");
qint16 repeat = xml.attributes().value("Repeat").toString().toInt(NULL, 16);
if(repeat == 0)
{
repeat = 1;
}
QString temp = xml.readElementText();
for(qint16 i = 0; i < repeat; i++)
{
foreach(char byte, temp.toAscii())
{
offset.Data.append(byte);
}
}
offset.Data.append('\0');
appinfo.Offsets.append(offset);
}
}
}
void MainWindow::on_btnLoad_clicked()
{
QFileDialog dialog(ui->centralWidget, Qt::Popup);
QString filename;
filename = dialog.getOpenFileName(this, ("Select the executable of " + Apps[ui->cmbApp->currentIndex()].Name),
"", "Executable(*.exe);;Any(*.*)", 0, QFileDialog::DontConfirmOverwrite);
if(!filename.isEmpty())
{
AppInfo app = Apps[ui->cmbApp->currentIndex()];
PROCESS_INFORMATION proc_info;
STARTUPINFO start_info;
ZeroMemory(&proc_info,sizeof(proc_info));
ZeroMemory(&start_info, sizeof(start_info));
start_info.cb = sizeof(start_info);
CreateProcess(static_cast<LPCWSTR>(filename.toStdWString().c_str()), const_cast<LPWSTR>(app.Args.toStdWString().c_str()),
NULL, NULL, FALSE, app.Suspended?CREATE_SUSPENDED:0, NULL, NULL, &start_info,&proc_info);
HANDLE hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_info.dwProcessId);
if(!hproc)
{
hproc = proc_info.hProcess;
}
if(hproc)
{
foreach(OffsetData offset, app.Offsets)
{
DWORD old_protect = 0;
if(VirtualProtectEx(hproc, (void*)offset.Offset, offset.Data.size(), PAGE_EXECUTE_READWRITE, &old_protect))
{
for(qint16 i = 0; i < offset.Data.count(); i++)
{
char temp = offset.Data[i];
if(!WriteProcessMemory(hproc, (void*)(offset.Offset + i), static_cast<LPCVOID>(&temp), 1, NULL))
{
TerminateProcess(proc_info.hProcess, 1);
qDebug("Write Error %d", GetLastError());
QMessageBox(QMessageBox::Critical,
"Load error", QString(
"Failed to write memory\nError code %1\nProcess Handle %2\nOffset %3\nData size %4\n")
.arg(GetLastError()).arg((int)hproc).arg(offset.Offset).arg(offset.Data.size()),
QMessageBox::Ok, this, Qt::Popup | Qt::MSWindowsFixedSizeDialogHint).exec();
return;
}
}
if(!offset.AllAccess)
{
DWORD trash = 0;
VirtualProtectEx(hproc, (void*)offset.Offset, offset.Data.size(), old_protect, &trash);
}
}
else
{
TerminateProcess(proc_info.hProcess, 2);
qDebug("Set Memory attributes error %d", GetLastError());
QMessageBox(QMessageBox::Critical,
"Load error", QString(
"Failed to set memory attributes\nError code %1\nProcess Handle %2\nOffset %3\nData size %4\n")
.arg(GetLastError()).arg((int)hproc).arg(offset.Offset).arg(offset.Data.size()),
QMessageBox::Ok, this, Qt::Popup | Qt::MSWindowsFixedSizeDialogHint).exec();
return;
}
}
if(app.Suspended)
{
ResumeThread(proc_info.hThread);
}
CloseHandle(hproc);
}
else
{
QMessageBox(QMessageBox::Critical,
"Load error", QString(
"Cant open handle\nError code %1").arg(GetLastError()),
QMessageBox::Ok, this, Qt::Popup | Qt::MSWindowsFixedSizeDialogHint).exec();
}
CloseHandle(proc_info.hProcess);
CloseHandle(proc_info.hThread);
}
}
void MainWindow::on_btnAbout_clicked()
{
QMessageBox(QMessageBox::Information,
"About", "By Hacker_wap\nhttp://www.forum-invaders.com.br",
QMessageBox::Ok, this, Qt::Popup | Qt::MSWindowsFixedSizeDialogHint).exec();
}