mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-09-04 22:45:47 +00:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
343fe653ee | ||
|
|
bfb4e91be7 | ||
|
|
898d1c1789 | ||
|
|
e4167afbec | ||
|
|
aeaf99729f | ||
|
|
d125a063ce | ||
|
|
ce926f7cc9 | ||
|
|
aea2da2a36 | ||
|
|
c869dca3c1 | ||
|
|
cbe8254d84 | ||
|
|
331df17ee7 | ||
|
|
35852182b2 | ||
|
|
e0d1eb1a98 | ||
|
|
0717a39c02 | ||
|
|
4993be82a6 | ||
|
|
0dbed4777f | ||
|
|
3b529862d1 | ||
|
|
6da98653fc | ||
|
|
27e023fb28 | ||
|
|
df6b25a30e | ||
|
|
60294067c7 | ||
|
|
d309253b06 | ||
|
|
b3579cb363 | ||
|
|
0f2c5e6081 | ||
|
|
8f59465bf0 | ||
|
|
736af6817b | ||
|
|
10a56eb673 | ||
|
|
6518dda504 | ||
|
|
74e812fa2b | ||
|
|
810909828a | ||
|
|
49f4ad0a59 | ||
|
|
ece607c8f7 | ||
|
|
1426fc061a | ||
|
|
7579dadaea | ||
|
|
6b6669fb23 | ||
|
|
5f603dcebc | ||
|
|
e1994f69d6 | ||
|
|
39af3326bd | ||
|
|
c657f2e736 | ||
|
|
a8dd672a66 | ||
|
|
cf01bbda4d | ||
|
|
1c9207d498 | ||
|
|
f1ed27cb52 | ||
|
|
8d38a80dd8 | ||
|
|
f4af3671be | ||
|
|
2f0f0b1abb | ||
|
|
ea10a1a4c7 | ||
|
|
bd03ecb963 | ||
|
|
5b909283a0 | ||
|
|
289ea3a34f | ||
|
|
aaf997c20d | ||
|
|
ab61c4937f | ||
|
|
8790f8f322 | ||
|
|
5137e190ac | ||
|
|
97974bd9c6 | ||
|
|
a99490184d | ||
|
|
da97108900 | ||
|
|
ba72caaead | ||
|
|
8e8f42831f | ||
|
|
aea034bcf6 | ||
|
|
a7ddc582b1 | ||
|
|
cb0310bbcd | ||
|
|
38b73158f4 | ||
|
|
ac9c61924d | ||
|
|
073e8811d8 | ||
|
|
3207b0ccd3 | ||
|
|
65dff5204a | ||
|
|
10349947e6 | ||
|
|
2e7b31abf5 | ||
|
|
32ef5f3aeb | ||
|
|
3ba9e027e3 | ||
|
|
f6fea00c16 | ||
|
|
391d019a42 | ||
|
|
4c6ab80b09 | ||
|
|
098f967cfd | ||
|
|
e61c981f84 | ||
|
|
29663ed175 | ||
|
|
fd2baf25a0 | ||
|
|
f65a65e830 | ||
|
|
dc8118e5ab | ||
|
|
9b4d525aa2 | ||
|
|
eef9552fda | ||
|
|
2126382b54 | ||
|
|
a9eef1d574 | ||
|
|
bd097583eb | ||
|
|
23a853d585 | ||
|
|
9b6b8c7e2f | ||
|
|
4c52806821 | ||
|
|
136c1ddcd4 | ||
|
|
e5fb3ff784 | ||
|
|
9dd745578b | ||
|
|
9d06111ac5 | ||
|
|
7fdd5724bb |
19
.github/workflows/mikrotik_patch_6.yml
vendored
19
.github/workflows/mikrotik_patch_6.yml
vendored
@@ -3,8 +3,8 @@ name: Patch Mikrotik RouterOS 6.x
|
|||||||
on:
|
on:
|
||||||
# push:
|
# push:
|
||||||
# branches: [ "main" ]
|
# branches: [ "main" ]
|
||||||
schedule:
|
# schedule:
|
||||||
- cron: "0 0 * * *"
|
# - cron: "0 0 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -17,7 +17,7 @@ env:
|
|||||||
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
||||||
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_PUBLIC_KEY }}
|
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_PUBLIC_KEY }}
|
||||||
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
||||||
MIKRO_NPK_SIGN_PUBLIC_LKEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_LKEY }}
|
MIKRO_NPK_SIGN_PUBLIC_KEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_KEY }}
|
||||||
MIKRO_CLOUD_PUBLIC_KEY: ${{ secrets.MIKRO_CLOUD_PUBLIC_KEY }}
|
MIKRO_CLOUD_PUBLIC_KEY: ${{ secrets.MIKRO_CLOUD_PUBLIC_KEY }}
|
||||||
MIKRO_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
|
MIKRO_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
|
||||||
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
|
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
|
||||||
@@ -221,17 +221,18 @@ jobs:
|
|||||||
- name: Upload Files
|
- name: Upload Files
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./publish/$LATEST_VERSION
|
sudo mkdir -p ./publish/$LATEST_VERSION
|
||||||
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWEST6.${{ matrix.channel }}
|
echo $LATEST_VERSION $BUILD_TIME | sudo tee ./publish/NEWEST6.${{ matrix.channel }}
|
||||||
cp CHANGELOG ./publish/$LATEST_VERSION/
|
sudo cp CHANGELOG ./publish/$LATEST_VERSION/
|
||||||
cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
||||||
sudo apt-get install -y lftp > /dev/null 2>&1
|
sudo chown -R root:root ./publish/
|
||||||
|
sudo apt-get install -y lftp ssh sshpass > /dev/null 2>&1
|
||||||
sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <<EOF
|
sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <<EOF
|
||||||
set sftp:auto-confirm yes
|
set sftp:auto-confirm yes
|
||||||
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
||||||
bye
|
bye
|
||||||
EOF
|
EOF
|
||||||
|
sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} "chown -R 32768:32768 /rw/disk/${{ secrets.SSH_DIRECTORY }}/"
|
||||||
- name: Clear Cloudflare cache
|
- name: Clear Cloudflare cache
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
208
.github/workflows/mikrotik_patch_7.yml
vendored
208
.github/workflows/mikrotik_patch_7.yml
vendored
@@ -2,10 +2,36 @@ name: Patch Mikrotik RouterOS 7.x
|
|||||||
on:
|
on:
|
||||||
# push:
|
# push:
|
||||||
# branches: [ "main" ]
|
# branches: [ "main" ]
|
||||||
schedule:
|
# schedule:
|
||||||
- cron: "0 0 * * *"
|
# - cron: "0 0 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
arch:
|
||||||
|
description: 'Architecture (x86, arm64)'
|
||||||
|
required: true
|
||||||
|
default: 'x86'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- x86
|
||||||
|
- arm64
|
||||||
|
channel:
|
||||||
|
description: 'Channel (stable, testing)'
|
||||||
|
required: true
|
||||||
|
default: 'stable'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- stable
|
||||||
|
- testing
|
||||||
|
version:
|
||||||
|
description: "Version ('', 7.17, 7.17.1, 7.17.2,...)"
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
|
buildtime:
|
||||||
|
description: "Build Time"
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
@@ -16,7 +42,7 @@ env:
|
|||||||
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
||||||
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_PUBLIC_KEY }}
|
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_PUBLIC_KEY }}
|
||||||
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
||||||
MIKRO_NPK_SIGN_PUBLIC_LKEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_LKEY }}
|
MIKRO_NPK_SIGN_PUBLIC_KEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_KEY }}
|
||||||
MIKRO_CLOUD_PUBLIC_KEY: ${{ secrets.MIKRO_CLOUD_PUBLIC_KEY }}
|
MIKRO_CLOUD_PUBLIC_KEY: ${{ secrets.MIKRO_CLOUD_PUBLIC_KEY }}
|
||||||
MIKRO_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
|
MIKRO_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
|
||||||
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
|
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
|
||||||
@@ -35,20 +61,25 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Set build time
|
- name: Set build time
|
||||||
id: set_buildtime
|
id: set_buildtime
|
||||||
run: echo "BUILD_TIME=$(date +'%s')" >> $GITHUB_OUTPUT
|
run: |
|
||||||
|
_BUILD_TIME=${{ github.event.inputs.buildtime }}
|
||||||
|
if [ -z "$_BUILD_TIME" ]; then
|
||||||
|
echo "BUILD_TIME=$(date +'%s')" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "BUILD_TIME=$_BUILD_TIME" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
Patch_RouterOS:
|
Patch_RouterOS:
|
||||||
needs: Set_BuildTime
|
needs: Set_BuildTime
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
arch: [x86,arm64]
|
arch: ${{ fromJSON(format('["{0}"]', github.event.inputs.arch || 'x86')) }}
|
||||||
channel: [stable, testing]
|
channel: ${{ fromJSON(format('["{0}"]', github.event.inputs.channel || 'stable')) }}
|
||||||
env:
|
env:
|
||||||
TZ: 'Asia/Shanghai'
|
TZ: 'Asia/Shanghai'
|
||||||
LATEST_VERSION: ""
|
LATEST_VERSION: ""
|
||||||
ARCH: ""
|
ARCH: ""
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -62,7 +93,10 @@ jobs:
|
|||||||
id: get_latest
|
id: get_latest
|
||||||
run: |
|
run: |
|
||||||
echo $(uname -a)
|
echo $(uname -a)
|
||||||
LATEST_VERSION=$(wget -nv -O - https://${{ env.MIKRO_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
LATEST_VERSION=${{ github.event.inputs.version }}
|
||||||
|
if [ -z "$_LATEST_VERSION" ]; then
|
||||||
|
LATEST_VERSION=$(wget -nv -O - https://${{ env.MIKRO_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
||||||
|
fi
|
||||||
echo Latest Version:$LATEST_VERSION
|
echo Latest Version:$LATEST_VERSION
|
||||||
if [ "${{ github.event_name }}" == "schedule" ]; then
|
if [ "${{ github.event_name }}" == "schedule" ]; then
|
||||||
_LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
_LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
||||||
@@ -86,6 +120,25 @@ jobs:
|
|||||||
ARCH='-arm64'
|
ARCH='-arm64'
|
||||||
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
has_patched_npk=false
|
||||||
|
if wget -nv --spider https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/$LATEST_VERSION/routeros-$LATEST_VERSION$ARCH.npk; then
|
||||||
|
echo "RouterOS NPK file exists, attempting to download..."
|
||||||
|
if wget -nv -O routeros-$LATEST_VERSION$ARCH.npk https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/$LATEST_VERSION/routeros-$LATEST_VERSION$ARCH.npk; then
|
||||||
|
echo "RouterOS NPK file downloaded successfully."
|
||||||
|
has_patched_npk=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "has_patched_npk=$has_patched_npk" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
echo "{\"arch\": \"${{ matrix.arch }}\", \"channel\": \"${{ matrix.channel }}\", \"latest_version\": \"$LATEST_VERSION\",\"build_time\": \"$BUILD_TIME\",\"patched\": \"$has_patched_npk\"}" > latest_version_${{ matrix.arch }}_${{ matrix.channel }}.json
|
||||||
|
sudo apt-get update > /dev/null
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: latest_version_${{ matrix.arch }}_${{ matrix.channel }}
|
||||||
|
path: latest_version_${{ matrix.arch }}_${{ matrix.channel }}.json
|
||||||
|
|
||||||
- name: Cache Squashfs
|
- name: Cache Squashfs
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
@@ -120,19 +173,19 @@ jobs:
|
|||||||
sudo mksquashfs option-root option.sfs -quiet -comp xz -no-xattrs -b 256k
|
sudo mksquashfs option-root option.sfs -quiet -comp xz -no-xattrs -b 256k
|
||||||
sudo rm -rf option-root
|
sudo rm -rf option-root
|
||||||
if [ "${{ matrix.arch }}" == "x86" ]; then
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
||||||
sudo wget -O cpython-3.11.9.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20240713/cpython-3.11.9+20240713-x86_64-unknown-linux-gnu-install_only.tar.gz
|
sudo wget -O cpython.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-x86_64-unknown-linux-musl-install_only_stripped.tar.gz
|
||||||
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
||||||
sudo wget -O cpython-3.11.9.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20240713/cpython-3.11.9+20240713-aarch64-unknown-linux-gnu-install_only.tar.gz
|
sudo wget -O cpython.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-aarch64-unknown-linux-gnu-install_only_stripped.tar.gz
|
||||||
fi
|
fi
|
||||||
sudo tar -xf cpython-3.11.9.tar.gz
|
sudo tar -xf cpython.tar.gz
|
||||||
sudo rm cpython-3.11.9.tar.gz
|
sudo rm cpython.tar.gz
|
||||||
sudo rm -rf ./python/include
|
sudo rm -rf ./python/include
|
||||||
sudo rm -rf ./python/share
|
sudo rm -rf ./python/share
|
||||||
sudo mksquashfs python python3.sfs -quiet -comp xz -no-xattrs -b 256k
|
sudo mksquashfs python python3.sfs -quiet -comp xz -no-xattrs -b 256k
|
||||||
sudo rm -rf ./python
|
sudo rm -rf ./python
|
||||||
|
|
||||||
- name: Cache NetInstall ${{ env.LATEST_VERSION }}
|
- name: Cache NetInstall ${{ env.LATEST_VERSION }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
id: cache-netinstall
|
id: cache-netinstall
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
@@ -142,13 +195,13 @@ jobs:
|
|||||||
key: netinstall-${{ env.LATEST_VERSION }}
|
key: netinstall-${{ env.LATEST_VERSION }}
|
||||||
|
|
||||||
- name: Get netinstall ${{ env.LATEST_VERSION }}
|
- name: Get netinstall ${{ env.LATEST_VERSION }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip
|
sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip
|
||||||
sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz
|
sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz
|
||||||
|
|
||||||
- name: Patch netinstall ${{ env.LATEST_VERSION }}
|
- name: Patch netinstall ${{ env.LATEST_VERSION }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
sudo unzip netinstall.zip
|
sudo unzip netinstall.zip
|
||||||
sudo -E python3 patch.py netinstall netinstall.exe
|
sudo -E python3 patch.py netinstall netinstall.exe
|
||||||
@@ -183,13 +236,17 @@ jobs:
|
|||||||
sudo rsync -a ./iso/ ./new_iso/
|
sudo rsync -a ./iso/ ./new_iso/
|
||||||
sudo umount ./iso
|
sudo umount ./iso
|
||||||
sudo rm -rf ./iso
|
sudo rm -rf ./iso
|
||||||
sudo mv ./new_iso/routeros-$LATEST_VERSION$ARCH.npk ./
|
if [ "${{ steps.get_latest.outputs.has_patched_npk }}" == "false" ]; then
|
||||||
sudo -E python3 patch.py npk routeros-$LATEST_VERSION$ARCH.npk
|
sudo mv ./new_iso/routeros-$LATEST_VERSION$ARCH.npk ./
|
||||||
|
sudo -E python3 patch.py npk routeros-$LATEST_VERSION$ARCH.npk
|
||||||
|
else
|
||||||
|
sudo -E python3 npk.py sign routeros-$LATEST_VERSION$ARCH.npk routeros-$LATEST_VERSION$ARCH.npk
|
||||||
|
fi
|
||||||
NPK_FILES=$(find ./new_iso/*.npk)
|
NPK_FILES=$(find ./new_iso/*.npk)
|
||||||
for file in $NPK_FILES; do
|
for file in $NPK_FILES; do
|
||||||
sudo -E python3 npk.py sign $file $file
|
sudo -E python3 npk.py sign $file $file
|
||||||
done
|
done
|
||||||
sudo cp routeros-$LATEST_VERSION$ARCH.npk ./new_iso/
|
sudo cp -f routeros-$LATEST_VERSION$ARCH.npk ./new_iso/
|
||||||
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./option-$LATEST_VERSION$ARCH.npk option ./option.sfs -desc="busybox"
|
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./option-$LATEST_VERSION$ARCH.npk option ./option.sfs -desc="busybox"
|
||||||
sudo cp option-$LATEST_VERSION$ARCH.npk ./new_iso/
|
sudo cp option-$LATEST_VERSION$ARCH.npk ./new_iso/
|
||||||
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./python3-$LATEST_VERSION$ARCH.npk python3 ./python3.sfs -desc="python 3.11.9"
|
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./python3-$LATEST_VERSION$ARCH.npk python3 ./python3.sfs -desc="python 3.11.9"
|
||||||
@@ -238,7 +295,7 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Cache refind
|
- name: Cache refind
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
id: cache-refind
|
id: cache-refind
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
@@ -246,11 +303,11 @@ jobs:
|
|||||||
key: refind
|
key: refind
|
||||||
|
|
||||||
- name: Get refind
|
- name: Get refind
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip
|
run: sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip
|
||||||
|
|
||||||
- name: Create install-image-${{ env.LATEST_VERSION }}.img
|
- name: Create install-image-${{ env.LATEST_VERSION }}.img
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
sudo modprobe nbd
|
sudo modprobe nbd
|
||||||
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
||||||
@@ -288,7 +345,7 @@ jobs:
|
|||||||
sudo rm ./install-image-$LATEST_VERSION.img
|
sudo rm ./install-image-$LATEST_VERSION.img
|
||||||
|
|
||||||
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
|
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'arm64'
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
id: cache-chr-img
|
id: cache-chr-img
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
@@ -297,7 +354,7 @@ jobs:
|
|||||||
key: chr-${{ env.LATEST_VERSION }}-${{ matrix.arch }}.img
|
key: chr-${{ env.LATEST_VERSION }}-${{ matrix.arch }}.img
|
||||||
|
|
||||||
- name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
- name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-chr-img.outputs.cache-hit != 'true' && matrix.arch == 'arm64'
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-chr-img.outputs.cache-hit != 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
sudo wget -nv -O chr.img.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/chr-$LATEST_VERSION$ARCH.img.zip
|
sudo wget -nv -O chr.img.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/chr-$LATEST_VERSION$ARCH.img.zip
|
||||||
sudo unzip chr.img.zip
|
sudo unzip chr.img.zip
|
||||||
@@ -305,10 +362,10 @@ jobs:
|
|||||||
sudo mv chr-$LATEST_VERSION$ARCH.img chr.img
|
sudo mv chr-$LATEST_VERSION$ARCH.img chr.img
|
||||||
|
|
||||||
- name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
- name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
sudo modprobe nbd
|
sudo modprobe nbd
|
||||||
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
sudo apt-get install -y qemu-utils > /dev/null
|
||||||
truncate --size 128M chr-$LATEST_VERSION$ARCH.img
|
truncate --size 128M chr-$LATEST_VERSION$ARCH.img
|
||||||
sgdisk --clear --set-alignment=2 \
|
sgdisk --clear --set-alignment=2 \
|
||||||
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
||||||
@@ -329,12 +386,44 @@ jobs:
|
|||||||
sudo mkdir -p ./img/{boot,routeros}
|
sudo mkdir -p ./img/{boot,routeros}
|
||||||
sudo mount /dev/nbd0p1 ./img/boot/
|
sudo mount /dev/nbd0p1 ./img/boot/
|
||||||
if [ "${{ matrix.arch }}" == "x86" ]; then
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
||||||
sudo mkdir -p ./img/boot/{BOOT,EFI/BOOT}
|
sudo cp chr.img chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||||
sudo cp BOOTX64.EFI ./img/boot/EFI/BOOT/BOOTX64.EFI
|
sudo qemu-nbd -c /dev/nbd1 -f raw chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||||
sudo extlinux --install -H 64 -S 32 ./img/boot/BOOT
|
sudo -E python3 patch.py block /dev/nbd1p1 EFI/BOOT/BOOTX64.EFI
|
||||||
echo -e "default system\nlabel system\n\tkernel /EFI/BOOT/BOOTX64.EFI\n\tappend load_ramdisk=1 root=/dev/ram0 quiet" > syslinux.cfg
|
sudo mkdir -p ./chr/{boot,routeros}
|
||||||
sudo cp syslinux.cfg ./img/boot/BOOT/
|
sudo mount /dev/nbd1p1 ./chr/boot/
|
||||||
sudo rm syslinux.cfg
|
sudo mkdir -p ./img/boot/EFI/BOOT
|
||||||
|
sudo cp ./chr/boot/EFI/BOOT/BOOTX64.EFI ./img/boot/EFI/BOOT/BOOTX64.EFI
|
||||||
|
sudo umount /dev/nbd1p1
|
||||||
|
sudo shred -v -n 1 -z /dev/nbd1p2
|
||||||
|
sudo mkfs.ext4 -F -L "RouterOS" -m 0 /dev/nbd1p2
|
||||||
|
sudo mount /dev/nbd1p2 ./chr/routeros/
|
||||||
|
sudo mkdir -p ./chr/routeros/{var/pdb/{system,option},boot,rw}
|
||||||
|
sudo cp ./all_packages/option-$LATEST_VERSION$ARCH.npk ./chr/routeros/var/pdb/option/image
|
||||||
|
sudo cp ./all_packages/routeros-$LATEST_VERSION$ARCH.npk ./chr/routeros/var/pdb/system/image
|
||||||
|
sudo umount /dev/nbd1p2
|
||||||
|
sudo qemu-nbd -d /dev/nbd1
|
||||||
|
sudo rm -rf ./chr
|
||||||
|
|
||||||
|
sudo qemu-img convert -f raw -O qcow2 chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2
|
||||||
|
sudo qemu-img convert -f raw -O vmdk chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk
|
||||||
|
sudo qemu-img convert -f raw -O vpc chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vhd
|
||||||
|
sudo qemu-img convert -f raw -O vhdx chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vhdx
|
||||||
|
sudo qemu-img convert -f raw -O vdi chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vdi
|
||||||
|
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2.zip chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhd.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhd
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhdx.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhdx
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vdi.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vdi
|
||||||
|
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.img.zip chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||||
|
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.vhd
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.vhdx
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.vdi
|
||||||
|
sudo rm chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||||
|
|
||||||
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
||||||
sudo qemu-nbd -c /dev/nbd1 -f raw chr.img
|
sudo qemu-nbd -c /dev/nbd1 -f raw chr.img
|
||||||
sudo mkdir -p ./chr/boot
|
sudo mkdir -p ./chr/boot
|
||||||
@@ -375,20 +464,26 @@ jobs:
|
|||||||
sudo rm chr-$LATEST_VERSION$ARCH.vdi
|
sudo rm chr-$LATEST_VERSION$ARCH.vdi
|
||||||
sudo rm chr-$LATEST_VERSION$ARCH.img
|
sudo rm chr-$LATEST_VERSION$ARCH.img
|
||||||
|
|
||||||
|
|
||||||
- name: Upload Files
|
- name: Upload Files
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./publish/$LATEST_VERSION
|
if [ "${{ steps.get_latest.outputs.has_patched_npk }}" == "false" ]; then
|
||||||
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }}
|
OUTDIR="$LATEST_VERSION-UNDONE"
|
||||||
cp CHANGELOG ./publish/$LATEST_VERSION/
|
else
|
||||||
cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
OUTDIR="$LATEST_VERSION"
|
||||||
sudo apt-get install -y lftp > /dev/null 2>&1
|
fi
|
||||||
|
sudo mkdir -p ./publish/$OUTDIR
|
||||||
|
sudo cp CHANGELOG ./publish/$OUTDIR/
|
||||||
|
sudo cp ./all_packages/*.npk ./publish/$OUTDIR/
|
||||||
|
sudo chown -R root:root ./publish/
|
||||||
|
sudo apt-get install -y lftp ssh sshpass > /dev/null 2>&1
|
||||||
sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <<EOF
|
sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <<EOF
|
||||||
set sftp:auto-confirm yes
|
set sftp:auto-confirm yes
|
||||||
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
||||||
bye
|
bye
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Clear Cloudflare cache
|
- name: Clear Cloudflare cache
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
@@ -398,7 +493,7 @@ jobs:
|
|||||||
--data '{"purge_everything": true}'
|
--data '{"purge_everything": true}'
|
||||||
|
|
||||||
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
run: |
|
run: |
|
||||||
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||||
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
|
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
|
||||||
@@ -414,7 +509,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.get_latest.outputs.has_patched_npk == 'true'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
|
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
|
||||||
@@ -428,6 +523,35 @@ jobs:
|
|||||||
netinstall-${{ env.LATEST_VERSION }}.*
|
netinstall-${{ env.LATEST_VERSION }}.*
|
||||||
install-image-${{ env.LATEST_VERSION }}.zip
|
install-image-${{ env.LATEST_VERSION }}.zip
|
||||||
routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||||
option-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
|
||||||
all_packages-*-${{ env.LATEST_VERSION }}.zip
|
all_packages-*-${{ env.LATEST_VERSION }}.zip
|
||||||
*.EFI
|
|
||||||
|
Create_CSV:
|
||||||
|
needs: Patch_RouterOS
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
pattern: latest_version_*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Create Packages CSV File
|
||||||
|
run: |
|
||||||
|
sudo apt-get install ssh sshpass
|
||||||
|
for file in artifacts/latest_version_*.json; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
arch=$(jq -r '.arch' "$file")
|
||||||
|
channel=$(jq -r '.channel' "$file")
|
||||||
|
latest_version=$(jq -r '.latest_version' "$file")
|
||||||
|
build_time=$(jq -r '.build_time' "$file")
|
||||||
|
has_patched_npk=$(jq -r '.patched' "$file")
|
||||||
|
echo "Arch: $arch, Channel: $channel, Latest Version: $latest_version,Build Time: $build_time,Has Patched NPK: $has_patched_npk"
|
||||||
|
if [ "$has_patched_npk" == "false" ]; then
|
||||||
|
OUTDIR="$latest_version-UNDONE"
|
||||||
|
else
|
||||||
|
OUTDIR="$latest_version"
|
||||||
|
fi
|
||||||
|
sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} "echo $latest_version $build_time | tee /rw/disk/${{ secrets.SSH_DIRECTORY }}/NEWESTa7.$channel; /rw/disk/${{ secrets.SSH_DIRECTORY }}/packages.sh /rw/disk/${{ secrets.SSH_DIRECTORY }}/$OUTDIR"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} "chown -R 32768:32768 /rw/disk/${{ secrets.SSH_DIRECTORY }}/"
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_6.yml)
|
||||||
|
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_7.yml)
|
||||||
# MikroTik RouterOS Patch [[English](README_EN.md)]
|
# MikroTik RouterOS Patch [[English](README_EN.md)]
|
||||||
|
|
||||||
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
|
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
|
||||||
@@ -50,3 +52,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_6.yml)
|
||||||
|
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_7.yml)
|
||||||
# MikroTik RouterOS Patch [[中文](README.md)]
|
# MikroTik RouterOS Patch [[中文](README.md)]
|
||||||
|
|
||||||
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
|
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
|
||||||
@@ -44,4 +46,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
11
mikro.py
11
mikro.py
@@ -1,8 +1,7 @@
|
|||||||
|
import random
|
||||||
import struct
|
import struct
|
||||||
from sha256 import SHA256
|
from sha256 import SHA256
|
||||||
from toyecc import AffineCurvePoint, getcurvebyname, FieldElement,ECPrivateKey,ECPublicKey,Tools
|
from toyecc import AffineCurvePoint, getcurvebyname, FieldElement,ECPrivateKey,ECPublicKey,Tools
|
||||||
from toyecc.Random import secure_rand_int_between
|
|
||||||
|
|
||||||
|
|
||||||
MIKRO_BASE64_CHARACTER_TABLE = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
MIKRO_BASE64_CHARACTER_TABLE = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||||
@@ -39,8 +38,8 @@ def mikro_softwareid_encode(id:int)->str:
|
|||||||
assert(isinstance(id, int))
|
assert(isinstance(id, int))
|
||||||
ret = ''
|
ret = ''
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
ret += chr(SOFTWARE_ID_CHARACTER_TABLE[id % 0x23])
|
ret += chr(SOFTWARE_ID_CHARACTER_TABLE[id % len(SOFTWARE_ID_CHARACTER_TABLE)])
|
||||||
id //= 0x23
|
id //= len(SOFTWARE_ID_CHARACTER_TABLE)
|
||||||
if i == 3:
|
if i == 3:
|
||||||
ret += '-'
|
ret += '-'
|
||||||
return ret
|
return ret
|
||||||
@@ -167,7 +166,7 @@ def mikro_kcdsa_sign(data:bytes,private_key:bytes)->bytes:
|
|||||||
private_key:ECPrivateKey = ECPrivateKey(Tools.bytestoint_le(private_key), curve)
|
private_key:ECPrivateKey = ECPrivateKey(Tools.bytestoint_le(private_key), curve)
|
||||||
public_key:ECPublicKey = private_key.pubkey
|
public_key:ECPublicKey = private_key.pubkey
|
||||||
while True:
|
while True:
|
||||||
nonce_secret = secure_rand_int_between(1, curve.n - 1)
|
nonce_secret = random.SystemRandom().randint(1, curve.n - 1)
|
||||||
nonce_point = nonce_secret * curve.G
|
nonce_point = nonce_secret * curve.G
|
||||||
nonce = int(nonce_point.x) % curve.n
|
nonce = int(nonce_point.x) % curve.n
|
||||||
nonce_hash = mikro_sha256(Tools.inttobytes_le(nonce,32))
|
nonce_hash = mikro_sha256(Tools.inttobytes_le(nonce,32))
|
||||||
@@ -205,4 +204,4 @@ def mikro_kcdsa_verify(data:bytes, signature:bytes, public_key:bytes)->bool:
|
|||||||
nonce = int((public_key * signature + curve.G * data_hash).x)
|
nonce = int((public_key * signature + curve.G * data_hash).x)
|
||||||
if mikro_sha256(Tools.inttobytes_le(nonce,32))[:len(nonce_hash)] == nonce_hash:
|
if mikro_sha256(Tools.inttobytes_le(nonce,32))[:len(nonce_hash)] == nonce_hash:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
66
patch.py
66
patch.py
@@ -1,7 +1,34 @@
|
|||||||
import subprocess,lzma
|
import subprocess,lzma
|
||||||
import struct,os
|
import struct,os,re
|
||||||
from npk import NovaPackage,NpkPartID,NpkFileContainer
|
from npk import NovaPackage,NpkPartID,NpkFileContainer
|
||||||
|
|
||||||
|
def replace_chunks(old_chunks,new_chunks,data,name):
|
||||||
|
pattern_parts = [re.escape(chunk) + b'(.{0,6})' for chunk in old_chunks[:-1]]
|
||||||
|
pattern_parts.append(re.escape(old_chunks[-1]))
|
||||||
|
pattern_bytes = b''.join(pattern_parts)
|
||||||
|
pattern = re.compile(pattern_bytes, flags=re.DOTALL)
|
||||||
|
def replace_match(match):
|
||||||
|
replaced = b''.join([new_chunks[i] + match.group(i+1) for i in range(len(new_chunks) - 1)])
|
||||||
|
replaced += new_chunks[-1]
|
||||||
|
print(f'{name} public key patched {b"".join(old_chunks)[:16].hex().upper()}...')
|
||||||
|
return replaced
|
||||||
|
return re.sub(pattern, replace_match, data)
|
||||||
|
|
||||||
|
def replace_key(old,new,data,name=''):
|
||||||
|
old_chunks = [old[i:i+4] for i in range(0, len(old), 4)]
|
||||||
|
new_chunks = [new[i:i+4] for i in range(0, len(new), 4)]
|
||||||
|
data = replace_chunks(old_chunks, new_chunks, data,name)
|
||||||
|
if os.environ['ARCH'] == '-arm64' and os.environ['LATEST_VERSION'] == '7.17.2':
|
||||||
|
old_bytes = old_chunks[4] + old_chunks[5] + old_chunks[2] + old_chunks[0] + old_chunks[1] + old_chunks[6] + old_chunks[7]
|
||||||
|
new_bytes = new_chunks[4] + new_chunks[5] + new_chunks[2] + new_chunks[0] + new_chunks[1] + new_chunks[6] + new_chunks[7]
|
||||||
|
if old_bytes in data:
|
||||||
|
print(f'{name} public key patched {old[:16].hex().upper()}...')
|
||||||
|
data = data.replace(old_bytes,new_bytes)
|
||||||
|
old_codes = [bytes.fromhex('793583E2'),bytes.fromhex('FD3A83E2'),bytes.fromhex('193D83E2')]
|
||||||
|
new_codes = [bytes.fromhex('FF34A0E3'),bytes.fromhex('753C83E2'),bytes.fromhex('FC3083E2')]
|
||||||
|
data = replace_chunks(old_codes, new_codes, data,name)
|
||||||
|
return data
|
||||||
|
|
||||||
def patch_bzimage(data:bytes,key_dict:dict):
|
def patch_bzimage(data:bytes,key_dict:dict):
|
||||||
PE_TEXT_SECTION_OFFSET = 414
|
PE_TEXT_SECTION_OFFSET = 414
|
||||||
HEADER_PAYLOAD_OFFSET = 584
|
HEADER_PAYLOAD_OFFSET = 584
|
||||||
@@ -22,9 +49,7 @@ def patch_bzimage(data:bytes,key_dict:dict):
|
|||||||
initramfs = initramfs[:cpio_offset2]
|
initramfs = initramfs[:cpio_offset2]
|
||||||
new_initramfs = initramfs
|
new_initramfs = initramfs
|
||||||
for old_public_key,new_public_key in key_dict.items():
|
for old_public_key,new_public_key in key_dict.items():
|
||||||
if old_public_key in new_initramfs:
|
new_initramfs = replace_key(old_public_key,new_public_key,new_initramfs,'initramfs')
|
||||||
print(f'initramfs public key patched {old_public_key[:16].hex().upper()}...')
|
|
||||||
new_initramfs = new_initramfs.replace(old_public_key,new_public_key)
|
|
||||||
new_vmlinux = vmlinux.replace(initramfs,new_initramfs)
|
new_vmlinux = vmlinux.replace(initramfs,new_initramfs)
|
||||||
new_vmlinux_xz = lzma.compress(new_vmlinux,check=lzma.CHECK_CRC32,filters=[
|
new_vmlinux_xz = lzma.compress(new_vmlinux,check=lzma.CHECK_CRC32,filters=[
|
||||||
{"id": lzma.FILTER_X86},
|
{"id": lzma.FILTER_X86},
|
||||||
@@ -53,6 +78,7 @@ def patch_block(dev:str,file:str,key_dict):
|
|||||||
stdout,_ = run_shell_command(f"debugfs {dev} -R 'stat {file}' 2> /dev/null | sed -n '11p' ")
|
stdout,_ = run_shell_command(f"debugfs {dev} -R 'stat {file}' 2> /dev/null | sed -n '11p' ")
|
||||||
#(0-11):1592-1603, (IND):1173, (12-15):1604-1607, (16-26):1424-1434
|
#(0-11):1592-1603, (IND):1173, (12-15):1604-1607, (16-26):1424-1434
|
||||||
blocks_info = stdout.decode().strip().split(',')
|
blocks_info = stdout.decode().strip().split(',')
|
||||||
|
print(f'blocks_info : {blocks_info}')
|
||||||
blocks = []
|
blocks = []
|
||||||
ind_block_id = None
|
ind_block_id = None
|
||||||
for block_info in blocks_info:
|
for block_info in blocks_info:
|
||||||
@@ -60,6 +86,7 @@ def patch_block(dev:str,file:str,key_dict):
|
|||||||
if _tmp[0].strip() == '(IND)':
|
if _tmp[0].strip() == '(IND)':
|
||||||
ind_block_id = int(_tmp[1])
|
ind_block_id = int(_tmp[1])
|
||||||
else:
|
else:
|
||||||
|
print(f'block_info : {block_info}')
|
||||||
id_range = _tmp[0].strip().replace('(','').replace(')','').split('-')
|
id_range = _tmp[0].strip().replace('(','').replace(')','').split('-')
|
||||||
block_range = _tmp[1].strip().replace('(','').replace(')','').split('-')
|
block_range = _tmp[1].strip().replace('(','').replace(')','').split('-')
|
||||||
blocks += [id for id in range(int(block_range[0]),int(block_range[1])+1)]
|
blocks += [id for id in range(int(block_range[0]),int(block_range[1])+1)]
|
||||||
@@ -81,15 +108,23 @@ def patch_initrd_xz(initrd_xz:bytes,key_dict:dict,ljust=True):
|
|||||||
initrd = lzma.decompress(initrd_xz)
|
initrd = lzma.decompress(initrd_xz)
|
||||||
new_initrd = initrd
|
new_initrd = initrd
|
||||||
for old_public_key,new_public_key in key_dict.items():
|
for old_public_key,new_public_key in key_dict.items():
|
||||||
if old_public_key in new_initrd:
|
new_initrd = replace_key(old_public_key,new_public_key,new_initrd,'initrd')
|
||||||
print(f'initrd public key patched {old_public_key[:16].hex().upper()}...')
|
preset = 6
|
||||||
new_initrd = new_initrd.replace(old_public_key,new_public_key)
|
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": preset }] )
|
||||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": 9,}] )
|
while len(new_initrd_xz) > len(initrd_xz) and preset < 9:
|
||||||
|
print(f'preset:{preset}')
|
||||||
|
print(f'new initrd xz size:{len(new_initrd_xz)}')
|
||||||
|
print(f'old initrd xz size:{len(initrd_xz)}')
|
||||||
|
preset += 1
|
||||||
|
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": preset }] )
|
||||||
|
if len(new_initrd_xz) > len(initrd_xz):
|
||||||
|
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": 9 | lzma.PRESET_EXTREME,'dict_size': 32*1024*1024,"lc": 4,"lp": 0, "pb": 0,}] )
|
||||||
if ljust:
|
if ljust:
|
||||||
assert len(new_initrd_xz) <= len(initrd_xz),'new initrd xz size is too big'
|
print(f'preset:{preset}')
|
||||||
print(f'new initrd xz size:{len(new_initrd_xz)}')
|
print(f'new initrd xz size:{len(new_initrd_xz)}')
|
||||||
print(f'old initrd xz size:{len(initrd_xz)}')
|
print(f'old initrd xz size:{len(initrd_xz)}')
|
||||||
print(f'ljust size:{len(initrd_xz)-len(new_initrd_xz)}')
|
print(f'ljust size:{len(initrd_xz)-len(new_initrd_xz)}')
|
||||||
|
assert len(new_initrd_xz) <= len(initrd_xz),'new initrd xz size is too big'
|
||||||
new_initrd_xz = new_initrd_xz.ljust(len(initrd_xz),b'\0')
|
new_initrd_xz = new_initrd_xz.ljust(len(initrd_xz),b'\0')
|
||||||
return new_initrd_xz
|
return new_initrd_xz
|
||||||
|
|
||||||
@@ -242,21 +277,22 @@ def patch_kernel(data:bytes,key_dict):
|
|||||||
def patch_squashfs(path,key_dict):
|
def patch_squashfs(path,key_dict):
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
|
if file =='loader':
|
||||||
|
continue
|
||||||
file = os.path.join(root,file)
|
file = os.path.join(root,file)
|
||||||
if os.path.isfile(file):
|
if os.path.isfile(file):
|
||||||
data = open(file,'rb').read()
|
data = open(file,'rb').read()
|
||||||
for old_public_key,new_public_key in key_dict.items():
|
for old_public_key,new_public_key in key_dict.items():
|
||||||
if old_public_key in data:
|
_data = replace_key(old_public_key,new_public_key,data,file)
|
||||||
print(f'{file} public key patched {old_public_key[:16].hex().upper()}...')
|
if _data != data:
|
||||||
data = data.replace(old_public_key,new_public_key)
|
open(file,'wb').write(_data)
|
||||||
open(file,'wb').write(data)
|
|
||||||
data = open(file,'rb').read()
|
|
||||||
url_dict = {
|
url_dict = {
|
||||||
os.environ['MIKRO_LICENCE_URL'].encode():os.environ['CUSTOM_LICENCE_URL'].encode(),
|
os.environ['MIKRO_LICENCE_URL'].encode():os.environ['CUSTOM_LICENCE_URL'].encode(),
|
||||||
os.environ['MIKRO_UPGRADE_URL'].encode():os.environ['CUSTOM_UPGRADE_URL'].encode(),
|
os.environ['MIKRO_UPGRADE_URL'].encode():os.environ['CUSTOM_UPGRADE_URL'].encode(),
|
||||||
os.environ['MIKRO_CLOUD_URL'].encode():os.environ['CUSTOM_CLOUD_URL'].encode(),
|
os.environ['MIKRO_CLOUD_URL'].encode():os.environ['CUSTOM_CLOUD_URL'].encode(),
|
||||||
os.environ['MIKRO_CLOUD_PUBLIC_KEY'].encode():os.environ['CUSTOM_CLOUD_PUBLIC_KEY'].encode(),
|
os.environ['MIKRO_CLOUD_PUBLIC_KEY'].encode():os.environ['CUSTOM_CLOUD_PUBLIC_KEY'].encode(),
|
||||||
}
|
}
|
||||||
|
data = open(file,'rb').read()
|
||||||
for old_url,new_url in url_dict.items():
|
for old_url,new_url in url_dict.items():
|
||||||
if old_url in data:
|
if old_url in data:
|
||||||
print(f'{file} url patched {old_url.decode()[:7]}...')
|
print(f'{file} url patched {old_url.decode()[:7]}...')
|
||||||
@@ -331,7 +367,7 @@ if __name__ == '__main__':
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
key_dict = {
|
key_dict = {
|
||||||
bytes.fromhex(os.environ['MIKRO_LICENSE_PUBLIC_KEY']):bytes.fromhex(os.environ['CUSTOM_LICENSE_PUBLIC_KEY']),
|
bytes.fromhex(os.environ['MIKRO_LICENSE_PUBLIC_KEY']):bytes.fromhex(os.environ['CUSTOM_LICENSE_PUBLIC_KEY']),
|
||||||
bytes.fromhex(os.environ['MIKRO_NPK_SIGN_PUBLIC_LKEY']):bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PUBLIC_KEY'])
|
bytes.fromhex(os.environ['MIKRO_NPK_SIGN_PUBLIC_KEY']):bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PUBLIC_KEY'])
|
||||||
}
|
}
|
||||||
kcdsa_private_key = bytes.fromhex(os.environ['CUSTOM_LICENSE_PRIVATE_KEY'])
|
kcdsa_private_key = bytes.fromhex(os.environ['CUSTOM_LICENSE_PRIVATE_KEY'])
|
||||||
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])
|
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])
|
||||||
|
|||||||
Reference in New Issue
Block a user