diff --git a/README.md b/README.md index e58ca23..4fb5a40 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ ### CHR image is both support BIOS and UEFI boot mode. ### Support online upgrade. -![](install.png) -![](routeros.png) +![](image/install.png) +![](image/routeros.png) ### license RouterOS for x86. -![](x86.png) +![](image/x86.png) ### license RouterOS for chr, Support online renew license. -![](chr.png) +![](image/chr.png) ## How to use shell install option-{version}.npk package diff --git a/README_CN.md b/README_CN.md index 5547961..dc4eebe 100644 --- a/README_CN.md +++ b/README_CN.md @@ -6,13 +6,13 @@ ### CHR镜像文件同时支持BIOS和UEFI启动模式 ### 支持在线升级 -![](install.png) -![](routeros.png) +![](image/install.png) +![](image/routeros.png) ### x86模式授权许可 -![](x86.png) +![](image/x86.png) ### chr模式授权许可,支持在线授权许可 -![](chr.png) +![](image/chr.png) ## 如何使用Shell 安装 option-{version}.npk 包 diff --git a/chr.png b/image/chr.png similarity index 100% rename from chr.png rename to image/chr.png diff --git a/install.png b/image/install.png similarity index 100% rename from install.png rename to image/install.png diff --git a/routeros.png b/image/routeros.png similarity index 100% rename from routeros.png rename to image/routeros.png diff --git a/x86.png b/image/x86.png similarity index 100% rename from x86.png rename to image/x86.png diff --git a/mikrotik.ico b/mikrotik.ico deleted file mode 100644 index 6e31b43..0000000 Binary files a/mikrotik.ico and /dev/null differ diff --git a/netinstall.py b/netinstall.py index 009cf45..51bcf18 100644 --- a/netinstall.py +++ b/netinstall.py @@ -1,15 +1,4 @@ import struct,lzma -# ROUTEROS_BOOT = { -# 129:{'arch':'power','name':'Powerboot','filter':lzma.FILTER_POWERPC}, -# 130:{'arch':'e500','name':'e500_boot'}, -# 131:{'arch':'mips','name':'Mips_boot'}, -# 135:{'arch':'400','name':'440__boot'}, -# 136:{'arch':'tile','name':'tile_boot'}, -# 137:{'arch':'arm','name':'ARM__boot','filter':lzma.FILTER_ARMTHUMB}, -# 138:{'arch':'mmips','name':'MMipsBoot'}, -# 139:{'arch':'arm64','name':'ARM64__boot','filter':lzma.FILTER_ARMTHUMB}, -# 143:{'arch':'x86_64','name':'x86_64boot'} -# } def find_7zXZ_data(data:bytes): offset1 = 0 diff --git a/patch.py b/patch.py index 2107243..0b4c2c3 100644 --- a/patch.py +++ b/patch.py @@ -71,38 +71,8 @@ def patch_squashfs(path,key_dict): data = data.replace(old_url,new_url) open(file,'wb').write(data) - -def patch_elf(data: bytes,key_dict:dict): - def find_7zXZ_data(data:bytes): - offset1 = 0 - _data = data - while b'\xFD7zXZ\x00\x00\x01' in _data: - offset1 = offset1 + _data.index(b'\xFD7zXZ\x00\x00\x01') + 8 - _data = _data[offset1:] - offset1 -= 8 - offset2 = 0 - _data = data - while b'\x00\x01\x59\x5A' in _data: - offset2 = offset2 + _data.index(b'\x00\x01\x59\x5A') + 4 - _data = _data[offset2:] - offset2 - return data[offset1:offset2] - - initrd_xz = find_7zXZ_data(data) - 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'initramfs public key patched {old_public_key[:16].hex().upper()}...') - new_initrd = new_initrd.replace(old_public_key,new_public_key) - filters=[{"id": lzma.FILTER_LZMA2, "preset": 9,}] - new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=filters) - 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_data = data.replace(initrd_xz,new_initrd_xz) - return new_data - def patch_kernel(data:bytes,key_dict): + from netinstall import patch_elf if data[:2] == b'MZ': print('patching EFI Kernel') if data[56:60] == b'ARM\x64':