mirror of
https://huihui.cat/mirrors/MikroTikPatch.git
synced 2025-12-10 03:24:37 +01:00
Update patch.py
Signed-off-by: elseif <elseif@live.cn>
This commit is contained in:
parent
cf01bbda4d
commit
a8dd672a66
1 changed files with 3 additions and 2 deletions
5
patch.py
5
patch.py
|
|
@ -10,10 +10,11 @@ def replace_key(old,new,data,name=''):
|
|||
pattern_bytes = b''.join(pattern_parts)
|
||||
pattern = re.compile(pattern_bytes, flags=re.DOTALL)
|
||||
def replace_match(match):
|
||||
print(f'{name} found public key {match.group()[:30].hex().upper()}')
|
||||
print(f'{name} public key patched {old[:16].hex().upper()}...')
|
||||
print(f'{name} found public key at {match.start()} {match.group().hex().upper()}')
|
||||
replaced = b''.join([new_chunks[i] + match.group(i+1) for i in range(len(new_chunks) - 1)])
|
||||
replaced += new_chunks[-1]
|
||||
print(f'{name} replace public key {replaced.hex().upper()}')
|
||||
print(f'{name} public key patched {old[:16].hex().upper()}...')
|
||||
return replaced
|
||||
return re.sub(pattern, replace_match, data)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue