modified: README.md
modified: README_CN.md renamed: chr.png -> image/chr.png renamed: install.png -> image/install.png renamed: routeros.png -> image/routeros.png renamed: x86.png -> image/x86.png deleted: mikrotik.ico modified: netinstall.py modified: patch.py
@ -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
|
||||
|
@ -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 包
|
||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 607 KiB After Width: | Height: | Size: 607 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
BIN
mikrotik.ico
Before Width: | Height: | Size: 9.4 KiB |
@ -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
|
||||
|
32
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':
|
||||
|