Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复Typo并优化代码格式 #15

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d1f202b
Fix typo
lzcapp May 30, 2024
bcd98e8
Update app.py
lzcapp May 30, 2024
9aaa3bb
Create docker-image.yml
lzcapp Jun 14, 2024
1c2daf1
Update docker-image.yml
lzcapp Jun 14, 2024
e4da6d8
Update docker-image.yml
lzcapp Jun 14, 2024
bd2fad2
Update docker-image.yml
lzcapp Jun 14, 2024
e542cd9
Delete .github/workflows/docker-image.yml
lzcapp Jun 14, 2024
a33798b
Update main.yml
lzcapp Jun 14, 2024
6566c91
Update requirements.txt
lzcapp Jun 14, 2024
279bbe2
Update requirements.txt
lzcapp Jun 14, 2024
72aeb5b
Update main.yml
lzcapp Jun 14, 2024
ae2925b
Update
lzcapp Jun 14, 2024
d72aebb
Merge branch 'main' of https://github.com/lzcapp/MobaXterm-GenKey
lzcapp Jun 14, 2024
be0a7f4
Update index.html
lzcapp Jun 14, 2024
fceb824
Update README.md
lzcapp Jun 14, 2024
2efb39a
Update main.yml
lzcapp Jun 14, 2024
a299866
Update main.yml
lzcapp Jun 14, 2024
1843808
Update README.md
lzcapp Jun 15, 2024
1f40622
Update README.md
lzcapp Jun 15, 2024
aa6c366
Update index.html
lzcapp Jun 16, 2024
b3cfe2f
Update
lzcapp Jun 17, 2024
a22c9de
Update
lzcapp Jun 17, 2024
ad8a9c2
Update main.yml
lzcapp Jun 17, 2024
947f1a3
Update main.yml
lzcapp Jun 17, 2024
c834a3d
Update main.yml
lzcapp Jun 17, 2024
70eef37
Update main.yml
lzcapp Jun 17, 2024
03e8955
Update main.yml
lzcapp Jun 17, 2024
6022690
Update main.yml
lzcapp Jun 17, 2024
885c5dd
Update main.yml
lzcapp Jun 17, 2024
bb74ce6
Update requirements.txt
lzcapp Jun 17, 2024
3fb5b87
Update requirements.txt
lzcapp Jun 17, 2024
9fe6151
Update Dockerfile
lzcapp Jun 17, 2024
339d4c4
Update dependencies
lzcapp Jun 17, 2024
6be7371
Update Dockerfile
lzcapp Jun 17, 2024
5aed148
Update Dockerfile
lzcapp Jun 17, 2024
2084f85
Update Dockerfile
lzcapp Jun 17, 2024
8aae90e
Update README.md
lzcapp Jun 17, 2024
8b1878c
Update Dockerfile
lzcapp Jun 17, 2024
a247e26
Update main.yml
lzcapp Jun 17, 2024
dd0194d
Update main.yml
lzcapp Jun 17, 2024
85c6c12
Update README.md
lzcapp Jun 17, 2024
009cb11
Update app.py
lzcapp Jul 5, 2024
cb4192a
Update app.py
lzcapp Jul 5, 2024
8b46d41
Update index.html
lzcapp Jul 9, 2024
5544ce4
Update index.html
lzcapp Jul 9, 2024
01445ae
Update index.html
lzcapp Jul 12, 2024
eed1240
Update README.md
lzcapp Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Docker Image CI

on:
push:
Expand All @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.idea/**
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6-slim
FROM python:3.12-alpine

MAINTAINER malaohu <[email protected]>

Expand Down
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
&ensp; ![Docker Image Version](https://img.shields.io/docker/v/seeleo/mobaxterm-genkey?style=for-the-badge)
&ensp; ![Docker Image Size](https://img.shields.io/docker/image-size/seeleo/mobaxterm-genkey?style=for-the-badge) &ensp; ![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
78 changes: 46 additions & 32 deletions app.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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', '')
Expand All @@ -115,14 +125,17 @@ def get_lc():
return lc


#@app.route('/download/<lc>')
# @app.route('/download/<lc>')
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')
Expand All @@ -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
)
Loading