mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Feat&Improve: Support gen pass code binding with domain
This commit is contained in:
@@ -85,10 +85,11 @@ std::string execCommand(const char* cmd)
|
||||
result.erase(remove(result.begin(), result.end(), '\r'), result.end());
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return result;
|
||||
return result.empty() ? "ERROR" : result;
|
||||
}
|
||||
|
||||
std::string getHardwareID_PS() {
|
||||
std::string getHardwareID_PS()
|
||||
{
|
||||
// Get-WmiObject <20><> PowerShell 2.0+ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (>=Win7)
|
||||
const char* psScript =
|
||||
"(Get-WmiObject Win32_Processor).ProcessorId + '|' + "
|
||||
@@ -107,20 +108,23 @@ std::string getHardwareID_PS() {
|
||||
}
|
||||
|
||||
// <20><>ȡӲ<C8A1><D3B2> ID<49><44>CPU + <20><><EFBFBD><EFBFBD> + Ӳ<>̣<EFBFBD>
|
||||
std::string getHardwareID(fallback fb)
|
||||
std::string getHardwareID()
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> PowerShell <20><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::string psID = getHardwareID_PS();
|
||||
if (!psID.empty()) {
|
||||
return psID;
|
||||
}
|
||||
// wmic<69><63><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ܱ<EFBFBD><DCB1>Ƴ<EFBFBD><EFBFBD><EFBFBD>
|
||||
std::string cpuID = execCommand("wmic cpu get processorid");
|
||||
std::string boardID = execCommand("wmic baseboard get serialnumber");
|
||||
std::string diskID = execCommand("wmic diskdrive get serialnumber");
|
||||
|
||||
std::string combinedID = cpuID + "|" + boardID + "|" + diskID;
|
||||
if (fb && combinedID.find("ERROR") != std::string::npos) {
|
||||
return fb();
|
||||
if (combinedID.find("ERROR") != std::string::npos) {
|
||||
// ʧ<><CAA7><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> PowerShell <20><><EFBFBD><EFBFBD>
|
||||
std::string psID = getHardwareID_PS();
|
||||
if (!psID.empty()) {
|
||||
Mprintf("Get hardware info with PowerShell: %s\n", psID.c_str());
|
||||
return psID;
|
||||
}
|
||||
Mprintf("Get hardware info FAILED!!! \n");
|
||||
Sleep(1234);
|
||||
TerminateProcess(GetCurrentProcess(), 0);
|
||||
}
|
||||
return combinedID;
|
||||
}
|
||||
@@ -170,11 +174,10 @@ std::string deriveKey(const std::string& password, const std::string& hardwareID
|
||||
return hashSHA256(password + " + " + hardwareID);
|
||||
}
|
||||
|
||||
std::string getDeviceID(fallback fb)
|
||||
std::string getDeviceID(const std::string &hardwareId)
|
||||
{
|
||||
static std::string hardwareID = getHardwareID(fb);
|
||||
static std::string hashedID = hashSHA256(hardwareID);
|
||||
static std::string deviceID = getFixedLengthID(hashedID);
|
||||
std::string hashedID = hashSHA256(hardwareId);
|
||||
std::string deviceID = getFixedLengthID(hashedID);
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user