|
|
|
@ -1,8 +1,19 @@ |
|
|
|
from mitmproxy import http |
|
|
|
from mitmproxy.tools.dump import DumpMaster |
|
|
|
from mitmproxy import options,http |
|
|
|
import os |
|
|
|
|
|
|
|
#https://upgrade.mikrotik.com/routeros/NEWESTa7.stable |
|
|
|
#https://upgrade.mikrotik.com/routeros/7.15.1/CHANGELOG |
|
|
|
|
|
|
|
|
|
|
|
class UpgradeAddon: |
|
|
|
def __init__(self, upstream_server): |
|
|
|
self.upstream_server = upstream_server |
|
|
|
def request(self,flow: http.HTTPFlow) -> 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]) |
|
|
|
@ -29,13 +40,10 @@ class UpgradeAddon: |
|
|
|
flow.response = http.Response.make(status_code=404) |
|
|
|
|
|
|
|
async def start_listen(port): |
|
|
|
from mitmproxy.tools.dump import DumpMaster |
|
|
|
from mitmproxy import options |
|
|
|
opts = options.Options(listen_host='0.0.0.0',listen_port=port,mode=['reverse:https://upgrade.mikrotik.com/']) |
|
|
|
print(f'listening at *:{port}') |
|
|
|
print(f'open http://127.0.0.1:{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()]) |
|
|
|
master.addons.add(UpgradeAddon(upstream_server)) |
|
|
|
try: |
|
|
|
await master.run() |
|
|
|
except KeyboardInterrupt: |
|
|
|
@ -47,3 +55,5 @@ if __name__ == "__main__": |
|
|
|
print(f'ip dns static add name=upgrade.mikrotik.com address=<your ip address>') |
|
|
|
print(f'ip dns cache flush') |
|
|
|
asyncio.run(start_listen(80)) |
|
|
|
|
|
|
|
|