mirror of
https://github.com/Neo-Desktop/WindowsXPKg
synced 2025-06-12 08:34:16 +03:00
Compare commits
278 Commits
Server-200
...
8368b6a6c7
Author | SHA1 | Date | |
---|---|---|---|
8368b6a6c7 | |||
2415d1374f | |||
d1024950da | |||
1ca5114b21 | |||
da10583fdf | |||
034c00a5b8 | |||
cd050c65d6 | |||
02434e935d | |||
09f1300afc | |||
a3de0e845f | |||
6287b4c773 | |||
a5ce3abe13 | |||
27344f6d4b | |||
01b216dbc4 | |||
c29db1d30a | |||
1c1e26012f | |||
75f22215b1 | |||
be99f6b8e9 | |||
e830f97e7e | |||
0251546d0d | |||
a12afcd601 | |||
c7a555abe4 | |||
74ff4bf144 | |||
2b408913c4 | |||
c965b88113 | |||
2bc3503fd8 | |||
3fbd1cffea | |||
4bf3800281 | |||
8ec60bf396 | |||
5fbbd5e6eb | |||
d378c6499e | |||
3ea8731271 | |||
018f9f533c | |||
f1f1e0e6ea | |||
c4b63c15b2 | |||
1548e14169 | |||
72d48dd38b | |||
00d4906b28 | |||
88f60630c1 | |||
2ac6920e2c | |||
8f843ad4c3 | |||
2753bf2a40 | |||
d17ada2e64 | |||
6685b38aac | |||
884d8c9703 | |||
5ba2dbddd4 | |||
bf40bb6402 | |||
12a041c380 | |||
ecd9cd8dd2 | |||
6989ae6c94 | |||
ac510f8253 | |||
72c42f66c9 | |||
759c4009ef | |||
78c358c933 | |||
1d5e233c19 | |||
6c06732331 | |||
f347231362 | |||
a7e97e45ee | |||
bf57c32eae | |||
25db955b61 | |||
1aeceb28f1 | |||
b451a04f3c | |||
3e5e03df4d | |||
e3bdc93249 | |||
36b2eb3e7d | |||
49fefca596 | |||
178c9e0689 | |||
214d2d38a5 | |||
3ae078e3c5 | |||
12e511b3a5 | |||
21bac3b66c | |||
09842ace12 | |||
0d016b8872 | |||
b1743f4bff | |||
cc765edb4f | |||
4d1b5d6681 | |||
f59d77bdd1 | |||
71cbd19017 | |||
974f400cfc | |||
a2d521c230 | |||
d53409f5bd | |||
2703e17f69 | |||
680239bdb7 | |||
104bdb19e3 | |||
f2f859faeb | |||
a2d9c46a4b | |||
f65533bbb3 | |||
90e31b667a | |||
492d245f86 | |||
361a39e204 | |||
31993afb62 | |||
b3f64e6330 | |||
ccf93a0089 | |||
ae391a5e50 | |||
3620cf5af6 | |||
33774f7ad2 | |||
06ed5ef240 | |||
161aa2de4c | |||
a50688657d | |||
1679583e64 | |||
02c85b50b1 | |||
93732e152b | |||
95803054ba | |||
8619fccb11 | |||
06b9d937b1 | |||
453151f20f | |||
1bb00cf53d | |||
a787fc8e85 | |||
582ddf1bb8 | |||
13bf69c7e1 | |||
b7965f19e8 | |||
52c9a57ea2 | |||
283df1c1fe | |||
c1eb81490b | |||
2ee6a99acd | |||
1370a6ecff | |||
e3a6b78407 | |||
9fec269ad0 | |||
6ae5c9e435 | |||
a6bfaed6e8 | |||
f7b41a9810 | |||
e76eb7ac33 | |||
c91bbad69a | |||
75e81e7049 | |||
e9131e45c8 | |||
c664ea7f9c | |||
f95501b789 | |||
444f8c45c7 | |||
de09feb18f | |||
bde4371cbe | |||
f43a2d5c37 | |||
46c39df15d | |||
c078247bea | |||
232be6aba2 | |||
c0c3149be7 | |||
8e15a4f5b8 | |||
d411d56d81 | |||
11253c5e2c | |||
9f7920ca2d | |||
9063e32a89 | |||
958169ccb5 | |||
63fbbd83ef | |||
de659846d4 | |||
7c4bcdc847 | |||
859a21656c | |||
4b2ef7ac72 | |||
216c9cdf9d | |||
8f685a022c | |||
e4058ddf19 | |||
45004623be | |||
a4cb524fed | |||
03ae90163a | |||
c1e9a0f021 | |||
152c03456c | |||
ea51438766 | |||
8ee1acc2be | |||
3134a6f7a3 | |||
b75d08b3be | |||
20c84661b2 | |||
fefc8552b6 | |||
503fa3e1d8 | |||
15cbe19006 | |||
de04746c5e | |||
9817a83e74 | |||
bcd51e0e4e | |||
4b60737bb4 | |||
bc23fc5233 | |||
dc64133adf | |||
477f5c9af2 | |||
32a14cb8d9 | |||
db5ff7cd74 | |||
ca9ccc43ee | |||
57b2477e44 | |||
73a9cb3b2a | |||
40c60e656f | |||
62ab8caf87 | |||
7ea57ed136 | |||
529543ceef | |||
b1c80d3fa9 | |||
149f525a51 | |||
3e100d79a6 | |||
4bc029e645 | |||
fa0f832919 | |||
c306573fe8 | |||
88640191e8 | |||
e3b4485aa2 | |||
34619a2202 | |||
d4d50d9885 | |||
f11552509a | |||
eed869981b | |||
947fd48f38 | |||
0b94791ee1 | |||
f6755b0c22 | |||
3a7a37d814 | |||
4973d71d64 | |||
aa8e5ff8e7 | |||
4f7fb772a5 | |||
cc3900d4d0 | |||
726be7da20 | |||
98c8db7e02 | |||
8c295cf973 | |||
fcaa449ead | |||
42c24b57a1 | |||
0204d8486b | |||
6d3fd0031d | |||
cd3cc31cd6 | |||
29465ffb37 | |||
11dedcbd5f | |||
b69dbd541c | |||
530e5cdc21 | |||
da7e88b970 | |||
04e6362d7e | |||
1603dbd6e2 | |||
150f7433dc | |||
79d62a3b1b | |||
35c18d473b | |||
632c84249c | |||
d20cb1fa49 | |||
983acba760 | |||
974695b178 | |||
9b3abe7fb9 | |||
9812529903 | |||
21e31fd1b6 | |||
799fee5a68 | |||
1c5f93b687 | |||
3922223b9f | |||
9302ebd751 | |||
08ec7cb9bb | |||
8e4285c960 | |||
63bc103384 | |||
06920ede2a | |||
3f95974e61 | |||
166a0b5df7 | |||
e9a10e2882 | |||
728bf2a781 | |||
7c62596aa5 | |||
574b7b3b32 | |||
7944a9b15f | |||
6b85db12c9 | |||
19cce11bc2 | |||
475241e608 | |||
a14d44cdca | |||
d930648230 | |||
72d441b539 | |||
e437cc548a | |||
cc009d0ad4 | |||
96639bbaf7 | |||
1f30ff762d | |||
62e2e37373 | |||
814b8e48fb | |||
8088c455ff | |||
88619134bc | |||
bd11fb5eed | |||
5bf1da663a | |||
f5423a8eb0 | |||
3999ed0996 | |||
46adbee701 | |||
44dbb1e722 | |||
05ee5eb933 | |||
ac47a88f7e | |||
f5a76d8df5 | |||
388464da68 | |||
b6ade7c890 | |||
3764743558 | |||
ad91633ae1 | |||
aadeb8fe46 | |||
b7c6621809 | |||
1564056d68 | |||
fa12ad2c48 | |||
78194d7ab9 | |||
04601b7260 | |||
2af9f6db64 | |||
8c506fe798 | |||
a7a670be02 | |||
92938eb908 | |||
a40632a7fe | |||
9b040f9613 | |||
3d300e0c84 |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
build*/
|
||||
cmake-build*/
|
||||
djgpp-build*/
|
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto eol=lf
|
||||
|
||||
*.c text
|
||||
*.h text
|
||||
*.cpp text
|
||||
*.hpp text
|
||||
*.json text
|
||||
*.txt text
|
||||
LICENSE text
|
||||
*.md text
|
||||
fully-licensed-wpa.txt -text
|
87
.github/workflows/dos-djgpp.yml
vendored
Normal file
87
.github/workflows/dos-djgpp.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (DOS DJGPP)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CC: ${{ github.workspace }}/djgpp/bin/i586-pc-msdosdjgpp-gcc
|
||||
CXX: ${{ github.workspace }}/djgpp/bin/i586-pc-msdosdjgpp-g++
|
||||
CMAKE_FIND_ROOT_PATH: ${{ github.workspace }}/djgpp
|
||||
WATT_ROOT: ${{ github.workspace }}/djgpp/watt32
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup build environment
|
||||
run: |
|
||||
sudo apt -y update
|
||||
sudo apt -y install build-essential cmake wget 7zip git flex libfl-dev nasm libslang2-dev pkg-config libslang2-modules gcc-multilib
|
||||
|
||||
- name: Download and Setup DJGPP Toolchain
|
||||
run: |
|
||||
pushd ${{ github.workspace }}
|
||||
wget https://github.com/andrewwutw/build-djgpp/releases/download/v3.4/djgpp-linux64-gcc1220.tar.bz2
|
||||
tar xjf djgpp-linux64-gcc1220.tar.bz2
|
||||
cd ${{ github.workspace }}/djgpp
|
||||
git clone https://github.com/UMSKT/Watt-32.git watt32
|
||||
cd watt32/util
|
||||
make clean && make linux
|
||||
cd ../src
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
./configur.sh djgpp
|
||||
make -f djgpp.mak
|
||||
ln -s ${WATT_ROOT}/lib/libwatt.a ${{ github.workspace }}/djgpp/lib
|
||||
|
||||
- name: Checkout and Cross Compile OpenSSL 3.1.2
|
||||
run: |
|
||||
git clone https://github.com/UMSKT/openssl.git openssl
|
||||
pushd openssl
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
./Configure no-threads -DOPENSSL_DEV_NO_ATOMICS --prefix=${{ github.workspace }}/djgpp DJGPP
|
||||
make && make install
|
||||
popd
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
pushd build
|
||||
cmake ../ -D DJGPP_WATT32=${WATT_ROOT}/lib/libwatt.a -D CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
|
||||
make
|
||||
|
||||
- name: Move executable to upload directory
|
||||
run: |
|
||||
mkdir build/actions_upload
|
||||
mv build/umskt.exe build/actions_upload/
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-DOS
|
||||
path: build/actions_upload
|
65
.github/workflows/freebsd.yml
vendored
Normal file
65
.github/workflows/freebsd.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by techguy16 on 07/23/2023
|
||||
# @Maintainer techguy16
|
||||
|
||||
name: C/C++ CI (FreeBSD)
|
||||
|
||||
on:
|
||||
#push:
|
||||
# branches: [ "*" ]
|
||||
# paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
#pull_request:
|
||||
# branches: [ "*" ]
|
||||
# paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: build-x86_64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build & Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
envs: 'MYTOKEN MYTOKEN2'
|
||||
usesh: true
|
||||
prepare: |
|
||||
pkg install -y cmake openssl git bash
|
||||
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
./umskt # Execute the test here
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-FreeBSD
|
||||
path: build/actions_upload
|
87
.github/workflows/linux.yml
vendored
Normal file
87
.github/workflows/linux.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by TheTank20 on 06/13/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (Linux)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86
|
||||
- arch: x86_64
|
||||
- arch: aarch64
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup latest Alpine Linux for ${{ matrix.arch }}
|
||||
uses: jirutka/setup-alpine@v1
|
||||
with:
|
||||
packages: >
|
||||
bash
|
||||
build-base
|
||||
cmake
|
||||
git
|
||||
musl-dev
|
||||
openssl-dev
|
||||
openssl-libs-static
|
||||
zlib-dev
|
||||
arch: ${{ matrix.arch }}
|
||||
shell-name: alpine-target.sh
|
||||
|
||||
- name: Configure and build UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=ON
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-linux-${{ matrix.arch }}-static
|
||||
path: build/actions_upload
|
||||
|
||||
- name: Configure and build static internal deps UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=OFF BUILD_SHARED_LIBS=OFF
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
||||
|
||||
- name: Configure and build shared deps UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=OFF BUILD_SHARED_LIBS=ON
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
60
.github/workflows/macos.yml
vendored
Normal file
60
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by techguy16 on 07/23/2023
|
||||
# @Maintainer techguy16
|
||||
|
||||
name: C/C++ CI (macOS)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-x86:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Configure and build UMSKT
|
||||
run: |
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd build/actions_upload
|
||||
./umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-macOS-${{ matrix.arch }}
|
||||
path: build/actions_upload
|
198
.github/workflows/windows.yml
vendored
Normal file
198
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by TheTank20 on 06/13/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (Windows)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-32bit:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
# https://github.com/actions/runner-images/issues/6067#issuecomment-1213069040
|
||||
- name: Install Windows XP Support for Visual Studio
|
||||
run: |
|
||||
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
|
||||
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
$componentsToAdd = @(
|
||||
"Microsoft.VisualStudio.Component.WinXP"
|
||||
)
|
||||
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
|
||||
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
|
||||
if ($process.ExitCode -eq 0)
|
||||
{
|
||||
Write-Host "components have been successfully added"
|
||||
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "components were not installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Download And Install 32-bit OpenSSL
|
||||
run: |
|
||||
$installDir = "$Env:ProgramFiles\OpenSSL"
|
||||
# Define the URL for the JSON file containing the hashes
|
||||
$jsonUrl = "https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json"
|
||||
|
||||
# Download the JSON data
|
||||
$jsonData = Invoke-RestMethod -Uri $jsonUrl
|
||||
|
||||
# Initialize variables for the latest version and URL
|
||||
$latestVersion = "0.0.0"
|
||||
$latestUrl = ""
|
||||
|
||||
# Iterate through the files to find the latest 3.1.x version
|
||||
foreach ($file in $jsonData.files.PSObject.Properties) {
|
||||
$details = $file.Value
|
||||
if ($details.basever -like "3.1*" -and $file.Name -like "Win32OpenSSL*") {
|
||||
if ([version]$details.basever -gt [version]$latestVersion) {
|
||||
$latestVersion = $details.basever
|
||||
$latestUrl = $details.url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Output the latest version and URL
|
||||
Write-Output "Latest OpenSSL Win32 3.1.x version: $latestVersion"
|
||||
Write-Output "Download link: $latestUrl"
|
||||
|
||||
$installerURL = $latestURL
|
||||
$installerName = "Win32OpenSSL.exe"
|
||||
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
|
||||
|
||||
Remove-Item "$installDir" -Force -Recurse
|
||||
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
|
||||
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
|
||||
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Configure UMSKT
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
generator: "Visual Studio 17 2022"
|
||||
options: CMAKE_SYSTEM_VERSION="5.1.2600"
|
||||
args: -A "Win32" -T v141_xp
|
||||
|
||||
- name: Build UMSKT
|
||||
working-directory: build
|
||||
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-Win32
|
||||
path: build/Release
|
||||
|
||||
build-64bit:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Install Windows XP Support for Visual Studio
|
||||
run: |
|
||||
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
|
||||
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
$componentsToAdd = @(
|
||||
"Microsoft.VisualStudio.Component.WinXP"
|
||||
)
|
||||
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
|
||||
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
|
||||
if ($process.ExitCode -eq 0)
|
||||
{
|
||||
Write-Host "components have been successfully added"
|
||||
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "components were not installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Download And Install 64-bit OpenSSL
|
||||
run: |
|
||||
$installDir = "$Env:ProgramFiles\OpenSSL"
|
||||
# Define the URL for the JSON file containing the hashes
|
||||
$jsonUrl = "https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json"
|
||||
|
||||
# Download the JSON data
|
||||
$jsonData = Invoke-RestMethod -Uri $jsonUrl
|
||||
|
||||
# Initialize variables for the latest version and URL
|
||||
$latestVersion = "0.0.0"
|
||||
$latestUrl = ""
|
||||
|
||||
# Iterate through the files to find the latest 3.1.x version
|
||||
foreach ($file in $jsonData.files.PSObject.Properties) {
|
||||
$details = $file.Value
|
||||
if ($details.basever -like "3.1*" -and $file.Name -like "Win64OpenSSL*") {
|
||||
if ([version]$details.basever -gt [version]$latestVersion) {
|
||||
$latestVersion = $details.basever
|
||||
$latestUrl = $details.url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Output the latest version and URL
|
||||
Write-Output "Latest OpenSSL Win64 3.1.x version: $latestVersion"
|
||||
Write-Output "Download link: $latestUrl"
|
||||
|
||||
$installerURL = $latestURL
|
||||
$installerName = "Win64OpenSSL.exe"
|
||||
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
|
||||
|
||||
Remove-Item "$installDir" -Force -Recurse
|
||||
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
|
||||
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
|
||||
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Configure UMSKT
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
generator: "Visual Studio 17 2022"
|
||||
args: -A "x64" -T "v141_xp"
|
||||
|
||||
- name: Build UMSKT
|
||||
working-directory: build
|
||||
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-Win64
|
||||
path: build/Release
|
255
.gitignore
vendored
Normal file
255
.gitignore
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
build/*
|
||||
*.tar
|
||||
*.exe
|
||||
*.wasm
|
||||
umskt
|
||||
|
||||
### NotepadPP template
|
||||
# Notepad++ backups #
|
||||
*.bak
|
||||
|
||||
### VisualStudioCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### JetBrains+all template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Linux template
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
### Windows template
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### Vim template
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### SublimeText template
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
sftp-config-alt*.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
### CMake template
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeSettings.json
|
||||
|
||||
# Visual Studio
|
||||
.vs/
|
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
UMSKT
|
2
.idea/WindowsXPKg.iml
generated
Normal file
2
.idea/WindowsXPKg.iml
generated
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
15
.idea/misc.xml
generated
Normal file
15
.idea/misc.xml
generated
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="CidrRootsConfiguration">
|
||||
<sourceRoots>
|
||||
<file path="$PROJECT_DIR$/src" />
|
||||
</sourceRoots>
|
||||
<libraryRoots>
|
||||
<file path="$PROJECT_DIR$/lib" />
|
||||
</libraryRoots>
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/build" />
|
||||
</excludeRoots>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
223
CMakeLists.txt
Normal file
223
CMakeLists.txt
Normal file
@ -0,0 +1,223 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Andrew on 05/30/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
PROJECT(UMSKT)
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path")
|
||||
|
||||
OPTION(BUILD_SHARED_LIBS "Build internal libraries as dynamic" OFF)
|
||||
OPTION(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
|
||||
OPTION(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
|
||||
OPTION(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
|
||||
OPTION(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
|
||||
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS})
|
||||
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS})
|
||||
|
||||
# macOS does not support static build
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(UMSKT_USE_SHARED_OPENSSL ON)
|
||||
endif()
|
||||
|
||||
# neither does dos idk i'm trying random stuff
|
||||
if (DJGPP_WATT32)
|
||||
SET(UMSKT_USE_SHARED_OPENSSL ON)
|
||||
endif()
|
||||
|
||||
IF(UMSKT_USE_SHARED_OPENSSL)
|
||||
SET(OPENSSL_USE_STATIC_LIBS FALSE)
|
||||
SET(OPENSSL_MSVC_STATIC_RT FALSE)
|
||||
MESSAGE(STATUS "[UMSKT] Requesting dynamic version of OpenSSL")
|
||||
ELSE()
|
||||
SET(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
SET(OPENSSL_MSVC_STATIC_RT TRUE)
|
||||
MESSAGE(STATUS "[UMSKT] Requesting static version of OpenSSL")
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
||||
IF(DJGPP_WATT32)
|
||||
SET(CMAKE_SYSTEM_NAME MSDOS)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} ${DJGPP_WATT32})
|
||||
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS} ${WATT_ROOT}/lib)
|
||||
ENDIF()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(BUILD_SHARED_LIBS ON)
|
||||
MESSAGE(STATUS "[UMSKT] macOS has no static library - Shared library forced on")
|
||||
endif()
|
||||
|
||||
# if we're compiling with MSVC, respect the DEBUG compile option
|
||||
IF(MSVC)
|
||||
SET(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "/MT")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "/MD")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/MDd")
|
||||
ENDIF()
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
|
||||
SET(CMAKE_ENABLE_EXPORTS ON)
|
||||
SET(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
|
||||
SET(UMSKT_EXE_WINDOWS_DLL src/windows/dllmain.cpp)
|
||||
ENDIF()
|
||||
|
||||
IF(MUSL_STATIC)
|
||||
MESSAGE(STATUS "[UMSKT] Performing a fully static build using muslc")
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
SET(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
||||
ENDIF()
|
||||
|
||||
# find the system installed OpenSSL development library
|
||||
FIND_PACKAGE(OpenSSL REQUIRED)
|
||||
IF(NOT OPENSSL_FOUND)
|
||||
MESSAGE(SEND_ERROR "OpenSSL Development Libraries Not Found")
|
||||
MESSAGE(SEND_ERROR "Please consult your package manager of choice to install the prerequisite")
|
||||
MESSAGE(SEND_ERROR "The package name is commonly called libssl-dev or openssl-dev depending on distribution")
|
||||
MESSAGE(FATAL_ERROR "Can not continue without OpenSSL")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT MUSL_STATIC)
|
||||
# if we found shared libraries - do the following:
|
||||
IF (OPENSSL_USE_STATIC_LIBS)
|
||||
MESSAGE(STATUS "[UMSKT] requested static version of OpenSSL")
|
||||
if (NOT UMSKT_USE_SHARED_OPENSSL)
|
||||
MESSAGE(STATUS "[UMSKT] not asked for shared version of OpenSSL")
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} "ws2_32.lib")
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} "crypt32.lib")
|
||||
MESSAGE(STATUS "[UMSKT] msvc adding ws2_32.lib crypt32.lib")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
STRING(REGEX MATCH "(\\.so|\\.dll|\\.dylib)$" OPENSSL_CRYPTO_SHARED "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
IF(OPENSSL_CRYPTO_SHARED)
|
||||
MESSAGE(STATUS "[UMSKT] Detected Shared library version of OpenSSL")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "[UMSKT] Detected Static Library version of OpenSSL")
|
||||
|
||||
# static libcrypto on Fedora needs -lz at link time
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
IF (NOT ZLIB_FOUND)
|
||||
MESSAGE(FATAL_ERROR "[UMSKT] linux static OpenSSL requires zlib")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# initalize cpm.CMake
|
||||
INCLUDE(cmake/CPM.cmake)
|
||||
|
||||
# fetch cpm.CMake dependencies
|
||||
# Include JSON development library
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
VERSION 3.11.2
|
||||
)
|
||||
|
||||
# Include fmt development library
|
||||
CPMAddPackage(
|
||||
NAME fmt
|
||||
GITHUB_REPOSITORY fmtlib/fmt
|
||||
GIT_TAG 10.0.0
|
||||
VERSION 10.0.0
|
||||
)
|
||||
|
||||
# Include cmrc resource compiler
|
||||
CPMAddPackage(
|
||||
NAME cmrc
|
||||
GITHUB_REPOSITORY vector-of-bool/cmrc
|
||||
GIT_TAG 2.0.1
|
||||
VERSION 2.0.1
|
||||
)
|
||||
|
||||
# Include Crypto++ development library
|
||||
#CPMAddPackage(
|
||||
# NAME cryptopp-cmake
|
||||
# GITHUB_REPOSITORY abdes/cryptopp-cmake
|
||||
# GIT_TAG CRYPTOPP_8_8_0
|
||||
# VERSION 8.8.0
|
||||
# OPTIONS "CRYPTOPP_BUILD_TESTING OFF"
|
||||
#)
|
||||
|
||||
#include googletest unit testing library
|
||||
#CPMAddPackage(
|
||||
# NAME googletest
|
||||
# GITHUB_REPOSITORY google/googletest
|
||||
# VERSION 1.13.0
|
||||
# OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
|
||||
#)
|
||||
|
||||
### Resource compilation
|
||||
CMRC_ADD_RESOURCE_LIBRARY(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json)
|
||||
|
||||
SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp src/libumskt/pidgen3/key.cpp src/libumskt/pidgen3/util.cpp src/libumskt/confid/confid.cpp src/libumskt/pidgen2/PIDGEN2.cpp src/libumskt/debugoutput.cpp)
|
||||
|
||||
#### Separate Build Path for emscripten
|
||||
IF (EMSCRIPTEN)
|
||||
ADD_EXECUTABLE(umskt ${LIBUMSKT_SRC})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(umskt -static OpenSSL::Crypto cryptopp::cryptopp fmt)
|
||||
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
|
||||
ELSE()
|
||||
ADD_LIBRARY(_umskt ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
||||
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_DIRECTORIES(_umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
TARGET_LINK_LIBRARIES(_umskt ${OPENSSL_CRYPTO_LIBRARIES} fmt ${UMSKT_LINK_LIBS})
|
||||
|
||||
### UMSKT executable compilation
|
||||
ADD_EXECUTABLE(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
||||
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
IF(MSVC AND MSVC_MSDOS_STUB)
|
||||
SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
|
||||
ENDIF()
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
install(TARGETS umskt DESTINATION bin)
|
||||
ENDIF()
|
||||
|
||||
### Copy Shared Libraries and dependency files
|
||||
IF (OPENSSL_CRYPTO_SHARED)
|
||||
GET_FILENAME_COMPONENT(OPENSSL_CRYPTO_LIBRARY_FILENAME ${OPENSSL_CRYPTO_LIBRARY} NAME)
|
||||
CONFIGURE_FILE(${OPENSSL_CRYPTO_LIBRARY} "${CMAKE_CURRENT_BINARY_DIR}/${OPENSSL_CRYPTO_LIBRARY_FILENAME}" COPYONLY)
|
||||
ENDIF()
|
||||
ENDIF()
|
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@ -0,0 +1,53 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prereqisites
|
||||
FROM alpine:latest as prereqisites
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
build-base \
|
||||
cmake \
|
||||
git \
|
||||
musl-dev \
|
||||
openssl-dev \
|
||||
openssl-libs-static
|
||||
|
||||
|
||||
# Stage 2: Build
|
||||
FROM prereqisites as builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& cmake -DMUSL_STATIC=ON .. \
|
||||
&& make
|
||||
|
||||
# Stage 3: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=builder /src/build/umskt /umskt
|
||||
|
||||
# invoke via
|
||||
# docker build -o type=tar,dest=umskt.tar .
|
123
Dockerfile.djgpp
Normal file
123
Dockerfile.djgpp
Normal file
@ -0,0 +1,123 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prerequisites
|
||||
FROM alpine:latest as prerequisites
|
||||
|
||||
# Stage 1: Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
autoconf \
|
||||
automake \
|
||||
bash \
|
||||
bison \
|
||||
build-base \
|
||||
clang \
|
||||
cmake \
|
||||
coreutils \
|
||||
curl \
|
||||
elfutils-dev \
|
||||
findutils \
|
||||
git \
|
||||
gawk \
|
||||
flex \
|
||||
libelf \
|
||||
libslirp-dev \
|
||||
linux-headers \
|
||||
nasm \
|
||||
sed \
|
||||
slang-dev \
|
||||
texinfo \
|
||||
unzip \
|
||||
zlib-dev
|
||||
|
||||
|
||||
FROM prerequisites as djgpp
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# Stage 2: compile djgpp for muslc
|
||||
ENV DJGPP_PREFIX=/djgpp BUILD_VER=12.2.0-i386
|
||||
RUN git clone https://github.com/andrewwutw/build-djgpp.git djgpp \
|
||||
&& cd djgpp \
|
||||
&& cd script \
|
||||
&& wget https://gist.github.com/Neo-Desktop/4cfd708f61f5847a7bf457d38db3b59f/raw/25d24cf509b0fc486d5d18ecb6656f120c3d0e51/12.2.0-i386 -O 12.2.0-i386 \
|
||||
&& chmod +x 12.2.0-i386 \
|
||||
&& cd ../patch \
|
||||
&& wget https://gist.github.com/Neo-Desktop/4cfd708f61f5847a7bf457d38db3b59f/raw/25d24cf509b0fc486d5d18ecb6656f120c3d0e51/patch-alpine-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch -O patch-alpine-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch \
|
||||
&& cd .. \
|
||||
&& sed -i 's/i586/i386/g' setenv/setenv \
|
||||
&& sed -i 's/i586/i386/g' setenv/setenv.bat \
|
||||
&& ./build-djgpp.sh $BUILD_VER \
|
||||
&& rm -rf /tmp/djgpp
|
||||
|
||||
# Stage 3: compile watt32 for djgpp-i386
|
||||
FROM djgpp as watt32
|
||||
WORKDIR /djgpp
|
||||
ENV WATT_ROOT=/djgpp/watt32 DJGPP_PREFIX=i386-pc-msdosdjgpp
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN git clone https://github.com/gvanem/Watt-32.git watt32 \
|
||||
&& cd watt32/util \
|
||||
&& make clean && make linux \
|
||||
&& cd ../src \
|
||||
&& source /djgpp/setenv \
|
||||
&& ./configur.sh djgpp \
|
||||
&& sed -i 's/i586/i386/g' djgpp.mak \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/djgpp.err -O ../inc/sys/djgpp.err \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/syserr.c -O build/djgpp/syserr.c \
|
||||
&& make -f djgpp.mak \
|
||||
&& ln -s /djgpp/watt32/lib/libwatt.a /djgpp/lib
|
||||
|
||||
# Stage 4: compile OpenSSL for djgpp-i386/watt32
|
||||
FROM watt32 as openssl
|
||||
WORKDIR /tmp
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN git clone https://github.com/openssl/openssl.git openssl \
|
||||
&& cd openssl \
|
||||
&& git checkout openssl-3.1.1 \
|
||||
&& source /djgpp/setenv \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/50-djgpp.conf.patch -O Configurations/50-djgpp.conf.patch \
|
||||
&& git apply Configurations/50-djgpp.conf.patch \
|
||||
&& ./Configure no-threads -DOPENSSL_DEV_NO_ATOMICS --prefix=/djgpp DJGPP \
|
||||
&& make && make install
|
||||
|
||||
# Stage 5: compile UMSKT
|
||||
FROM openssl as build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
ENV CC=/djgpp/bin/i386-pc-msdosdjgpp-gcc CXX=/djgpp/bin/i386-pc-msdosdjgpp-g++ PKG_CONFIG_PATH=/djgpp/lib/pkgconfig VERBOSE=1
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& source /djgpp/setenv \
|
||||
&& cmake -DDJGPP_WATT32=${WATT_ROOT}/lib/libwatt.a .. \
|
||||
&& make
|
||||
|
||||
CMD ["bash"]
|
||||
|
||||
# Stage 6: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=build /src/build/umskt.exe /umskt.exe
|
||||
|
||||
# invoke via
|
||||
# docker build -f Dockerfile.djgpp -o type=tar,dest=umskt-dos.tar .
|
64
Dockerfile.emscripten
Normal file
64
Dockerfile.emscripten
Normal file
@ -0,0 +1,64 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/25/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prerequisites
|
||||
FROM emscripten/emsdk:latest as prerequisites
|
||||
RUN apt update \
|
||||
&& apt -y install pkg-config \
|
||||
&& apt -y clean autoclean autoremove
|
||||
|
||||
# Stage 2: compile OpenSSL for emscripten
|
||||
FROM prerequisites as openssl
|
||||
WORKDIR /tmp
|
||||
ENV EMSCRIPTEN=/emsdk/upstream/emscripten VERBOSE=1
|
||||
RUN git clone https://github.com/openssl/openssl.git openssl \
|
||||
&& cd openssl \
|
||||
&& git checkout openssl-3.1.1 \
|
||||
&& emconfigure ./Configure gcc -no-tests -no-asm -static -fPIC -no-sock -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom --prefix=$EMSCRIPTEN/cache/sysroot|| exit $? \
|
||||
&& sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile \
|
||||
&& emmake make -j 12 build_generated libssl.a libcrypto.a build_libs_nodep \
|
||||
&& rm -rf $EMSCRIPTEN/cache/sysroot/include/openssl \
|
||||
&& cp -R include/openssl $EMSCRIPTEN/cache/sysroot/include \
|
||||
&& cp libcrypto.a libssl.a $EMSCRIPTEN/cache/sysroot/lib \
|
||||
&& cp libcrypto.pc libssl.pc openssl.pc $EMSCRIPTEN/cache/sysroot/lib/pkgconfig/ \
|
||||
&& cd .. \
|
||||
&& rm -rf openssl
|
||||
|
||||
# Stage 3: compile UMSKT
|
||||
FROM openssl as build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& emcmake cmake .. \
|
||||
&& emmake make
|
||||
|
||||
CMD ["bash"]
|
||||
|
||||
# Stage 4: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=build /src/build/umskt.html /src/build/umskt.wasm /src/build/umskt.js /
|
||||
|
||||
# invoke via
|
||||
# docker build -f Dockerfile.emscripten -o type=tar,dest=umskt-wasm.tar .
|
86
Dockerfile.windows
Normal file
86
Dockerfile.windows
Normal file
@ -0,0 +1,86 @@
|
||||
# escape=`
|
||||
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Visual Studio
|
||||
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8.1 as visualstudio
|
||||
# Download and install Build Tools for Visual Studio 2022 for native desktop workload.
|
||||
#ADD https://aka.ms/vs/17/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
|
||||
ADD vs_buildtools.exe C:\TEMP\vs_buildtools.exe
|
||||
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
|
||||
--add Microsoft.VisualStudio.Workload.VCTools `
|
||||
--add Microsoft.VisualStudio.Workload.MSBuildTools `
|
||||
--add Microsoft.VisualStudio.Component.WinXP `
|
||||
--includeRecommended `
|
||||
--installPath C:\BuildTools \
|
||||
|
||||
# Stage 2: Install Chocolatey and Prereqisites
|
||||
FROM visualstudio as prereqisites
|
||||
WORKDIR C:\TEMP\
|
||||
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"]
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "choco feature enable -n allowGlobalConfirmation"]
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "choco install git --params \"'/GitAndUnixToolsOnPath /WindowsTerminal /NoShellIntegration /NoGuiHereIntegration /NoShellHereIntegration /NoCredentialManager /SChannel'\""]
|
||||
|
||||
#Install OpenSSL 32bit 3.1.1
|
||||
#ADD https://slproweb.com/download/Win32OpenSSL-3_1_1.msi C:\TEMP\Win32OpenSSL-3_1_1.msi
|
||||
ADD Win32OpenSSL-3_1_1.msi C:\TEMP\Win32OpenSSL-3_1_1.msi
|
||||
RUN msiexec /i C:\TEMP\Win32OpenSSL-3_1_1.msi /quiet /qn /norestart
|
||||
|
||||
#Install OpenSSL 64bit 3.1.1
|
||||
#ADD https://slproweb.com/download/Win64OpenSSL-3_1_1.msi C:\TEMP\Win64OpenSSL-3_1_1.msi
|
||||
ADD Win64OpenSSL-3_1_1.msi C:\TEMP\Win64OpenSSL-3_1_1.msi
|
||||
RUN msiexec /i C:\TEMP\Win64OpenSSL-3_1_1.msi /quiet /qn /norestart
|
||||
|
||||
# Stage 3: Build the 32-bit version of UMSKT
|
||||
FROM prereqisites as Build32
|
||||
WORKDIR C:\umskt\
|
||||
COPY . C:\umskt\
|
||||
|
||||
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat && `
|
||||
mkdir C:\umskt\build && `
|
||||
cd C:\umskt\build && `
|
||||
cmake -DMSVC_MSDOS_STUB:string=..\umskt.exe .. -G "Visual Studio 17 2022" -A "Win32" -T v141_xp && `
|
||||
msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
# Stage 4: Build the 64-bit version of UMSKT
|
||||
FROM prereqisites as Build64
|
||||
|
||||
WORKDIR C:\umskt\
|
||||
COPY . C:\umskt\
|
||||
|
||||
ENV OPENSSL_ROOT_DIR="C:\Program Files\OpenSSL-Win64"
|
||||
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat && `
|
||||
mkdir C:\umskt\build && `
|
||||
cd C:\umskt\build && `
|
||||
cmake .. && `
|
||||
msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
# Stage 5: Copy binaries to an output/runtime image
|
||||
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8.1 as output
|
||||
|
||||
COPY --from=Build32 C:\umskt\build\Release\umskt.exe C:\umskt\umskt.exe
|
||||
COPY --from=Build64 C:\umskt\build\Release\umskt.exe C:\umskt\umskt64.exe
|
||||
|
||||
#invoke via
|
||||
# docker build -f Dockerfile.windows .
|
||||
# docker run <hash>
|
||||
# docker cp <plug>:C:\umskt umskt-win
|
674
LICENSE
674
LICENSE
@ -1,21 +1,661 @@
|
||||
MIT License
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (c) 2019 TheMCHK
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
133
README.md
133
README.md
@ -1,33 +1,122 @@
|
||||
## **Windows XP Keygen!**
|
||||
# Universal MS Key Toolkit (UMSKT)
|
||||
|
||||
# **FAQ**
|
||||
**Connect with us**
|
||||
|
||||
* **What does it do?**
|
||||
[](https://umskt.zulipchat.com)
|
||||
[](https://web.libera.chat/gamja/?nick=Guest?#mspid)
|
||||
[](https://discord.gg/PpBSpuphWM)
|
||||
|
||||
This program allows you to generate endless Windows XP keys.
|
||||
You also can use it to check your already existing keys.
|
||||
**Build status**
|
||||
|
||||
* **How does it work?**
|
||||
[](../../actions/workflows/windows.yml)
|
||||
|
||||
This program is based on [this paper](https://www.licenturion.com/xp/fully-licensed-wpa.txt) Basically,
|
||||
it uses a cracked private key from Microsoft to sign some stuff encoded in the 25-digit product key. It also does this process in reverse to check for the validation of the keys.
|
||||
[](../../actions/workflows/macos.yml)
|
||||
|
||||
* **How do I use it?**
|
||||
[](../../actions/workflows/linux.yml)
|
||||
|
||||
It all comes down to four simple steps:
|
||||
|
||||
|
||||
**1.** Use this program to generate a key, and use such key during installation.
|
||||
|
||||
**2.** After installation, you will be prompted to activate Windows. Select the
|
||||
*telephone activation* method, then, fire up [this website](https://msdev.gointeract.io/interact/index?interaction=1461173234028-3884f8602eccbe259104553afa8415434b4581-05d1&accountId=microsoft&appkey=196de13c-e946-4531-98f6-2719ec8405ce) and enter the installation ID that the activation wizard gave you.
|
||||
|
||||
**3.** Click "**Next**"
|
||||
|
||||
**4.** Profit!
|
||||
[](../../actions/workflows/freebsd.yml)
|
||||
|
||||
[](../../actions/workflows/dos-djgpp.yml)
|
||||
|
||||
------
|
||||
|
||||
### Plan of Action / ToDo List
|
||||
|
||||
In light of the recent exponential interest in this project I've decided to put updates of this project here:
|
||||
|
||||
[Please see ticket #8 for more information](https://github.com/UMSKT/UMSKT/issues/8)
|
||||
|
||||
------
|
||||
|
||||
### **FAQ**
|
||||
|
||||
#### **What does it do?**
|
||||
|
||||
* This program is a tool for researching and experimenting with retro Microsoft product licensing, for products released before 2012.
|
||||
|
||||
#### **How does it work?**
|
||||
|
||||
* [Enderman's XPKeygen Readme explains everything in detail.](https://github.com/Endermanch/XPKeygen)
|
||||
|
||||
#### **How do I use it?**
|
||||
|
||||
* It all comes down to four simple steps:
|
||||
|
||||
------
|
||||
|
||||
### **Usage**
|
||||
#### 1. Download the latest version of UMSKT
|
||||
|
||||
* *(GitHub account required)*
|
||||
* Download the latest experimental version using the Actions tab ([Windows](../../actions/workflows/windows.yml?query=branch%3Amaster+is%3Asuccess), [Linux](../../actions/workflows/linux.yml?query=branch%3Amaster+is%3Asuccess), [macOS](../../actions/workflows/macos.yml?query=branch%3Amaster+is%3Asuccess), [FreeBSD](../../actions/workflows/freebsd.yml?query=branch%3Amaster+is%3Asuccess), [DOS DJGPP](../../actions/workflows/dos-djgpp.yml?query=branch%3Amaster+is%3Asuccess))
|
||||
|
||||
|
||||
* *(GitHub account \*not\* required)*
|
||||
* Download the latest release for your operating system and architecture from [the releases page](../../releases)
|
||||
|
||||
**REQUIREMENTS:**
|
||||
* **Note:** Before continuing, please ensure you have the `umskt` executable extracted and on UNIX-like systems, have execution permissions (`chmod +x umskt`).
|
||||
|
||||
* `OpenSSL >0.9.8b`
|
||||
#### 2. Install OpenSSL.
|
||||
For Windows, click [here](https://slproweb.com/products/Win32OpenSSL.html) and choose the right version. For other operating systems, consult your package manager.
|
||||
*Note: This only applies if the build you download has OpenSSL embedded (static library) or not. You can usually tell if the download size is measured in KB or MB. If it's MB, you don't need this.*
|
||||
|
||||
#### 3. Run `umskt` to generate a key, or add `--help` or `-h` to see more options.
|
||||
|
||||
#### 4. *(Activation step for `Retail` and `OEM` only)*
|
||||
* After installation, you will be prompted to activate Windows.
|
||||
|
||||
|
||||
* Select the **telephone activation** method, then, run `umskt -i <Installation ID>` using the `Installation ID` the activation Wizard provides for you
|
||||
* If you're activating a non-Windows product, use `umskt -i <Installation ID> -m <Product>`, where `<Product>` is one of `OFFICEXP`, `OFFICE2K3`, `OFFICE2K7`, or `PLUSDME`
|
||||
* If activating Office 2003/2007, use `umskt -i <Installation ID> -m <Product> -p <Product ID>`
|
||||
|
||||
#### 4. Profit!
|
||||
|
||||
|
||||
------
|
||||
|
||||
|
||||
### Authors
|
||||
The list of people who have helped to bring the XP generation to where it is now:
|
||||
* z22
|
||||
* MSKey
|
||||
* diamondggg
|
||||
* pottzman
|
||||
* david4599
|
||||
* Endermanch
|
||||
* Neo-Desktop
|
||||
* WitherOrNot
|
||||
* TheTank20
|
||||
* InvoxiPlayGames
|
||||
* brakmic
|
||||
* techguy16
|
||||
|
||||
(the list will be updated to add more collaborators)
|
||||
|
||||
------
|
||||
|
||||
### **Development Requirements:**
|
||||
|
||||
* `build-essential`
|
||||
* `cmake`
|
||||
* `make`
|
||||
* `gcc`
|
||||
* `g++`
|
||||
* `git`
|
||||
|
||||
#### Build Steps:
|
||||
|
||||
1. `git clone https://github.com/UMSKT/UMSKT`
|
||||
2. `cd UMSKT/build`
|
||||
3. `cmake ..`
|
||||
4. `make`
|
||||
|
||||
|
||||
-----
|
||||
|
||||
### **Known Ports**
|
||||
|
||||
| Language | Author | Repo URL |
|
||||
|----------|-----------|-----------------------------------------------------------|
|
||||
| Rust | Alex Page | [anpage/umskt-rs](https://github.com/anpage/umskt-rs) |
|
||||
| Python | techguy16 | [techguy16/umsktpy](https://github.com/techguy16/umsktpy) |
|
||||
|
0
build/.gitkeep
Normal file
0
build/.gitkeep
Normal file
33
cmake/CPM.cmake
Normal file
33
cmake/CPM.cmake
Normal file
@ -0,0 +1,33 @@
|
||||
set(CPM_DOWNLOAD_VERSION 0.38.1)
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
|
||||
function(download_cpm)
|
||||
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||
download_cpm()
|
||||
else()
|
||||
# resume download if it previously failed
|
||||
file(READ ${CPM_DOWNLOAD_LOCATION} check)
|
||||
if("${check}" STREQUAL "")
|
||||
download_cpm()
|
||||
endif()
|
||||
unset(check)
|
||||
endif()
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
99
doc/Vista+.md
Normal file
99
doc/Vista+.md
Normal file
@ -0,0 +1,99 @@
|
||||
## 6. Product ID
|
||||
|
||||
Product ID is 5 groups of decimals, e.g.:
|
||||
|
||||
```
|
||||
AAAAA BBB CCCCCCC DD EEE
|
||||
52273 005 6861993 09 146
|
||||
```
|
||||
|
||||
If you search `ProductID` in registry, you will find a product ID associated with your currently installed one.
|
||||
|
||||
The meaning of each group of numbers:
|
||||
|
||||
| Number | Meaning |
|
||||
| --------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `AAAAA` | Product code. e.g.: `55661` for Windows Pro; `55660` for Windows Home. |
|
||||
| `BBB` | First 3 effective number digits of Primary Product Serial. |
|
||||
| `CCCCCCC` | Last 6 effective number digits of Primary Product Serial, and a digit of checksum. |
|
||||
| `DD` | Public key index number for product validation. e.g.: Pro is 22, VLK is 23. |
|
||||
| `EEE` | Nonce (random number), for generating different install ID when doing activation via telephone. |
|
||||
|
||||
For `CCCCCCC` mentioned above, it had two parts including 1 digit and 6 digits. The checksum is calculated as follows: **Add all digits together (including the checksum digit), it is divisible by 7.**
|
||||
For example: the last 6 digits of Primary Product Serial is `728439`, then `7 + 2 + 8 + 4 + 3 + 9 = 33` , then the checksum digit should be `2`, because `7 + 2 + 8 + 4 + 3 + 9 + 2 = 33 + 2 = 35`, and 35 is divisible by 7. So the `CCCCCCC` in Product ID should be `7284392`.
|
||||
|
||||
## 7. OEM related mechanism
|
||||
<!-- Oh boy this section is a total mess... The original content itself is confusing as hell.. -->
|
||||
|
||||
For licensed product to OEMs, starting from Windows XP, Microsoft is using SLP (System-Locked Preinstallation) technology, aka.: before installing the OS, lock in the motherboard with the OS. Windows XP used SLP 1.0, it works by detecting specific string set by OEM in BIOS. This method is easy to be spoofed, but the VLK crack is more easy to use so this method is not wide-spread.
|
||||
From the Windows Vista, SLP upgraded to 2.0 . Primarily the change is using cryptographic key pairs to sign the data to prevent spoofing. This requires a special SLIC (Software Licensing Internal Code) table in BIOS to support this.
|
||||
In Windows 7 series of product, SLP 2.1 is used, but there is no major changes in SLP for this revision, only updated the marker in SLIC to 2.1 .
|
||||
|
||||
SLIC is the important part of SLP, usually directly backed in BIOS ROM, as the most underlying information of OS activation. SLIC contains the digital signature of OEM, when OS is activating, the upper level certificate must can be verified with the OEM information inside SLIC. SLIC usually contained inside SLDT(Software Licensing Description Table), which 374 bytes long, and SLDT itself is contained inside ACPI(Advanced Configuration and Power Management Interface).
|
||||
|
||||
OEM certificate is a certification file provided by Microsoft, including to some mandatory information provided by OEM, the extension for the file is `xrm-ms`. The OEM certificate including the OEM identification information and digitally signed by Microsoft. When OS is activating, the OEM certificate must can be validated against SLIC.
|
||||
|
||||
OEM product key seems no difference with retail product key, but OEM key is only valid for OEM activation, and it identifies the Windows product variation. Windows Vista cancelled the VLK model, only OEM activation is provided, and used SLP 2.0, used public key instead plain text for validation, caused difficulties for cracking.
|
||||
|
||||
### Windows Vista (SLP 2.0)
|
||||
<!-- Following procedure is for SLP 2.0, which is for Windows Vista. -->
|
||||
The procedure for SLP 2.0 verification is as follows:
|
||||
|
||||
1. When installing Windows Vista, retail version user need to input the serial (CD-KEY) presented on the box. For users who got the OEM version of Windows Vista with the computer, they can find a sticker that corresponding the version they got with the computer, as a voucher for purchasing the Windows Vista OEM version. The system identifies different versions of Windows Vista based on their serial numbers, such as Home Basic, Home Advanced, Business, Ultimate, and so on. After installation, the serial number is converted into 4 sets of letters or numbers, which is the "Product ID" shown in the "System Properties". The second group is the "OEM" one, which is the serial number (CD-KEY) of the OEM version. From now on, the product ID replaces the CD-KEY <!-- as user inputted their retail CD-KEY on the box, this OEM product ID became the CD-KEY in this case -->, and the installer generates an OEM certificate for the OEM version of the installation <!-- "product certificate" maybe? And, installed to where? usually the installation is done by OEM. The information is conflicting with the "OEM certificate is a certification file provided by Microsoft" mentioned above. -->.
|
||||
|
||||
2. The information in the BIOS got loaded into RAM every time system boots.
|
||||
|
||||
3. After logging into the Windows Vista, OS calls SLP service to check the licensed rights of running product, especially the activation status. It starts to identify the licensing status of the system based on the product ID. If no product ID is detected or no valid retail version product ID is detected, it is considered as inactivated. If a valid retail version product ID is detected, it is considered successfully activated. If an OEM version of the product ID is detected, continue with the OEM verification.
|
||||
|
||||
4. If the OEM product ID is detected, the OEM verification process starts, and it will check the installed OEM certificate <!-- "product certificate" ? --> is valid. It mainly uses the SLIC public key from BIOS which is loaded into the RAM, to verify the digital signature of product certificate <!-- Yes, this "product certificate" came from nowhere, so I guess this the OEM certificate that installed while installing the Windows Vista by OEM. -->. If validation failed, it is considered as inactivated.
|
||||
|
||||
5. Verify the OEM ID field between SLIC and RSDT (Root System Description Table), and compare the OEM ID field and OEM Table ID fields between SLIC and XSDT (Extended System Description Table). If they didn't match, it is considered as inactivated.
|
||||
|
||||
6. After the above hurdles, the OEM license will be considered as activated. If not then fallback to inactivated and continue with normal procedure, like require user to activate the Windows.
|
||||
|
||||
### Windows 7 (SLP 2.1)
|
||||
<!-- Following procedure is for SLP 2.1, which is for Windows 7. -->
|
||||
Windows 7 still retains the OEM activation policy, but using SLP 2.1 instead.
|
||||
|
||||
Here is more detailed verification process:
|
||||
|
||||
1. After the activation process starts, if the correct SLP Key is detected, the OEM activation process starts, otherwise the WPA activation (online or telephone activation) is performed.
|
||||
|
||||
2. Detect the OEM certificate <!-- "product certificate" ? -->, and use the digital signature inside the OEM certificate to validate the it (Microsoft used their private key to sign the OEM certificate, and verified against the public key), if verified then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
3. Compare the OEM public key, OEM ID and various fields with the information presented in the OEM certificate <!-- "product certificate" ? -->. If they match (this means OEM public key and etc. are correct), then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
4. Use OEM public key verify against the digital signature of the Marker inside SLIC. if verified (this means the Message in the Marker is correct. <!-- There is no where talked about what is that Message and Marker. -->) then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
5. Verify the Windows Logo <!-- I guess? "Windows Logo" part can be directly translate to "Windows Flag Mark", and this "Flag" means that actual waving thing, not a digital bit. I guess this approach is similar as the Nintendo logo bitmap inside Game Boy game cartridge ROM thing. --> inside the Marker. If the Windows Logo is present, then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
6. Verify the version of Marker. If it's at least `0x20001` then continue on OEM activation process, otherwise OEM activation failed, and continue on WPA activation process.
|
||||
|
||||
7. Compare the OEM ID and OEM Table ID against all corresponding ACPI table headers. If they match, then OEM activation completed successfully, otherwise continue on WPA activation process.
|
||||
|
||||
Key points (Not containing all details, this info is only there to emphasize the key points of Microsoft encryption):
|
||||
|
||||
1. OEM certificate <!-- "product certificate" ? --> contains
|
||||
- Data (OEM ID and other information, Microsoft public key, etc.)
|
||||
- Hash (Hash of data)
|
||||
- Signature (Hash were signed with Microsoft private key)
|
||||
|
||||
2. SLIC contains:
|
||||
- Data (OEM ID, Marker version, etc., Microsoft public key, etc.)
|
||||
- Hash (Hash the data)
|
||||
- Signature (Hash were signed with Microsoft private key)
|
||||
|
||||
3. First, use the public key to verify whether the signatures of OEM and SLIC, then, compare the OEM ID, public key and other information in OEM and SLIC to see whether they are the same; verify the Marker version is matching the type of system currently installed.
|
||||
|
||||
* * *
|
||||
Oh boy what a mess...
|
||||
|
||||
This source is from CSDN.net, and this is a known "copy paste and profit" site that infamous in China.
|
||||
|
||||
This article is old enough that the author is actually had integrity and cited all the actual juicy sources. However, all the actual juicy sources were long gone, because the BBS that the author cited is down,only unusable archives were left (reported by discord member @itsmefeng ).
|
||||
|
||||
This article isn't providing enough information on how to crack the Windows Vista/7 activation process. We may need more actual good sources for this.
|
||||
|
||||
For better understanding I provided some comment (as HTML comments for Markdown compatibility). Hopefully it will be useful.
|
||||
|
||||
-- Some Anonymous Person
|
607
doc/fully-licensed-wpa.txt
Normal file
607
doc/fully-licensed-wpa.txt
Normal file
@ -0,0 +1,607 @@
|
||||
|
||||
Inside Windows Product Activation
|
||||
|
||||
A Fully Licensed Paper
|
||||
|
||||
July 2001
|
||||
|
||||
Fully Licensed GmbH, Rudower Chaussee 29, 12489 Berlin, Germany
|
||||
|
||||
http://www.licenturion.com
|
||||
|
||||
|
||||
>> INTRODUCTION
|
||||
|
||||
The current public discussion of Windows Product Activation (WPA) is
|
||||
characterized by uncertainty and speculation. In this paper we supply
|
||||
the technical details of WPA - as implemented in Windows XP - that
|
||||
Microsoft should have published long ago.
|
||||
|
||||
While we strongly believe that every software vendor has the right to
|
||||
enforce the licensing terms governing the use of a piece of licensed
|
||||
software by technical means, we also do believe that each individual
|
||||
has the right to detailed knowledge about the full implications of the
|
||||
employed means and possible limitations imposed by it on software
|
||||
usage.
|
||||
|
||||
In this paper we answer what we think are currently the two most
|
||||
important open questions related to Windows Product Activation.
|
||||
|
||||
* Exactly what information is transmitted during activation?
|
||||
|
||||
* How do hardware modifications affect an already activated
|
||||
installation of Windows XP?
|
||||
|
||||
Our answers to these questions are based on Windows XP Release
|
||||
Candidate 1 (build 2505). Later builds as well as the final version of
|
||||
Windows XP might differ from build 2505, e.g. in the employed
|
||||
cryptographic keys or the layout of some of the data
|
||||
structures.
|
||||
|
||||
However, beyond such minor modifications we expect Microsoft to cling
|
||||
to the general architecture of their activation mechanism. Thus, we
|
||||
are convinced that the answers provided by this paper will still be
|
||||
useful when the final version of Windows XP ships.
|
||||
|
||||
This paper supplies in-depth technical information about the inner
|
||||
workings of WPA. Still, the discussion is a little vague at some
|
||||
points in order not to facilitate the task of an attacker attempting
|
||||
to circumvent the license enforcement supplied by the activation
|
||||
mechanism.
|
||||
|
||||
XPDec, a command line utility suitable for verifying the presented
|
||||
information, can be obtained from http://www.licenturion.com/xp/. It
|
||||
implements the algorithms presented in this paper. Reading its source
|
||||
code, which is available from the same location, is highly
|
||||
recommended.
|
||||
|
||||
We have removed an important cryptographic key from the XPDec source
|
||||
code. Recompiling the source code will thus fail to produce a working
|
||||
executable. The XPDec executable on our website, however, contains
|
||||
this key and is fully functional.
|
||||
|
||||
So, download the source code to learn about the inner workings of WPA,
|
||||
but obtain the executable to experiment with your installation of
|
||||
Windows XP.
|
||||
|
||||
We expect the reader to be familiar with the general procedure of
|
||||
Windows Product Activation.
|
||||
|
||||
>> INSIDE THE INSTALLATION ID
|
||||
|
||||
We focused our research on product activation via telephone. We did
|
||||
so, because we expected this variant of activation to be the most
|
||||
straight-forward to analyze.
|
||||
|
||||
The first step in activating Windows XP via telephone is supplying the
|
||||
call-center agent with the Installation ID displayed by msoobe.exe,
|
||||
the application that guides a user through the activation process. The
|
||||
Installation ID is a number consisting of 50 decimal digits that are
|
||||
divided into groups of six digits each, as in
|
||||
|
||||
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
|
||||
|
||||
In this authentic Installation ID we have substituted digits that we
|
||||
prefer not to disclose by 'X' characters.
|
||||
|
||||
If msoobe.exe is invoked more than once, it provides a different
|
||||
Installation ID each time.
|
||||
|
||||
In return, the call-center agent provides a Confirmation ID matching
|
||||
the given Installation ID. Entering the Confirmation ID completes the
|
||||
activation process.
|
||||
|
||||
Since the Installation ID is the only piece of information revealed
|
||||
during activation, the above question concerning the information
|
||||
transmitted during the activation process is equivalent to the
|
||||
question
|
||||
|
||||
'How is the Installation ID generated?'
|
||||
|
||||
To find an answer to this question, we trace back each digit of the
|
||||
Installation ID to its origins.
|
||||
|
||||
>>> Check digits
|
||||
|
||||
The rightmost digit in each of the groups is a check digit to guard
|
||||
against simple errors such as the call center agent's mistyping of one
|
||||
of the digits read to him or her. The value of the check digit is
|
||||
calculated by adding the other five digits in the group, adding the
|
||||
digits at even positions a second time, and dividing the sum by
|
||||
seven. The remainder of the division is the value of the check
|
||||
digit. In the above example the check digit for the first group (6) is
|
||||
calculated as follows.
|
||||
|
||||
1 | 2 | 3 | 4 | 5 <- position
|
||||
---+---+---+---+---
|
||||
0 | 0 | 2 | 6 | 6 <- digits
|
||||
|
||||
0 + 0 + 2 + 6 + 6 = 14 (step 1: add all digits)
|
||||
0 + 6 + 14 = 20 (step 2: add even digits again)
|
||||
|
||||
step 3: division
|
||||
20 / 7 = 2, remainder is 20 - (2 * 7) = 6
|
||||
|
||||
=> check digit is 6
|
||||
|
||||
Adding the even digits twice is probably intended to guard against the
|
||||
relatively frequent error of accidentally swapping two digits while
|
||||
typing, as in 00626 vs. 00266, which yield different check digits.
|
||||
|
||||
>>> Decoding
|
||||
|
||||
Removing the check digits results in a 41-digit decimal number. A
|
||||
decimal number of this length roughly corresponds to a 136-bit binary
|
||||
number. In fact, the 41-digit number is just the decimal encoding of
|
||||
such a 136-bit multi-precision integer, which is stored in little
|
||||
endian byte order as a byte array. Hence, the above Installation ID
|
||||
can also be represented as a sequence of 17 bytes as in
|
||||
|
||||
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
|
||||
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
|
||||
0x00
|
||||
|
||||
In this representation of the above Installation ID 'X' characters
|
||||
again substitute the digits that we prefer not to disclose. The '0x'
|
||||
prefix denotes hex notation throughout this paper.
|
||||
|
||||
>>> Decryption
|
||||
|
||||
When decoding arbitrary Installation IDs it can be noticed that the
|
||||
most significant byte always seems to be 0x00 or 0x01, whereas the
|
||||
other bytes look random. The reason for this is that the lower 16
|
||||
bytes of the Installation ID are encrypted, whereas the most
|
||||
significant byte is kept in plaintext.
|
||||
|
||||
The cryptographic algorithm employed to encrypt the Installation ID is
|
||||
a proprietary four-round Feistel cipher. Since the block of input
|
||||
bytes passed to a Feistel cipher is divided into two blocks of equal
|
||||
size, this class of ciphers is typically applied to input blocks
|
||||
consisting of an even number of bytes - in this case the lower 16 of
|
||||
the 17 input bytes. The round function of the cipher is the SHA-1
|
||||
message digest algorithm keyed with a four-byte sequence.
|
||||
|
||||
Let + denote the concatenation of two byte sequences, ^ the XOR
|
||||
operation, L and R the left and right eight-byte input half for one
|
||||
round, L' and R' the output halves of said round, and First-8() a
|
||||
function that returns the first eight bytes of an SHA-1 message
|
||||
digest. Then one round of decryption looks as follows.
|
||||
|
||||
L' = R ^ First-8(SHA-1(L + Key))
|
||||
R' = L
|
||||
|
||||
The result of the decryption is 16 bytes of plaintext, which are -
|
||||
together with the 17th unencrypted byte - from now on interpreted as
|
||||
four double words in little endian byte order followed by a single
|
||||
byte as in
|
||||
|
||||
name | size | offset
|
||||
-----+-------------+-------
|
||||
H1 | double word | 0
|
||||
H2 | double word | 4
|
||||
P1 | double word | 8
|
||||
P2 | double word | 12
|
||||
P3 | byte | 16
|
||||
|
||||
H1 and H2 specify the hardware configuration that the Installation ID
|
||||
is linked to. P1 and P2 as well as the remaining byte P3 contain the
|
||||
Product ID associated with the Installation ID.
|
||||
|
||||
>>> Product ID
|
||||
|
||||
The Product ID consists of five groups of decimal digits, as in
|
||||
|
||||
AAAAA-BBB-CCCCCCC-DDEEE
|
||||
|
||||
If you search your registry for a value named 'ProductID', you will
|
||||
discover the ID that applies to your installation. The 'About' window
|
||||
of Internet Explorer should also yield your Product ID.
|
||||
|
||||
>>>> Decoding
|
||||
|
||||
The mapping between the Product ID in decimal representation and its
|
||||
binary encoding in the double words P1 and P2 and the byte P3 is
|
||||
summarized in the following table.
|
||||
|
||||
digits | length | encoding
|
||||
--------+---------+---------------------------------------
|
||||
AAAAA | 17 bits | bit 0 to bit 16 of P1
|
||||
BBB | 10 bits | bit 17 to bit 26 of P1
|
||||
CCCCCCC | 28 bits | bit 27 to bit 31 of P1 (lower 5 bits)
|
||||
| | bit 0 to bit 22 of P2 (upper 23 bits)
|
||||
DDEEE | 17 bits | bit 23 to bit 31 of P2 (lower 9 bits)
|
||||
| | bit 0 to bit 7 of P3 (upper 8 bits)
|
||||
|
||||
The meaning of each of the five groups of digits is documented in the
|
||||
next table.
|
||||
|
||||
digits | meaning
|
||||
--------+-------------------------------------------------
|
||||
AAAAA | apparently always 55034 (in Windows XP RC1)
|
||||
BBB | most significant three digits of Raw Product Key
|
||||
| (see below)
|
||||
CCCCCCC | least significant six digits of Raw Product Key
|
||||
| plus check digit (see below)
|
||||
DD | index of the public key used to verify the
|
||||
| Product Key (see below)
|
||||
EEE | random value
|
||||
|
||||
As can be seen, the (Raw) Product Key plays an important role in
|
||||
generating the Product ID.
|
||||
|
||||
>>>> Product Key
|
||||
|
||||
The Raw Product Key is buried inside the Product Key that is printed
|
||||
on the sticker distributed with each Windows XP CD. It consists of
|
||||
five alphanumeric strings separated by '-' characters, where each
|
||||
string is composed of five characters, as in
|
||||
|
||||
FFFFF-GGGGG-HHHHH-JJJJJ-KKKKK
|
||||
|
||||
Each character is one of the following 24 letters and digits:
|
||||
|
||||
B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9
|
||||
|
||||
Very similar to the decimal encoding of the Installation ID the 25
|
||||
characters of the Product Key form a base-24 encoding of the binary
|
||||
representation of the Product Key. Decoding the Product Key yields a
|
||||
multi-precision integer of roughly 115 bits, which is stored - again
|
||||
in little endian byte order - in an array of 15 bytes. Decoding the
|
||||
above Product Key results in the following byte sequence.
|
||||
|
||||
0x6F 0xFA 0x95 0x45 0xFC 0x75 0xB5 0x52
|
||||
0xBB 0xEF 0xB1 0x17 0xDA 0xCD 0x00
|
||||
|
||||
Of these 15 bytes the least significant four bytes contain the Raw
|
||||
Product Key in little endian byte order. The least significant bit is
|
||||
removed by shifting this 32-bit value (0x4595FA6F - remember the
|
||||
little endian byte order) to the left by one bit position, resulting
|
||||
in a Raw Product Key of 0x22CAFD37, or
|
||||
|
||||
583728439
|
||||
|
||||
in decimal notation.
|
||||
|
||||
The eleven remaining bytes form a digital signature, allowing
|
||||
verification of the authenticity of the Product Key by means of a
|
||||
hard-coded public key.
|
||||
|
||||
>>>> Product Key -> Product ID
|
||||
|
||||
The three most significant digits, i.e. 583, of the Raw Product Key's
|
||||
nine-digit decimal representation directly map to the BBB component of
|
||||
the Product ID described above.
|
||||
|
||||
To obtain the CCCCCCC component, a check digit is appended to the
|
||||
remaining six digits 728439. The check digit is chosen such that the
|
||||
sum of all digits - including the check digit - is divisible by
|
||||
seven. In the given case, the sum of the six digits is
|
||||
|
||||
7 + 2 + 8 + 4 + 3 + 9 = 33
|
||||
|
||||
which results in a check digit of 2, since
|
||||
|
||||
7 + 2 + 8 + 4 + 3 + 9 + 2 = 33 + 2 = 35
|
||||
|
||||
which is divisible by seven. The CCCCCCC component of the Product ID
|
||||
is therefore 7284392.
|
||||
|
||||
For verifying a Product Key, more than one public key is available. If
|
||||
verification with the first public key fails, the second is tried,
|
||||
etc. The DD component of the Product ID specifies which of the public
|
||||
keys in this sequence was successfully used to verify the Product Key.
|
||||
|
||||
This mechanism might be intended to support several different parties
|
||||
generating valid Product Keys with different individual private keys.
|
||||
|
||||
However, the different private keys might also represent different
|
||||
versions of a product. A Product Key for the 'professional' release
|
||||
could then be signed with a different key than a Product Key for the
|
||||
'server' release. The DD component would then represent the product
|
||||
version.
|
||||
|
||||
Finally, a valid Product ID derived from our example Product Key might
|
||||
be
|
||||
|
||||
55034-583-7284392-00123
|
||||
|
||||
which indicates that the first public key (DD = index = 0) matched and
|
||||
123 was chosen as the random number EEE.
|
||||
|
||||
The randomly selected EEE component is the reason for msoobe.exe
|
||||
presenting a different Installation ID at each invocation. Because of
|
||||
the applied encryption this small change results in a completely
|
||||
different Installation ID.
|
||||
|
||||
So, the Product ID transmitted during activation will most probably
|
||||
differ in the last three digits from your Product ID as displayed by
|
||||
Internet Explorer or as stored in the registry.
|
||||
|
||||
>>> Hardware Information
|
||||
|
||||
As discussed above, the hardware configuration linked to the
|
||||
Installation ID is represented by the two double words H1 and H2.
|
||||
|
||||
>>>> Bit-fields
|
||||
|
||||
For this purpose, the double words are divided into twelve
|
||||
bit-fields. The relationship between the computer hardware and the
|
||||
bit-fields is given in the following table.
|
||||
|
||||
double word | offset | length | bit-field value based on
|
||||
------------+--------+--------+----------------------------
|
||||
H1 | 0 | 10 | volume serial number string
|
||||
| | | of system volume
|
||||
H1 | 10 | 10 | network adapter MAC address
|
||||
| | | string
|
||||
H1 | 20 | 7 | CD-ROM drive hardware
|
||||
| | | identification string
|
||||
H1 | 27 | 5 | graphics adapter hardware
|
||||
| | | identification string
|
||||
H2 | 0 | 3 | unused, set to 001
|
||||
H2 | 3 | 6 | CPU serial number string
|
||||
H2 | 9 | 7 | harddrive hardware
|
||||
| | | identification string
|
||||
H2 | 16 | 5 | SCSI host adapter hardware
|
||||
| | | identification string
|
||||
H2 | 21 | 4 | IDE controller hardware
|
||||
| | | identification string
|
||||
H2 | 25 | 3 | processor model string
|
||||
H2 | 28 | 3 | RAM size
|
||||
H2 | 31 | 1 | 1 = dockable
|
||||
| | | 0 = not dockable
|
||||
|
||||
Bit 31 of H2 specifies, whether the bit-fields represent a notebook
|
||||
computer that supports a docking station. If docking is possible, the
|
||||
activation mechanism will be more tolerant with respect to future
|
||||
hardware modifications. Here, the idea is that plugging a notebook
|
||||
into its docking station possibly results in changes to its hardware
|
||||
configuration, e.g. a SCSI host adapter built into the docking station
|
||||
may become available.
|
||||
|
||||
Bits 2 through 0 of H2 are unused and always set to 001.
|
||||
|
||||
If the hardware component corresponding to one of the remaining ten
|
||||
bit-fields is present, the respective bit-field contains a non-zero
|
||||
value describing the component. A value of zero marks the hardware
|
||||
component as not present.
|
||||
|
||||
All hardware components are identified by a hardware identification
|
||||
string obtained from the registry. Hashing this string provides the
|
||||
value for the corresponding bit-field.
|
||||
|
||||
>>>> Hashing
|
||||
|
||||
The hash result is obtained by feeding the hardware identification
|
||||
string into the MD5 message digest algorithm and picking the number of
|
||||
bits required for a bit-field from predetermined locations in the
|
||||
resulting message digest. Different predetermined locations are used
|
||||
for different bit-fields. In addition, a hash result of zero is
|
||||
avoided by calculating
|
||||
|
||||
Hash = (Hash % BitFieldMax) + 1
|
||||
|
||||
where BitFieldMax is the maximal value that may be stored in the
|
||||
bit-field in question, e.g. 1023 for a 10-bit bit-field, and 'x % y'
|
||||
denotes the remainder of the division of x by y. This results in
|
||||
values between 1 and BitFieldMax. The obtained value is then stored in
|
||||
the respective bit-field.
|
||||
|
||||
>>>> RAM bit-field
|
||||
|
||||
The bit-field related to the amount of RAM available to the operating
|
||||
system is calculated differently. The seven valid values specify the
|
||||
approximate amount of available RAM as documented in the following
|
||||
table.
|
||||
|
||||
value | amount of RAM available
|
||||
------+---------------------------
|
||||
0 | (bit-field unused)
|
||||
1 | below 32 MB
|
||||
2 | between 32 MB and 63 MB
|
||||
3 | between 64 MB and 127 MB
|
||||
4 | between 128 MB and 255 MB
|
||||
5 | between 256 MB and 511 MB
|
||||
6 | between 512 MB and 1023 MB
|
||||
7 | above 1023 MB
|
||||
|
||||
It is important to note that the amount of RAM is retrieved by calling
|
||||
the GlobalMemoryStatus() function, which reports a few hundred
|
||||
kilobytes less than the amount of RAM physically installed. So, 128 MB
|
||||
of RAM would typically be classified as "between 64 MB and 127 MB".
|
||||
|
||||
>>>> Real-world example
|
||||
|
||||
Let us have a look at a real-world example. On one of our test systems
|
||||
the hardware information consists of the following eight bytes.
|
||||
|
||||
0xC5 0x95 0x12 0xAC 0x01 0x6E 0x2C 0x32
|
||||
|
||||
Converting the bytes into H1 and H2, we obtain
|
||||
|
||||
H1 = 0xAC1295C5 and H2 = 0x322C6E01
|
||||
|
||||
Splitting H1 and H2 yields the next table in which we give the value
|
||||
of each of the bit-fields and the information from which each value is
|
||||
derived.
|
||||
|
||||
dw & | |
|
||||
offset | value | derived from
|
||||
-------+-------+-----------------------------------------------
|
||||
H1 0 | 0x1C5 | '1234-ABCD'
|
||||
H1 10 | 0x0A5 | '00C0DF089E44'
|
||||
H1 20 | 0x37 | 'SCSI\CDROMPLEXTOR_CD-ROM_PX-32TS__1.01'
|
||||
H1 27 | 0x15 | 'PCI\VEN_102B&DEV_0519&SUBSYS_00000000&REV_01'
|
||||
H2 0 | 0x1 | (unused, always 0x1)
|
||||
H2 3 | 0x00 | (CPU serial number not present)
|
||||
H2 9 | 0x37 | 'SCSI\DISKIBM_____DCAS-34330______S65A'
|
||||
H2 16 | 0x0C | 'PCI\VEN_9004&DEV_7178&SUBSYS_00000000&REV_03'
|
||||
H2 21 | 0x1 | 'PCI\VEN_8086&DEV_7111&SUBSYS_00000000&REV_01'
|
||||
H2 25 | 0x1 | 'GenuineIntel Family 6 Model 3'
|
||||
H2 28 | 0x3 | (system has 128 MB of RAM)
|
||||
H2 31 | 0x0 | (system is not dockable)
|
||||
|
||||
>>> Using XPDec
|
||||
|
||||
XPDec is a utility to be run from the command prompt. It may be
|
||||
invoked with one of four command line options to carry out one of four
|
||||
tasks.
|
||||
|
||||
>>>> XPDec -i
|
||||
|
||||
This option enables you to access the information hidden in an
|
||||
Installation ID. It decodes the Installation ID, decrypts it, and
|
||||
displays the values of the hardware bit-fields as well as the Product
|
||||
ID of your product. Keep in mind that the last three digits of the
|
||||
Product ID contained in the Installation ID are randomly selected and
|
||||
differ from the Product ID displayed by Internet Explorer.
|
||||
|
||||
The only argument needed for the '-i' option is the Installation ID,
|
||||
as in
|
||||
|
||||
XPDec -i 002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
|
||||
|
||||
>>>> XPDec -p
|
||||
|
||||
To help you trace the origin of your Product ID, this option decodes a
|
||||
Product Key and displays the Raw Product Key as it would be used in a
|
||||
Product ID.
|
||||
|
||||
The only argument needed for the '-p' option is the Product Key, as in
|
||||
|
||||
XPDec -p FFFFF-GGGGG-HHHHH-JJJJJ-KKKKK
|
||||
|
||||
Note that this option does not verify the digital signature of the
|
||||
Product Key.
|
||||
|
||||
>>>> XPDec -v
|
||||
|
||||
This option calculates the hash of a given volume serial number. It
|
||||
was implemented to illustrate our description of string hashing. First
|
||||
use '-i' to display the hardware bit-fields. Then use this option to
|
||||
verify our claims concerning the volume serial number hash.
|
||||
|
||||
The only argument needed for the '-v' option is the volume serial
|
||||
number of your system volume, as in
|
||||
|
||||
XPDec -v 1234-ABCD
|
||||
|
||||
(The volume serial number is part of the 'dir' command's output.)
|
||||
|
||||
>>>> XPDec -m
|
||||
|
||||
This option calculates the network adapter bit-field value
|
||||
corresponding to the given MAC address. Similar to '-v' this option
|
||||
was implemented as a proof of concept.
|
||||
|
||||
The only argument needed for the '-m' option is the MAC address of
|
||||
your network adapter, as in
|
||||
|
||||
XPDec -m 00-C0-DF-08-9E-44
|
||||
|
||||
(Use the 'route print' command to obtain the MAC address of your
|
||||
network adapter.)
|
||||
|
||||
>> HARDWARE MODIFICATIONS
|
||||
|
||||
When looking at the effects of hardware modifications on an already
|
||||
activated installation of Windows XP, the file 'wpa.dbl' in the
|
||||
'system32' directory plays a central role. It is a simple
|
||||
RC4-encrypted database that stores, among other things like expiration
|
||||
information and the Confirmation ID of an activated installation,
|
||||
|
||||
a) the bit-field values representing the current hardware
|
||||
configuration,
|
||||
|
||||
and
|
||||
|
||||
b) the bit-field values representing the hardware configuration
|
||||
at the time of product activation.
|
||||
|
||||
While a) is automatically updated each time the hardware configuration
|
||||
is modified in order to reflect the changes, b) remains fixed. Hence,
|
||||
b) can be thought of as a snapshot of the hardware configuration at
|
||||
the time of product activation.
|
||||
|
||||
This snapshot does not exist in the database before product activation
|
||||
and if we compare the size of 'wpa.dbl' before and after activation,
|
||||
we will notice an increased file size. This is because the snapshot is
|
||||
added to the database.
|
||||
|
||||
When judging whether re-activation is necessary, the bit-field values
|
||||
of a) are compared to the bit-field values of b), i.e. the current
|
||||
hardware configuration is compared to the hardware configuration at
|
||||
the time of activation.
|
||||
|
||||
>>> Non-dockable computer
|
||||
|
||||
Typically all bit-fields with the exception of the unused field and
|
||||
the 'dockable' field are compared. If more than three of these ten
|
||||
bit-fields have changed in a) since product activation, re-activation
|
||||
is required.
|
||||
|
||||
This means, for example, that in our above real-world example, we
|
||||
could replace the harddrive and the CD-ROM drive and substantially
|
||||
upgrade our RAM without having to re-activate our Windows XP
|
||||
installation.
|
||||
|
||||
However, if we completely re-installed Windows XP, the information in
|
||||
b) would be lost and we would have to re-activate our installation,
|
||||
even if we had not changed our hardware.
|
||||
|
||||
>>> Dockable computer
|
||||
|
||||
If bit 31 of H2 indicates that our computer supports a docking
|
||||
station, however, only seven of the ten bit-fields mentioned above are
|
||||
compared. The bit-fields corresponding to the SCSI host adapter, the
|
||||
IDE controller, and the graphics board are omitted. But again, of
|
||||
these remaining seven bit-fields, only up to three may change without
|
||||
requiring re-activation.
|
||||
|
||||
>> CONCLUSIONS
|
||||
|
||||
In this paper we have given a technical overview of Windows Product
|
||||
Activation as implemented in Windows XP. We have shown what
|
||||
information the data transmitted during product activation is derived
|
||||
from and how hardware upgrades affect an already activated
|
||||
installation.
|
||||
|
||||
Looking at the technical details of WPA, we do not think that it is as
|
||||
problematic as many people have expected. We think so, because WPA is
|
||||
tolerant with respect to hardware modifications. In addition, it is
|
||||
likely that more than one hardware component map to a certain value
|
||||
for a given bit-field. From the above real-world example we know that
|
||||
the PX-32TS maps to the value 0x37 = 55. But there are probably many
|
||||
other CD-ROM drives that map to the same value. Hence, it is
|
||||
impossible to tell from the bit-field value whether it is a PX-32TS
|
||||
that we are using or one of the other drives that map to the same
|
||||
value.
|
||||
|
||||
In contrast to many critics of Windows Product Activation, we think
|
||||
that WPA does not prevent typical hardware modifications and,
|
||||
moreover, respects the user's right to privacy.
|
||||
|
||||
>> ABOUT THE AUTHORS
|
||||
|
||||
Fully Licensed GmbH is a start-up company focusing on novel approaches
|
||||
to online software licensing and distribution. Have a look at their
|
||||
website at
|
||||
|
||||
http://www.licenturion.com
|
||||
|
||||
for more information.
|
||||
|
||||
Their research branch every now and then analyzes licensing solutions
|
||||
implemented by other companies.
|
||||
|
||||
>> COPYRIGHT
|
||||
|
||||
Copyright (C) 2001 Fully Licensed GmbH (www.licenturion.com)
|
||||
All rights reserved.
|
||||
|
||||
You are free to do whatever you want with this paper. However, you
|
||||
have to supply the URL of its online version
|
||||
|
||||
http://www.licenturion.com/xp/
|
||||
|
||||
with any work derived from this paper to give credit to its authors.
|
557
main.cpp
557
main.cpp
@ -1,557 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include <openssl/ec.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define FIELD_BITS 384
|
||||
|
||||
#define FIELD_BYTES 48
|
||||
|
||||
unsigned char cset[] = "BCDFGHJKMPQRTVWXY2346789";
|
||||
|
||||
static void unpack(unsigned long *pid, unsigned long *hash, unsigned long *sig, unsigned long *raw)
|
||||
|
||||
{
|
||||
|
||||
// pid = Bit 0..30
|
||||
|
||||
pid[0] = raw[0] & 0x7fffffff;
|
||||
|
||||
// hash(s) = Bit 31..58
|
||||
|
||||
hash[0] = ((raw[0] >> 31) | (raw[1] << 1)) & 0xfffffff;
|
||||
|
||||
// sig(e) = bit 58..113
|
||||
|
||||
sig[0] = (raw[1] >> 27) | (raw[2] << 5);
|
||||
|
||||
sig[1] = (raw[2] >> 27) | (raw[3] << 5);
|
||||
|
||||
}
|
||||
|
||||
static void pack(unsigned long *raw, unsigned long *pid, unsigned long *hash, unsigned long *sig)
|
||||
|
||||
{
|
||||
|
||||
raw[0] = pid[0] | ((hash[0] & 1) << 31);
|
||||
|
||||
raw[1] = (hash[0] >> 1) | ((sig[0] & 0x1f) << 27);
|
||||
|
||||
raw[2] = (sig[0] >> 5) | (sig[1] << 27);
|
||||
|
||||
raw[3] = sig[1] >> 5;
|
||||
|
||||
}
|
||||
|
||||
// Reverse data
|
||||
|
||||
static void endian(unsigned char *data, int len)
|
||||
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len/2; i++) {
|
||||
|
||||
unsigned char temp;
|
||||
|
||||
temp = data;
|
||||
|
||||
data = data[len-i-1];
|
||||
|
||||
data[len-i-1] = temp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void unbase24(unsigned long *x, unsigned char *c)
|
||||
|
||||
{
|
||||
|
||||
memset(x, 0, 16);
|
||||
|
||||
int i, n;
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
BN_zero(y);
|
||||
|
||||
for (i = 0; i < 25; i++)
|
||||
|
||||
{
|
||||
|
||||
BN_mul_word(y, 24);
|
||||
|
||||
BN_add_word(y, c);
|
||||
|
||||
}
|
||||
|
||||
n = BN_num_bytes(y);
|
||||
|
||||
BN_bn2bin(y, (unsigned char *)x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
endian((unsigned char *)x, n);
|
||||
|
||||
}
|
||||
|
||||
void base24(unsigned char *c, unsigned long *x)
|
||||
|
||||
{
|
||||
|
||||
unsigned char y[16];
|
||||
|
||||
int i;
|
||||
|
||||
BIGNUM *z;
|
||||
|
||||
// Convert x to BigNum z
|
||||
|
||||
memcpy(y, x, sizeof(y)); // Copy X to Y; Y=X
|
||||
|
||||
for (i = 15; y == 0; i--) {} i++; // skip following nulls
|
||||
|
||||
endian(y, i); // Reverse y
|
||||
|
||||
z = BN_bin2bn(y, i, NULL); // Convert y to BigNum z
|
||||
|
||||
// Divide z by 24 and convert remainder with cset to Base24-CDKEY Char
|
||||
|
||||
c[25] = 0;
|
||||
|
||||
for (i = 24; i >= 0; i--) {
|
||||
|
||||
unsigned char t = BN_div_word(z, 24);
|
||||
|
||||
c = cset[t];
|
||||
|
||||
}
|
||||
|
||||
BN_free(z);
|
||||
|
||||
}
|
||||
|
||||
void print_product_id(unsigned long *pid)
|
||||
|
||||
{
|
||||
|
||||
char raw[12];
|
||||
|
||||
char b[6], c[8];
|
||||
|
||||
int i, digit = 0;
|
||||
|
||||
// Cut a away last bit of pid and convert it to an accii-number (=raw)
|
||||
|
||||
sprintf(raw, "%d", pid[0] >> 1);
|
||||
|
||||
// Make b-part {640-....}
|
||||
|
||||
strncpy(b, raw, 3);
|
||||
|
||||
b[3] = 0;
|
||||
|
||||
// Make c-part {...-123456X...}
|
||||
|
||||
strcpy(c, raw + 3);
|
||||
|
||||
// Make checksum digit-part {...56X-}
|
||||
|
||||
assert(strlen© == 6);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
|
||||
digit -= c - '0'; // Sum digits
|
||||
|
||||
while (digit < 0)
|
||||
|
||||
digit += 7;
|
||||
|
||||
c[6] = digit + '0';
|
||||
|
||||
c[7] = 0;
|
||||
|
||||
printf("Product ID: 55274-%s-%s-23xxx\n", b, c);
|
||||
|
||||
}
|
||||
|
||||
void print_product_key(unsigned char *pk)
|
||||
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
assert(strlen((const char *)pk) == 25);
|
||||
|
||||
for (i = 0; i < 25; i++) {
|
||||
|
||||
putchar(pk);
|
||||
|
||||
if (i != 24 && i % 5 == 4) putchar('-');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void verify(EC_GROUP *ec, EC_POINT *generator, EC_POINT *public_key, char *cdkey)
|
||||
|
||||
{
|
||||
|
||||
unsigned char key[25];
|
||||
|
||||
int i, j, k;
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
// remove Dashs from CDKEY
|
||||
|
||||
for (i = 0, k = 0; i < strlen(cdkey); i++) {
|
||||
|
||||
for (j = 0; j < 24; j++) {
|
||||
|
||||
if (cdkey != '-' && cdkey == cset[j]) {
|
||||
|
||||
key[k++] = j;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
assert(j < 24);
|
||||
|
||||
}
|
||||
|
||||
if (k >= 25) break;
|
||||
|
||||
}
|
||||
|
||||
// Base24_CDKEY -> Bin_CDKEY
|
||||
|
||||
unsigned long bkey[4] = {0};
|
||||
|
||||
unsigned long pid[1], hash[1], sig[2];
|
||||
|
||||
unbase24(bkey, key);
|
||||
|
||||
// Output Bin_CDKEY
|
||||
|
||||
printf("%.8x %.8x %.8x %.8x\n", bkey[3], bkey[2], bkey[1], bkey[0]);
|
||||
|
||||
// Divide/Extract pid_data, hash, sig from Bin_CDKEY
|
||||
|
||||
unpack(pid, hash, sig, bkey);
|
||||
|
||||
print_product_id(pid);
|
||||
|
||||
printf("PID: %.8x\nHash: %.8x\nSig: %.8x %.8x\n", pid[0], hash[0], sig[1], sig[0]);
|
||||
|
||||
BIGNUM *e, *s;
|
||||
|
||||
/* e = hash, s = sig */
|
||||
|
||||
e = BN_new();
|
||||
|
||||
BN_set_word(e, hash[0]);
|
||||
|
||||
endian((unsigned char *)sig, sizeof(sig));
|
||||
|
||||
s = BN_bin2bn((unsigned char *)sig, sizeof(sig), NULL);
|
||||
|
||||
BIGNUM *x = BN_new();
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
EC_POINT *u = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT *v = EC_POINT_new(ec);
|
||||
|
||||
/* v = s*generator + e*(-public_key) */
|
||||
|
||||
EC_POINT_mul(ec, u, NULL, generator, s, ctx);
|
||||
|
||||
EC_POINT_mul(ec, v, NULL, public_key, e, ctx);
|
||||
|
||||
EC_POINT_add(ec, v, u, v, ctx);
|
||||
|
||||
EC_POINT_get_affine_coordinates_GFp(ec, v, x, y, ctx);
|
||||
|
||||
unsigned char buf[FIELD_BYTES], md[20];
|
||||
|
||||
unsigned long h;
|
||||
|
||||
unsigned char t[4];
|
||||
|
||||
SHA_CTX h_ctx;
|
||||
|
||||
/* h = (fist 32 bits of SHA1(pid || v.x, v.y)) >> 4 */
|
||||
|
||||
SHA1_Init(&h_ctx);
|
||||
|
||||
t[0] = pid[0] & 0xff;
|
||||
|
||||
t[1] = (pid[0] & 0xff00) >> 8;
|
||||
|
||||
t[2] = (pid[0] & 0xff0000) >> 16;
|
||||
|
||||
t[3] = (pid[0] & 0xff000000) >> 24;
|
||||
|
||||
SHA1_Update(&h_ctx, t, sizeof(t));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(x, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(y, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
SHA1_Final(md, &h_ctx);
|
||||
|
||||
h = (md[0] | (md[1] << 8) | (md[2] << 16) | (md[3] << 24)) >> 4;
|
||||
|
||||
h &= 0xfffffff;
|
||||
|
||||
printf("Calculated hash: %.8x\n", h);
|
||||
|
||||
if (h == hash[0]) printf("Key valid\n");
|
||||
|
||||
else printf("Key invalid\n");
|
||||
|
||||
putchar('\n');
|
||||
|
||||
BN_free(e);
|
||||
|
||||
BN_free(s);
|
||||
|
||||
BN_free(x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
EC_POINT_free(u);
|
||||
|
||||
EC_POINT_free(v);
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
}
|
||||
|
||||
void generate(unsigned char *pkey, EC_GROUP *ec, EC_POINT *generator, BIGNUM *order, BIGNUM *priv, unsigned long *pid)
|
||||
|
||||
{
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
BIGNUM *k = BN_new();
|
||||
|
||||
BIGNUM *s = BN_new();
|
||||
|
||||
BIGNUM *x = BN_new();
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
EC_POINT *r = EC_POINT_new(ec);
|
||||
|
||||
unsigned long bkey[4];
|
||||
|
||||
// Loop in case signaturepart will make cdkey(base-24 "digits") longer than 25
|
||||
|
||||
do {
|
||||
|
||||
BN_pseudo_rand(k, FIELD_BITS, -1, 0);
|
||||
|
||||
EC_POINT_mul(ec, r, NULL, generator, k, ctx);
|
||||
|
||||
EC_POINT_get_affine_coordinates_GFp(ec, r, x, y, ctx);
|
||||
|
||||
SHA_CTX h_ctx;
|
||||
|
||||
unsigned char t[4], md[20], buf[FIELD_BYTES];
|
||||
|
||||
unsigned long hash[1];
|
||||
|
||||
/* h = (fist 32 bits of SHA1(pid || r.x, r.y)) >> 4 */
|
||||
|
||||
SHA1_Init(&h_ctx);
|
||||
|
||||
t[0] = pid[0] & 0xff;
|
||||
|
||||
t[1] = (pid[0] & 0xff00) >> 8;
|
||||
|
||||
t[2] = (pid[0] & 0xff0000) >> 16;
|
||||
|
||||
t[3] = (pid[0] & 0xff000000) >> 24;
|
||||
|
||||
SHA1_Update(&h_ctx, t, sizeof(t));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(x, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(y, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
SHA1_Final(md, &h_ctx);
|
||||
|
||||
hash[0] = (md[0] | (md[1] << 8) | (md[2] << 16) | (md[3] << 24)) >> 4;
|
||||
|
||||
hash[0] &= 0xfffffff;
|
||||
|
||||
/* s = priv*h + k */
|
||||
|
||||
BN_copy(s, priv);
|
||||
|
||||
BN_mul_word(s, hash[0]);
|
||||
|
||||
BN_mod_add(s, s, k, order, ctx);
|
||||
|
||||
unsigned long sig[2] = {0};
|
||||
|
||||
BN_bn2bin(s, (unsigned char *)sig);
|
||||
|
||||
endian((unsigned char *)sig, BN_num_bytes(s));
|
||||
|
||||
pack(bkey, pid, hash, sig);
|
||||
|
||||
printf("PID: %.8x\nHash: %.8x\nSig: %.8x %.8x\n", pid[0], hash[0], sig[1], sig[0]);
|
||||
|
||||
} while (bkey[3] >= 0x62a32);
|
||||
|
||||
base24(pkey, bkey);
|
||||
|
||||
BN_free(k);
|
||||
|
||||
BN_free(s);
|
||||
|
||||
BN_free(x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
EC_POINT_free®;
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
|
||||
// Init
|
||||
|
||||
BIGNUM *a, *b, *p, *gx, *gy, *pubx, *puby, *n, *priv;
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
// make BigNumbers
|
||||
|
||||
a = BN_new();
|
||||
|
||||
b = BN_new();
|
||||
|
||||
p = BN_new();
|
||||
|
||||
gx = BN_new();
|
||||
|
||||
gy = BN_new();
|
||||
|
||||
pubx = BN_new();
|
||||
|
||||
puby = BN_new();
|
||||
|
||||
n = BN_new();
|
||||
|
||||
priv = BN_new();
|
||||
|
||||
// Data from pidgen-Bink-resources
|
||||
|
||||
/* Elliptic curve parameters: y^2 = x^3 + ax + b mod p */
|
||||
|
||||
BN_hex2bn(&p, "92ddcf14cb9e71f4489a2e9ba350ae29454d98cb93bdbcc07d62b502ea12238ee904a8b20d017197aae0c103b32713a9");
|
||||
|
||||
BN_set_word(a, 1);
|
||||
|
||||
BN_set_word(b, 0);
|
||||
|
||||
/* base point (generator) G */
|
||||
|
||||
BN_hex2bn(&gx, "46E3775ECE21B0898D39BEA57050D422A0AF989E497962BAEE2CB17E0A28D5360D5476B8DC966443E37A14F1AEF37742");
|
||||
|
||||
BN_hex2bn(&gy, "7C8E741D2C34F4478E325469CD491603D807222C9C4AC09DDB2B31B3CE3F7CC191B3580079932BC6BEF70BE27604F65E");
|
||||
|
||||
/* inverse of public key */
|
||||
|
||||
BN_hex2bn(&pubx, "5D8DBE75198015EC41C45AAB6143542EB098F6A5CC9CE4178A1B8A1E7ABBB5BC64DF64FAF6177DC1B0988AB00BA94BF8");
|
||||
|
||||
BN_hex2bn(&puby, "23A2909A0B4803C89F910C7191758B48746CEA4D5FF07667444ACDB9512080DBCA55E6EBF30433672B894F44ACE92BFA");
|
||||
|
||||
// Computed data
|
||||
|
||||
/* order of G - computed in 18 hours using a P3-450 */
|
||||
|
||||
BN_hex2bn(&n, "DB6B4C58EFBAFD");
|
||||
|
||||
/* THE private key - computed in 10 hours using a P3-450 */
|
||||
|
||||
BN_hex2bn(&priv, "565B0DFF8496C8");
|
||||
|
||||
// Calculation
|
||||
|
||||
EC_GROUP *ec = EC_GROUP_new_curve_GFp(p, a, b, ctx);
|
||||
|
||||
EC_POINT *g = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT_set_affine_coordinates_GFp(ec, g, gx, gy, ctx);
|
||||
|
||||
EC_POINT *pub = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT_set_affine_coordinates_GFp(ec, pub, pubx, puby, ctx);
|
||||
|
||||
unsigned char pkey[26];
|
||||
|
||||
unsigned long pid[1];
|
||||
|
||||
pid[0] = 640000000 << 1; /* <- change */
|
||||
|
||||
// generate a key
|
||||
|
||||
generate(pkey, ec, g, n, priv, pid);
|
||||
|
||||
print_product_key(pkey); printf("\n\n");
|
||||
|
||||
// verify the key
|
||||
|
||||
verify(ec, g, pub, (char*)pkey);
|
||||
|
||||
// Cleanup
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
606
src/cli.cpp
Normal file
606
src/cli.cpp
Normal file
@ -0,0 +1,606 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
CLI::~CLI()
|
||||
{
|
||||
EC_GROUP_free(eCurve);
|
||||
EC_POINT_free(genPoint);
|
||||
EC_POINT_free(pubPoint);
|
||||
BN_free(privateKey);
|
||||
BN_free(genOrder);
|
||||
}
|
||||
|
||||
bool CLI::loadJSON(const fs::path& filename, json *output) {
|
||||
if (!filename.empty() && !fs::exists(filename)) {
|
||||
fmt::print("ERROR: File {} does not exist\n", filename.string());
|
||||
return false;
|
||||
}
|
||||
else if (fs::exists(filename)) {
|
||||
std::ifstream f(filename);
|
||||
*output = json::parse(f, nullptr, false, false);
|
||||
}
|
||||
else if (filename.empty()) {
|
||||
cmrc::embedded_filesystem fs = cmrc::umskt::get_filesystem();
|
||||
cmrc::file keys = fs.open("keys.json");
|
||||
*output = json::parse(keys, nullptr, false, false);
|
||||
}
|
||||
|
||||
if (output->is_discarded()) {
|
||||
fmt::print("ERROR: Unable to parse keys from {}\n", filename.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CLI::showHelp(char *argv[]) {
|
||||
fmt::print("usage: {} \n", argv[0]);
|
||||
fmt::print("\t-h --help\tshow this message\n");
|
||||
fmt::print("\t-v --verbose\tenable verbose output\n");
|
||||
fmt::print("\t-n --number\tnumber of keys to generate (defaults to 1)\n");
|
||||
fmt::print("\t-f --file\tspecify which keys file to load\n");
|
||||
fmt::print("\t-i --instid\tinstallation ID used to generate confirmation ID\n");
|
||||
fmt::print("\t-m --mode\tproduct family to activate.\n\t\t\tvalid options are \"WINDOWS\", \"OFFICEXP\", \"OFFICE2K3\", \"OFFICE2K7\" or \"PLUSDME\"\n\t\t\t(defaults to \"WINDOWS\")\n");
|
||||
fmt::print("\t-p --productid\tthe product ID of the Program to activate. only required for Office 2K3 and Office 2K7 programs\n");
|
||||
fmt::print("\t-b --binkid\tspecify which BINK identifier to load (defaults to 2E)\n");
|
||||
fmt::print("\t-l --list\tshow which products/binks can be loaded\n");
|
||||
fmt::print("\t-c --channelid\tspecify which Channel Identifier to use (defaults to 640)\n");
|
||||
fmt::print("\t-s --serial\tspecifies a serial to use in the product ID (defaults to random, BINK1998 only)\n");
|
||||
fmt::print("\t-u --upgrade\tspecifies the Product Key will be an \"Upgrade\" version\n");
|
||||
fmt::print("\t-V --validate\tproduct key to validate signature\n");
|
||||
fmt::print("\t-N --nonewlines\tdisables newlines (for easier embedding in other apps)\n");
|
||||
fmt::print("\t-o --override\tDisables version check for confirmation ID's, if you need this send an issue on GitHub");
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
int CLI::parseCommandLine(int argc, char* argv[], Options* options) {
|
||||
// set default options
|
||||
*options = Options {
|
||||
"2E",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
640,
|
||||
0,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
MODE_BINK1998_GENERATE,
|
||||
WINDOWS
|
||||
};
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string arg = argv[i];
|
||||
if (arg == "-v" || arg == "--verbose") {
|
||||
options->verbose = true;
|
||||
UMSKT::setDebugOutput(stderr);
|
||||
} else if (arg == "-h" || arg == "--help") {
|
||||
options->help = true;
|
||||
} else if (arg == "-n" || arg == "--number") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
int nKeys;
|
||||
if (!sscanf(argv[i+1], "%d", &nKeys)) {
|
||||
options->error = true;
|
||||
} else {
|
||||
options->numKeys = nKeys;
|
||||
}
|
||||
i++;
|
||||
} else if (arg == "-b" || arg == "--bink") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
options->binkid = argv[i+1];
|
||||
i++;
|
||||
} else if (arg == "-l" || arg == "--list") {
|
||||
options->list = true;
|
||||
} else if (arg == "-c" || arg == "--channelid") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
int siteID;
|
||||
if (!sscanf(argv[i+1], "%d", &siteID)) {
|
||||
options->error = true;
|
||||
} else {
|
||||
options->channelID = siteID;
|
||||
}
|
||||
i++;
|
||||
} else if (arg == "-s" || arg == "--serial") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
int serial_val;
|
||||
if (!sscanf(argv[i+1], "%d", &serial_val)) {
|
||||
options->error = true;
|
||||
} else {
|
||||
options->serialSet = true;
|
||||
options->serial = serial_val;
|
||||
}
|
||||
i++;
|
||||
} else if (arg == "-u" || arg == "--upgrade") {
|
||||
options->upgrade = true;
|
||||
} else if (arg == "-f" || arg == "--file") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
options->keysFilename = argv[i+1];
|
||||
i++;
|
||||
} else if (arg == "-i" || arg == "--instid") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
options->instid = argv[i+1];
|
||||
options->applicationMode = MODE_CONFIRMATION_ID;
|
||||
i++;
|
||||
} else if (arg == "-m" || arg == "--mode") {
|
||||
std::string mode = argv[i+1];
|
||||
char *p = &mode[0];
|
||||
for (; *p; p++) {
|
||||
*p = toupper((unsigned char)*p);
|
||||
}
|
||||
p = &mode[0];
|
||||
if (strcmp(p, "WINDOWS") == 0) {
|
||||
options->activationMode = WINDOWS;
|
||||
} else if (strcmp(p, "OFFICEXP") == 0) {
|
||||
options->activationMode = OFFICE_XP;
|
||||
} else if (strcmp(p, "OFFICE2K3") == 0) {
|
||||
options->activationMode = OFFICE_2K3;
|
||||
} else if (strcmp(p, "OFFICE2K7") == 0) {
|
||||
options->activationMode = OFFICE_2K7;
|
||||
} else if (strcmp(p, "PLUSDME") == 0) {
|
||||
options->activationMode = PLUS_DME;
|
||||
}
|
||||
i++;
|
||||
} else if (arg == "-p" || arg == "--productid") {
|
||||
if (i == argc -1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
options->productid = argv[i+1];
|
||||
i++;
|
||||
} else if (arg == "-V" || arg == "--validate") {
|
||||
if (i == argc - 1) {
|
||||
options->error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
options->keyToCheck = argv[i+1];
|
||||
options->applicationMode = MODE_BINK1998_VALIDATE;
|
||||
i++;
|
||||
|
||||
} else if (arg == "-N" || arg == "--nonewlines") {
|
||||
options->nonewlines = true;
|
||||
} else if (arg == "-o" || arg == "--override") {
|
||||
options->overrideVersion = true;
|
||||
} else {
|
||||
options->error = true;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure that a product id is entered for OFFICE_2K3 or OFFICE_2K7 IIDs
|
||||
if ((options->activationMode == OFFICE_2K3 || options->activationMode == OFFICE_2K7) && (options->productid.empty() || options->instid.empty()) ) {
|
||||
return options->error = true;
|
||||
}
|
||||
|
||||
return !options->error;
|
||||
}
|
||||
|
||||
int CLI::validateCommandLine(Options* options, char *argv[], json *keys) {
|
||||
if (options->help || options->error) {
|
||||
if (options->error) {
|
||||
fmt::print("error parsing command line options\n");
|
||||
}
|
||||
showHelp(argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (options->verbose) {
|
||||
if(options->keysFilename.empty()) {
|
||||
fmt::print("Loading internal keys file\n");
|
||||
} else {
|
||||
fmt::print("Loading keys file {}\n", options->keysFilename);
|
||||
}
|
||||
}
|
||||
|
||||
if (!loadJSON(options->keysFilename, keys)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (options->verbose) {
|
||||
if(options->keysFilename.empty()) {
|
||||
fmt::print("Loaded internal keys file successfully\n");
|
||||
} else {
|
||||
fmt::print("Loaded keys from {} successfully\n",options->keysFilename);
|
||||
}
|
||||
}
|
||||
|
||||
if (options->list) {
|
||||
for (auto el : (*keys)["Products"].items()) {
|
||||
int id;
|
||||
sscanf((el.value()["BINK"][0]).get<std::string>().c_str(), "%x", &id);
|
||||
std::cout << el.key() << ": " << el.value()["BINK"] << std::endl;
|
||||
}
|
||||
|
||||
fmt::print("\n\n");
|
||||
fmt::print("** Please note: any BINK ID other than 2E is considered experimental at this time **\n");
|
||||
fmt::print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int intBinkID;
|
||||
sscanf(options->binkid.c_str(), "%x", &intBinkID);
|
||||
|
||||
// FE and FF are BINK 1998, but do not generate valid keys, so we throw an error
|
||||
if (intBinkID >= 0xFE) {
|
||||
fmt::print("ERROR: Terminal Services BINKs (FE and FF) are unsupported at this time\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (intBinkID >= 0x40) {
|
||||
// set bink2002 validate mode if in bink1998 validate mode, else set bink2002 generate mode
|
||||
options->applicationMode = (options->applicationMode == MODE_BINK1998_VALIDATE) ? MODE_BINK2002_VALIDATE : MODE_BINK2002_GENERATE;
|
||||
}
|
||||
|
||||
if (options->channelID > 999) {
|
||||
fmt::print("ERROR: refusing to create a key with a Channel ID greater than 999\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// don't allow any serial not between 0 and 999999
|
||||
if (options->serial > 999999 || options->serial < 0) {
|
||||
fmt::print("ERROR: refusing to create a key with a Serial not between 000000 and 999999\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CLI::printID(DWORD *pid) {
|
||||
char raw[12];
|
||||
char b[6], c[8];
|
||||
int i, digit = 0;
|
||||
|
||||
// Convert PID to ascii-number (=raw)
|
||||
snprintf(raw, sizeof(raw), "%09u", pid[0]);
|
||||
|
||||
// Make b-part {640-....}
|
||||
strncpy(b, raw, 3);
|
||||
b[3] = 0;
|
||||
|
||||
// Make c-part {...-123456X...}
|
||||
strcpy(c, raw + 3);
|
||||
|
||||
// Make checksum digit-part {...56X-}
|
||||
assert(strlen(c) == 6);
|
||||
for (i = 0; i < 6; i++)
|
||||
digit -= c[i] - '0'; // Sum digits
|
||||
|
||||
while (digit < 0)
|
||||
digit += 7;
|
||||
c[6] = digit + '0';
|
||||
c[7] = 0;
|
||||
|
||||
fmt::print("> Product ID: PPPPP-{}-{}-23xxx\n", b, c);
|
||||
}
|
||||
|
||||
void CLI::printKey(char *pk) {
|
||||
assert(strlen(pk) >= PK_LENGTH);
|
||||
|
||||
std::string spk = pk;
|
||||
fmt::print("{}-{}-{}-{}-{}",
|
||||
spk.substr(0,5),
|
||||
spk.substr(5,5),
|
||||
spk.substr(10,5),
|
||||
spk.substr(15,5),
|
||||
spk.substr(20,5));
|
||||
}
|
||||
|
||||
bool CLI::stripKey(const char *in_key, char out_key[PK_LENGTH]) {
|
||||
// copy out the product key stripping out extraneous characters
|
||||
const char *p = in_key;
|
||||
size_t i = 0;
|
||||
for (; *p; p++) {
|
||||
// strip out space or dash
|
||||
if (*p == ' ' || *p == '-')
|
||||
continue;
|
||||
// check if we've passed the product key length to avoid overflow
|
||||
if (i >= PK_LENGTH)
|
||||
return false;
|
||||
// convert to uppercase - if character allowed, copy into array
|
||||
for (int j = 0; j < strlen(PIDGEN3::pKeyCharset); j++) {
|
||||
if (toupper(*p) == PIDGEN3::pKeyCharset[j]) {
|
||||
out_key[i++] = toupper(*p);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// only return true if we've handled exactly PK_LENGTH chars
|
||||
return (i == PK_LENGTH);
|
||||
}
|
||||
|
||||
CLI::CLI(Options options, json keys) {
|
||||
this->options = options;
|
||||
this->keys = keys;
|
||||
|
||||
this->BINKID = options.binkid.c_str();
|
||||
|
||||
// We cannot produce a valid key without knowing the private key k. The reason for this is that
|
||||
// we need the result of the function K(x; y) = kG(x; y).
|
||||
this->privateKey = BN_new();
|
||||
|
||||
// We can, however, validate any given key using the available public key: {p, a, b, G, K}.
|
||||
// genOrder the order of the generator G, a value we have to reverse -> Schoof's Algorithm.
|
||||
this->genOrder = BN_new();
|
||||
|
||||
/* Computed data */
|
||||
BN_dec2bn(&this->genOrder, this->keys["BINK"][this->BINKID]["n"]. get<std::string>().c_str());
|
||||
BN_dec2bn(&this->privateKey, this->keys["BINK"][this->BINKID]["priv"].get<std::string>().c_str());
|
||||
|
||||
if (options.verbose) {
|
||||
fmt::print("----------------------------------------------------------- \n");
|
||||
fmt::print("Loaded the following elliptic curve parameters: BINK[{}]\n", this->BINKID);
|
||||
fmt::print("----------------------------------------------------------- \n");
|
||||
fmt::print(" P: {}\n", this->keys["BINK"][this->BINKID]["p"].get<std::string>());
|
||||
fmt::print(" a: {}\n", this->keys["BINK"][this->BINKID]["a"].get<std::string>());
|
||||
fmt::print(" b: {}\n", this->keys["BINK"][this->BINKID]["b"].get<std::string>());
|
||||
fmt::print("Gx: {}\n", this->keys["BINK"][this->BINKID]["g"]["x"].get<std::string>());
|
||||
fmt::print("Gy: {}\n", this->keys["BINK"][this->BINKID]["g"]["y"].get<std::string>());
|
||||
fmt::print("Kx: {}\n", this->keys["BINK"][this->BINKID]["pub"]["x"].get<std::string>());
|
||||
fmt::print("Ky: {}\n", this->keys["BINK"][this->BINKID]["pub"]["y"].get<std::string>());
|
||||
fmt::print(" n: {}\n", this->keys["BINK"][this->BINKID]["n"].get<std::string>());
|
||||
fmt::print(" k: {}\n", this->keys["BINK"][this->BINKID]["priv"].get<std::string>());
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
|
||||
eCurve = PIDGEN3::initializeEllipticCurve(
|
||||
this->keys["BINK"][this->BINKID]["p"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["a"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["b"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["g"]["x"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["g"]["y"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["pub"]["x"].get<std::string>(),
|
||||
this->keys["BINK"][this->BINKID]["pub"]["y"].get<std::string>(),
|
||||
this->genPoint,
|
||||
this->pubPoint
|
||||
);
|
||||
|
||||
this->count = 0;
|
||||
this->total = this->options.numKeys;
|
||||
}
|
||||
|
||||
int CLI::BINK1998Generate() {
|
||||
// raw PID/serial value
|
||||
DWORD nRaw = this->options.channelID * 1'000'000 ; /* <- change */
|
||||
|
||||
// using user-provided serial
|
||||
if (this->options.serialSet) {
|
||||
// just in case, make sure it's less than 999999
|
||||
int serialRnd = (this->options.serial % 999999);
|
||||
nRaw += serialRnd;
|
||||
} else {
|
||||
// generate a random number to use as a serial
|
||||
BIGNUM *bnrand = BN_new();
|
||||
BN_rand(bnrand, 19, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
|
||||
int oRaw;
|
||||
char *cRaw = BN_bn2dec(bnrand);
|
||||
|
||||
sscanf(cRaw, "%d", &oRaw);
|
||||
nRaw += (oRaw % 999999); // ensure our serial is less than 999999
|
||||
BN_free(bnrand);
|
||||
}
|
||||
|
||||
if (this->options.verbose) {
|
||||
// print the resulting Product ID
|
||||
// PID value is printed in BINK1998::Generate
|
||||
printID(&nRaw);
|
||||
}
|
||||
|
||||
// generate a key
|
||||
BN_sub(this->privateKey, this->genOrder, this->privateKey);
|
||||
|
||||
for (int i = 0; i < this->total; i++) {
|
||||
PIDGEN3::BINK1998::Generate(this->eCurve, this->genPoint, this->genOrder, this->privateKey, nRaw, options.upgrade, this->pKey);
|
||||
|
||||
bool isValid = PIDGEN3::BINK1998::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
|
||||
if (isValid) {
|
||||
CLI::printKey(this->pKey);
|
||||
if (i < this->total - 1 || this->options.verbose) {
|
||||
fmt::print("\n");
|
||||
}
|
||||
this->count += isValid;
|
||||
}
|
||||
else {
|
||||
if (this->options.verbose) {
|
||||
CLI::printKey(this->pKey);
|
||||
fmt::print(" [Invalid]");
|
||||
if (i < this->total - 1) {
|
||||
fmt::print("\n");
|
||||
}
|
||||
}
|
||||
this->total++; // queue a redo, basically
|
||||
}
|
||||
}
|
||||
|
||||
if (this->options.verbose) {
|
||||
fmt::print("\nSuccess count: {}/{}", this->count, this->total);
|
||||
}
|
||||
if (this->options.nonewlines == false) {
|
||||
fmt::print("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLI::BINK2002Generate() {
|
||||
DWORD pChannelID = this->options.channelID;
|
||||
|
||||
if (this->options.verbose) {
|
||||
fmt::print("> Channel ID: {:03d}\n", this->options.channelID);
|
||||
}
|
||||
|
||||
// generate a key
|
||||
for (int i = 0; i < this->total; i++) {
|
||||
DWORD pAuthInfo;
|
||||
RAND_bytes((BYTE *)&pAuthInfo, 4);
|
||||
pAuthInfo &= BITMASK(10);
|
||||
|
||||
if (this->options.verbose) {
|
||||
fmt::print("> AuthInfo: {}\n", pAuthInfo);
|
||||
}
|
||||
|
||||
PIDGEN3::BINK2002::Generate(this->eCurve, this->genPoint, this->genOrder, this->privateKey, pChannelID, pAuthInfo, options.upgrade, this->pKey);
|
||||
|
||||
bool isValid = PIDGEN3::BINK2002::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
|
||||
if (isValid) {
|
||||
CLI::printKey(this->pKey);
|
||||
if (i < this->total - 1 || this->options.verbose) { // check if end of list or verbose
|
||||
fmt::print("\n");
|
||||
}
|
||||
this->count += isValid; // add to count
|
||||
}
|
||||
else {
|
||||
if (this->options.verbose) {
|
||||
CLI::printKey(this->pKey); // print the key
|
||||
fmt::print(" [Invalid]"); // and add " [Invalid]" to the key
|
||||
if (i < this->total - 1) { // check if end of list
|
||||
fmt::print("\n");
|
||||
}
|
||||
}
|
||||
this->total++; // queue a redo, basically
|
||||
}
|
||||
}
|
||||
|
||||
if (this->options.verbose) {
|
||||
fmt::print("\nSuccess count: {}/{}", this->count, this->total);
|
||||
}
|
||||
if (this->options.nonewlines == false) {
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLI::BINK1998Validate() {
|
||||
char product_key[PK_LENGTH]{};
|
||||
|
||||
if (!CLI::stripKey(this->options.keyToCheck.c_str(), product_key)) {
|
||||
fmt::print("ERROR: Product key is in an incorrect format!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CLI::printKey(product_key);
|
||||
fmt::print("\n");
|
||||
if (!PIDGEN3::BINK1998::Verify(this->eCurve, this->genPoint, this->pubPoint, product_key)) {
|
||||
fmt::print("ERROR: Product key is invalid! Wrong BINK ID?\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fmt::print("Key validated successfully!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLI::BINK2002Validate() {
|
||||
char product_key[PK_LENGTH]{};
|
||||
|
||||
if (!CLI::stripKey(this->options.keyToCheck.c_str(), product_key)) {
|
||||
fmt::print("ERROR: Product key is in an incorrect format!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CLI::printKey(product_key);
|
||||
fmt::print("\n");
|
||||
if (!PIDGEN3::BINK2002::Verify(this->eCurve, this->genPoint, this->pubPoint, product_key)) {
|
||||
fmt::print("ERROR: Product key is invalid! Wrong BINK ID?\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fmt::print("Key validated successfully!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLI::ConfirmationID() {
|
||||
char confirmation_id[49];
|
||||
int err = ConfirmationID::Generate(this->options.instid.c_str(), confirmation_id, options.activationMode, options.productid, options.overrideVersion);
|
||||
|
||||
switch (err) {
|
||||
case ERR_TOO_SHORT:
|
||||
fmt::print("ERROR: Installation ID is too short.\n");
|
||||
return 1;
|
||||
|
||||
case ERR_TOO_LARGE:
|
||||
fmt::print("ERROR: Installation ID is too long.\n");
|
||||
return 1;
|
||||
|
||||
case ERR_INVALID_CHARACTER:
|
||||
fmt::print("ERROR: Invalid character in installation ID.\n");
|
||||
return 1;
|
||||
|
||||
case ERR_INVALID_CHECK_DIGIT:
|
||||
fmt::print("ERROR: Installation ID checksum failed. Please check that it is typed correctly.\n");
|
||||
return 1;
|
||||
|
||||
case ERR_UNKNOWN_VERSION:
|
||||
fmt::print("ERROR: Unknown installation ID version.\n");
|
||||
return 1;
|
||||
|
||||
case ERR_UNLUCKY:
|
||||
fmt::print("ERROR: Unable to generate valid confirmation ID.\n");
|
||||
return 1;
|
||||
|
||||
case SUCCESS:
|
||||
fmt::print(confirmation_id);
|
||||
if (this->options.nonewlines == false) {
|
||||
fmt::print("\n");
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
fmt::print("Unknown error occurred during Confirmation ID generation: {}\n", err);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
106
src/cli.h
Normal file
106
src/cli.h
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/6/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_CLI_H
|
||||
#define UMSKT_CLI_H
|
||||
|
||||
#include "header.h"
|
||||
|
||||
#include <cmrc/cmrc.hpp>
|
||||
|
||||
#include "libumskt/libumskt.h"
|
||||
#include "libumskt/pidgen2/PIDGEN2.h"
|
||||
#include "libumskt/pidgen3/PIDGEN3.h"
|
||||
#include "libumskt/pidgen3/BINK1998.h"
|
||||
#include "libumskt/pidgen3/BINK2002.h"
|
||||
#include "libumskt/confid/confid.h"
|
||||
|
||||
CMRC_DECLARE(umskt);
|
||||
|
||||
enum ACTIVATION_ALGORITHM {
|
||||
WINDOWS = 0,
|
||||
OFFICE_XP = 1,
|
||||
OFFICE_2K3 = 2,
|
||||
OFFICE_2K7 = 3,
|
||||
PLUS_DME = 4,
|
||||
};
|
||||
|
||||
enum MODE {
|
||||
MODE_BINK1998_GENERATE = 0,
|
||||
MODE_BINK2002_GENERATE = 1,
|
||||
MODE_CONFIRMATION_ID = 2,
|
||||
MODE_BINK1998_VALIDATE = 3,
|
||||
MODE_BINK2002_VALIDATE = 4,
|
||||
};
|
||||
|
||||
struct Options {
|
||||
std::string binkid;
|
||||
std::string keysFilename;
|
||||
std::string instid;
|
||||
std::string keyToCheck;
|
||||
std::string productid;
|
||||
int channelID;
|
||||
int serial;
|
||||
int numKeys;
|
||||
bool upgrade;
|
||||
bool serialSet;
|
||||
bool verbose;
|
||||
bool help;
|
||||
bool error;
|
||||
bool list;
|
||||
bool nonewlines;
|
||||
bool overrideVersion;
|
||||
|
||||
MODE applicationMode;
|
||||
ACTIVATION_ALGORITHM activationMode;
|
||||
};
|
||||
|
||||
class CLI {
|
||||
Options options;
|
||||
json keys;
|
||||
const char* BINKID;
|
||||
BIGNUM *privateKey, *genOrder;
|
||||
EC_POINT *genPoint, *pubPoint;
|
||||
EC_GROUP *eCurve;
|
||||
char pKey[25];
|
||||
int count, total;
|
||||
|
||||
public:
|
||||
CLI(Options options, json keys);
|
||||
~CLI();
|
||||
|
||||
static bool loadJSON(const fs::path& filename, json *output);
|
||||
static void showHelp(char *argv[]);
|
||||
static int parseCommandLine(int argc, char* argv[], Options *options);
|
||||
static int validateCommandLine(Options* options, char *argv[], json *keys);
|
||||
static void printID(DWORD *pid);
|
||||
static void printKey(char *pk);
|
||||
static bool stripKey(const char *in_key, char out_key[PK_LENGTH]);
|
||||
|
||||
int BINK1998Generate();
|
||||
int BINK2002Generate();
|
||||
int BINK1998Validate();
|
||||
int BINK2002Validate();
|
||||
int ConfirmationID();
|
||||
};
|
||||
|
||||
#endif //UMSKT_CLI_H
|
41
src/header.h
Normal file
41
src/header.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 5/26/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_HEADER_H
|
||||
#define UMSKT_HEADER_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#endif //UMSKT_HEADER_H
|
1073
src/libumskt/confid/confid.cpp
Normal file
1073
src/libumskt/confid/confid.cpp
Normal file
File diff suppressed because it is too large
Load Diff
73
src/libumskt/confid/confid.h
Normal file
73
src/libumskt/confid/confid.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/6/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_CONFID_H
|
||||
#define UMSKT_CONFID_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
// Confirmation ID generator constants
|
||||
#define SUCCESS 0
|
||||
#define ERR_TOO_SHORT 1
|
||||
#define ERR_TOO_LARGE 2
|
||||
#define ERR_INVALID_CHARACTER 3
|
||||
#define ERR_INVALID_CHECK_DIGIT 4
|
||||
#define ERR_UNKNOWN_VERSION 5
|
||||
#define ERR_UNLUCKY 6
|
||||
|
||||
|
||||
typedef struct {
|
||||
QWORD u[2];
|
||||
QWORD v[2];
|
||||
} TDivisor;
|
||||
|
||||
EXPORT class ConfirmationID {
|
||||
static int calculateCheckDigit(int pid);
|
||||
static QWORD residue_add(QWORD x, QWORD y);
|
||||
static QWORD residue_sub(QWORD x, QWORD y);
|
||||
static QWORD __umul128(QWORD a, QWORD b, QWORD* hi);
|
||||
static QWORD ui128_quotient_mod(QWORD lo, QWORD hi);
|
||||
static QWORD residue_mul(QWORD x, QWORD y);
|
||||
static QWORD residue_pow(QWORD x, QWORD y);
|
||||
static QWORD inverse(QWORD u, QWORD v);
|
||||
static QWORD residue_inv(QWORD x);
|
||||
static QWORD residue_sqrt(QWORD what);
|
||||
static int find_divisor_v(TDivisor* d);
|
||||
static int polynomial_mul(int adeg, const QWORD a[], int bdeg, const QWORD b[], int resultprevdeg, QWORD result[]);
|
||||
static int polynomial_div_monic(int adeg, QWORD a[], int bdeg, const QWORD b[], QWORD* quotient);
|
||||
static void polynomial_xgcd(int adeg, const QWORD a[3], int bdeg, const QWORD b[3], int* pgcddeg, QWORD gcd[3], int* pmult1deg, QWORD mult1[3], int* pmult2deg, QWORD mult2[3]);
|
||||
static int u2poly(const TDivisor* src, QWORD polyu[3], QWORD polyv[2]);
|
||||
static void divisor_add(const TDivisor* src1, const TDivisor* src2, TDivisor* dst);
|
||||
static void divisor_mul(const TDivisor* src, QWORD mult, TDivisor* dst);
|
||||
static void divisor_mul128(const TDivisor* src, QWORD mult_lo, QWORD mult_hi, TDivisor* dst);
|
||||
static unsigned rol(unsigned x, int shift);
|
||||
static void sha1_single_block(unsigned char input[64], unsigned char output[20]);
|
||||
static void decode_iid_new_version(unsigned char* iid, unsigned char* hwid, int* version);
|
||||
static void Mix(unsigned char* buffer, size_t bufSize, const unsigned char* key, size_t keySize);
|
||||
static void Unmix(unsigned char* buffer, size_t bufSize, const unsigned char* key, size_t keySize);
|
||||
|
||||
public:
|
||||
static int Generate(const char* installation_id_str, char confirmation_id[49], int mode, std::string productid, bool overrideVersion);
|
||||
//EXPORT static int CLIRun();
|
||||
};
|
||||
|
||||
#endif //UMSKT_CONFID_H
|
35
src/libumskt/debugoutput.cpp
Normal file
35
src/libumskt/debugoutput.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/25/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "libumskt.h"
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
std::FILE* UMSKT::debug = std::fopen("NUL:", "w");
|
||||
#else
|
||||
std::FILE* UMSKT::debug = std::fopen("/dev/null", "w");
|
||||
#endif
|
||||
|
||||
|
||||
void UMSKT::setDebugOutput(std::FILE* input) {
|
||||
debug = input;
|
||||
}
|
60
src/libumskt/libumskt.cpp
Normal file
60
src/libumskt/libumskt.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/25/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "libumskt.h"
|
||||
#include "confid/confid.h"
|
||||
#include "pidgen3/PIDGEN3.h"
|
||||
#include "pidgen3/BINK1998.h"
|
||||
#include "pidgen3/BINK2002.h"
|
||||
#include "pidgen2/PIDGEN2.h"
|
||||
|
||||
FNEXPORT int ConfirmationID_Generate(const char* installation_id_str, char confirmation_id[49], int mode, std::string productid, bool bypassVersion) {
|
||||
return ConfirmationID::Generate(installation_id_str, confirmation_id, mode, productid, bypassVersion);
|
||||
}
|
||||
|
||||
FNEXPORT EC_GROUP* PIDGEN3_initializeEllipticCurve(char* pSel, char* aSel, char* bSel, char* generatorXSel, char* generatorYSel, char* publicKeyXSel, char* publicKeyYSel, EC_POINT *&genPoint, EC_POINT *&pubPoint) {
|
||||
return PIDGEN3::initializeEllipticCurve(pSel, aSel, bSel, generatorXSel, generatorYSel, publicKeyXSel, publicKeyYSel, genPoint, pubPoint);
|
||||
}
|
||||
|
||||
FNEXPORT bool PIDGEN3_BINK1998_Verify(EC_GROUP *eCurve, EC_POINT *basePoint, EC_POINT *publicKey, char (&pKey)[25]) {
|
||||
return PIDGEN3::BINK1998::Verify(eCurve, basePoint, publicKey, pKey);
|
||||
}
|
||||
|
||||
FNEXPORT void PIDGEN3_BINK1998_Generate(EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pSerial, BOOL pUpgrade,char (&pKey)[25]) {
|
||||
return PIDGEN3::BINK1998::Generate(eCurve, basePoint, genOrder, privateKey, pSerial, pUpgrade, pKey);
|
||||
}
|
||||
|
||||
FNEXPORT bool PIDGEN3_BINK2002_Verify(EC_GROUP *eCurve, EC_POINT *basePoint, EC_POINT *publicKey, char (&cdKey)[25]) {
|
||||
return PIDGEN3::BINK2002::Verify(eCurve, basePoint, publicKey, cdKey);
|
||||
}
|
||||
|
||||
FNEXPORT void PIDGEN3_BINK2002_Generate(EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pChannelID, DWORD pAuthInfo, BOOL pUpgrade, char (&pKey)[25]) {
|
||||
return PIDGEN3::BINK2002::Generate(eCurve, basePoint, genOrder, privateKey, pChannelID, pAuthInfo, pUpgrade, pKey);
|
||||
}
|
||||
|
||||
FNEXPORT int PIDGEN2_GenerateRetail(char* channelID, char* &keyout) {
|
||||
return PIDGEN2::GenerateRetail(channelID, keyout);
|
||||
}
|
||||
|
||||
FNEXPORT int PIDGEN2_GenerateOEM(char* year, char* day, char* oem, char* keyout) {
|
||||
return PIDGEN2::GenerateOEM(year, day, oem, keyout);
|
||||
}
|
73
src/libumskt/libumskt.h
Normal file
73
src/libumskt/libumskt.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_LIBUMSKT_H
|
||||
#define UMSKT_LIBUMSKT_H
|
||||
|
||||
#include "../typedefs.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
// Algorithm macros
|
||||
#define PK_LENGTH 25
|
||||
#define NULL_TERMINATOR 1
|
||||
|
||||
#define FIELD_BITS 384
|
||||
#define FIELD_BYTES 48
|
||||
#define FIELD_BITS_2003 512
|
||||
#define FIELD_BYTES_2003 64
|
||||
|
||||
#define SHA_MSG_LENGTH_XP (4 + 2 * FIELD_BYTES)
|
||||
#define SHA_MSG_LENGTH_2003 (3 + 2 * FIELD_BYTES_2003)
|
||||
|
||||
#define NEXTSNBITS(field, n, offset) (((QWORD)(field) >> (offset)) & ((1ULL << (n)) - 1))
|
||||
#define FIRSTNBITS(field, n) NEXTSNBITS((field), (n), 0)
|
||||
|
||||
#define HIBYTES(field, bytes) NEXTSNBITS((QWORD)(field), ((bytes) * 8), ((bytes) * 8))
|
||||
#define LOBYTES(field, bytes) FIRSTNBITS((QWORD)(field), ((bytes) * 8))
|
||||
|
||||
#define BYDWORD(n) (DWORD)(*((n) + 0) | *((n) + 1) << 8 | *((n) + 2) << 16 | *((n) + 3) << 24)
|
||||
#define BITMASK(n) ((1ULL << (n)) - 1)
|
||||
|
||||
class UMSKT {
|
||||
public:
|
||||
static std::FILE* debug;
|
||||
class PIDGEN2;
|
||||
class PIDGEN3;
|
||||
class ConfigurationID;
|
||||
|
||||
static void setDebugOutput(std::FILE* input);
|
||||
};
|
||||
|
||||
|
||||
#endif //UMSKT_LIBUMSKT_H
|
135
src/libumskt/pidgen2/PIDGEN2.cpp
Normal file
135
src/libumskt/pidgen2/PIDGEN2.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "PIDGEN2.h"
|
||||
|
||||
const char* channelIDBlacklist [7] = {"333", "444", "555", "666", "777", "888", "999"};
|
||||
const char* validYears[8] = { "95", "96", "97", "98", "99", "00", "01", "02"};
|
||||
|
||||
bool PIDGEN2::isNumericString(char* input) {
|
||||
for(int i = 0; i < strlen(input); i++) {
|
||||
if (input[i] < '0' || input[i] > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int PIDGEN2::addDigits(char* input) {
|
||||
int output = 0;
|
||||
|
||||
if (!isNumericString(input)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < strlen(input); i++) {
|
||||
output += input[i] - '0';
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
bool PIDGEN2::isValidChannelID(char* channelID) {
|
||||
if (strlen(channelID) > 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 6; i++) {
|
||||
if (strcmp(channelID, channelIDBlacklist[i]) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PIDGEN2::isValidOEMID(char* OEMID) {
|
||||
if (!isNumericString(OEMID)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen(OEMID) > 5) {
|
||||
if (OEMID[0] != '0' || OEMID[1] != '0') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int mod = addDigits(OEMID);
|
||||
|
||||
return (mod % 21 == 0);
|
||||
}
|
||||
|
||||
bool PIDGEN2::isValidYear(char* year) {
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
if (year == validYears[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PIDGEN2::isValidDay(char* day) {
|
||||
if (!isNumericString(day)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int iDay = std::stoi(day);
|
||||
if (iDay == 0 || iDay >= 365) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PIDGEN2::isValidRetailProductID(char* productID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int PIDGEN2::GenerateRetail(char* channelID, char* &keyout) {
|
||||
if (!isValidChannelID(channelID)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PIDGEN2::GenerateOEM(char* year, char* day, char* oem, char* &keyout) {
|
||||
if (!isValidOEMID(oem)) {
|
||||
int mod = addDigits(oem);
|
||||
mod += mod % 21;
|
||||
|
||||
strcpy(oem, fmt::format("{:07d}", mod).c_str());
|
||||
}
|
||||
|
||||
if (!isValidYear(year)) {
|
||||
strcpy(year, validYears[0]);
|
||||
}
|
||||
|
||||
if (!isValidDay(day)) {
|
||||
int iday = std::stoi(day);
|
||||
iday = (iday + 1) % 365;
|
||||
}
|
||||
|
||||
strcpy(keyout, fmt::format("{}{}-OEM-{}-{}", year, day, oem, oem).c_str());
|
||||
|
||||
return 0;
|
||||
}
|
41
src/libumskt/pidgen2/PIDGEN2.h
Normal file
41
src/libumskt/pidgen2/PIDGEN2.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_PIDGEN2_H
|
||||
#define UMSKT_PIDGEN2_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
EXPORT class PIDGEN2 {
|
||||
public:
|
||||
static bool isNumericString(char* input);
|
||||
static bool isValidChannelID(char* channelID);
|
||||
static bool isValidOEMID(char* OEMID);
|
||||
static bool isValidYear(char* year);
|
||||
static bool isValidDay(char* day);
|
||||
static bool isValidRetailProductID(char* productID);
|
||||
static int addDigits(char* input);
|
||||
static int GenerateRetail(char* channelID, char* &keyout);
|
||||
static int GenerateOEM(char* year, char* day, char* oem, char* &keyout);
|
||||
};
|
||||
|
||||
#endif //UMSKT_PIDGEN2_H
|
289
src/libumskt/pidgen3/BINK1998.cpp
Normal file
289
src/libumskt/pidgen3/BINK1998.cpp
Normal file
@ -0,0 +1,289 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*
|
||||
* @History {
|
||||
* Algorithm was initially written and open sourced by z22
|
||||
* and uploaded to GitHub by TheMCHK in August of 2019
|
||||
*
|
||||
* Endermanch (Andrew) rewrote the algorithm in May of 2023
|
||||
* }
|
||||
*/
|
||||
|
||||
#include "BINK1998.h"
|
||||
|
||||
/* Unpacks a Windows XP-like Product Key. */
|
||||
void PIDGEN3::BINK1998::Unpack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL &pUpgrade,
|
||||
DWORD &pSerial,
|
||||
DWORD &pHash,
|
||||
QWORD &pSignature
|
||||
) {
|
||||
// We're assuming that the quantity of information within the product key is at most 114 bits.
|
||||
// log2(24^25) = 114.
|
||||
|
||||
// Upgrade = Bit 0
|
||||
pUpgrade = FIRSTNBITS(pRaw[0], 1);
|
||||
|
||||
// Serial = Bits [1..30] -> 30 bits
|
||||
pSerial = NEXTSNBITS(pRaw[0], 30, 1);
|
||||
|
||||
// Hash = Bits [31..58] -> 28 bits
|
||||
pHash = NEXTSNBITS(pRaw[0], 28, 31);
|
||||
|
||||
// Signature = Bits [59..113] -> 56 bits
|
||||
pSignature = FIRSTNBITS(pRaw[1], 51) << 5 | NEXTSNBITS(pRaw[0], 5, 59);
|
||||
}
|
||||
|
||||
/* Packs a Windows XP-like Product Key. */
|
||||
void PIDGEN3::BINK1998::Pack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL pUpgrade,
|
||||
DWORD pSerial,
|
||||
DWORD pHash,
|
||||
QWORD pSignature
|
||||
) {
|
||||
// The quantity of information the key provides is 114 bits.
|
||||
// We're storing it in 2 64-bit quad-words with 14 trailing bits.
|
||||
// 64 * 2 = 128
|
||||
|
||||
// Signature [114..59] <- Hash [58..31] <- Serial [30..1] <- Upgrade [0]
|
||||
pRaw[0] = FIRSTNBITS(pSignature, 5) << 59 | FIRSTNBITS(pHash, 28) << 31 | pSerial << 1 | pUpgrade;
|
||||
pRaw[1] = NEXTSNBITS(pSignature, 51, 5);
|
||||
}
|
||||
|
||||
/* Verifies a Windows XP-like Product Key. */
|
||||
bool PIDGEN3::BINK1998::Verify(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
EC_POINT *publicKey,
|
||||
char (&pKey)[25]
|
||||
) {
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
QWORD pRaw[2]{},
|
||||
pSignature;
|
||||
|
||||
DWORD pData,
|
||||
pSerial,
|
||||
pHash;
|
||||
|
||||
BOOL pUpgrade;
|
||||
|
||||
// Convert Base24 CD-key to bytecode.
|
||||
PIDGEN3::unbase24((BYTE *)pRaw, pKey);
|
||||
|
||||
// Extract RPK, hash and signature from bytecode.
|
||||
Unpack(pRaw, pUpgrade, pSerial, pHash, pSignature);
|
||||
|
||||
fmt::print(UMSKT::debug, "Validation results:\n");
|
||||
fmt::print(UMSKT::debug, " Upgrade: 0x{:08x}\n", pUpgrade);
|
||||
fmt::print(UMSKT::debug, " Serial: 0x{:08x}\n", pSerial);
|
||||
fmt::print(UMSKT::debug, " Hash: 0x{:08x}\n", pHash);
|
||||
fmt::print(UMSKT::debug, " Signature: 0x{:08x}\n", pSignature);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
pData = pSerial << 1 | pUpgrade;
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* e = Hash
|
||||
* s = Schnorr Signature
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* P = sG + eK
|
||||
*
|
||||
*/
|
||||
|
||||
BIGNUM *e = BN_lebin2bn((BYTE *)&pHash, sizeof(pHash), nullptr),
|
||||
*s = BN_lebin2bn((BYTE *)&pSignature, sizeof(pSignature), nullptr),
|
||||
*x = BN_new(),
|
||||
*y = BN_new();
|
||||
|
||||
// Create 2 points on the elliptic curve.
|
||||
EC_POINT *t = EC_POINT_new(eCurve);
|
||||
EC_POINT *p = EC_POINT_new(eCurve);
|
||||
|
||||
// t = sG
|
||||
EC_POINT_mul(eCurve, t, nullptr, basePoint, s, numContext);
|
||||
|
||||
// P = eK
|
||||
EC_POINT_mul(eCurve, p, nullptr, publicKey, e, numContext);
|
||||
|
||||
// P += t
|
||||
EC_POINT_add(eCurve, p, t, p, numContext);
|
||||
|
||||
// x = P.x; y = P.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, p, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH]{},
|
||||
msgBuffer[SHA_MSG_LENGTH_XP]{},
|
||||
xBin[FIELD_BYTES]{},
|
||||
yBin[FIELD_BYTES]{};
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
BN_bn2lebin(x, xBin, FIELD_BYTES);
|
||||
BN_bn2lebin(y, yBin, FIELD_BYTES);
|
||||
|
||||
// Assemble the SHA message.
|
||||
memcpy((void *)&msgBuffer[0], (void *)&pData, 4);
|
||||
memcpy((void *)&msgBuffer[4], (void *)xBin, FIELD_BYTES);
|
||||
memcpy((void *)&msgBuffer[4 + FIELD_BYTES], (void *)yBin, FIELD_BYTES);
|
||||
|
||||
// compHash = SHA1(pSerial || P.x || P.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 28 bits.
|
||||
DWORD compHash = BYDWORD(msgDigest) >> 4 & BITMASK(28);
|
||||
|
||||
BN_free(e);
|
||||
BN_free(s);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
|
||||
EC_POINT_free(t);
|
||||
EC_POINT_free(p);
|
||||
|
||||
// If the computed hash checks out, the key is valid.
|
||||
return compHash == pHash;
|
||||
}
|
||||
|
||||
/* Generates a Windows XP-like Product Key. */
|
||||
void PIDGEN3::BINK1998::Generate(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
BIGNUM *genOrder,
|
||||
BIGNUM *privateKey,
|
||||
DWORD pSerial,
|
||||
BOOL pUpgrade,
|
||||
char (&pKey)[25]
|
||||
) {
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
BIGNUM *c = BN_new(),
|
||||
*s = BN_new(),
|
||||
*x = BN_new(),
|
||||
*y = BN_new();
|
||||
|
||||
QWORD pRaw[2]{},
|
||||
pSignature = 0;
|
||||
|
||||
// Data segment of the RPK.
|
||||
DWORD pData = pSerial << 1 | pUpgrade;
|
||||
|
||||
do {
|
||||
EC_POINT *r = EC_POINT_new(eCurve);
|
||||
|
||||
// Generate a random number c consisting of 384 bits without any constraints.
|
||||
BN_rand(c, FIELD_BITS, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
|
||||
// Pick a random derivative of the base point on the elliptic curve.
|
||||
// R = cG;
|
||||
EC_POINT_mul(eCurve, r, nullptr, basePoint, c, numContext);
|
||||
|
||||
// Acquire its coordinates.
|
||||
// x = R.x; y = R.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, r, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH]{},
|
||||
msgBuffer[SHA_MSG_LENGTH_XP]{},
|
||||
xBin[FIELD_BYTES]{},
|
||||
yBin[FIELD_BYTES]{};
|
||||
|
||||
// Convert coordinates to bytes.
|
||||
BN_bn2lebin(x, xBin, FIELD_BYTES);
|
||||
BN_bn2lebin(y, yBin, FIELD_BYTES);
|
||||
|
||||
// Assemble the SHA message.
|
||||
memcpy((void *)&msgBuffer[0], (void *)&pData, 4);
|
||||
memcpy((void *)&msgBuffer[4], (void *)xBin, FIELD_BYTES);
|
||||
memcpy((void *)&msgBuffer[4 + FIELD_BYTES], (void *)yBin, FIELD_BYTES);
|
||||
|
||||
// pHash = SHA1(pSerial || R.x || R.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed pHash.
|
||||
// Truncate the pHash to 28 bits.
|
||||
DWORD pHash = BYDWORD(msgDigest) >> 4 & BITMASK(28);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* c = Random multiplier
|
||||
* e = Hash
|
||||
* s = Signature
|
||||
* n = Order of G
|
||||
* k = Private Key
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* R(x, y) = Random derivative of the generator
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* We need to find the signature s that satisfies the equation with a given hash:
|
||||
* P = sG + eK
|
||||
* s = ek + c (mod n) <- computation optimization
|
||||
*/
|
||||
|
||||
// s = ek;
|
||||
BN_copy(s, privateKey);
|
||||
BN_mul_word(s, pHash);
|
||||
|
||||
// s += c (mod n)
|
||||
BN_mod_add(s, s, c, genOrder, numContext);
|
||||
|
||||
// Translate resulting scalar into a 64-bit integer (the byte order is little-endian).
|
||||
BN_bn2lebinpad(s, (BYTE *)&pSignature, BN_num_bytes(s));
|
||||
|
||||
// Pack product key.
|
||||
Pack(pRaw, pUpgrade, pSerial, pHash, pSignature);
|
||||
|
||||
fmt::print(UMSKT::debug, "Generation results:\n");
|
||||
fmt::print(UMSKT::debug, " Upgrade: 0x{:08x}\n", pUpgrade);
|
||||
fmt::print(UMSKT::debug, " Serial: 0x{:08x}\n", pSerial);
|
||||
fmt::print(UMSKT::debug, " Hash: 0x{:08x}\n", pHash);
|
||||
fmt::print(UMSKT::debug, " Signature: 0x{:08x}\n", pSignature);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
EC_POINT_free(r);
|
||||
} while (pSignature > BITMASK(55));
|
||||
// ↑ ↑ ↑
|
||||
// The signature can't be longer than 55 bits, else it will
|
||||
// make the CD-key longer than 25 characters.
|
||||
|
||||
// Convert bytecode to Base24 CD-key.
|
||||
base24(pKey, (BYTE *)pRaw);
|
||||
|
||||
BN_free(c);
|
||||
BN_free(s);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
}
|
64
src/libumskt/pidgen3/BINK1998.h
Normal file
64
src/libumskt/pidgen3/BINK1998.h
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/6/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_BINK1998_H
|
||||
#define UMSKT_BINK1998_H
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
EXPORT class PIDGEN3::BINK1998 {
|
||||
public:
|
||||
static void Unpack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL &pUpgrade,
|
||||
DWORD &pSerial,
|
||||
DWORD &pHash,
|
||||
QWORD &pSignature
|
||||
);
|
||||
|
||||
static void Pack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL pUpgrade,
|
||||
DWORD pSerial,
|
||||
DWORD pHash,
|
||||
QWORD pSignature
|
||||
);
|
||||
|
||||
static bool Verify(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
EC_POINT *publicKey,
|
||||
char (&pKey)[25]
|
||||
);
|
||||
|
||||
static void Generate(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
BIGNUM *genOrder,
|
||||
BIGNUM *privateKey,
|
||||
DWORD pSerial,
|
||||
BOOL pUpgrade,
|
||||
char (&pKey)[25]
|
||||
);
|
||||
};
|
||||
|
||||
#endif //UMSKT_BINK1998_H
|
386
src/libumskt/pidgen3/BINK2002.cpp
Normal file
386
src/libumskt/pidgen3/BINK2002.cpp
Normal file
@ -0,0 +1,386 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*
|
||||
* @History {
|
||||
* Algorithm was initially written and open sourced by z22
|
||||
* and uploaded to GitHub by TheMCHK in August of 2019
|
||||
*
|
||||
* Endermanch (Andrew) rewrote the algorithm in May of 2023
|
||||
* }
|
||||
*/
|
||||
|
||||
#include "BINK2002.h"
|
||||
|
||||
/* Unpacks a Windows Server 2003-like Product Key. */
|
||||
void PIDGEN3::BINK2002::Unpack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL &pUpgrade,
|
||||
DWORD &pChannelID,
|
||||
DWORD &pHash,
|
||||
QWORD &pSignature,
|
||||
DWORD &pAuthInfo
|
||||
) {
|
||||
// We're assuming that the quantity of information within the product key is at most 114 bits.
|
||||
// log2(24^25) = 114.
|
||||
|
||||
// Upgrade = Bit 0
|
||||
pUpgrade = FIRSTNBITS(pRaw[0], 1);
|
||||
|
||||
// Channel ID = Bits [1..10] -> 10 bits
|
||||
pChannelID = NEXTSNBITS(pRaw[0], 10, 1);
|
||||
|
||||
// Hash = Bits [11..41] -> 31 bits
|
||||
pHash = NEXTSNBITS(pRaw[0], 31, 11);
|
||||
|
||||
// Signature = Bits [42..103] -> 62 bits
|
||||
// The quad-word signature overlaps AuthInfo in bits 104 and 105,
|
||||
// hence Microsoft employs a secret technique called: Signature = HIDWORD(Signature) >> 2 | LODWORD(Signature)
|
||||
pSignature = NEXTSNBITS(pRaw[1], 30, 10) << 32 | FIRSTNBITS(pRaw[1], 10) << 22 | NEXTSNBITS(pRaw[0], 22, 42);
|
||||
|
||||
// AuthInfo = Bits [104..113] -> 10 bits
|
||||
pAuthInfo = NEXTSNBITS(pRaw[1], 10, 40);
|
||||
}
|
||||
|
||||
/* Packs a Windows Server 2003-like Product Key. */
|
||||
void PIDGEN3::BINK2002::Pack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL pUpgrade,
|
||||
DWORD pChannelID,
|
||||
DWORD pHash,
|
||||
QWORD pSignature,
|
||||
DWORD pAuthInfo
|
||||
) {
|
||||
// AuthInfo [113..104] <- Signature [103..42] <- Hash [41..11] <- Channel ID [10..1] <- Upgrade [0]
|
||||
pRaw[0] = FIRSTNBITS(pSignature, 22) << 42 | (QWORD)pHash << 11 | pChannelID << 1 | pUpgrade;
|
||||
pRaw[1] = FIRSTNBITS(pAuthInfo, 10) << 40 | NEXTSNBITS(pSignature, 40, 22);
|
||||
}
|
||||
|
||||
/* Verifies a Windows Server 2003-like Product Key. */
|
||||
bool PIDGEN3::BINK2002::Verify(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
EC_POINT *publicKey,
|
||||
char (&cdKey)[25]
|
||||
) {
|
||||
BN_CTX *context = BN_CTX_new();
|
||||
|
||||
QWORD bKey[2]{},
|
||||
pSignature = 0;
|
||||
|
||||
DWORD pData,
|
||||
pChannelID,
|
||||
pHash,
|
||||
pAuthInfo;
|
||||
|
||||
BOOL pUpgrade;
|
||||
|
||||
// Convert Base24 CD-key to bytecode.
|
||||
unbase24((BYTE *)bKey, cdKey);
|
||||
|
||||
// Extract product key segments from bytecode.
|
||||
Unpack(bKey, pUpgrade, pChannelID, pHash, pSignature, pAuthInfo);
|
||||
|
||||
pData = pChannelID << 1 | pUpgrade;
|
||||
|
||||
fmt::print(UMSKT::debug, "Validation results:\n");
|
||||
fmt::print(UMSKT::debug, " Upgrade: 0x{:08x}\n", pUpgrade);
|
||||
fmt::print(UMSKT::debug, "Channel ID: 0x{:08x}\n", pChannelID);
|
||||
fmt::print(UMSKT::debug, " Hash: 0x{:08x}\n", pHash);
|
||||
fmt::print(UMSKT::debug, " Signature: 0x{:08x}\n", pSignature);
|
||||
fmt::print(UMSKT::debug, " AuthInfo: 0x{:08x}\n", pAuthInfo);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH]{},
|
||||
msgBuffer[SHA_MSG_LENGTH_2003]{},
|
||||
xBin[FIELD_BYTES_2003]{},
|
||||
yBin[FIELD_BYTES_2003]{};
|
||||
|
||||
// Assemble the first SHA message.
|
||||
msgBuffer[0x00] = 0x5D;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
msgBuffer[0x03] = (pHash & 0x000000FF);
|
||||
msgBuffer[0x04] = (pHash & 0x0000FF00) >> 8;
|
||||
msgBuffer[0x05] = (pHash & 0x00FF0000) >> 16;
|
||||
msgBuffer[0x06] = (pHash & 0xFF000000) >> 24;
|
||||
msgBuffer[0x07] = (pAuthInfo & 0x00FF);
|
||||
msgBuffer[0x08] = (pAuthInfo & 0xFF00) >> 8;
|
||||
msgBuffer[0x09] = 0x00;
|
||||
msgBuffer[0x0A] = 0x00;
|
||||
|
||||
// newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00)
|
||||
SHA1(msgBuffer, 11, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 64-bit integer - this is our computed intermediate signature.
|
||||
// As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2 bits (per spec).
|
||||
QWORD iSignature = NEXTSNBITS(BYDWORD(&msgDigest[4]), 30, 2) << 32 | BYDWORD(msgDigest);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* e = Hash
|
||||
* s = Schnorr Signature
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* P = s(sG + eK)
|
||||
*
|
||||
*/
|
||||
|
||||
BIGNUM *e = BN_lebin2bn((BYTE *)&iSignature, sizeof(iSignature), nullptr),
|
||||
*s = BN_lebin2bn((BYTE *)&pSignature, sizeof(pSignature), nullptr),
|
||||
*x = BN_new(),
|
||||
*y = BN_new();
|
||||
|
||||
// Create 2 points on the elliptic curve.
|
||||
EC_POINT *p = EC_POINT_new(eCurve);
|
||||
EC_POINT *t = EC_POINT_new(eCurve);
|
||||
|
||||
// t = sG
|
||||
EC_POINT_mul(eCurve, t, nullptr, basePoint, s, context);
|
||||
|
||||
// p = eK
|
||||
EC_POINT_mul(eCurve, p, nullptr, publicKey, e, context);
|
||||
|
||||
// p += t
|
||||
EC_POINT_add(eCurve, p, t, p, context);
|
||||
|
||||
// p *= s
|
||||
EC_POINT_mul(eCurve, p, nullptr, p, s, context);
|
||||
|
||||
// x = p.x; y = p.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, p, x, y, context);
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
BN_bn2lebin(x, xBin, FIELD_BYTES_2003);
|
||||
BN_bn2lebin(y, yBin, FIELD_BYTES_2003);
|
||||
|
||||
// Assemble the second SHA message.
|
||||
msgBuffer[0x00] = 0x79;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
|
||||
memcpy((void *)&msgBuffer[3], (void *)xBin, FIELD_BYTES_2003);
|
||||
memcpy((void *)&msgBuffer[3 + FIELD_BYTES_2003], (void *)yBin, FIELD_BYTES_2003);
|
||||
|
||||
// compHash = SHA1(79 || Channel ID || p.x || p.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 31 bits.
|
||||
DWORD compHash = BYDWORD(msgDigest) & BITMASK(31);
|
||||
|
||||
BN_free(s);
|
||||
BN_free(e);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
|
||||
BN_CTX_free(context);
|
||||
|
||||
EC_POINT_free(p);
|
||||
EC_POINT_free(t);
|
||||
|
||||
// If the computed hash checks out, the key is valid.
|
||||
return compHash == pHash;
|
||||
}
|
||||
|
||||
/* Generates a Windows Server 2003-like Product Key. */
|
||||
void PIDGEN3::BINK2002::Generate(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
BIGNUM *genOrder,
|
||||
BIGNUM *privateKey,
|
||||
DWORD pChannelID,
|
||||
DWORD pAuthInfo,
|
||||
BOOL pUpgrade,
|
||||
char (&pKey)[25]
|
||||
) {
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
BIGNUM *c = BN_new(),
|
||||
*e = BN_new(),
|
||||
*s = BN_new(),
|
||||
*x = BN_new(),
|
||||
*y = BN_new();
|
||||
|
||||
QWORD pRaw[2]{},
|
||||
pSignature = 0;
|
||||
|
||||
// Data segment of the RPK.
|
||||
DWORD pData = pChannelID << 1 | pUpgrade;
|
||||
|
||||
BOOL noSquare;
|
||||
|
||||
do {
|
||||
EC_POINT *r = EC_POINT_new(eCurve);
|
||||
|
||||
// Generate a random number c consisting of 512 bits without any constraints.
|
||||
BN_rand(c, FIELD_BITS_2003, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
|
||||
// R = cG
|
||||
EC_POINT_mul(eCurve, r, nullptr, basePoint, c, numContext);
|
||||
|
||||
// Acquire its coordinates.
|
||||
// x = R.x; y = R.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, r, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH]{},
|
||||
msgBuffer[SHA_MSG_LENGTH_2003]{},
|
||||
xBin[FIELD_BYTES_2003]{},
|
||||
yBin[FIELD_BYTES_2003]{};
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
BN_bn2lebin(x, xBin, FIELD_BYTES_2003);
|
||||
BN_bn2lebin(y, yBin, FIELD_BYTES_2003);
|
||||
|
||||
// Assemble the first SHA message.
|
||||
msgBuffer[0x00] = 0x79;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
|
||||
memcpy((void *)&msgBuffer[3], (void *)xBin, FIELD_BYTES_2003);
|
||||
memcpy((void *)&msgBuffer[3 + FIELD_BYTES_2003], (void *)yBin, FIELD_BYTES_2003);
|
||||
|
||||
// pHash = SHA1(79 || Channel ID || R.x || R.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 31 bits.
|
||||
DWORD pHash = BYDWORD(msgDigest) & BITMASK(31);
|
||||
|
||||
// Assemble the second SHA message.
|
||||
msgBuffer[0x00] = 0x5D;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
msgBuffer[0x03] = (pHash & 0x000000FF);
|
||||
msgBuffer[0x04] = (pHash & 0x0000FF00) >> 8;
|
||||
msgBuffer[0x05] = (pHash & 0x00FF0000) >> 16;
|
||||
msgBuffer[0x06] = (pHash & 0xFF000000) >> 24;
|
||||
msgBuffer[0x07] = (pAuthInfo & 0x00FF);
|
||||
msgBuffer[0x08] = (pAuthInfo & 0xFF00) >> 8;
|
||||
msgBuffer[0x09] = 0x00;
|
||||
msgBuffer[0x0A] = 0x00;
|
||||
|
||||
// newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00)
|
||||
SHA1(msgBuffer, 11, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 64-bit integer - this is our computed intermediate signature.
|
||||
// As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2 bits (per spec).
|
||||
QWORD iSignature = NEXTSNBITS(BYDWORD(&msgDigest[4]), 30, 2) << 32 | BYDWORD(msgDigest);
|
||||
|
||||
BN_lebin2bn((BYTE *)&iSignature, sizeof(iSignature), e);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* c = Random multiplier
|
||||
* e = Intermediate Signature
|
||||
* s = Signature
|
||||
* n = Order of G
|
||||
* k = Private Key
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* R(x, y) = Random derivative of the generator
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* s(sG + eK) = R (mod p)
|
||||
* ↓ K = kG; R = cG ↓
|
||||
*
|
||||
* s(sG + ekG) = cG (mod p)
|
||||
* s(s + ek)G = cG (mod p)
|
||||
* ↓ G cancels out, the scalar arithmetic shrinks to order n ↓
|
||||
*
|
||||
* s(s + ek) = c (mod n)
|
||||
* s² + (ek)s - c = 0 (mod n)
|
||||
* ↓ This is a quadratic equation in respect to the signature ↓
|
||||
*
|
||||
* s = (-ek ± √((ek)² + 4c)) / 2 (mod n)
|
||||
*/
|
||||
|
||||
// e = ek (mod n)
|
||||
BN_mod_mul(e, e, privateKey, genOrder, numContext);
|
||||
|
||||
// s = e
|
||||
BN_copy(s, e);
|
||||
|
||||
// s = (ek (mod n))²
|
||||
BN_mod_sqr(s, s, genOrder, numContext);
|
||||
|
||||
// c *= 4 (c <<= 2)
|
||||
BN_lshift(c, c, 2);
|
||||
|
||||
// s += c
|
||||
BN_add(s, s, c);
|
||||
|
||||
// Around half of numbers modulo a prime are not squares -> BN_sqrt_mod fails about half of the times,
|
||||
// hence if BN_sqrt_mod returns NULL, we need to restart with a different seed.
|
||||
// s = √((ek)² + 4c (mod n))
|
||||
noSquare = BN_mod_sqrt(s, s, genOrder, numContext) == nullptr;
|
||||
|
||||
// s = -ek + √((ek)² + 4c) (mod n)
|
||||
BN_mod_sub(s, s, e, genOrder, numContext);
|
||||
|
||||
// If s is odd, add order to it.
|
||||
// The order is a prime, so it can't be even.
|
||||
if (BN_is_odd(s))
|
||||
|
||||
// s = -ek + √((ek)² + 4c) + n
|
||||
BN_add(s, s, genOrder);
|
||||
|
||||
// s /= 2 (s >>= 1)
|
||||
BN_rshift1(s, s);
|
||||
|
||||
// Translate resulting scalar into a 64-bit integer (the byte order is little-endian).
|
||||
BN_bn2lebinpad(s, (BYTE *)&pSignature, BN_num_bytes(s));
|
||||
|
||||
// Pack product key.
|
||||
Pack(pRaw, pUpgrade, pChannelID, pHash, pSignature, pAuthInfo);
|
||||
|
||||
fmt::print(UMSKT::debug, "Generation results:\n");
|
||||
fmt::print(UMSKT::debug, " Upgrade: 0x{:08x}\n", pUpgrade);
|
||||
fmt::print(UMSKT::debug, "Channel ID: 0x{:08x}\n", pChannelID);
|
||||
fmt::print(UMSKT::debug, " Hash: 0x{:08x}\n", pHash);
|
||||
fmt::print(UMSKT::debug, " Signature: 0x{:08x}\n", pSignature);
|
||||
fmt::print(UMSKT::debug, " AuthInfo: 0x{:08x}\n", pAuthInfo);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
EC_POINT_free(r);
|
||||
} while (pSignature > BITMASK(62) || noSquare);
|
||||
// ↑ ↑ ↑
|
||||
// The signature can't be longer than 62 bits, else it will
|
||||
// overlap with the AuthInfo segment next to it.
|
||||
|
||||
// Convert bytecode to Base24 CD-key.
|
||||
base24(pKey, (BYTE *)pRaw);
|
||||
|
||||
BN_free(c);
|
||||
BN_free(s);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
BN_free(e);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
}
|
67
src/libumskt/pidgen3/BINK2002.h
Normal file
67
src/libumskt/pidgen3/BINK2002.h
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/6/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_BINK2002_H
|
||||
#define UMSKT_BINK2002_H
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
EXPORT class PIDGEN3::BINK2002 {
|
||||
public:
|
||||
static void Unpack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL &pUpgrade,
|
||||
DWORD &pChannelID,
|
||||
DWORD &pHash,
|
||||
QWORD &pSignature,
|
||||
DWORD &pAuthInfo
|
||||
);
|
||||
|
||||
static void Pack(
|
||||
QWORD (&pRaw)[2],
|
||||
BOOL pUpgrade,
|
||||
DWORD pChannelID,
|
||||
DWORD pHash,
|
||||
QWORD pSignature,
|
||||
DWORD pAuthInfo
|
||||
);
|
||||
|
||||
static bool Verify(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
EC_POINT *publicKey,
|
||||
char (&cdKey)[25]
|
||||
);
|
||||
|
||||
static void Generate(
|
||||
EC_GROUP *eCurve,
|
||||
EC_POINT *basePoint,
|
||||
BIGNUM *genOrder,
|
||||
BIGNUM *privateKey,
|
||||
DWORD pChannelID,
|
||||
DWORD pAuthInfo,
|
||||
BOOL pUpgrade,
|
||||
char (&pKey)[25]
|
||||
);
|
||||
};
|
||||
|
||||
#endif //UMSKT_BINK2002_H
|
54
src/libumskt/pidgen3/PIDGEN3.h
Normal file
54
src/libumskt/pidgen3/PIDGEN3.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_PIDGEN3_H
|
||||
#define UMSKT_PIDGEN3_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
class PIDGEN3 {
|
||||
public:
|
||||
class BINK1998;
|
||||
class BINK2002;
|
||||
|
||||
// util.cpp
|
||||
static int BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen); // Hello OpenSSL developers, please tell me, where is this function at?
|
||||
static void endian(BYTE *data, int length);
|
||||
static EC_GROUP* initializeEllipticCurve(
|
||||
std::string pSel,
|
||||
std::string aSel,
|
||||
std::string bSel,
|
||||
std::string generatorXSel,
|
||||
std::string generatorYSel,
|
||||
std::string publicKeyXSel,
|
||||
std::string publicKeyYSel,
|
||||
EC_POINT *&genPoint,
|
||||
EC_POINT *&pubPoint
|
||||
);
|
||||
|
||||
// key.cpp
|
||||
static constexpr char pKeyCharset[] = "BCDFGHJKMPQRTVWXY2346789";
|
||||
static void unbase24(BYTE *byteSeq, const char *cdKey);
|
||||
static void base24(char *cdKey, BYTE *byteSeq);
|
||||
};
|
||||
|
||||
#endif //UMSKT_PIDGEN3_H
|
86
src/libumskt/pidgen3/key.cpp
Normal file
86
src/libumskt/pidgen3/key.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 5/26/2023
|
||||
* @Maintainer Andrew
|
||||
*/
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
/* Converts from CD-key to a byte sequence. */
|
||||
void PIDGEN3::unbase24(BYTE *byteSeq, const char *cdKey) {
|
||||
BYTE pDecodedKey[PK_LENGTH + NULL_TERMINATOR]{};
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
BN_zero(y);
|
||||
|
||||
// Remove dashes from the CD-key and put it into a Base24 byte array.
|
||||
for (int i = 0, k = 0; i < strlen(cdKey) && k < PK_LENGTH; i++) {
|
||||
for (int j = 0; j < 24; j++) {
|
||||
if (cdKey[i] != '-' && cdKey[i] == pKeyCharset[j]) {
|
||||
pDecodedKey[k++] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty byte sequence.
|
||||
memset(byteSeq, 0, 16);
|
||||
|
||||
// Calculate the weighed sum of byte array elements.
|
||||
for (int i = 0; i < PK_LENGTH; i++) {
|
||||
BN_mul_word(y, PK_LENGTH - 1);
|
||||
BN_add_word(y, pDecodedKey[i]);
|
||||
}
|
||||
|
||||
// Acquire length.
|
||||
int n = BN_num_bytes(y);
|
||||
|
||||
// Place the generated code into the byte sequence.
|
||||
BN_bn2bin(y, byteSeq);
|
||||
BN_free(y);
|
||||
|
||||
// Reverse the byte sequence.
|
||||
endian(byteSeq, n);
|
||||
}
|
||||
|
||||
/* Converts from byte sequence to the CD-key. */
|
||||
void PIDGEN3::base24(char *cdKey, BYTE *byteSeq) {
|
||||
BYTE rbyteSeq[16];
|
||||
BIGNUM *z;
|
||||
|
||||
// Copy byte sequence to the reversed byte sequence.
|
||||
memcpy(rbyteSeq, byteSeq, sizeof(rbyteSeq));
|
||||
|
||||
// Skip trailing zeroes and reverse y.
|
||||
int length;
|
||||
|
||||
for (length = 15; rbyteSeq[length] == 0; length--);
|
||||
endian(rbyteSeq, ++length);
|
||||
|
||||
// Convert reversed byte sequence to BigNum z.
|
||||
z = BN_bin2bn(rbyteSeq, length, nullptr);
|
||||
|
||||
// Divide z by 24 and convert the remainder to a CD-key char.
|
||||
cdKey[25] = 0;
|
||||
|
||||
for (int i = 24; i >= 0; i--)
|
||||
cdKey[i] = pKeyCharset[BN_div_word(z, 24)];
|
||||
|
||||
BN_free(z);
|
||||
}
|
127
src/libumskt/pidgen3/util.cpp
Normal file
127
src/libumskt/pidgen3/util.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*/
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
int randomRange() {
|
||||
return 4; // chosen by fair dice roll
|
||||
// guaranteed to be random
|
||||
}
|
||||
|
||||
/* Convert data between endianness types. */
|
||||
void PIDGEN3::endian(BYTE *data, int length) {
|
||||
for (int i = 0; i < length / 2; i++) {
|
||||
BYTE temp = data[i];
|
||||
data[i] = data[length - i - 1];
|
||||
data[length - i - 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initializes the elliptic curve. */
|
||||
EC_GROUP* PIDGEN3::initializeEllipticCurve(
|
||||
const std::string pSel,
|
||||
const std::string aSel,
|
||||
const std::string bSel,
|
||||
const std::string generatorXSel,
|
||||
const std::string generatorYSel,
|
||||
const std::string publicKeyXSel,
|
||||
const std::string publicKeyYSel,
|
||||
EC_POINT *&genPoint,
|
||||
EC_POINT *&pubPoint
|
||||
) {
|
||||
// Initialize BIGNUM and BIGNUMCTX structures.
|
||||
// BIGNUM - Large numbers
|
||||
// BIGNUMCTX - Context large numbers (temporary)
|
||||
BIGNUM *a, *b, *p, *generatorX, *generatorY, *publicKeyX, *publicKeyY;
|
||||
BN_CTX *context;
|
||||
|
||||
// We're presented with an elliptic curve, a multivariable function y(x; p; a; b), where
|
||||
// y^2 % p = x^3 + ax + b % p.
|
||||
a = BN_new();
|
||||
b = BN_new();
|
||||
p = BN_new();
|
||||
|
||||
// Public key will consist of the resulting (x; y) values.
|
||||
publicKeyX = BN_new();
|
||||
publicKeyY = BN_new();
|
||||
|
||||
// G(x; y) is a generator function, its return value represents a point on the elliptic curve.
|
||||
generatorX = BN_new();
|
||||
generatorY = BN_new();
|
||||
|
||||
// Context variable
|
||||
context = BN_CTX_new();
|
||||
|
||||
/* Public data */
|
||||
BN_dec2bn(&p, pSel.c_str());
|
||||
BN_dec2bn(&a, aSel.c_str());
|
||||
BN_dec2bn(&b, bSel.c_str());
|
||||
BN_dec2bn(&generatorX, generatorXSel.c_str());
|
||||
BN_dec2bn(&generatorY, generatorYSel.c_str());
|
||||
|
||||
BN_dec2bn(&publicKeyX, publicKeyXSel.c_str());
|
||||
BN_dec2bn(&publicKeyY, publicKeyYSel.c_str());
|
||||
|
||||
/* Elliptic Curve calculations. */
|
||||
// The group is defined via Fp = all integers [0; p - 1], where p is prime.
|
||||
// The function EC_POINT_set_affine_coordinates() sets the x and y coordinates for the point p defined over the curve given in group.
|
||||
EC_GROUP *eCurve = EC_GROUP_new_curve_GFp(p, a, b, context);
|
||||
|
||||
// Create new point for the generator on the elliptic curve and set its coordinates to (genX; genY).
|
||||
genPoint = EC_POINT_new(eCurve);
|
||||
EC_POINT_set_affine_coordinates(eCurve, genPoint, generatorX, generatorY, context);
|
||||
|
||||
// Create new point for the public key on the elliptic curve and set its coordinates to (pubX; pubY).
|
||||
pubPoint = EC_POINT_new(eCurve);
|
||||
EC_POINT_set_affine_coordinates(eCurve, pubPoint, publicKeyX, publicKeyY, context);
|
||||
|
||||
// If generator and public key points are not on the elliptic curve, either the generator or the public key values are incorrect.
|
||||
assert(EC_POINT_is_on_curve(eCurve, genPoint, context) == true);
|
||||
assert(EC_POINT_is_on_curve(eCurve, pubPoint, context) == true);
|
||||
|
||||
// Cleanup
|
||||
BN_CTX_free(context);
|
||||
BN_free(p);
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(generatorX);
|
||||
BN_free(generatorY);
|
||||
BN_free(publicKeyX);
|
||||
BN_free(publicKeyY);
|
||||
|
||||
return eCurve;
|
||||
}
|
||||
|
||||
int PIDGEN3::BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen) {
|
||||
if (a == nullptr || to == nullptr)
|
||||
return 0;
|
||||
|
||||
int len = BN_bn2bin(a, to);
|
||||
|
||||
if (len > tolen)
|
||||
return -1;
|
||||
|
||||
// Choke point inside BN_bn2lebinpad: OpenSSL uses len instead of tolen.
|
||||
endian(to, tolen);
|
||||
|
||||
return len;
|
||||
}
|
63
src/main.cpp
Normal file
63
src/main.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "header.h"
|
||||
#include "cli.h"
|
||||
|
||||
Options options;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (!CLI::parseCommandLine(argc, argv, &options)) {
|
||||
fmt::print("error parsing command line options\n");
|
||||
CLI::showHelp(argv);
|
||||
return !options.error ? 0 : 1;
|
||||
}
|
||||
|
||||
json keys;
|
||||
|
||||
int status = CLI::validateCommandLine(&options, argv, &keys);
|
||||
if (status > 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
CLI run(options, keys);
|
||||
|
||||
switch(options.applicationMode) {
|
||||
case MODE_BINK1998_GENERATE:
|
||||
return run.BINK1998Generate();
|
||||
|
||||
case MODE_BINK2002_GENERATE:
|
||||
return run.BINK2002Generate();
|
||||
|
||||
case MODE_BINK1998_VALIDATE:
|
||||
return run.BINK1998Validate();
|
||||
|
||||
case MODE_BINK2002_VALIDATE:
|
||||
return run.BINK2002Validate();
|
||||
|
||||
case MODE_CONFIRMATION_ID:
|
||||
return run.ConfirmationID();
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
59
src/typedefs.h
Normal file
59
src/typedefs.h
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_TYPEDEFS_H
|
||||
#define UMSKT_TYPEDEFS_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <cassert>
|
||||
#else
|
||||
#define assert(x) /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT extern "C"
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#define FNEXPORT EMSCRIPTEN_KEEPALIVE EXPORT
|
||||
#else
|
||||
#define FNEXPORT EXPORT
|
||||
#endif
|
||||
|
||||
// Type definitions
|
||||
typedef bool BOOL;
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint16_t WORD;
|
||||
typedef uint32_t DWORD;
|
||||
typedef uint64_t QWORD;
|
||||
|
||||
#ifdef __SIZEOF_INT128__
|
||||
typedef unsigned __int128 OWORD;
|
||||
#endif
|
||||
|
||||
#endif //UMSKT_TYPEDEFS_H
|
46
src/windows/dllmain.cpp
Normal file
46
src/windows/dllmain.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
BOOLEAN WINAPI DllMain( IN HINSTANCE hDllHandle,
|
||||
IN DWORD nReason,
|
||||
IN LPVOID Reserved ) {
|
||||
|
||||
BOOLEAN bSuccess = TRUE;
|
||||
// Perform global initialization.
|
||||
switch (nReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
// For optimization.
|
||||
DisableThreadLibraryCalls(hDllHandle);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
// end DllMain
|
BIN
src/windows/icon.ico
Normal file
BIN
src/windows/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
38
src/windows/resource.h
Normal file
38
src/windows/resource.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 6/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by umskt.rc
|
||||
//
|
||||
#define IDI_ICON1 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
BIN
src/windows/umskt.rc
Normal file
BIN
src/windows/umskt.rc
Normal file
Binary file not shown.
Reference in New Issue
Block a user