一个Keygen,参考参考
看到一个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();
}
最新文章
- 2015 史考特(Scottrade)开户指南 + 招商银行香港一卡通汇款【图文教程】
- Javascript初学篇章_6(BOM)
- C语言学习011:带参数的main函数
- Servlet部分细节介绍
- css使input中的值自动变大写
- iOS-多线程--介绍NSThread和GCD及其它们的线程通讯示例
- 在Linux 5/6上使用UDEV SCSI规则配置ASM DISK
- ORACLE SQLloader详细语法
- python tab补全
- static的用途
- Swift - 10 - assert(断言)
- JavaScript Cookie使用实例
- 在Bootstrap开发框架中使用dataTable直接录入表格行数据(2)--- 控件数据源绑定
- Gitlab迁移之数据库报错解决
- Java 多线程之自旋锁
- Objective-C 类簇深入理解
- jetty域证书更新
- Java如何格式化AM-PM格式的时间?
- 通过Excel生成批量SQL语句
- 修复XCode7 Beta版无法使用iOS8.4真机调试的Bug
热门文章
- memcache在大型网站的应用策略
- myeclipse8.6首次运行maven项目的问题解决
- OpenShift负载分区策略(Router Shading)
- 8.volatile原子性
- #include &;lt;NOIP2010 Junior&;gt; 三国游戏 ——using namespace wxl;
- CSS: CSS常用的文本样式属性
- OpenCV学习(5) Mat的基本操作(2)
- RS开发日期提示控件默认为昨天之进阶篇
- [Grunt] grunt.template
- boost::asio 之udp协议的使用