Compare commits

...

45 Commits

Author SHA1 Message Date
elseif
3207b0ccd3
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 11:13:51 +08:00
elseif
65dff5204a
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 11:13:31 +08:00
elseif
10349947e6
Update patch.py
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 11:11:16 +08:00
elseif
2e7b31abf5
Update patch.py
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 10:55:50 +08:00
elseif
32ef5f3aeb
Update patch.py
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 10:53:36 +08:00
elseif
3ba9e027e3
Update patch.py
Signed-off-by: elseif <elseif@live.cn>
2025-01-18 10:46:54 +08:00
elseif
f6fea00c16
Merge pull request #74 from vnxme/system-random
Use SystemRandom to ensure crossplatform compatibility
2024-12-30 11:21:29 +08:00
vnxme
391d019a42 Use random.SystemRandom().randint
instead of toyecc.Random.secure_rand_int_between
2024-12-28 10:57:32 +03:00
elseif
4c6ab80b09
Merge pull request #66 from vnxme/env-consistency-fixes
Env consistency fixes
2024-12-14 12:40:16 +08:00
elseif
098f967cfd
Merge pull request #69 from loskiq/patch-1
Update mikro.py
2024-12-14 12:40:05 +08:00
Amir
e61c981f84
Update mikro.py
Signed-off-by: Amir <loskiq@gmail.com>
2024-12-13 17:23:54 +03:00
vnxme
29663ed175 Fix *_LICENSE_URL spelling 2024-12-12 11:45:40 +03:00
vnxme
fd2baf25a0 Fix MIKRO_NPK_SIGN_PUBLIC_KEY spelling 2024-12-12 11:45:40 +03:00
elseif
f65a65e830
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-12-06 03:00:00 +08:00
elseif
dc8118e5ab
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 11:30:52 +08:00
elseif
9b4d525aa2
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 11:30:14 +08:00
elseif
eef9552fda
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 11:03:27 +08:00
elseif
2126382b54
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 11:03:24 +08:00
elseif
a9eef1d574
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 10:51:22 +08:00
elseif
bd097583eb
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-29 10:50:39 +08:00
elseif
23a853d585
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-19 10:06:44 +08:00
elseif
9b6b8c7e2f
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-15 07:11:44 +08:00
elseif
4c52806821
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-15 06:54:21 +08:00
elseif
136c1ddcd4
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-15 06:50:21 +08:00
elseif
e5fb3ff784
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-15 06:45:54 +08:00
elseif
9dd745578b
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-11-15 06:27:16 +08:00
elseif
9d06111ac5
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-10-20 18:58:03 +08:00
elseif
7fdd5724bb
Update mikrotik_patch_7.yml
Signed-off-by: elseif <elseif@live.cn>
2024-10-20 18:56:38 +08:00
elseif
7719188665
Update README.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-30 14:06:45 +08:00
elseif
016a2de24f
Update README_EN.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-30 14:06:32 +08:00
elseif
2957c5a6ef
Update README.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-26 14:48:15 +08:00
elseif
ec407be988
Update README_EN.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-26 14:48:04 +08:00
elseif
ed0815f070
Update README_EN.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-26 14:47:29 +08:00
elseif
e88fbc0161
Update README.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-22 18:28:53 +08:00
elseif
6d1ebb4d8a
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 19:25:03 +08:00
elseif
ca24fa62b1
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 19:24:52 +08:00
elseif
73f15e63e7
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 19:21:23 +08:00
elseif
96df91e97c
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 19:19:07 +08:00
elseif
65fd858255
Update mikrotik_patch_6.yml
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 19:11:44 +08:00
elseif
208a160edc
Update README_EN.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 00:33:28 +08:00
elseif
c3781d822e
Update README.md
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 00:33:07 +08:00
elseif
f2eefbcc8f
Add files via upload
Signed-off-by: elseif <elseif@live.cn>
2024-08-19 00:32:26 +08:00
zyb
dc31de2e33 modified: patch.py 2024-08-08 15:21:50 +08:00
zyb
8d6181eb84 modified: mikro.py 2024-08-08 11:58:06 +08:00
zyb
6a69a53051 modified: README.md 2024-08-07 11:10:46 +08:00
8 changed files with 70 additions and 45 deletions

