py-kms no longer supports python2 (#72)

* Removed python2 references

* Removed python2 build files

* Typo

* Removed old python2 imports

* Added IPv6 note to README

Co-authored-by: Matteo ℱan <SystemRage@protonmail.com>
This commit is contained in:
Simonmicro 2020-07-08 22:40:34 +02:00 committed by GitHub
parent de61c660dd
commit 3d203cbe1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 258 deletions

View File

@ -21,44 +21,38 @@ _py-kms_ is a port of node-kms created by [cyrozap](http://forums.mydigitallife.
- Microsoft Office 2016 ( Volume License )
- Microsoft Office 2019 ( Volume License )
- It's written in Python:
- tested with Python 2.7.15rc1
- tested with Python 3.6.7
# Dependencies
- Python 3.x or Python 2.7.x or Python 2.6.x with the `argparse` module installed.
- Python 3.x.
- Tkinter module.
- If the `tzlocal` module is installed, the "Request Time" in the verbose output will be converted into local time. Otherwise, it will be in UTC.
- It can use the `sqlite3` module so you can use the database function, storing activation data so it can be recalled again.
- Installation example on Ubuntu / Mint:
- `sudo apt-get update`
- for python3
- `sudo apt-get install python3-tk python3-pip`
- `sudo pip3 install tzlocal pysqlite3`
- or for python2
- `sudo apt-get install python-tk python-pip`
- `sudo pip install tzlocal pysqlite`
# Usage
- __NOTE__: Pay attention to how invoke scripts, if you want to run with python2 use `python...` while for python3 use `python3...`, also depending on the Python versions that resides in your PC.
- To start the server, execute `python pykms_Server.py [IPADDRESS] [PORT]`, the default _IPADDRESS_ is "0.0.0.0" ( all interfaces ) and the default _PORT_ is "1688".
- To run the client (only for testing purposes), use `python pykms_Client.py [IPADDRESS] [PORT]`, with the same defaults of `pykms_Server.py`.
- To show the help pages type: `python pykms_Server.py -h` and `python pykms_Client.py -h`.
- To generate a random HWID use `-w` option: `python pykms_Server.py -w RANDOM`.
- To get the HWID from any server use the client, for example type: `python pykms_Client.py 0.0.0.0 1688 -m Windows8.1 -V INFO`.
- To start the server, execute `python3 pykms_Server.py [IPADDRESS] [PORT]`, the default _IPADDRESS_ is `0.0.0.0` or `::` ( all interfaces ) and the default _PORT_ is "1688".
- To run the client (only for testing purposes), use `python3 pykms_Client.py [IPADDRESS] [PORT]`, with the same defaults of `pykms_Server.py`.
- To show the help pages type: `python3 pykms_Server.py -h` and `python3 pykms_Client.py -h`.
- To generate a random HWID use `-w` option: `python3 pykms_Server.py -w RANDOM`.
- To get the HWID from any server use the client, for example type: `python3 pykms_Client.py 0.0.0.0 1688 -m Windows8.1 -V INFO`.
- To change your logfile path use `-F` option, for example: `python pykms_Server.py -F /path/to/your/logfile.log -V DEBUG`.
- To view a minimal set of logging information use `-V MINI` option, for example: `python pykms_Server.py -F /path/to/your/logfile.log -V MINI`.
- To redirect logging on stdout use `-F STDOUT` option, for example: `python pykms_Server.py -F STDOUT -V DEBUG`.
- You can create logfile and view logging information on stdout at the same time with `-F FILESTDOUT` option, for example: `python pykms_Server.py -F FILESTDOUT /path/to/your/logfile.log -V DEBUG`.
- With `-F STDOUTOFF` you disable all stdout messages (but a logfile will be created), for example: `python pykms_Server.py -F STDOUTOFF /path/to/your/logfile.log -V DEBUG`.
- To change your logfile path use `-F` option, for example: `python3 pykms_Server.py -F /path/to/your/logfile.log -V DEBUG`.
- To view a minimal set of logging information use `-V MINI` option, for example: `python3 pykms_Server.py -F /path/to/your/logfile.log -V MINI`.
- To redirect logging on stdout use `-F STDOUT` option, for example: `python3 pykms_Server.py -F STDOUT -V DEBUG`.
- You can create logfile and view logging information on stdout at the same time with `-F FILESTDOUT` option, for example: `python3 pykms_Server.py -F FILESTDOUT /path/to/your/logfile.log -V DEBUG`.
- With `-F STDOUTOFF` you disable all stdout messages (but a logfile will be created), for example: `python3 pykms_Server.py -F STDOUTOFF /path/to/your/logfile.log -V DEBUG`.
- With `-F FILEOFF` you disable logfile creation.
- Select timeout (seconds) for py-kms with `-t0` option, for example `python pykms_Server.py -t0 10`.
- Select timeout (seconds) for py-kms with `-t0` option, for example `python3 pykms_Server.py -t0 10`.
- Option `-y` enables printing asynchronously of messages (pretty / logging).
- For launching py-kms GUI make executable `pykms_Server.py` file with `chmod +x /path/to/folder/py-kms/pykms_Server.py`, then simply run `pykms_Server.py` double-clicking.
- You can run py-kms daemonized (via [Etrigan](https://github.com/SystemRage/Etrigan)) using a command like: `python pykms_Server.py etrigan start` and stop it with: `python pykms_Server.py etrigan stop`.
- With Etrigan you have another way to launch py-kms GUI (specially suitable if you're using a virtualenv), so: `python pykms_Server.py etrigan start -g`
and stop the GUI with `python pykms_Server.py etrigan stop` (or interact with the EXIT button).
- You can run py-kms daemonized (via [Etrigan](https://github.com/SystemRage/Etrigan)) using a command like: `python3 pykms_Server.py etrigan start` and stop it with: `python3 pykms_Server.py etrigan stop`.
- With Etrigan you have another way to launch py-kms GUI (specially suitable if you're using a virtualenv), so: `python3 pykms_Server.py etrigan start -g`
and stop the GUI with `python3 pykms_Server.py etrigan stop` (or interact with the EXIT button).
# Docker
![auto-docker](https://img.shields.io/docker/cloud/automated/pykmsorg/py-kms)
@ -71,8 +65,7 @@ There are three tags of the images available:
* `latest`, currently the same like minimal...
* `minimal`, wich is based on the python3 minimal configuration of py-kms. _This image does NOT include SQLLite support!_
* `python2`, which is fully configurable and equiped with SQLLite support and web interface.
* `python3`, which is like the `python2` tag - just with Python 3...
* `python3`, which is fully configurable and equiped with SQLLite support and web interface.
If you just want to use the image and don't want to build them yourself, you can use the official image at the docker hub (`pykmsorg/py-kms`).
To ensure that the image is always up-to-date you should check [watchtower](https://github.com/containrrr/watchtower) out!

View File

@ -87,5 +87,5 @@ ENV LOGFILE /var/log/pykms_logserver.log
# EN: log file size in MB
# RU: Максимальный размер Лог-файл в мегабайтах
ENV LOGSIZE ""
# Use this flag to set a maximum size (in MB) to the output log file. Desactivated by default.
# Use this flag to set a maximum size (in MB) to the output log file. Deactivated by default.
```

View File

@ -1,119 +0,0 @@
# Use Alpine Linux
FROM alpine:3.8
# Maintainer
#MAINTAINER Artur Petrov <artur@phpchain.ru>
# EN: Variables
# RU: Переменные
# EN: IP-address
# RU: IP-адрес
ENV IP 0.0.0.0
# The IP address to listen on. The default is "0.0.0.0" (all interfaces).
# EN: TCP-port
# RU: TCP-порт
ENV PORT 1688
# The network port to listen on. The default is "1688".
# EN: ePID
# RU: ePID
ENV EPID ""
# Use this flag to manually specify an ePID to use. If no ePID is specified, a random ePID will be generated.
# EN: lcid
# RU: lcid
ENV LCID 1033
# Use this flag to manually specify an LCID for use with randomly generated ePIDs. Default is 1033 (en-us).
# EN: the current client count
# RU: текущий счётчик запросов на активацию продуктов от Microsoft
ENV CLIENT_COUNT 26
# Use this flag to specify the current client count. Default is 26.
# A number >=25 is required to enable activation of client OSes; for server OSes and Office >=5.
# EN: the activation interval (in minutes)
# RU: интервал активации (в минутах)
ENV ACTIVATION_INTERVAL 120
# Use this flag to specify the activation interval (in minutes). Default is 120 minutes (2 hours).
# EN: the renewal interval (in minutes)
# RU: интервал обновления (в минутах)
ENV RENEWAL_INTERVAL 10080
# Use this flag to specify the renewal interval (in minutes). Default is 10080 minutes (7 days).
# EN: Use SQLITE
# RU: Использовать РСУБД SQLITE
ENV SQLITE false
# Use this flag to store request information from unique clients in an SQLite database.
# EN: hwid
# RU: hwid
ENV HWID "364F463A8863D35F"
# Use this flag to specify a HWID.
# The HWID must be an 16-character string of hex characters.
# The default is "364F463A8863D35F" or type "RANDOM" to auto generate the HWID.
# EN: log level ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG")
# RU: Уровень логирования ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG")
ENV LOGLEVEL ERROR
# Use this flag to set a Loglevel. The default is "ERROR".
# EN: log file
# RU: Лог-файл
ENV LOGFILE /var/log/pykms_logserver.log
# Use this flag to set an output Logfile. The default is "/var/log/pykms_logserver.log".
# EN: log file size in MB
# RU: Максимальный размер Лог-файл в мегабайтах
ENV LOGSIZE ""
# Use this flag to set a maximum size (in MB) to the output log file. Desactivated by default.
# EN: Startup script
# RU: Скрипт автозапуска
COPY start.sh /usr/bin/start.sh
# EN: Software installation
# RU: Установка программного обеспечения
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.8/main" >> /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add --update \
bash \
git \
python2 \
py2-argparse \
py2-tz \
py2-flask \
py2-pygments \
python2-tkinter \
py2-pysqlite \
py2-pip && \
# EN: Clone git-repo
# RU: Клонирование git-репозитория
git clone https://github.com/SystemRage/py-kms.git /tmp/py-kms && \
git clone https://github.com/coleifer/sqlite-web.git /tmp/sqlite_web && \
mv /tmp/py-kms/py-kms /home/ && \
mv /tmp/sqlite_web/sqlite_web /home/ && \
rm -rf /tmp/py-kms && \
rm -rf /tmp/sqlite_web && \
pip install peewee tzlocal && \
# EN: Change permissions
# RU: Меняем права доступа
chmod a+x /usr/bin/start.sh && \
# EN: Clear after install software
# RU: Очистка после установки программного обеспечения
apk del git
# Set Workdir
WORKDIR /home/py-kms
# Expose ports
EXPOSE ${PORT}/tcp
# Entry point
ENTRYPOINT ["/usr/bin/start.sh"]

View File

@ -1,4 +0,0 @@
docker stop py2-kms
docker rm py2-kms
docker image rm pykms/pykms:py2-kms
docker build -t pykms/pykms:py2-kms .

View File

@ -1,17 +0,0 @@
docker stop py2-kms
docker rm py2-kms
docker run -d --name py2-kms \
-t \
-p 8080:8080 \
-p 1688:1688 \
-e IP=0.0.0.0 \
-e PORT=1688 \
-e CLIENT_COUNT=30 \
-e SQLITE=true \
-e HWID=RANDOM \
-e LOGLEVEL=INFO \
-e LOGFILE=/var/log/py2-kms.log \
-e LOGSIZE=2 \
-v /etc/localtime:/etc/localtime:ro \
-v /var/log:/var/log:rw \
--restart unless-stopped pykms/pykms:py2-kms

View File

@ -1,52 +0,0 @@
#!/bin/bash
# EN: Start daemons
# RU: Запуск демонов
cd /home/py-kms
if [ "$SQLITE" == false ];
then
if [ "$EPID" == "" ];
then
if [ "$LOGSIZE" == "" ];
then
/usr/bin/python pykms_Server.py ${IP} ${PORT} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE}
else
/usr/bin/python pykms_Server.py ${IP} ${PORT} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} -S ${LOGSIZE}
fi
else
if [ "$LOGSIZE" == "" ];
then
/usr/bin/python pykms_Server.py ${IP} ${PORT} -e ${EPID} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE}
else
/usr/bin/python pykms_Server.py ${IP} ${PORT} -e ${EPID} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} -S ${LOGSIZE}
fi
fi
else
if [ "$EPID" == "" ];
then
if [ "$LOGSIZE" == "" ];
then
/bin/bash -c "/usr/bin/python pykms_Server.py ${IP} ${PORT} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -s -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} &"
sleep 5
/usr/bin/python pykms_Client.py ${IP} ${PORT} -m Windows7 &
/usr/bin/python /home/sqlite_web/sqlite_web.py -H ${IP} -x ${PWD}/clients.db
else
/bin/bash -c "/usr/bin/python pykms_Server.py ${IP} ${PORT} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -s -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} -S ${LOGSIZE} &"
sleep 5
/usr/bin/python pykms_Client.py ${IP} ${PORT} -m Windows7 &
/usr/bin/python /home/sqlite_web/sqlite_web.py -H ${IP} -x ${PWD}/clients.db
fi
else
if [ "$LOGSIZE" == "" ];
then
/bin/bash -c "/usr/bin/python pykms_Server.py ${IP} ${PORT} -e ${EPID} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -s -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} &"
sleep 5
/usr/bin/python pykms_Client.py ${IP} ${PORT} -m Windows7 &
/usr/bin/python /home/sqlite_web/sqlite_web.py -H ${IP} -x ${PWD}/clients.db
else
/bin/sh -c "/usr/bin/python pykms_Server.py ${IP} ${PORT} -e ${EPID} -l ${LCID} -c ${CLIENT_COUNT} -a ${ACTIVATION_INTERVAL} -r ${RENEWAL_INTERVAL} -s -w ${HWID} -V ${LOGLEVEL} -F ${LOGFILE} -S ${LOGSIZE} &"
sleep 5
/usr/bin/python pykms_Client.py ${IP} ${PORT} -m Windows7 &
/usr/bin/python /home/sqlite_web/sqlite_web.py -H ${IP} -x ${PWD}/clients.db
fi
fi
fi

View File

@ -5,22 +5,11 @@ import os
import sys
import threading
from time import sleep
try:
# Python 2.x imports
import Tkinter as tk
import ttk
import tkMessageBox as messagebox
import tkFileDialog as filedialog
import tkFont
except ImportError:
# Python 3.x imports
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
import tkinter.font as tkFont
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
import tkinter.font as tkFont
from pykms_Server import srv_options, srv_version, srv_config, server_terminate, serverqueue, serverthread
from pykms_GuiMisc import ToolTip, TextDoubleScroll, TextRedirect, ListboxOfRadiobuttons
from pykms_GuiMisc import custom_background, custom_pages

View File

@ -6,18 +6,9 @@ import sys
from collections import Counter
from time import sleep
import threading
try:
# Python 2.x imports
import Tkinter as tk
import ttk
import tkFont
except ImportError:
# Python 3.x imports
import tkinter as tk
from tkinter import ttk
import tkinter.font as tkFont
import tkinter as tk
from tkinter import ttk
import tkinter.font as tkFont
from pykms_Format import MsgMap, unshell_message, unformat_message
#------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -10,20 +10,10 @@ import logging
import os
import threading
import pickle
try:
# Python 2 import.
import SocketServer as socketserver
import Queue as Queue
import pykms_Selectors as selectors
from pykms_Time import monotonic as time
except ImportError:
# Python 3 import.
import socketserver
import queue as Queue
import selectors
from time import monotonic as time
import socketserver
import queue as Queue
import selectors
from time import monotonic as time
import pykms_RpcBind, pykms_RpcRequest
from pykms_RpcBase import rpcBase
from pykms_Dcerpc import MSRPCHeader