zoukankan      html  css  js  c++  java
  • 一个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();

    }

  • 相关阅读:
    Oozie时bin/oozied.sh start或bin/oozied.sh run出现Bootstrap进程无法启动,http://bigdatamaster:11000/oozie界面也无法打开?
    [ACM] POJ 2253 Frogger (最短路径变形,每条通路中的最长边的最小值)
    Echoprint系列--Android编译与调用
    shell编程之文本与日志过滤
    C++中搜索、截取字符串
    Swift中的UIKit重力学
    hbase0.96 put流程 源码分析
    [Docker]初次接触
    工作日志2014-08-25
    Flex和Servlet结合上传文件报错(二)
  • 原文地址:https://www.cnblogs.com/huhu0013/p/4227834.html
Copyright © 2011-2022 走看看