看到一个Keygen,我觉得还可以,参考参考
//////////////////////////////////////////////////////////////////
// //
// keygen for PCHunter_pro //
// //
// //
// //
//////////////////////////////////////////////////////////////////
#include <windows.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#include “crypto/aes.h” // 用到了cryptopp 库
#include “crypto/modes.h”
#include “crypto/filters.h”
using namespace CryptoPP;
template<class ByteT>
string hex2strByteT* hex, int len, const string& delim=” “) {
iflen == 0) return “”;
string s;
char x[4];
forint i=0; i<len; i++) {
sprintf_sx, 4, “%02X”, unsigned char*)hex)[i]);
s += x;
ifi != len-1) s += delim; // append delim if not the last char
}
return s;
}
string hex2strconst string& hex, const string& delim=” “) {
return hex2strhex.c_str), hex.length), delim);
}
string aes_encryptstring& plain, string& key) {
ECB_Mode< AES >::Encryption ebyte*)key.c_str), key.length));
string cipher;
StringSource ssplain, true,
new StreamTransformationFilter e,
new StringSink cipher ),
StreamTransformationFilter::NO_PADDING) );
return cipher;
}
#pragma packpush, 1)
struct reg {
byte unknown_1[80];
FILETIME ft_beg;
FILETIME ft_end;
byte unknown[32];
};
#pragma packpop)
int main) {
string key = “ShouJiErShiSiShi”;
reg r;
byte* p = byte*)&r;
forunsigned int i=0; i<sizeofreg); i++) { // 填充 00 ~ FF
p[i] = i;
}
SYSTEMTIME st;
GetSystemTime&st); // 得到当前时间 -> start time
SYSTEMTIME st_new = st;
st_new.wYear += 10; // 当前时间+10年 -> end time
SystemTimeToFileTime&st, &r.ft_beg); // 转成8字节的 FILETIME,xuetr用的这个
SystemTimeToFileTime&st_new, &r.ft_end);
string plain;
plain.assignconst char*)&r, sizeofr));
cout << “raw:” << endl << hex2strplain) << endl;
string encrypted = aes_encryptplain, key); // 加密
// cout << “encrypted:” << endl << hex2strencrypted) << endl;
ofstream ofs”c:/pchunter.ek”, ios::binary); // 写到 key file
ofs << hex2strencrypted, “”);
ofs.close);
}
