import datetime
import os
import re
import time
import struct
class de_yzjm():
def __init__(self):
self.file_list = []
# inline uint32 __ROR4__(uint32 value, int count) { return __ROL__((uint32)value, -count); }
def __ROR4__(self, value, count):
key = int('0x' + str(hex((value << (0x20 - count)) | (value >> count)))[-8:], 16)
return key
def getdir(self, dir_path, list_name):
for file in os.listdir(dir_path):
file_path = os.path.join(dir_path, file)
if os.path.isdir(file_path):
self.getdir(file_path, list_name)
else:
list_name.append(file_path)
return list_name
def getFileName(self, list_name):
for filename in list_name:
if filename.endswith('.BIN') or filename.endswith('.BNC'):
self.file_list.append(filename)
self.Dccode_YZ()
self.file_list = []
def Dccode_YZ(self):
for i in range(len(self.file_list)):
sfilename = self.file_list[i]
newFilePath = str(self.file_list[i]).replace("BIN", '').replace("BNC", '') + 'BKZ'
with open(self.file_list[i], 'rb') as BINFile:
buflist = list(bytearray(BINFile.read()))
buflist = re.findall('.{2}', "".join(list(map(lambda x: str(hex(x)).replace('0x', '').upper().rjust(2, '0'), buflist))))
flag = 0
if 'BIN' in sfilename:
if os.path.exists(newFilePath):
os.remove(newFilePath)
if '_001' in sfilename or 'ADASCONFIGURE.BIN' in sfilename or 'OFFLINECODECONFIGUE.BIN' in sfilename or 'SCN.BIN' in sfilename or 'SCNCONFIGUE.BIN' in sfilename or 'CFFANDHW.BIN' in sfilename or 'DOIPCONFIGUE.BIN' in sfilename or 'ECUCONFIGUER.BIN' in sfilename or 'FLASHCFG.BIN' in sfilename:
self.parse_spe_bin(buflist, newFilePath)
continue
if 'MENU' in sfilename:
continue
son_index = '00000000'
buflist = buflist[4:]
mes_len = int('0x' + ''.join((buflist[flag: flag + 4])[::-1]), 16)
mes_list = (buflist[flag: flag + mes_len])[4:]
self.parse_menu_mes(newFilePath, son_index, buflist, mes_list)
continue
print("正在解析" + self.file_list[i])
self.parse_yzjm(newFilePath, buflist)
if 'BNC' in sfilename:
if os.path.exists(newFilePath):
os.remove(newFilePath)
if 'GCF.BNC' in sfilename or 'MCF.BNC' in sfilename or 'PKW.BNC' in sfilename or 'VIN.BNC' in sfilename:
self.parse_spe_bnc(newFilePath, buflist)
continue
if 'ECUNAME.BNC' in sfilename:
self.parse_ecuname(sfilename)
continue
self.parse_bnc(sfilename, newFilePath, buflist)
continue
def parse_yzjm(self, newFilePath, buflist):
flag = 0
YZJM_flag = int('0x' + ''.join(buflist[flag: flag + 2][::-1]), 16) # 5
flag += 2
YZJM_info = buflist[flag : flag + YZJM_flag - 1]
flag += YZJM_flag
if ''.join(YZJM_info) != '595A4A4D':
return
car_info_flag = int('0x' + ''.join(buflist[flag: flag + 2][::-1]), 16)
flag += 2
car_info = buflist[flag : flag + car_info_flag - 1]
flag += car_info_flag
ver_info_flag = int('0x' + ''.join(buflist[flag: flag + 2][::-1]), 16)
flag += 2
ver_info = buflist[flag : flag + ver_info_flag - 1]
flag += ver_info_flag
file_ptr = buflist[flag: flag + 4][::-1]
file_ptr = int('0x' + ''.join(file_ptr), 16)
flag += 4
head_info = buflist[:flag]
info_list = buflist[flag:]
ver_len = len(ver_info)
car_len = len(car_info)
mes_list = []
if ver_len == 6 and car_len != 0:
v11 = 0
while v11 != 0xa:
mes_list.append(car_info[v11 % car_len])
v11 += 1
v13 = 0
for i in ver_info:
mes_list.append(i)
mes_list_2 = []
while v13 != 0x10:
v14 = int('0x' + mes_list[v13], 16)
if v13 % 4:
v15 = (v14 << (8 - v13 % 4)) | (v14 >> (v13 % 4))
else:
v15 = (0x20 * v14) | (v14 >> 3);
v13 += 1
mes_list_2.append(hex(v15)[-2:])
key_list = [0x81387667, 0x0189A22F, 0x92F2DDA3, 0xEF6A8FC3, 0x0F3D2C59, 0x86CA5C8F, 0x12234C8D, 0xFC0A7D09]
key_mes = re.findall('.{8}', ''.join(mes_list_2).upper())
i = 0
car_de_key = []
for mes in key_list:
r12 = self.__ROR4__(file_ptr, 0xa)
if i > 3:
i = 0
code = int('0x' + key_mes[i], 16) ^ (mes ^ r12)
car_de_key.append(code)
i += 1
# 标志位
flag = 0
# 判断文件是否已存在
if os.path.exists(newFilePath):
os.remove(newFilePath)
# with open(name, 'w', encoding='ISO-8859-1') as f:
mes_all = ''
while flag < len(info_list):
# lr 寄存器 起始值为 -1 可为0 混淆作用 置-1后 又加 1
lr = -1
# r4 寄存器 存储 4 字节数据
r4 = int('0x' + str(''.join(info_list[flag: flag + 4])), 16)
if r4 == 0:
mes = '00000000'
else:
# r5 寄存器 存储前 3 字节数据 最后一字节补 0
r5 = int('0x' + str(''.join(info_list[flag: flag + 3])).ljust(8, '0'), 16)
# 以下 3 句相当于: r6 = *(flag + ((*(flag - 1) + lr) & 0x1C)) ^ ((((r4 << 0x17) | (r5 >> 9)) >> 0xD) | (r5 >> 9 << 0x13));
r4 = (int(('0x' + str(hex(r4 << 0x17)).replace('0x', '')[-8:]).replace('xx', 'x'), 16) | r5 >> 9) >> 0xd
r5 = int(('0x' + str(hex(r4 | int(('0x' + str(hex((r5 >> 9) << 0x13)).replace('0x', '')[-8:]).replace('xx', 'x'), 16))).replace('0x', '')[-8:]).replace('xx', 'x'), 16)
mes = str(hex(car_de_key[int(int((flag + lr + 1) & 0x1c) / 4)] ^ r5)).replace('0x', '').upper().rjust(8, '0')
mes_all += mes
lr + 4
flag += 4
mes_all = ''.join(head_info) + mes_all
byte_mess = re.findall(r'.{2}', mes_all)
with open(newFilePath, 'wb') as f:
for byte_one in byte_mess:
int_byte = struct.pack('B', int('0x' + byte_one, 16))
f.write(int_byte)
f.flush()
def parse_bnc(self, sfilename, newFilePath, buflist):
password = chr(0xD3) # 0x50
f_read = open(sfilename, "rb")
f_write = open(newFilePath, "wb")
count = 0 # 当前密码加密索引
# 异或循环解密
for now in f_read: # 通过迭代器逐行访问
for nowByte in now[0:-2]: # 通过迭代器逐字符处理
newByte = nowByte ^ ord(password[count % len(password)])
count += 1
f_write.write(bytes([newByte]))
f_write.write(b'\r\n')
f_read.close()
f_write.close()
def parse_ecuname(self, path):
fileFullName = path.split(os.path.sep)
fileParent = path[0:len(path) - len(fileFullName[len(fileFullName) - 1])]
newFileName = "jiemi_" + fileFullName[len(fileFullName) - 1] + '.txt'
newFilePath = fileParent + newFileName
f_write = open(newFilePath, "w")
f_read = open(path, "rb")
for mes_no
没有合适的资源?快使用搜索试试~ 我知道了~
file-kit it's a good kit
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共18个文件
py:7个
pyc:6个
ui:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 0 0 下载量 96 浏览量
2022-11-18
14:00:39
上传
评论
收藏 19KB 7Z 举报
温馨提示
file-kit it's a good kit
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/octet-stream](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rplib](https://img-home.csdnimg.cn/images/20210720083646.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 18 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/6524afba876a4ca38ebf8a1ff2461b6d_qq_26394845.jpg!1)
锦楠
- 粉丝: 39
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)