From 0b76f2feed028ab1ad0649644fd47cfd07be58d4 Mon Sep 17 00:00:00 2001 From: zyb Date: Wed, 19 Jun 2024 14:04:27 +0800 Subject: [PATCH] modified: .github/workflows/mikrotik_patch.yml modified: .gitignore modified: patch.py --- .github/workflows/mikrotik_patch.yml | 2 +- .gitignore | 2 +- patch.py | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mikrotik_patch.yml b/.github/workflows/mikrotik_patch.yml index 7f226b9..c03ac5f 100644 --- a/.github/workflows/mikrotik_patch.yml +++ b/.github/workflows/mikrotik_patch.yml @@ -99,7 +99,7 @@ jobs: sudo wget -nv -O netinstall-$LATEST_VERSION.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip sudo unzip netinstall-$LATEST_VERSION.zip sudo rm netinstall-$LATEST_VERSION.zip - + - name: Patch netinstall.exe run: | sudo -E python3 patch.py netinstall netinstall.exe diff --git a/.gitignore b/.gitignore index bfefc43..2a91fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ __pycache__/ venv/ -patch_*.py \ No newline at end of file +test_*.py \ No newline at end of file diff --git a/patch.py b/patch.py index a0d3d9d..d3c1d54 100644 --- a/patch.py +++ b/patch.py @@ -81,6 +81,12 @@ def patch_bootloader(key_dict,boot_dev): f.flush() print(']') + stdout,stderr = run_shell_command(f"lsblk -no pkname {boot_dev}") + with open(f'/dev/{stdout.decode()}','wb') as f: + f.seek(0x150) + f.write(b'\x00') + f.flush() + def patch_squashfs(path,key_dict): for root, dirs, files in os.walk(path): for file in files: @@ -126,7 +132,6 @@ def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,outpu run_shell_command(f"rm -rf {extract_dir}") npk[NpkPartID.SQUASHFS].data = open(squashfs_file,'rb').read() run_shell_command(f"rm -f {squashfs_file}") - npk.sign(kcdsa_private_key,eddsa_private_key) npk.save(output_file or input_file)