[Python] 纯文本查看 复制代码
[mw_shl_code=python,true]# -*- 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[i] + K[i] + j) % 256
S[i], S[j] = S[j], S[i]
i, j = 0, 0
for x in range(len(inData)):
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
Buf += chr(S[(S[j] + S[i]) % 256] ^ ord(inData[x]))
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[0x40:]
assert CRC == binascii.crc32(buf[8:]) & 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[8:]),"result"))
# i, s = self.ParsePost(self.rc4(str(buf[:8]) + self.RC4_Key2, str(buf[8:])))
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[3], i[4])
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_())
[/mw_shl_code]