看到一个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 hex2str(ByteT* hex, int len, const string& delim=" ") {
if(len == 0) return "";
string s;
char x[4];
for(int i=0; i<len; i++) {
sprintf_s(x, 4, "%02X", ((unsigned char*)hex)[i]);
s += x;
if(i != len-1) s += delim; // append delim if not the last char
}
return s;
}
string hex2str(const string& hex, const string& delim=" ") {
return hex2str(hex.c_str(), hex.length(), delim);
}

string aes_encrypt(string& plain, string& key) {
ECB_Mode< AES >::Encryption e((byte*)key.c_str(), key.length());
string cipher;
StringSource ss(plain, true,
new StreamTransformationFilter( e,
new StringSink( cipher ),
StreamTransformationFilter::NO_PADDING) );
return cipher;
}

#pragma pack(push, 1)
struct reg {
byte unknown_1[80];
FILETIME ft_beg;
FILETIME ft_end;
byte unknown[32];
};
#pragma pack(pop)

int main() {
string key = "ShouJiErShiSiShi";

reg r;
byte* p = (byte*)&r;
for(unsigned int i=0; i<sizeof(reg); 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.assign((const char*)&r, sizeof(r));
cout << "raw:" << endl << hex2str(plain) << endl;

string encrypted = aes_encrypt(plain, key); // 加密
// cout << "encrypted:" << endl << hex2str(encrypted) << endl;

ofstream ofs("c:/pchunter.ek", ios::binary); // 写到 key file
ofs << hex2str(encrypted, "");
ofs.close();

}

最新文章

  1. 2015 史考特(Scottrade)开户指南 + 招商银行香港一卡通汇款【图文教程】
  2. Javascript初学篇章_6(BOM)
  3. C语言学习011:带参数的main函数
  4. Servlet部分细节介绍
  5. css使input中的值自动变大写
  6. iOS-多线程--介绍NSThread和GCD及其它们的线程通讯示例
  7. 在Linux 5/6上使用UDEV SCSI规则配置ASM DISK
  8. ORACLE SQLloader详细语法
  9. python tab补全
  10. static的用途
  11. Swift - 10 - assert(断言)
  12. JavaScript Cookie使用实例
  13. 在Bootstrap开发框架中使用dataTable直接录入表格行数据(2)--- 控件数据源绑定
  14. Gitlab迁移之数据库报错解决
  15. Java 多线程之自旋锁
  16. Objective-C 类簇深入理解
  17. jetty域证书更新
  18. Java如何格式化AM-PM格式的时间?
  19. 通过Excel生成批量SQL语句
  20. 修复XCode7 Beta版无法使用iOS8.4真机调试的Bug

热门文章

  1. memcache在大型网站的应用策略
  2. myeclipse8.6首次运行maven项目的问题解决
  3. OpenShift负载分区策略(Router Shading)
  4. 8.volatile原子性
  5. #include &amp;lt;NOIP2010 Junior&amp;gt; 三国游戏 ——using namespace wxl;
  6. CSS: CSS常用的文本样式属性
  7. OpenCV学习(5) Mat的基本操作(2)
  8. RS开发日期提示控件默认为昨天之进阶篇
  9. [Grunt] grunt.template
  10. boost::asio 之udp协议的使用