GithubHelp home page GithubHelp logo

zyatom / py-gen-mur Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exp-codes/py-gen-mur

0.0 0.0 0.0 185 KB

python 机器码/用户码/注册码 生成器

Home Page: https://pypi.org/project/py-gen-mur/

License: MIT License

Python 100.00%

py-gen-mur's Introduction

py-gen-mur

python 机器码/用户码/注册码 生成器
python generate [m]achine_code [u]ser_code [r]egister_code


运行环境

安装说明

执行脚本:

python -m pip install --upgrade pip
python -m pip install py-gen-mur

使用场景说明

使用场景详见 测试用例

场景步骤一(管理员本地,可选)

因代码开源,不建议使用 mur.crypt.Crypt() 默认类。

建议使用此工具时,自定义指定 mur.crypt.Crypt() 构造函数的 keyiv

本代码中提供了 mur.crypt.gen_des_key()mur.crypt.gen_des_iv() 的方法,但是生成后必须找地方另外存储这两个值,否则之前使用其生成的注册码无法再解密。

from mur.crypt import *

my_des_key = gen_des_key()
my_des_iv = gen_des_key()

my_crypt = Crypt(
    key = my_des_iv, 
    iv = my_des_iv
)

场景步骤二(用户本地)

  1. 用户运行【生成机器码】的程序
  2. 生成放有【加密机器码】的文件
  3. 把【加密机器码】的文件提供给管理员
from mur.user import *

u_machine_code = gen_machine_code(my_crypt)

实际使用时可复制 gen_machine_code.py 到需要发布的程序,由用户执行生成【机器码】

场景步骤三(管理员本地)

  1. 管理员解密用户提供的【加密机器码】文件
  2. 同时为用户设置授权天数,生成【用户码】文件
  3. 结合两者生成【注册码】文件
  4. 把【用户码】文件和【注册码】文件提供给用户
from mur.admin import *

a_machine_code = read_machine_code()
days = input('请输入授权天数:')    # 0 表示永久
a_user_code = gen_user_code(days, my_crypt)
a_register_code = gen_register_code(
    a_machine_code, a_user_code, my_crypt
)

实际使用时可在本仓库中执行 python gen_register_code.py 为用户生成【用户码】和【注册码】

场景步骤四(用户本地)

  1. 用户运行应用主程序
  2. 主程序读取【用户码】文件(或让用户输入用户码)
  3. 主程序在用户本地重新生成【机器码】
  4. 主程序利用【用户码】和【机器码】生成【注册码】
  5. 主程序比对【生成的注册码】和【管理员提供的注册码】内容是否一致
  6. 若一致,且授权未过期,程序运行;否则,程序终止
from mur.user import *

u_user_code = read_user_code()
rst = verify_authorization(u_user_code, my_crypt)
if rst == True :
    app.run()
else :
    exit(1)

使用注意

凡是使用了此工具的程序,在发布该程序时,建议不要直接用 Pyinstaller 打包成 *.pyc,然后供用户使用,否则很容易被反编译破解。

建议先对源码做加密处理,再提供给用户使用。有两个方法,任选一个即可:

Cython 编译为动态链接

  1. 先使用 Cython 生成 *.py 的动态连接 *.pyd 文件
  2. 再使用 Pyinstaller 打包,才供用户使用。

可参考文档《Cython + Pyinstaller 防止反编译打包

Pyinstaller 加密

  1. 先用 pip 命令安装 tinyaespycrypto (需要提前安装 Microsoft Visual Studio 和设置环境变量 CL)
  2. 使用 Pyinstaller 打包时增加 --key ${password} (此时编译的中间文件为 *.pyc.encrypted)。

可参考文档:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.