我的exe文件名为“暗黑破坏神.exe“此文件包括proto文件。我想从文件中提取它们。你知道吗
我尝试了protoc和一些开源项目来提取文件,但是没有成功,现在我正在尝试使用python来提取文件。我正在为此进程使用另一个用户代码。你知道吗
我不知道它是如何工作的NSO\U协议抵消这个程序创建的任天堂开关文件格式“.NSO”。有没有办法把这个程序转换成二进制格式。你知道吗
from os.path import join, isfile
from binascii import hexlify as _hexlify
NSO_PATH = "C://Users/John/Desktop/Diablo.exe"
NSO_PROTO_OFFSET = 0xDC1EB4
def hexlify(b: (bytes, bytearray)) -> (bytes, bytearray):
return _hexlify(b).decode("utf8")
if __name__ == "__main__":
with open(NSO_PATH, "rb") as nso_file:
# seek to protobuf file listing
nso_file.seek(NSO_PROTO_OFFSET)
total_dumped = 0
while True:
# print file offset
print(hex(nso_file.tell()))
# read protobuf name
b = None
protobuf_name = b""
while True:
b = nso_file.read(1)
if b[0] == 0:
break
protobuf_name += b
protobuf_name = protobuf_name.decode("utf8", errors="ignore")
print(protobuf_name)
# no null-terminator
#assert nso_file.read(1)[0] == 0, "non-null-terminator found"
# read compiled name
b = None
compiled_name = b""
while True:
b = nso_file.read(1)
if b[0] == 0:
break
compiled_name += b
compiled_name = compiled_name.decode("utf8", errors="ignore")
print(compiled_name)
# skip null-terminator
#assert nso_file.read(1)[0] == 0, "non-null-terminator found"
if protobuf_name in ["GameMessage.proto", "Leaderboard.proto"]: # empty
continue
if protobuf_name == "Settings.proto": # last one in the list
break
# read out the protobin
protobin = b""
while True:
b = nso_file.read(1)
if b[0] == 0:
break
protobin += b
#print(hexlify(protobin))
out_path = join("extracted", protobuf_name + "bin")
if not isfile(out_path):
with open(out_path, "wb") as f:
f.write(protobin)
else:
print("%s already exists, skipping" % (out_path))
total_dumped += 1
print("Dumped %s protobin(s)" % (total_dumped))```
目前没有回答
相关问题 更多 >
编程相关推荐