From 96515d2333bf5a2783e147ea8ec7e5a9bade43a6 Mon Sep 17 00:00:00 2001 From: zyb Date: Sun, 14 Jul 2024 22:16:10 +0800 Subject: [PATCH] modified: README.md modified: README_CN.md modified: netinstall.py deleted: upgrade.py --- README.md | 5 ++--- README_CN.md | 5 ++--- netinstall.py | 5 ++--- upgrade.py | 59 --------------------------------------------------- 4 files changed, 6 insertions(+), 68 deletions(-) delete mode 100644 upgrade.py diff --git a/README.md b/README.md index bfabcd2..e58ca23 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,8 @@ ### patch.py Patch public key and sign NPK files ### netinstall.py - Modify netinstallexe to enable network installation of NPK files that have been resigned in ISO -### upgrade.py - By adding static domain name resolution in RouterOS, the NPK file that has been resigned in ISO can be installed during the upgrade process. + Patch netinstall to enable network installation of NPK files that have been resigned in ISO + ## all patches are applied automatically with [Github Action](https://github.com/elseif/MikroTikPatch/blob/main/.github/workflows/mikrotik_patch.yml). diff --git a/README_CN.md b/README_CN.md index d49d1c3..5547961 100644 --- a/README_CN.md +++ b/README_CN.md @@ -31,9 +31,8 @@ ### patch.py 替换公钥并签名 ### netinstall.py - 替换 netinstallexe 中的bootloader的公钥,使通过网络安装时可以安装ISO文件内的npk文件 -### upgrade.py - 在RouterOS内增加静态域名解析,使升级时可以安装ISO文件内的npk文件 + 替换 netinstall 中的 bootloader 的公钥,使通过网络安装时可以安装ISO文件内的npk文件 + ## 所有的修补操作都自动运行在[Github Action](https://github.com/elseif/MikroTikPatch/blob/main/.github/workflows/mikrotik_patch.yml)。 diff --git a/netinstall.py b/netinstall.py index 2a625f2..009cf45 100644 --- a/netinstall.py +++ b/netinstall.py @@ -132,7 +132,6 @@ def patch_netinstall(key_dict: dict,input_file,output_file=None): STRING_TABLE_INDEX = struct.unpack_from(b' None: - flow.request.host = self.upstream_server - flow.request.scheme = "https" - flow.request.port = 443 - print(flow.request.url) - if len(flow.request.path_components)==3 and flow.request.path_components[0] == 'routeros': - version = flow.request.path_components[1] - file = os.path.join(version,flow.request.path_components[2]) - if flow.request.method == 'HEAD': - if os.path.exists(version) and os.path.isfile(file): - flow.response = http.Response.make( - status_code=200, - headers={ - 'Content-Type': 'application/octet-stream', - 'Accept-Ranges':'bytes', - 'Content-Length': str(os.stat(file).st_size), - } - ) - else: - flow.response = http.Response.make(status_code=404) - elif flow.request.method == 'GET' and flow.request.path_components[2].endswith('.npk'): - if os.path.exists(version) and os.path.isfile(file): - flow.response = http.Response.make( - status_code=200, - content=open(file,'rb').read(), - headers={'Content-Type': 'application/octet-stream',}, - ) - else: - flow.response = http.Response.make(status_code=404) - -async def start_listen(port): - opts = options.Options(listen_host='0.0.0.0',listen_port=port) - upstream_server = "upgrade.mikrotik.com" - master = DumpMaster(opts) - master.addons.add(UpgradeAddon(upstream_server)) - try: - await master.run() - except KeyboardInterrupt: - master.shutdown() -if __name__ == "__main__": - import asyncio - from package import check_install_package - check_install_package(['mitmproxy']) - print(f'ip dns static add name=upgrade.mikrotik.com address=') - print(f'ip dns cache flush') - asyncio.run(start_listen(80)) - -