python转成GUI的InputBox,再编译成EXE
本帖最后由 冥界3大法王 于 2021-2-26 18:29 编辑#https://bbs.pediy.com/
#!/usr/bin/env python
import os, sys, struct, time, binascii, hashlib
RC4_Key2= 'Eg\xa2\x99_\x83\xf1\x10'
def rc4(Key, inData):
Buf = ""
S = range(256)
K = (map(lambda x:ord(x), Key) * (256 / len(Key) + 1))[:256]
j = 0
for i in range(256):
j = (S + K + j) % 256
S, S = S, S
i, j = 0, 0
for x in range(len(inData)):
i = (i + 1) % 256
j = (j + S) % 256
S, S = S, S
Buf += chr(S[(S + S) % 256] ^ ord(inData))
return Buf
def Long2Int(longdata):
lo = longdata & 0xFFFFFFFF
hi = (longdata >> 32) & 0x7FFFFFFF
return hi, lo
def KeygenSN(LicenseSerial, MachineID):
mhi, mlo = Long2Int(MachineID)
lhi, llo = Long2Int(LicenseSerial)
hi_Key = (mhi - lhi + 0x55667788) & 0x7FFFFFFF
lo_Key = (mlo + llo + 0x11223344) & 0xFFFFFFFF
Z0, = struct.unpack('<Q', struct.pack('<LL', lo_Key, hi_Key))
Z1 = int(time.time()) ^ 0x56739ACD
s = sum(map(lambda x:int(x, 16), "%x" % Z1)) % 10
return "%dZ%d%d" % (Z0, Z1, s)
def ParsePost(buf):
Info = struct.unpack('<3L2Q4LQ3L', buf[:0x40])
flag, CRC, UserSerial, LicenseSerial, MachineID, build_type, \
Ver_Major, Ver_Minor, Ver_Buildid, Ver_Timestamp, \
TimeOffset, Kclass, Random2 = Info
SysInfoData = buf
assert CRC == binascii.crc32(buf) & 0xFFFFFFFF
return Info, SysInfoData
def DecodeRc4Str(buf):
buf = buf.decode('hex')
i, s = ParsePost(rc4(buf[:8] + RC4_Key2, buf))
return i, s
def GetJebLicenseKey():
licdata = raw_input("Input License Data:\n") # "粘来注册码!" =========>就这行
if licdata:
i, MachineID = DecodeRc4Str(licdata)
SN = KeygenSN(i, i)
print "JEB License Key:", SN
return SN
GetJebLicenseKey()
raw_input("Enter to Exit...")
用的是py2exe, 要求:python 2.7 x64
转成EXE成功了,但是命令行的回显功能没有了。。。
生成的注册码看不到了。。。
调用一个GUI的,然后转成EXE的就成
不然下次系统一重装JEB注册码生成,又得折腾一通
在线的不好用,抽风。。。{:301_1006:} 这个是做什么的?看不明白呀 ccwuax 发表于 2021-2-26 18:40
这个是做什么的?看不明白呀
Create keygen. 至少 发一个License,别人也好调试 本帖最后由 zyjsuper 于 2021-2-26 21:06 编辑
建议考虑PyQT实现,代码是用python3编写,GUI界面可供参考,代码部分还是您自己完善。
安装依赖pip install pyqt5 pyqt5-tools pyperclip
使用pyinstaller --noupx -Fw gui.py -i gui.ico打包成exe即可
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'form.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.Do not edit this file unless you know what you are doing.
import os, sys, struct, time, binascii, hashlib
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, QRectF
from PyQt5.QtGui import QCursor, QPainterPath, QPainter, QBrush, QColor
from PyQt5.QtWidgets import QWidget
import pyperclip
class RoundShadow(QWidget):
"""圆角边框类"""
def __init__(self, parent=None):
super(RoundShadow, self).__init__(parent)
self.border_width = 8
# 设置 窗口无边框和背景透明 *必须
# self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint|QtCore.Qt.WindowStaysOnTopHint)
def paintEvent(self, event):
# 阴影
path = QPainterPath()
path.setFillRule(Qt.WindingFill)
pat = QPainter(self)
pat.setRenderHint(pat.Antialiasing)
pat.fillPath(path, QBrush(Qt.white))
color = QColor(192, 192, 192, 50)
for i in range(10):
i_path = QPainterPath()
i_path.setFillRule(Qt.WindingFill)
ref = QRectF(10 - i, 10 - i, self.width() - (10 - i) * 2, self.height() - (10 - i) * 2)
# i_path.addRect(ref)
i_path.addRoundedRect(ref, self.border_width, self.border_width)
color.setAlpha(int(150 - i ** 0.5 * 50))
pat.setPen(color)
pat.drawPath(i_path)
# 圆角
pat2 = QPainter(self)
pat2.setRenderHint(pat2.Antialiasing)# 抗锯齿
pat2.setBrush(Qt.cyan)
pat2.setPen(Qt.transparent)
rect = self.rect()
rect.setLeft(-1)
rect.setTop(-1)
rect.setWidth(rect.width() - 1 )
rect.setHeight(rect.height() -1 )
pat2.drawRoundedRect(rect, 8, 8)
class Ui_keygen(RoundShadow,QWidget):
def __init__(self):
super(Ui_keygen, self).__init__()
self.setupUi()
def setupUi(self):
self.setObjectName("keygen")
self.setFixedSize(364, 196)
self.label = QtWidgets.QLabel(self)
self.label.setGeometry(QtCore.QRect(110, 0, 211, 31))
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setPointSize(16)
self.label.setFont(font)
self.label.setObjectName("label")
self.frame = QtWidgets.QFrame(self)
self.frame.setGeometry(QtCore.QRect(10, 40, 261, 71))
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Sunken)
self.frame.setObjectName("frame")
self.textEdit = QtWidgets.QTextEdit(self.frame)
self.textEdit.setGeometry(QtCore.QRect(0, 0, 261, 61))
self.textEdit.setObjectName("textEdit")
self.frame_2 = QtWidgets.QFrame(self)
self.frame_2.setGeometry(QtCore.QRect(10, 100, 261, 81))
self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.frame_2.setObjectName("frame_2")
self.textEdit_2 = QtWidgets.QTextEdit(self.frame_2)
self.textEdit_2.setGeometry(QtCore.QRect(0, 10, 261, 71))
self.textEdit_2.setObjectName("textEdit_2")
self.pushButton = QtWidgets.QPushButton(self)
self.pushButton.setGeometry(QtCore.QRect(280, 60, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self)
self.pushButton_2.setGeometry(QtCore.QRect(280, 130, 75, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self)
self.pushButton_3.setGeometry(QtCore.QRect(330, 0, 31, 23))
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton.setStyleSheet('''
QPushButton
{text-align : center;
background-color : white;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 3px;
padding: 2px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:hover
{text-align : center;
background-color : DeepSkyBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:pressed
{text-align : center;
background-color : CadetBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
''')
self.pushButton_2.setStyleSheet('''
QPushButton
{text-align : center;
background-color : white;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 3px;
padding: 2px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:hover
{text-align : center;
background-color : DeepSkyBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:pressed
{text-align : center;
background-color : CadetBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
''')
self.pushButton_3.setStyleSheet('''
QPushButton
{text-align : center;
background-color : white;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 3px;
padding: 2px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:hover
{text-align : center;
background-color : DeepSkyBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
QPushButton:pressed
{text-align : center;
background-color : CadetBlue;
font: bold;
border-color: gray;
border-width: 1px;
border-radius: 5px;
padding: 1px;
height : 14px;
border-style: outset;
font : 12px;}
''')
self.retranslateUi(self)
QtCore.QMetaObject.connectSlotsByName(self)
self.pushButton_3.clicked.connect(self.exitapp)
self.pushButton.clicked.connect(self.GetJebLicenseKey)
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.m_flag = True
self.m_Position = event.globalPos() - self.pos()# 获取鼠标相对窗口的位置
event.accept()
self.setCursor(QCursor(Qt.OpenHandCursor))# 更改鼠标图标
def mouseMoveEvent(self, QMouseEvent):
if Qt.LeftButton and self.m_flag:
self.move(QMouseEvent.globalPos() - self.m_Position)# 更改窗口位置
QMouseEvent.accept()
def mouseReleaseEvent(self, QMouseEvent):
self.m_flag = False
self.setCursor(QCursor(Qt.ArrowCursor))
def exitapp(self):
sys.exit(0)
def rc4(self,Key, inData):
Buf = ""
S = range(256)
K = (list(map(lambda x: ord(x), Key)) * (256 / len(Key) + 1))[:256]
j = 0
for i in range(256):
j = (S + K + j) % 256
S, S = S, S
i, j = 0, 0
for x in range(len(inData)):
i = (i + 1) % 256
j = (j + S) % 256
S, S = S, S
Buf += chr(S[(S + S) % 256] ^ ord(inData))
return Buf
def RC4_Key2(self):
return "result"
def Long2Int(self,longdata):
lo = longdata & 0xFFFFFFFF
hi = (longdata >> 32) & 0x7FFFFFFF
return hi, lo
def KeygenSN(self,LicenseSerial, MachineID):
mhi, mlo = self.Long2Int(MachineID)
lhi, llo = self.Long2Int(LicenseSerial)
hi_Key = (mhi - lhi + 0x55667788) & 0x7FFFFFFF
lo_Key = (mlo + llo + 0x11223344) & 0xFFFFFFFF
Z0, = struct.unpack('<Q', struct.pack('<LL', lo_Key, hi_Key))
Z1 = int(time.time()) ^ 0x56739ACD
s = sum(map(lambda x: int(x, 16), "%x" % Z1)) % 10
return "%dZ%d%d" % (Z0, Z1, s)
def ParsePost(self,buf):
Info = struct.unpack('<3L2Q4LQ3L', buf[:0x40])
flag, CRC, UserSerial, LicenseSerial, MachineID, build_type, \
Ver_Major, Ver_Minor, Ver_Buildid, Ver_Timestamp, \
TimeOffset, Kclass, Random2 = Info
SysInfoData = buf
assert CRC == binascii.crc32(buf) & 0xFFFFFFFF
return Info, SysInfoData
def DecodeRc4Str(self,buf):
buf = binascii.hexlify(bytes(buf, "utf-8"))
i, s = self.ParsePost(self.rc4(str(buf[:8]) + str(buf),"result"))
# i, s = self.ParsePost(self.rc4(str(buf[:8]) + self.RC4_Key2, str(buf)))
return i, s
def GetJebLicenseKey(self):
self.textEdit.setText(pyperclip.paste())
licdata = self.textEdit.toPlainText()# "粘来注册码!" =========>就这行
print(licdata)
if licdata:
i, MachineID = self.DecodeRc4Str(licdata )
SN = self.KeygenSN(i, i)
self.textEdit_2.setText(SN)
def retranslateUi(self, keygen):
_translate = QtCore.QCoreApplication.translate
keygen.setWindowTitle(_translate("keygen", "keygen"))
self.label.setText(_translate("keygen", "JEB 算号器"))
self.pushButton.setText(_translate("keygen", "粘贴"))
self.pushButton_2.setText(_translate("keygen", "复制"))
self.pushButton_3.setText(_translate("keygen", "X"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = Ui_keygen()
MainWindow.show()
sys.exit(app.exec_()) ReLoading 发表于 2021-2-26 19:44
至少 发一个License,别人也好调试
"48000000A369CE73763028AACBDDF79057B8BEE91AEDB88F8E0DEE0615D9B33C03DE6A7698B9ACF89DCA78AC5AFBB5F468403DBF682D7B17B8D26155C4CFE116F89580C4FE02E7EE27E4E9052A88929B" 冥界3大法王 发表于 2021-2-26 18:44
Create keygen.
懒得写UI,放在云函数了,key=(这里填上License)
https://service-2fyjhk0z-1256931199.sh.apigw.tencentcs.com/CreateKeyGen?key=48000000A369CE73763028AACBDDF79057B8BEE91AEDB88F8E0DEE0615D9B33C03DE6A7698B9ACF89DCA78AC5AFBB5F468403DBF682D7B17B8D26155C4CFE116F89580C4FE02E7EE27E4E9052A88929B 不太会 python2 改成了python3 用的tk 简单写了下ui pyinstaller 打包 windows10 测试运行没有问题。 其他没详细测试https://wwa.lanzouj.com/idR83mf2mpg
页:
[1]