Перейти к содержимому
Zone of Games Forum

Рекомендованные сообщения

2 часа назад, ramyosama сказал:

Can someone send me this script that decrypts .lsb files?

 

https://b.top4top.io/p_3216vo3vu0.jpg


Via:

For %%a In (*.lsb) Do @Call c:\Python36\python.exe lisbts_decrypter.py %%a %%a.txt

 

Script:

#!/usr/bin/env python3

import sys, os, struct, binascii, itertools

if len(sys.argv) < 3:
	script_file_name = os.path.split(sys.argv[0])[1]
	print('usage: {0} <lsb file> <text file>'.format(script_file_name))
	sys.exit()

input_file_path = sys.argv[1]
if not os.path.isfile(input_file_path):
	print('error: invalid input file specified')
	sys.exit()

output_file_path = sys.argv[2]
if os.path.exists(output_file_path) and not os.path.isfile(output_file_path):
	print('error: invalid output file specified')
	sys.exit()

def read_u8(f):
	return struct.unpack('<B', f.read(struct.calcsize('B')))[0]

def read_u16(f):
	return struct.unpack('<H', f.read(struct.calcsize('H')))[0]

def read_u32(f):
	return struct.unpack('<I', f.read(struct.calcsize('I')))[0]

obf_key = binascii.unhexlify('AA1123343221E83BBA1224354231F85BCA13253652A1087BDA14263762C1789B')

def xor_crypt(key, data):
	return ''.join(chr(a ^ b) for (a, b) in zip(data, itertools.cycle(key)))

def decode_language_sheet(input_file_path, output_file_path):
	dir, full_name = os.path.split(input_file_path)
	name = os.path.splitext(full_name)[0]

	header_fmt = '<HI'
	entry_fmt = '<BH'

	transtab = str.maketrans({
		'\\': r'\\',
		'\r': r'\r',
		'\n': r'\n',
		'\t': r'\t',
		'\v': r'\v',
		'\b': r'\b',
	})

	with open(output_file_path, 'wb') as fo:
		with open(input_file_path, 'rb') as fi:
			count, value_offset = struct.unpack(header_fmt, fi.read(struct.calcsize(header_fmt)))
			key_offset = 0

			offset = struct.calcsize(header_fmt)

			key_lengths, value_lengths = [], []
			fi.seek(struct.calcsize(header_fmt))
			for i in range(count):
				key_lengths.append(read_u8(fi))
			for i in range(count):
				value_lengths.append(read_u16(fi))

			fi.seek(struct.calcsize(header_fmt) + count * struct.calcsize(entry_fmt))
			data = xor_crypt(obf_key, fi.read())
			for i in range(count):
				key, value = data[key_offset:key_offset + key_lengths[i]], data[value_offset:value_offset + value_lengths[i]]
				key_offset += key_lengths[i]
				value_offset += value_lengths[i]
				value = value.translate(transtab)
				fo.write('{0}={1}\n'.format(key, value).encode('utf-8'))

decode_language_sheet(input_file_path, output_file_path)

 

Поделиться сообщением


Ссылка на сообщение

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас



×