mirror of
https://github.com/Simplxss/SignerServer.git
synced 2024-11-21 00:37:53 +08:00
fix vector empty cause qq crash
This commit is contained in:
parent
b66ccb1f72
commit
8828f68988
@ -4935,7 +4935,7 @@ get_range_offset_and_length(Range r, size_t content_length) {
|
|||||||
assert(0 <= r.first && r.first < static_cast<ssize_t>(content_length));
|
assert(0 <= r.first && r.first < static_cast<ssize_t>(content_length));
|
||||||
assert(r.first <= r.second &&
|
assert(r.first <= r.second &&
|
||||||
r.second < static_cast<ssize_t>(content_length));
|
r.second < static_cast<ssize_t>(content_length));
|
||||||
|
(void)(content_length);
|
||||||
return std::make_pair(r.first, static_cast<size_t>(r.second - r.first) + 1);
|
return std::make_pair(r.first, static_cast<size_t>(r.second - r.first) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
load.js
2
load.js
@ -9,7 +9,7 @@ const qqPkgInfo = require(path.join(exePath, "resources/app/package.json"));
|
|||||||
if (os.platform() === "win32") {
|
if (os.platform() === "win32") {
|
||||||
QQWrapper = require(path.join(exePath, "resources/app/versions", qqPkgInfo.version, "wrapper.node"));
|
QQWrapper = require(path.join(exePath, "resources/app/versions", qqPkgInfo.version, "wrapper.node"));
|
||||||
appid = "537213803";
|
appid = "537213803";
|
||||||
qua = `V1_WIN_NQ_${qqVersionConfigInfo.curVersion.replace("-", "_")}_GW_B`;
|
qua = `V1_WIN_NQ_${qqPkgInfo.version.replace("-", "_")}_GW_B`;
|
||||||
} else {
|
} else {
|
||||||
QQWrapper = require(path.join(exePath, "resources/app/wrapper.node"));
|
QQWrapper = require(path.join(exePath, "resources/app/wrapper.node"));
|
||||||
appid = "537213827";
|
appid = "537213827";
|
||||||
|
@ -18,6 +18,26 @@ void Exports::Load() {
|
|||||||
throw std::runtime_error("Failed to load version.dll from system32\n");
|
throw std::runtime_error("Failed to load version.dll from system32\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> ExportNames_version = {
|
||||||
|
"GetFileVersionInfoA",
|
||||||
|
"GetFileVersionInfoByHandle",
|
||||||
|
"GetFileVersionInfoExA",
|
||||||
|
"GetFileVersionInfoExW",
|
||||||
|
"GetFileVersionInfoSizeA",
|
||||||
|
"GetFileVersionInfoSizeExA",
|
||||||
|
"GetFileVersionInfoSizeExW",
|
||||||
|
"GetFileVersionInfoSizeW",
|
||||||
|
"GetFileVersionInfoW",
|
||||||
|
"VerFindFileA",
|
||||||
|
"VerFindFileW",
|
||||||
|
"VerInstallFileA",
|
||||||
|
"VerInstallFileW",
|
||||||
|
"VerLanguageNameA",
|
||||||
|
"VerLanguageNameW",
|
||||||
|
"VerQueryValueA",
|
||||||
|
"VerQueryValueW"
|
||||||
|
};
|
||||||
|
|
||||||
// get addresses of original functions
|
// get addresses of original functions
|
||||||
for (int i = 0; i < 17; i++) {
|
for (int i = 0; i < 17; i++) {
|
||||||
OriginalFuncs_version[i] = GetProcAddress(version, ExportNames_version[i].c_str());
|
OriginalFuncs_version[i] = GetProcAddress(version, ExportNames_version[i].c_str());
|
||||||
|
@ -5,26 +5,6 @@
|
|||||||
|
|
||||||
extern "C" FARPROC OriginalFuncs_version[17];
|
extern "C" FARPROC OriginalFuncs_version[17];
|
||||||
|
|
||||||
inline std::vector<std::string> ExportNames_version = {
|
|
||||||
"GetFileVersionInfoA",
|
|
||||||
"GetFileVersionInfoByHandle",
|
|
||||||
"GetFileVersionInfoExA",
|
|
||||||
"GetFileVersionInfoExW",
|
|
||||||
"GetFileVersionInfoSizeA",
|
|
||||||
"GetFileVersionInfoSizeExA",
|
|
||||||
"GetFileVersionInfoSizeExW",
|
|
||||||
"GetFileVersionInfoSizeW",
|
|
||||||
"GetFileVersionInfoW",
|
|
||||||
"VerFindFileA",
|
|
||||||
"VerFindFileW",
|
|
||||||
"VerInstallFileA",
|
|
||||||
"VerInstallFileW",
|
|
||||||
"VerLanguageNameA",
|
|
||||||
"VerLanguageNameW",
|
|
||||||
"VerQueryValueA",
|
|
||||||
"VerQueryValueW"
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Exports {
|
namespace Exports {
|
||||||
void Load();
|
void Load();
|
||||||
}
|
}
|
@ -8,7 +8,11 @@ void __stdcall TlsCallback(PVOID hModule, DWORD fdwReason, PVOID pContext) {
|
|||||||
if (!TlsOnce) {
|
if (!TlsOnce) {
|
||||||
// for version.dll proxy
|
// for version.dll proxy
|
||||||
// load exports as early as possible
|
// load exports as early as possible
|
||||||
Exports::Load();
|
try {
|
||||||
|
Exports::Load();
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
printf("Failed to load exports: %s\n", e.what());
|
||||||
|
}
|
||||||
TlsOnce = true;
|
TlsOnce = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
145
src/server.cpp
145
src/server.cpp
@ -24,74 +24,79 @@ std::string ConstructResponse(const std::string &sign, const std::string &extra,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Server::Server(int port) {
|
Server::Server(int port) {
|
||||||
std::atomic<uint64_t> counter(0);
|
printf("Start server on port: %d\n", port);
|
||||||
|
std::thread(&Server::Init, this, port)
|
||||||
svr.Post("/sign", [this, &counter](const httplib::Request &req, httplib::Response &res)
|
.detach();
|
||||||
{
|
}
|
||||||
try {
|
|
||||||
rapidjson::Document doc;
|
void Server::Init(int port) {
|
||||||
doc.Parse(req.body.c_str(), req.body.size());
|
try {
|
||||||
|
svr.Post("/sign", [this](const httplib::Request &req, httplib::Response &res) {
|
||||||
std::string_view cmd = doc["cmd"].GetString();
|
try {
|
||||||
std::string_view src = doc["src"].GetString();
|
rapidjson::Document doc;
|
||||||
int seq = doc["seq"].GetInt();
|
doc.Parse(req.body.c_str(), req.body.size());
|
||||||
|
|
||||||
auto [signDataHex, extraDataHex, tokenDataHex] = sign.Call(cmd, src, seq);
|
std::string_view cmd = doc["cmd"].GetString();
|
||||||
std::string buffer = ConstructResponse(signDataHex, extraDataHex, tokenDataHex);
|
std::string_view src = doc["src"].GetString();
|
||||||
counter++;
|
int seq = doc["seq"].GetInt();
|
||||||
|
|
||||||
res.set_content(buffer, "application/json");
|
auto [signDataHex, extraDataHex, tokenDataHex] = sign.Call(cmd, src, seq);
|
||||||
}
|
std::string buffer = ConstructResponse(signDataHex, extraDataHex, tokenDataHex);
|
||||||
catch (...) {
|
counter++;
|
||||||
res.set_content("Bad Request", "text/plain");
|
|
||||||
res.status = httplib::StatusCode::BadRequest_400;
|
res.set_content(buffer, "application/json");
|
||||||
}
|
}
|
||||||
});
|
catch (...) {
|
||||||
|
res.set_content("Bad Request", "text/plain");
|
||||||
svr.Get("/sign", [this, &counter](const httplib::Request &req, httplib::Response &res)
|
res.status = httplib::StatusCode::BadRequest_400;
|
||||||
{
|
}
|
||||||
try {
|
});
|
||||||
std::string cmd = req.get_param_value("cmd");
|
|
||||||
std::string src = req.get_param_value("src");
|
svr.Get("/sign", [this](const httplib::Request &req, httplib::Response &res) {
|
||||||
int seq = std::stoi(req.get_param_value("seq"));
|
try {
|
||||||
|
std::string cmd = req.get_param_value("cmd");
|
||||||
auto [signDataHex, extraDataHex, tokenDataHex] = sign.Call(cmd, src, seq);
|
std::string src = req.get_param_value("src");
|
||||||
std::string buffer = ConstructResponse(signDataHex, extraDataHex, tokenDataHex);
|
int seq = std::stoi(req.get_param_value("seq"));
|
||||||
counter++;
|
|
||||||
|
auto [signDataHex, extraDataHex, tokenDataHex] = sign.Call(cmd, src, seq);
|
||||||
res.set_content(buffer, "application/json");
|
std::string buffer = ConstructResponse(signDataHex, extraDataHex, tokenDataHex);
|
||||||
}
|
counter++;
|
||||||
catch (...) {
|
|
||||||
res.set_content("Bad Request", "text/plain");
|
res.set_content(buffer, "application/json");
|
||||||
res.status = httplib::StatusCode::BadRequest_400;
|
}
|
||||||
}
|
catch (...) {
|
||||||
});
|
res.set_content("Bad Request", "text/plain");
|
||||||
|
res.status = httplib::StatusCode::BadRequest_400;
|
||||||
svr.Get("/ping", [](const httplib::Request &req, httplib::Response &res)
|
}
|
||||||
{
|
});
|
||||||
rapidjson::StringBuffer buffer;
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
svr.Get("/ping", [](const httplib::Request &req, httplib::Response &res) {
|
||||||
|
rapidjson::StringBuffer buffer;
|
||||||
writer.StartObject();
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
writer.Key("code");
|
|
||||||
writer.Int(0);
|
writer.StartObject();
|
||||||
writer.EndObject();
|
writer.Key("code");
|
||||||
|
writer.Int(0);
|
||||||
res.set_content(buffer.GetString(), "application/json");
|
writer.EndObject();
|
||||||
});
|
|
||||||
|
res.set_content(buffer.GetString(), "application/json");
|
||||||
svr.Get("/count", [&counter](const httplib::Request &req, httplib::Response &res)
|
});
|
||||||
{
|
|
||||||
rapidjson::StringBuffer buffer;
|
svr.Get("/count", [this](const httplib::Request &req, httplib::Response &res) {
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::StringBuffer buffer;
|
||||||
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
writer.StartObject();
|
|
||||||
writer.Key("count");
|
writer.StartObject();
|
||||||
writer.String(std::to_string(counter.load()).c_str());
|
writer.Key("count");
|
||||||
writer.EndObject();
|
writer.String(std::to_string(counter.load()).c_str());
|
||||||
|
writer.EndObject();
|
||||||
res.set_content(buffer.GetString(), "application/json");
|
|
||||||
});
|
res.set_content(buffer.GetString(), "application/json");
|
||||||
|
});
|
||||||
std::thread([this, port]{ svr.listen("0.0.0.0", port); }).detach();
|
|
||||||
|
bool ret = svr.listen("127.0.0.1", port); // crach here
|
||||||
|
}
|
||||||
|
catch(std::exception &e) {
|
||||||
|
printf("Server init failed: %s\n", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,6 +7,10 @@ public:
|
|||||||
Server(int port);
|
Server(int port);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
httplib::Server svr;
|
|
||||||
Sign sign;
|
Sign sign;
|
||||||
|
httplib::Server svr;
|
||||||
|
std::atomic<uint64_t> counter = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Init(int port);
|
||||||
};
|
};
|
27
src/sign.cpp
27
src/sign.cpp
@ -1,8 +1,6 @@
|
|||||||
#include "sign.h"
|
#include "sign.h"
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -23,12 +21,13 @@
|
|||||||
|
|
||||||
// 签名函数定义
|
// 签名函数定义
|
||||||
#if defined(_WIN_PLATFORM_)
|
#if defined(_WIN_PLATFORM_)
|
||||||
#define CURRENT_VERSION "9.9.9-23361"
|
#define CURRENT_VERSION "9.9.10-24108"
|
||||||
#if defined(_X64_ARCH_)
|
#if defined(_X64_ARCH_)
|
||||||
std::map<std::string, uint64_t> addrMap = {
|
std::map<std::string, uint64_t> addrMap = {
|
||||||
{"9.9.2-16183", 0x2E0D0},
|
{"9.9.2-16183", 0x2E0D0},
|
||||||
{"9.9.9-23361", 0x2EB50},
|
{"9.9.9-23361", 0x2EB50},
|
||||||
{"9.9.9-23424", 0x2EB50}};
|
{"9.9.9-23424", 0x2EB50},
|
||||||
|
{"9.9.10-24108", 0x2EB50}};
|
||||||
#elif defined(_X86_ARCH_)
|
#elif defined(_X86_ARCH_)
|
||||||
std::map<std::string, uint64_t> addrMap = {
|
std::map<std::string, uint64_t> addrMap = {
|
||||||
{"9.9.2-15962", 0x2BD70},
|
{"9.9.2-15962", 0x2BD70},
|
||||||
@ -86,15 +85,17 @@ std::string Bin2Hex(const uint8_t *ptr, size_t length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Sign::Sign() {
|
Sign::Sign() {
|
||||||
std::thread([this]{ while (false) {
|
printf("Start init sign\n");
|
||||||
try {
|
std::thread([this]{
|
||||||
Init();
|
while (true) {
|
||||||
}
|
try {
|
||||||
catch (const std::exception &e) {
|
Init();
|
||||||
std::cerr << e.what() << '\n';
|
break;
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
}
|
||||||
continue;
|
catch (const std::exception &e) {
|
||||||
}
|
printf("Init sign failed: %s\n", e.what());
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
} }).detach();
|
} }).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
typedef int (*SignFunctionType)(const char *cmd, const unsigned char *src, size_t src_len, int seq, unsigned char *result);
|
typedef int (*SignFunctionType)(const char *cmd, const unsigned char *src, size_t src_len, int seq, unsigned char *result);
|
||||||
SignFunctionType SignFunction = nullptr;
|
SignFunctionType SignFunction = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user