This repository was archived by the owner on Apr 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathPassword_Offline.h
More file actions
131 lines (102 loc) · 3.41 KB
/
Copy pathPassword_Offline.h
File metadata and controls
131 lines (102 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <iostream>
#include <string>
#include <openssl/sha.h>
#include<sstream>
#include <zlib.h>
#include<Windows.h>
#include <iomanip>
#include "Struct/HackSettings.hpp"
using namespace std;
extern HackSettings hackSettings;
class HashVerificator {
public:
static std::string get_hwid_password() {
std::string machineCode = "";
DWORD serialNumber;
GetVolumeInformation("C:\\", NULL, 0, &serialNumber, NULL, NULL, NULL, 0);
machineCode += to_string(serialNumber);
machineCode += hackSettings.guiSettings.hackVersion;
std::string toVerify = HashVerificator::get_password(machineCode);
return toVerify;
}
static std::string get_password(std::string s) {
int hash = 0;
SYSTEMTIME utcTime;
GetSystemTime(&utcTime);
int dateUTC = utcTime.wYear * 10000 + utcTime.wMonth * 100 + utcTime.wDay;
std::string dateUTC_str = to_string(dateUTC);
s += dateUTC_str;
hash = calculate_hash(s);
int checksum1 = calculate_checksum(hash);
int numWithChecksum = hash * 10 + checksum1;
int checksum2 = calculate_checksum(numWithChecksum);
int sixDigitNumber = abs(numWithChecksum * 10 + checksum2);
if (sixDigitNumber < 100000) {
sixDigitNumber += 100000;
}
stringstream ss;
ss << std::setw(6) << std::setfill('0') << sixDigitNumber;
std::string formatted = ss.str();
return formatted;
}
/// <summary>
/// 校验验证码是否合法
/// </summary>
/// <returns></returns>
static int validate(int number) {
// 检查数字是否为正数
if (number <= 0) {
return -1;
}
// 检查数字是否为 6 位数字
if (number < 100000 || number > 999999) {
return -1;
}
// 获取校验和 1 和校验和 2
int checksum2 = number % 10;
int numWithChecksum2 = number / 10;
int checksum1 = numWithChecksum2 % 10;
int hash = numWithChecksum2 / 10;
int correctCheckSum1 = calculate_checksum(hash);
// 计算数字的哈希值
//int calculatedHash = calculate_hash(to_string(hash));
// 验证校验和 1 和校验和 2
if (checksum1 != calculate_checksum(hash)) {
return -1;
}
int numWithChecksum1 = hash * 10 + checksum1;
if (checksum2 != calculate_checksum(numWithChecksum2)) {
return -1;
}
return 1;
}
private:
static int calculate_hash(const std::string& s) {
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256((const unsigned char*)s.c_str(), s.length(), hash);
// 将SHA-256哈希值的前4个字节转换为4位数字
long long num = 0;
for (int i = 0; i < 4; i++) {
if (hash[i] < 0) {
num = num * 256 + hash[i] + 256;
}
else {
num = num * 256 + hash[i];
}
}
int result = (int)(num % 10000);
return result;
}
static int calculate_checksum(int num) {
std::stringstream ss;
ss << num;
std::string numString = ss.str();
uLong crc = crc32(0L, Z_NULL, 0);
crc = crc32(crc, (const Bytef*)numString.c_str(), numString.length());
long long checksum = crc;
return std::abs(checksum % 10);
}
};
int main() {
return 0;
}