View File

@ -17,7 +17,7 @@ env:
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_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_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
@ -138,6 +138,7 @@ jobs:
if: steps.get_latest.outputs.has_new_version == 'true'
run: |
sudo modprobe nbd
sudo apt-get update
sudo apt-get install -y qemu-utils extlinux > /dev/null
truncate --size 64M install-image-$LATEST_VERSION.img
sudo qemu-nbd -c /dev/nbd0 -f raw install-image-$LATEST_VERSION.img
@ -191,6 +192,7 @@ jobs:
sudo cp ./all_packages/dude-$LATEST_VERSION.npk ./chr/var/pdb/dude/image
sudo -E python3 patch.py npk ./chr/var/pdb/routeros-x86/image
sudo cp ./chr/var/pdb/routeros-x86/image ./all_packages/routeros-x86-$LATEST_VERSION.npk
sudo cp ./all_packages/routeros-x86-$LATEST_VERSION.npk routeros-x86-$LATEST_VERSION.npk
sudo umount ./chr
sudo qemu-nbd -d /dev/nbd0
sudo rm -rf ./chr
@ -219,17 +221,18 @@ jobs:
- name: Upload Files
if: steps.get_latest.outputs.has_new_version == 'true'
run: |
mkdir -p ./publish/$LATEST_VERSION
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWEST6.${{ matrix.channel }}
cp CHANGELOG ./publish/$LATEST_VERSION/
cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
sudo apt-get install -y lftp > /dev/null 2>&1
sudo mkdir -p ./publish/$LATEST_VERSION
echo $LATEST_VERSION $BUILD_TIME | sudo tee ./publish/NEWEST6.${{ matrix.channel }}
sudo cp CHANGELOG ./publish/$LATEST_VERSION/
sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
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
set sftp:auto-confirm yes
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
bye
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
if: steps.get_latest.outputs.has_new_version == 'true'
run: |
@ -267,5 +270,5 @@ jobs:
mikrotik-${{ env.LATEST_VERSION }}.iso
chr-${{ env.LATEST_VERSION }}*.zip
install-image-${{ env.LATEST_VERSION }}.zip
system-${{ env.LATEST_VERSION }}.npk
routeros-x86-${{ env.LATEST_VERSION }}.npk
all_packages-x86-${{ env.LATEST_VERSION }}.zip

View File

@ -16,7 +16,7 @@ env:
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
CUSTOM_CLOUD_PUBLIC_KEY: ${{ secrets.CUSTOM_CLOUD_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_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
@ -86,6 +86,7 @@ jobs:
ARCH='-arm64'
echo "ARCH=$ARCH" >> $GITHUB_ENV
fi
sudo apt-get update > /dev/null
- name: Cache Squashfs
if: steps.get_latest.outputs.has_new_version == 'true'
@ -120,12 +121,12 @@ jobs:
sudo mksquashfs option-root option.sfs -quiet -comp xz -no-xattrs -b 256k
sudo rm -rf option-root
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
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
sudo tar -xf cpython-3.11.9.tar.gz
sudo rm cpython-3.11.9.tar.gz
sudo tar -xf cpython.tar.gz
sudo rm cpython.tar.gz
sudo rm -rf ./python/include
sudo rm -rf ./python/share
sudo mksquashfs python python3.sfs -quiet -comp xz -no-xattrs -b 256k
@ -378,16 +379,19 @@ jobs:
- name: Upload Files
if: steps.get_latest.outputs.has_new_version == 'true'
run: |
mkdir -p ./publish/$LATEST_VERSION
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }}
cp CHANGELOG ./publish/$LATEST_VERSION/
cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
sudo apt-get install -y lftp > /dev/null 2>&1
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/
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
set sftp:auto-confirm yes
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'
@ -428,6 +432,5 @@ jobs:
netinstall-${{ env.LATEST_VERSION }}.*
install-image-${{ env.LATEST_VERSION }}.zip
routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
option-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
all_packages-*-${{ env.LATEST_VERSION }}.zip
*.EFI

