mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-08-26 18:15:56 +00:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
4
.github/workflows/mikrotik_patch_6.yml
vendored
4
.github/workflows/mikrotik_patch_6.yml
vendored
@@ -3,8 +3,8 @@ name: Patch Mikrotik RouterOS 6.x
|
||||
on:
|
||||
# push:
|
||||
# branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
# schedule:
|
||||
# - cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
|
||||
193
.github/workflows/mikrotik_patch_7.yml
vendored
193
.github/workflows/mikrotik_patch_7.yml
vendored
@@ -2,10 +2,36 @@ name: Patch Mikrotik RouterOS 7.x
|
||||
on:
|
||||
# push:
|
||||
# branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
# schedule:
|
||||
# - cron: "0 0 * * *"
|
||||
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:
|
||||
contents: write
|
||||
|
||||
@@ -35,20 +61,25 @@ jobs:
|
||||
steps:
|
||||
- name: Set build time
|
||||
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:
|
||||
needs: Set_BuildTime
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86,arm64]
|
||||
channel: [stable, testing]
|
||||
arch: ${{ fromJSON(format('["{0}"]', github.event.inputs.arch || 'x86')) }}
|
||||
channel: ${{ fromJSON(format('["{0}"]', github.event.inputs.channel || 'stable')) }}
|
||||
env:
|
||||
TZ: 'Asia/Shanghai'
|
||||
LATEST_VERSION: ""
|
||||
ARCH: ""
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -62,7 +93,10 @@ jobs:
|
||||
id: get_latest
|
||||
run: |
|
||||
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
|
||||
if [ "${{ github.event_name }}" == "schedule" ]; then
|
||||
_LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
||||
@@ -86,7 +120,25 @@ jobs:
|
||||
ARCH='-arm64'
|
||||
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
||||
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
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
@@ -133,7 +185,7 @@ jobs:
|
||||
sudo rm -rf ./python
|
||||
|
||||
- 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
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -143,13 +195,13 @@ jobs:
|
||||
key: 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: |
|
||||
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
|
||||
|
||||
- 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: |
|
||||
sudo unzip netinstall.zip
|
||||
sudo -E python3 patch.py netinstall netinstall.exe
|
||||
@@ -184,13 +236,15 @@ jobs:
|
||||
sudo rsync -a ./iso/ ./new_iso/
|
||||
sudo umount ./iso
|
||||
sudo rm -rf ./iso
|
||||
sudo mv ./new_iso/routeros-$LATEST_VERSION$ARCH.npk ./
|
||||
sudo -E python3 patch.py npk routeros-$LATEST_VERSION$ARCH.npk
|
||||
if [ "${{ steps.get_latest.outputs.has_patched_npk }}" == "false" ]; then
|
||||
sudo mv ./new_iso/routeros-$LATEST_VERSION$ARCH.npk ./
|
||||
sudo -E python3 patch.py npk routeros-$LATEST_VERSION$ARCH.npk
|
||||
fi
|
||||
NPK_FILES=$(find ./new_iso/*.npk)
|
||||
for file in $NPK_FILES; do
|
||||
sudo -E python3 npk.py sign $file $file
|
||||
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 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"
|
||||
@@ -239,7 +293,7 @@ jobs:
|
||||
cd ..
|
||||
|
||||
- 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
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -247,11 +301,11 @@ jobs:
|
||||
key: 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
|
||||
|
||||
- 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: |
|
||||
sudo modprobe nbd
|
||||
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
||||
@@ -289,7 +343,7 @@ jobs:
|
||||
sudo rm ./install-image-$LATEST_VERSION.img
|
||||
|
||||
- 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
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -298,7 +352,7 @@ jobs:
|
||||
key: chr-${{ env.LATEST_VERSION }}-${{ matrix.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: |
|
||||
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
|
||||
@@ -306,10 +360,10 @@ jobs:
|
||||
sudo mv chr-$LATEST_VERSION$ARCH.img chr.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: |
|
||||
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
|
||||
sgdisk --clear --set-alignment=2 \
|
||||
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
||||
@@ -330,12 +384,44 @@ jobs:
|
||||
sudo mkdir -p ./img/{boot,routeros}
|
||||
sudo mount /dev/nbd0p1 ./img/boot/
|
||||
if [ "${{ matrix.arch }}" == "x86" ]; then
|
||||
sudo mkdir -p ./img/boot/{BOOT,EFI/BOOT}
|
||||
sudo cp BOOTX64.EFI ./img/boot/EFI/BOOT/BOOTX64.EFI
|
||||
sudo extlinux --install -H 64 -S 32 ./img/boot/BOOT
|
||||
echo -e "default system\nlabel system\n\tkernel /EFI/BOOT/BOOTX64.EFI\n\tappend load_ramdisk=1 root=/dev/ram0 quiet" > syslinux.cfg
|
||||
sudo cp syslinux.cfg ./img/boot/BOOT/
|
||||
sudo rm syslinux.cfg
|
||||
sudo cp chr.img chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||
sudo qemu-nbd -c /dev/nbd1 -f raw chr-$LATEST_VERSION$ARCH-legacy-bios.img
|
||||
sudo -E python3 patch.py block /dev/nbd1p1 EFI/BOOT/BOOTX64.EFI
|
||||
sudo mkdir -p ./chr/{boot,routeros}
|
||||
sudo mount /dev/nbd1p1 ./chr/boot/
|
||||
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
|
||||
sudo qemu-nbd -c /dev/nbd1 -f raw chr.img
|
||||
sudo mkdir -p ./chr/boot
|
||||
@@ -376,13 +462,18 @@ jobs:
|
||||
sudo rm chr-$LATEST_VERSION$ARCH.vdi
|
||||
sudo rm chr-$LATEST_VERSION$ARCH.img
|
||||
|
||||
|
||||
- name: Upload Files
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
run: |
|
||||
sudo mkdir -p ./publish/$LATEST_VERSION
|
||||
echo $LATEST_VERSION $BUILD_TIME | sudo tee ./publish/NEWESTa7.${{ matrix.channel }}
|
||||
sudo cp CHANGELOG ./publish/$LATEST_VERSION/
|
||||
sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
||||
if [ "${{ steps.get_latest.outputs.has_patched_npk }}" == "false" ]; then
|
||||
OUTDIR="$LATEST_VERSION-UNDONE"
|
||||
else
|
||||
OUTDIR="$LATEST_VERSION"
|
||||
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
|
||||
@@ -390,9 +481,7 @@ jobs:
|
||||
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
||||
bye
|
||||
EOF
|
||||
sudo apt-get install ssh sshpass
|
||||
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
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
run: |
|
||||
@@ -402,7 +491,7 @@ jobs:
|
||||
--data '{"purge_everything": true}'
|
||||
|
||||
- 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: |
|
||||
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
|
||||
@@ -418,7 +507,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- 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
|
||||
with:
|
||||
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
|
||||
@@ -433,4 +522,34 @@ jobs:
|
||||
install-image-${{ env.LATEST_VERSION }}.zip
|
||||
routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||
all_packages-*-${{ env.LATEST_VERSION }}.zip
|
||||
|
||||
|
||||
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)]
|
||||
|
||||
### [[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)]
|
||||
|
||||
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
|
||||
@@ -44,4 +46,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
48
patch.py
48
patch.py
@@ -1,7 +1,34 @@
|
||||
import subprocess,lzma
|
||||
import struct,os
|
||||
import struct,os,re
|
||||
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):
|
||||
PE_TEXT_SECTION_OFFSET = 414
|
||||
HEADER_PAYLOAD_OFFSET = 584
|
||||
@@ -22,9 +49,7 @@ def patch_bzimage(data:bytes,key_dict:dict):
|
||||
initramfs = initramfs[:cpio_offset2]
|
||||
new_initramfs = initramfs
|
||||
for old_public_key,new_public_key in key_dict.items():
|
||||
if old_public_key in new_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_initramfs = replace_key(old_public_key,new_public_key,new_initramfs,'initramfs')
|
||||
new_vmlinux = vmlinux.replace(initramfs,new_initramfs)
|
||||
new_vmlinux_xz = lzma.compress(new_vmlinux,check=lzma.CHECK_CRC32,filters=[
|
||||
{"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' ")
|
||||
#(0-11):1592-1603, (IND):1173, (12-15):1604-1607, (16-26):1424-1434
|
||||
blocks_info = stdout.decode().strip().split(',')
|
||||
print(f'blocks_info : {blocks_info}')
|
||||
blocks = []
|
||||
ind_block_id = None
|
||||
for block_info in blocks_info:
|
||||
@@ -60,6 +86,7 @@ def patch_block(dev:str,file:str,key_dict):
|
||||
if _tmp[0].strip() == '(IND)':
|
||||
ind_block_id = int(_tmp[1])
|
||||
else:
|
||||
print(f'block_info : {block_info}')
|
||||
id_range = _tmp[0].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)]
|
||||
@@ -81,9 +108,7 @@ def patch_initrd_xz(initrd_xz:bytes,key_dict:dict,ljust=True):
|
||||
initrd = lzma.decompress(initrd_xz)
|
||||
new_initrd = initrd
|
||||
for old_public_key,new_public_key in key_dict.items():
|
||||
if old_public_key in new_initrd:
|
||||
print(f'initrd public key patched {old_public_key[:16].hex().upper()}...')
|
||||
new_initrd = new_initrd.replace(old_public_key,new_public_key)
|
||||
new_initrd = replace_key(old_public_key,new_public_key,new_initrd,'initrd')
|
||||
preset = 6
|
||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": preset }] )
|
||||
while len(new_initrd_xz) > len(initrd_xz) and preset < 9:
|
||||
@@ -252,14 +277,15 @@ def patch_kernel(data:bytes,key_dict):
|
||||
def patch_squashfs(path,key_dict):
|
||||
for root, dirs, files in os.walk(path):
|
||||
for file in files:
|
||||
if file =='loader':
|
||||
continue
|
||||
file = os.path.join(root,file)
|
||||
if os.path.isfile(file):
|
||||
data = open(file,'rb').read()
|
||||
for old_public_key,new_public_key in key_dict.items():
|
||||
if old_public_key in data:
|
||||
print(f'{file} public key patched {old_public_key[:16].hex().upper()}...')
|
||||
data = data.replace(old_public_key,new_public_key)
|
||||
open(file,'wb').write(data)
|
||||
_data = replace_key(old_public_key,new_public_key,data,file)
|
||||
if _data != data:
|
||||
open(file,'wb').write(_data)
|
||||
url_dict = {
|
||||
os.environ['MIKRO_LICENCE_URL'].encode():os.environ['CUSTOM_LICENCE_URL'].encode(),
|
||||
os.environ['MIKRO_UPGRADE_URL'].encode():os.environ['CUSTOM_UPGRADE_URL'].encode(),
|
||||
|
||||
Reference in New Issue
Block a user