modified: netinstall.py

modified:   npk.py
This commit is contained in:
zyb 2024-07-16 13:50:22 +08:00
parent 89a1042e60
commit bd814b57d8
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,6 @@ def find_7zXZ_data(data:bytes):
while b'\x00\x00\x00\x00\x01\x59\x5A' in _data:
offset2 = offset2 + _data.index(b'\x00\x00\x00\x00\x01\x59\x5A') + 7
_data = _data[offset2:]
offset2
return data[offset1:offset2]
def patch_elf(data: bytes,key_dict:dict):
@ -136,7 +135,7 @@ def patch_netinstall(key_dict: dict,input_file,output_file=None):
id,name_ptr,data_ptr,data_size = struct.unpack_from('<IIII',netinstall[offset+i*16:offset+i*16+16])
name = netinstall[text_section_offset+name_ptr-text_section_addr:].split(b'\0')[0]
data = netinstall[text_section_offset+data_ptr-text_section_addr:text_section_offset+data_ptr-text_section_addr+data_size]
print(f'found {name.decode()}({id}) bootloader')
print(f'found {name.decode()}({id}) bootloader offset {hex(text_section_offset+data_ptr-text_section_addr)} size {data_size}')
try:
if data[:2] == b'MZ':
new_data = patch_pe(data,key_dict)

3
npk.py
View File

@ -185,7 +185,8 @@ class NovaPackage:
def sign(self,kcdsa_private_key:bytes,eddsa_private_key:bytes):
import hashlib
from mikro import mikro_kcdsa_sign,mikro_eddsa_sign
self[NpkPartID.SIGNATURE].data = b'\0'*(20+48+64)
if len(self[NpkPartID.SIGNATURE].data) != 20+48+64:
self[NpkPartID.SIGNATURE].data = b'\0'*(20+48+64)
sha1_digest = self.get_digest(hashlib.new('SHA1'))
sha256_digest = self.get_digest(hashlib.new('SHA256'))
kcdsa_signature = mikro_kcdsa_sign(sha256_digest[:20],kcdsa_private_key)