diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1080305..89e9334 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: ci +name: Docker Image CI on: push: @@ -9,23 +9,56 @@ jobs: docker: runs-on: ubuntu-latest steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ${{ secrets.DOCKERHUB_USERNAME }}/mobaxterm-genkey + ghcr.io/${{ github.actor }}/mobaxterm-genkey + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: push: true - file: Dockerfile - tags: ${{ github.repository_owner }}/mobaxterm-genkey:latest + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/mobaxterm-genkey:latest + ghcr.io/${{ github.actor }}/mobaxterm-genkey:latest + ${{ steps.meta.outputs.tags }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aed891a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/.idea/** diff --git a/Dockerfile b/Dockerfile index df3159f..694cd2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6-slim +FROM python:3.12-alpine MAINTAINER malaohu diff --git a/README.md b/README.md index 2fd0896..29f046e 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,50 @@ -# MobaXterm-GenKey -你懂的!! +# MobaXterm-GenKey (Docker) -## 演示地址 -http://192.99.11.204:5000/ +🔗 For the static web app version, see [MobaXterm-GenKey-Web](https://github.com/lzcapp/MobaXterm-GenKey-Web). +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/lzcapp/MobaXterm-GenKey/main.yml?style=for-the-badge) +  ![Docker Image Version](https://img.shields.io/docker/v/seeleo/mobaxterm-genkey?style=for-the-badge) +  ![Docker Image Size](https://img.shields.io/docker/image-size/seeleo/mobaxterm-genkey?style=for-the-badge)   ![Website](https://img.shields.io/website?url=https%3A%2F%2Fmobaxterm.seeleo.com%2F&style=for-the-badge&label=mobaxterm.seeleo.com) +**FOR EDUCATIONAL AND TESTING PURPOSE ONLY** + +## Demo + +- [mobaxterm.seeleo.com](https://mobaxterm.seeleo.com/) + +## Local + +**Python 3** Required -## 本地启动 -需要安装Python3!!! ``` pip install --no-cache-dir -r requirements.txt python app.py ``` ## Docker + +### Docker Hub + ``` -docker pull malaohu/mobaxterm-genkey -docker run -d -p 5000:5000 malaohu/mobaxterm-genkey +docker pull seeleo/mobaxterm-genkey:latest +docker run -d -p 5000:5000 seeleo/mobaxterm-genkey:latest ``` -## 使用方法 -访问:IP:5000 -![image](https://user-images.githubusercontent.com/8140841/116803404-e94c8300-ab49-11eb-83db-ad0246ebedd3.png) +### Container Registry (GitHub) + +``` +docker pull ghcr.io/lzcapp/mobaxterm-genkey:latest +docker run -d -p 5000:5000 ghcr.io/lzcapp/mobaxterm-genkey:latest +``` -### 激活方式 -直接放到软件目录即可! +## Screenshot +![1](https://github.com/malaohu/MobaXterm-GenKey/assets/12462465/fa319fe6-b75c-404f-b6fb-59290cda0d66) +![2](https://github.com/malaohu/MobaXterm-GenKey/assets/12462465/ea5387f5-144a-4b1c-a8a8-0847a0912223) +## Credits -核心内容来自:https://github.com/flygon2018/MobaXterm-keygen -详细介绍文章:https://51.ruyo.net/17008.html +> - https://github.com/flygon2018/MobaXterm-keygen +> - https://github.com/malaohu/MobaXterm-GenKey +> - https://51.ruyo.net/17008.html diff --git a/app.py b/app.py index ddb5a7f..d15228a 100644 --- a/app.py +++ b/app.py @@ -1,16 +1,19 @@ -#/usr/bin/env python3 +# /usr/bin/env python3 -import os, sys, zipfile -from flask import Flask, request, send_file +import os import os.path +import zipfile + +from flask import Flask, request, send_file app = Flask(__name__) VariantBase64Table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' -VariantBase64Dict = { i : VariantBase64Table[i] for i in range(len(VariantBase64Table)) } -VariantBase64ReverseDict = { VariantBase64Table[i] : i for i in range(len(VariantBase64Table)) } +VariantBase64Dict = {i: VariantBase64Table[i] for i in range(len(VariantBase64Table))} +VariantBase64ReverseDict = {VariantBase64Table[i]: i for i in range(len(VariantBase64Table))} -def VariantBase64Encode(bs : bytes): + +def VariantBase64Encode(bs: bytes): result = b'' blocks_count, left_bytes = divmod(len(bs), 3) @@ -38,7 +41,8 @@ def VariantBase64Encode(bs : bytes): result += block.encode() return result -def VariantBase64Decode(s : str): + +def VariantBase64Decode(s: str): result = b'' blocks_count, left_bytes = divmod(len(s), 4) @@ -65,42 +69,48 @@ def VariantBase64Decode(s : str): else: raise ValueError('Invalid encoding.') -def EncryptBytes(key : int, bs : bytes): + +def EncryptBytes(key: int, bs: bytes): result = bytearray() for i in range(len(bs)): result.append(bs[i] ^ ((key >> 8) & 0xff)) key = result[-1] & key | 0x482D return bytes(result) -def DecryptBytes(key : int, bs : bytes): + +def DecryptBytes(key: int, bs: bytes): result = bytearray() for i in range(len(bs)): result.append(bs[i] ^ ((key >> 8) & 0xff)) key = bs[i] & key | 0x482D return bytes(result) + class LicenseType: Professional = 1 Educational = 3 - Persional = 4 - -def GenerateLicense(Type : LicenseType, Count : int, UserName : str, MajorVersion : int, MinorVersion): - assert(Count >= 0) - LicenseString = '%d#%s|%d%d#%d#%d3%d6%d#%d#%d#%d#' % (Type, - UserName, MajorVersion, MinorVersion, - Count, - MajorVersion, MinorVersion, MinorVersion, - 0, # Unknown - 0, # No Games flag. 0 means "NoGames = false". But it does not work. - 0) # No Plugins flag. 0 means "NoPlugins = false". But it does not work. + Personal = 4 + + +def GenerateLicense(Type: int, Count: int, UserName: str, MajorVersion: int, MinorVersion): + assert (Count >= 0) + LicenseString = '%d#%s|%d%d#%d#%d3%d6%d#%d#%d#%d#' % ( + Type, + UserName, MajorVersion, MinorVersion, + Count, + MajorVersion, MinorVersion, MinorVersion, + 0, # Unknown + 0, # No Games flag. 0 means "NoGames = false". But it does not work. + 0 # No Plugins flag. 0 means "NoPlugins = false". But it does not work. + ) EncodedLicenseString = VariantBase64Encode(EncryptBytes(0x787, LicenseString.encode())).decode() - FileName = EncodedLicenseString.replace('/','').replace('\\','') + FileName = EncodedLicenseString.replace('/', '').replace('\\', '') with zipfile.ZipFile(FileName, 'w') as f: - f.writestr('Pro.key', data = EncodedLicenseString) + f.writestr('Pro.key', data=EncodedLicenseString) return FileName -#@app.route('/gen') +# @app.route('/gen') def get_lc(): name = request.args.get('name', '') version = request.args.get('ver', '') @@ -115,14 +125,17 @@ def get_lc(): return lc -#@app.route('/download/') +# @app.route('/download/') def download_lc(lc): if lc and len(lc) > 5 and os.path.exists('./' + lc): - return send_file(lc, - as_attachment=True, - attachment_filename='Custom.mxtpro') + return send_file( + lc, + None, + True, + 'Custom.mxtpro' + ) else: - return "请检查用户名版本号是否正确!" + return "请检查用户名、版本号是否正确!" @app.route('/gen') @@ -136,8 +149,9 @@ def index(): return send_file('index.html') - - if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000, debug=False) - + app.run( + '0.0.0.0', + 5000, + False + ) diff --git a/index.html b/index.html index 03a6066..ac8198d 100644 --- a/index.html +++ b/index.html @@ -1,73 +1,194 @@ - - - MobaXterm Keygen + + + + MobaXterm GenKey - - -
-

MobaXterm Keygen

-
-
-
- - - - -
- -
-
+ + + + + + diff --git a/requirements.txt b/requirements.txt index 946ad91..f306f93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Flask==2.1.0 +Flask==3.0.3 +Werkzeug==3.0.3