View File

@ -1,14 +1,11 @@
# 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)]
### 国内镜像下载 密码: elseif
[ [123pan](https://www.123pan.com/s/IpxgTd-BYjQh.html) ]
[ [7.15.3](https://elseif.lanzouj.com/b00cre7g7a)]
[ [7.15.2](https://elseif.lanzouj.com/b00crdq4hg)]
[ [7.16beta4](https://elseif.lanzouj.com/b00crdq4fe) ]
[ [7.15.3-arm64](https://elseif.lanzouj.com/b00cre7g8b) ]
[ [7.15.2-arm64](https://elseif.lanzouj.com/b00crdq4ih) ]
[ [7.16beta4-arm64](https://elseif.lanzouj.com/b00crdq4gf) ]
[ [6.49.15](https://elseif.lanzouj.com/b00crdq4ji) ]
[ [6.49.13](https://elseif.lanzouj.com/b00crdq4kj) ]
@ -26,6 +23,9 @@
### Chr模式授权许可
![](image/chr.png)
![](image/arm.png)
![](image/mips.png)
## 如何使用Shell
安装 option-{version}.npk 包
telnet到RouterOS,用户名devel,密码与admin的密码相同

View File

@ -1,6 +1,6 @@
# MikroTik RouterOS Patch [[中文](README.md)]
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/+99Mw06p3K7NlMmNl)]
### [[Discord](https://discord.gg/keV6MWQFtX)] [[Telegram](https://t.me/mikrotikpatch)] [[Keygen(Telegram Bot)](https://t.me/ROS_Keygen_Bot)]
### Download [Latest Patched](https://github.com/elseif/MikroTikPatch/releases/latest) iso file,install it and enjoy.
### CHR image is both support BIOS and UEFI boot mode.
@ -19,6 +19,9 @@
### license RouterOS for chr
![](image/chr.png)
![](image/arm.png)
![](image/mips.png)
## How to use shell
install option-{version}.npk package
run telnet to routeros with username devel and password is same as admin

BIN
image/arm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

BIN
image/mips.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 KiB

View File

@ -1,11 +1,9 @@
import random
import struct
from sha256 import SHA256
from toyecc import AffineCurvePoint, getcurvebyname, FieldElement,ECPrivateKey,ECPublicKey,Tools
from toyecc.Random import secure_rand_int_between
MIKRO_LICENSE_HEADER = '-----BEGIN MIKROTIK SOFTWARE KEY------------'
MIKRO_LICENSE_FOOTER = '-----END MIKROTIK SOFTWARE KEY--------------'
MIKRO_BASE64_CHARACTER_TABLE = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
SOFTWARE_ID_CHARACTER_TABLE = b'TN0BYX18S5HZ4IA67DGF3LPCJQRUK9MW2VE'
@ -40,8 +38,8 @@ def mikro_softwareid_encode(id:int)->str:
assert(isinstance(id, int))
ret = ''
for i in range(8):
ret += chr(SOFTWARE_ID_CHARACTER_TABLE[id % 0x23])
id //= 0x23
ret += chr(SOFTWARE_ID_CHARACTER_TABLE[id % len(SOFTWARE_ID_CHARACTER_TABLE)])
id //= len(SOFTWARE_ID_CHARACTER_TABLE)
if i == 3:
ret += '-'
return ret
@ -168,7 +166,7 @@ def mikro_kcdsa_sign(data:bytes,private_key:bytes)->bytes:
private_key:ECPrivateKey = ECPrivateKey(Tools.bytestoint_le(private_key), curve)
public_key:ECPublicKey = private_key.pubkey
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 = int(nonce_point.x) % curve.n
nonce_hash = mikro_sha256(Tools.inttobytes_le(nonce,32))

View File

@ -84,8 +84,21 @@ def patch_initrd_xz(initrd_xz:bytes,key_dict:dict,ljust=True):
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_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": 9,}] )
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:
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:
print(f'preset:{preset}')
print(f'new initrd xz size:{len(new_initrd_xz)}')
print(f'old initrd xz size:{len(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')
return new_initrd_xz
@ -102,6 +115,7 @@ def find_7zXZ_data(data:bytes):
while b'\x00\x00\x00\x00\x01\x59\x5A' in _data:
offset2 = offset2 + _data.index(b'\x00\x00\x00\x00\x01\x59\x5A') + 7
_data = _data[offset2:]
print(f'found 7zXZ data offset:{offset1} size:{offset2-offset1}')
return data[offset1:offset2]
def patch_elf(data: bytes,key_dict:dict):
@ -119,6 +133,9 @@ def patch_pe(data: bytes,key_dict:dict):
new_vmlinux = vmlinux.replace(initrd_xz,new_initrd_xz)
new_vmlinux_xz = lzma.compress(new_vmlinux,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": 9,}] )
assert len(new_vmlinux_xz) <= len(vmlinux_xz),'new vmlinux xz size is too big'
print(f'new vmlinux xz size:{len(new_vmlinux_xz)}')
print(f'old vmlinux xz size:{len(vmlinux_xz)}')
print(f'ljust size:{len(vmlinux_xz)-len(new_vmlinux_xz)}')
new_vmlinux_xz = new_vmlinux_xz.ljust(len(vmlinux_xz),b'\0')
new_data = data.replace(vmlinux_xz,new_vmlinux_xz)
return new_data
@ -150,19 +167,20 @@ def patch_netinstall(key_dict: dict,input_file,output_file=None):
rva = sub_resource.directory.entries[0].data.struct.OffsetToData
size = sub_resource.directory.entries[0].data.struct.Size
data = pe.get_data(rva,size)
assert len(data) -4 >= struct.unpack_from('<I',data)[0] ,f'bootloader data size mismathch'
data = data[4:]
_size = struct.unpack('<I',data[:4])[0]
_data = data[4:4+_size]
try:
if data[:2] == b'MZ':
new_data = patch_pe(data,key_dict)
elif data[:4] == b'\x7FELF':
new_data = patch_elf(data,key_dict)
if _data[:2] == b'MZ':
new_data = patch_pe(_data,key_dict)
elif _data[:4] == b'\x7FELF':
new_data = patch_elf(_data,key_dict)
else:
raise Exception(f'unknown bootloader format {data[:4].hex().upper()}')
raise Exception(f'unknown bootloader format {_data[:4].hex().upper()}')
except Exception as e:
print(f'patch {bootloader["arch"]}({sub_resource.id}) bootloader failed {e}')
new_data = data
new_data = struct.pack("<I",len(new_data)) + new_data.ljust(len(data),b'\0')
new_data = _data
new_data = struct.pack("<I",_size) + new_data.ljust(len(_data),b'\0')
new_data = new_data.ljust(size,b'\0')
pe.set_bytes_at_rva(rva,new_data)
pe.write(output_file or input_file)
elif netinstall[:4] == b'\x7FELF':
@ -242,13 +260,13 @@ def patch_squashfs(path,key_dict):
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 = open(file,'rb').read()
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(),
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(),
}
data = open(file,'rb').read()
for old_url,new_url in url_dict.items():
if old_url in data:
print(f'{file} url patched {old_url.decode()[:7]}...')
@ -323,7 +341,7 @@ if __name__ == '__main__':
args = parser.parse_args()
key_dict = {
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'])
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])