bartlomiejduda/ReverseBox

GitHub: bartlomiejduda/ReverseBox

ReverseBox 是一个专为逆向工程师设计的 Python 工具库,整合了校验和计算、压缩解压、加解密、图像编解码及跨平台纹理 Swizzling 等常用功能。

Stars: 49 | Forks: 4

# 信息 **ReverseBox** 是一个 Python 包,包含一系列 在软件逆向工程中非常有用的函数。 **为什么选择 ReverseBox?**
它的设计旨在帮助: 1. 解压缩 / 压缩数据 2. 解密 / 加密数据 3. 繁琐的逆向工程任务 例如:测试不同的校验和算法以找出软件或文件格式中使用的算法 4. 分析文件格式 5. 解析数据结构 6. 封装输入/输出操作的函数 7. 搜索原始图像 **谁应该使用 ReverseBox?**
主要是开发者和逆向工程师(例如文件格式研究人员 或软件研究人员)。 # 功能列表 * Checksum (校验和) - Adler32 ✔️ - Cocos2d PVR ✔️ - Fletcher16 ✔️ - Fletcher32 ✔️ - Internet Checksum / IPv4 header checksum ✔️ - Sum8 ✔️ - Sum8 2s Complement ✔️ - Unix Sum BSD16 ✔️ - Unix Sum SYSV ✔️ - Xor8 ✔️ * CRC - CRC-8 ✔️ - CRC-8/CDMA2000 ✔️ - CRC-8/DARC ✔️ (仅封装) - CRC-16 (ARC) ✔️ - CRC-16 (Modbus) ✔️ - CRC-16 (Sick) ✔️ - CRC-16 (DNP) ✔️ - CRC-16 (EA CRCF) ✔️ - CRC-16-CCITT (XModem) ✔️ - CRC-16-CCITT (0xFFFF) ✔️ - CRC-16-CCITT (0x1D0F) ✔️ - CRC-16-CCITT (Kermit) ✔️ - CRC-32/CKSUM (Unix cksum) ✔️ - CRC-32 (ISO/HDLC) ✔️ - CRC-32 (Asobo) ✔️ - CRC-64 (Asobo) ✔️ - CRC-64/GO-ISO ✔️ (仅封装) * Compression (压缩) - Asobo (TODO) ❌ - BZE/BZZ (TODO) ❌ - BZIP2 ✔️ (仅封装) - GZIP (TODO) ❌ - JCALG1 (TODO) ❌ - LZ4 ✔️ (仅封装) - LZMA ✔️ (仅封装) - LZO / LZO1X ✔️ (仅封装) - LZSS (TODO) ❌ - MIO0 ✔️ - NitroSDK (TODO) ❌ - Oodle (TODO) ❌ - Refpack (EA Games) ✔️ (仅封装) - RNC (TODO) ❌ - ZLIB ✔️ (仅封装) - PS2 GS Texture Compression ✔️ - RLE TGA ✔️ - RLE TGA (reversed condition) ✔️ - PackBits (Macintosh RLE) ✔️ - (游戏特定) Re:Tiyoruga DAT compression ✔️ - (游戏特定) Intelligent Games Custom Huffman ✔️ - (游戏特定) Executioners RLE ✔️ - (游戏特定) Emergency RLE ✔️ - (游戏特定) Neversoft RLE ✔️ - (游戏特定) Tzar RLE ✔️ - (游戏特定) Leapster RLE ✔️ * Encryption (加密) - AES (TODO) ❌ - DES (TODO) ❌ - Lucifer / DTD-1 (TODO) ❌ - ROT13 ✔️ - XOR Cipher (Basic) ✔️ - XOR Cipher (Basic) Guesser ✔️ - Hatch Engine Encryption ✔️ - (游戏特定) XOR Cipher (Retro64 ECO) ✔️ - (游戏特定) XOR Cipher (Giana’s Return ZDA) ✔️ * Hash (哈希) - Additive Hash ✔️ - AP ✔️ - DJB2 ✔️ - RX3 ✔️ - FNV0-32 ✔️ - FNV0-64 ✔️ - FNV1-32 ✔️ - FNV1-64 ✔️ - FNV1A-32 ✔️ - FNV1A-64 ✔️ - Jenkins one-at-a-time ✔️ - SDBM ✔️ - SHA-1 ✔️ (仅封装) - SHA-2 (256 bits) ✔️ (仅封装) - MD2 ✔️ (仅封装) - MD5 ✔️ (仅封装) - Murmur3 ✔️ (仅封装) - (游戏特定) Hercules (TODO) ❌ - (游戏特定) E-racer (TODO) ❌ - (游戏特定) Pivotal Games DAT Hash ✔️ * Image (图像) - 3DS Swizzling/Twiddling ✔️ - CMPR Swizzling/Twiddling ✔️ - PS2 Swizzling/Twiddling ✔️ - PS2 Palette Swizzling/Twiddling ✔️ - PS4 Swizzling/Twiddling ✔️ - PS5 Swizzling/Twiddling ✔️ - PSP Swizzling/Twiddling ✔️ - PS Vita Swizzling/Twiddling ✔️ - XBOX 360 Swizzling/Twiddling ✔️ - GameCube/WII Swizzling/Twiddling ✔️ - Switch Swizzling/Twiddling ✔️ - WII U Swizzling/Twiddling ✔️ - XBOX/PS3 Swizzling/Twiddling (Morton Order) ✔️ - Dreamcast Swizzling/Twiddling (Morton Order) ✔️ - BC Swizzling/Twiddling ✔️ - PS2 GS Texture Swizzling/Twiddling ✔️ - Generating mipmaps ✔️ - 使用下表中提到的像素格式解码和编码图像:
| Pixel Format | Decode support | Encode support | |------------------------|---------------------|---------------------| | RGB121 |
✔️
|
| | ALPHA4 |
✔️
|
| | ALPHA4_17X |
✔️
|
✔️
| | RGB121_BYTE |
✔️
|
| | RGBA2222 |
✔️
|
| | RGBX2222 |
✔️
|
| | GRAY8 |
✔️
|
| | ALPHA8 |
✔️
|
| | ALPHA8_17X |
✔️
|
| | LA44 |
✔️
|
| | RGBX332 (RGB8) |
✔️
|
| | BGRX332 (BGR8) |
✔️
|
| | RGB565 |
✔️
|
✔️
| | BGR565 |
✔️
|
✔️
| | RGBX5551 |
✔️
|
✔️
| | RGBT5551 |
✔️
|
✔️
| | BGRT5551 |
✔️
|
| | RGBA5551 |
✔️
|
✔️
| | BGRA5551 |
✔️
|
✔️
| | BGRA5551_TZAR |
✔️
|
| | BGRX5551 |
✔️
|
| | RGBX6666 |
✔️
|
| | RGBA6666 |
✔️
|
| | RGB888 (RGB24) |
✔️
|
✔️
| | BGR888 (BGR24) |
✔️
|
✔️
| | ARGB4444 |
✔️
|
| | RGBA4444 |
✔️
|
| | ABGR4444 |
✔️
|
✔️
| | XBGR4444 |
✔️
|
| | RGBX4444 |
✔️
|
✔️
| | BGRA4444 |
✔️
|
✔️
| | BGRA4444_LEAPSTER |
✔️
|
| | BGRX4444 |
✔️
|
| | XRGB1555 |
✔️
|
| | ARGB1555 |
✔️
|
| | ABGR1555 |
✔️
|
| | XBGR1555 |
✔️
|
| | ARGB8888 |
✔️
|
✔️
| | ABGR8888 |
✔️
|
| | RGBA8888 |
✔️
|
✔️
| | BGRA8888 |
✔️
|
✔️
| | XRGB8888 |
✔️
|
| | RGBX8888 |
✔️
|
| | XBGR8888 |
✔️
|
| | BGRX8888 |
✔️
|
| | BGRT8888 |
✔️
|
| | BGRA8888_TZAR |
✔️
|
| | RGB48 |
✔️
|
| | BGR48 |
✔️
|
| | PAL4 |
✔️
|
✔️
| | PAL8 |
✔️
|
✔️
| | PAL8_TZAR |
✔️
|
| | PAL16 |
✔️
|
| | PAL32 |
✔️
|
| | PAL_I8A8 |
✔️
|
| | N64_RGB5A3 |
✔️
|
| | N64_BGR5A3 |
✔️
|
✔️
| | N64_I4 / GRAY4 |
✔️
|
✔️
| | N64_I8 / GRAY8 |
✔️
|
✔️
| | N64_IA4 |
✔️
|
✔️
| | N64_IA8 |
✔️
|
✔️
| | N64_RGBA32 |
✔️
|
| | N64_CMPR |
✔️
|
✔️
| | BC1/DXT1 |
✔️
|
✔️
| | PSP_DXT1 | |
| | DXT2 |
✔️
|
| | BC2/DXT3 |
✔️
|
✔️
| | PSP_DXT3 |
✔️
|
| | DXT4 |
✔️
|
✔️
| | BC3/DXT5 |
✔️
|
✔️
| | PSP_DXT5 |
✔️
|
| | BC4 |
✔️
|
✔️
| | BC5 |
✔️
|
✔️
| | BC6 |
✔️
|
✔️
| | BC7 |
✔️
|
✔️
| | PVRTCI_2bpp_RGB |
✔️
|
✔️
| | PVRTCI_2bpp_RGBA |
✔️
|
✔️
| | PVRTCI_4bpp_RGB |
✔️
|
✔️
| | PVRTCI_4bpp_RGBA |
✔️
|
✔️
| | PVRTCII_2bpp |
✔️
|
✔️
| | PVRTCII_4bpp |
✔️
|
✔️
| | ETC1 |
✔️
|
✔️
| | BW1bpp |
✔️
|
✔️
| | SharedExponentR9G9B9E5 |
✔️
|
✔️
| | RGBG8888 |
✔️
|
✔️
| | GRGB8888 |
✔️
|
✔️
| | ETC2_RGB |
✔️
|
✔️
| | ETC2_RGBA |
✔️
|
✔️
| | ETC2_RGB_A1 |
✔️
|
✔️
| | EAC_R11 |
✔️
|
✔️
| | EAC_RG11 |
✔️
|
✔️
| | ASTC_4x4 |
✔️
|
✔️
| | ASTC_5x4 |
✔️
|
✔️
| | ASTC_5x5 |
✔️
|
✔️
| | ASTC_6x5 |
✔️
|
✔️
| | ASTC_6x6 |
✔️
|
✔️
| | ASTC_8x5 |
✔️
|
✔️
| | ASTC_8x6 |
✔️
|
✔️
| | ASTC_8x8 |
✔️
|
✔️
| | ASTC_10x5 |
✔️
|
✔️
| | ASTC_10x6 |
✔️
|
✔️
| | ASTC_10x8 |
✔️
|
✔️
| | ASTC_10x10 |
✔️
|
✔️
| | ASTC_12x10 |
✔️
|
✔️
| | ASTC_12x12 |
✔️
|
✔️
| | ASTC_3x3x3 |
✔️
|
✔️
| | ASTC_4x3x3 |
✔️
|
✔️
| | ASTC_4x4x3 |
✔️
|
✔️
| | ASTC_4x4x4 |
✔️
|
✔️
| | ASTC_5x4x4 |
✔️
|
✔️
| | ASTC_5x5x4 |
✔️
|
✔️
| | ASTC_5x5x5 |
✔️
|
✔️
| | ASTC_6x5x5 |
✔️
|
✔️
| | ASTC_6x6x5 |
✔️
|
✔️
| | ASTC_6x6x6 |
✔️
|
✔️
| | BASISU_ETC1S |
✔️
|
✔️
| | BASISU_UASTC |
✔️
|
✔️
| | RGBM |
✔️
|
✔️
| | RGBD |
✔️
|
✔️
| | GST121 |
✔️
|
| | GST221 |
✔️
|
| | GST421 |
✔️
|
| | GST821 |
✔️
|
| | GST122 |
✔️
|
| | GST222 |
✔️
|
| | GST422 |
✔️
|
| | GST822 |
✔️
|
| | YUY2 |
✔️
|
| | NV12 |
✔️
|
| | NV21 |
✔️
|
| | UYVY |
✔️
|
| | YUV444P |
✔️
|
| | YUV410P |
✔️
|
| | YUV420P |
✔️
|
| | YUV422P |
✔️
|
| | YUV411P |
✔️
|
| | UYYVYY411 |
✔️
|
| | YUV440P |
✔️
|
| | YUVA420P |
✔️
|
| | AYUV |
✔️
|
| | GRAY8A (LA88) |
✔️
|
| | GRAY16 |
✔️
|
| | RG88 |
✔️
|
| | R8 |
✔️
|
| | G8 |
✔️
|
| | B8 |
✔️
|
| | R16 |
✔️
|
| | G16 |
✔️
|
| | B16 |
✔️
|
| | R32 |
✔️
|
| | G32 |
✔️
|
| | B32 |
✔️
|
| | BUMPMAP_SR |
✔️
|
| * IO (输入/输出) - File Reader ✔️ - File Writer ✔️ - Bytes Handler ✔️ - Translation Text Handler ✔️ - Mod Handler ✔️ - File extension checking ✔️ - Padding calculation ✔️ - File size checking ✔️ # Checksum 计算示例 // CRC32 计算 ``` from reversebox.crc import crc32_iso_hdlc from reversebox.common import common test_data = b'123456789' crc32_handler = crc32_iso_hdlc.CRC32Handler() crc32 = crc32_handler.calculate_crc32(test_data) print("CRC32_INT: ", crc32) print("CRC32_STR: ", common.convert_int_to_hex_string(crc32)) ``` // CRC32 输出 ``` CRC32_INT: 3421780262 CRC32_STR: 0xCBF43926 ``` # XOR 加密示例 // XOR Cipher (Basic) ``` from reversebox.encryption.encryption_xor_basic import xor_cipher_basic test_data = b'abcd' test_key = b'\x3D' xor_result = xor_cipher_basic(test_data, test_key) print(xor_result) ``` // XOR Cipher 输出 ``` b'\\_^Y' ``` # 文件处理器示例 // 文件读取 ``` import os from reversebox.io_files.file_handler import FileHandler file_path = os.path.join(os.path.dirname(__file__), "file.bin") file_reader = FileHandler(file_path, "rb") file_reader.open() value = file_reader.read_str(4, "utf8") print(value) ``` // File Reader 输出 ``` ABCD ``` # Hash 计算示例 // SHA-1 计算 ``` from reversebox.hash.hash_sha1 import SHA1Handler test_data = b'abcd' sha1_handler = SHA1Handler() sha1 = sha1_handler.calculate_sha1_hash(test_data) print("SHA-1 hash: ", sha1) ``` // SHA-1 输出 ``` SHA-1 hash: b'\x81\xfe\x8b\xfe\x87Wl>\xcb"Bo\x8eW\x84s\x82\x91z\xcf' ``` # 图像解码示例 // DXT1 压缩图像解码 ``` from reversebox.image.image_decoder import ImageDecoder from reversebox.image.image_formats import ImageFormats from reversebox.image.pillow_wrapper import PillowWrapper def show_img(): with open("image_data_dxt1_64x64.bin", "rb") as f: image_data = f.read() img_width: int = 64 img_height: int = 64 decoder = ImageDecoder() wrapper = PillowWrapper() converted_data: bytes = decoder.decode_compressed_image(image_data, img_width, img_height, ImageFormats.BC1_DXT1) pil_image = wrapper.get_pillow_image_from_rgba8888_data(converted_data, img_width, img_height) pil_image.show() if __name__ == '__main__': show_img() ``` # 更多示例 需要更多示例?
请查看使用 ReverseBox 编写的工具列表: - [Giana's Return ZDA Tool](https://github.com/bartlomiejduda/Tools/blob/master/NEW%20Tools/Gianas%20Return/Gianas_Return_ZDA_Tool.py) - [ObsCure 2 HVP Extractor](https://github.com/bartlomiejduda/Tools/blob/master/NEW%20Tools/ObsCure%202/ObsCure%202%20HVP%20Tools/Obscure_2_hvp_extractor.py) - [Tail Concerto Translation Tools](https://github.com/bartlomiejduda/Tools/tree/master/NEW%20Tools/Tail%20Concerto/Tail%20Concerto%20Tools) - [EA Graphics Manager](https://github.com/bartlomiejduda/EA-Graphics-Manager) - [Acclaim TRE Tool](https://github.com/bartlomiejduda/Tools/tree/master/NEW%20Tools/Acclaim/Acclaim_TRE_Tool) - [F-Zero X TEX Tool](https://github.com/bartlomiejduda/Tools/tree/master/NEW%20Tools/F-Zero%20X/TEX%20Tool) - [ImageHeat](https://github.com/bartlomiejduda/ImageHeat) - [Hatch Engine Archive Tool](https://github.com/bartlomiejduda/Tools/tree/master/NEW%20Tools/Hatch%20Engine/Hatch%20Engine%20Archive%20Tool) - [ReverseBox Demo](https://github.com/bartlomiejduda/Tools/tree/master/ReverseBox_Demo) - [Super Galdelic Hour .egg texture extractor/converter](https://gist.github.com/boringhexi/e3f2e5ad98c39cdafa4913d7db23f81d) - 以及更多... # 徽章 ![PyPI Downloads](https://static.pepy.tech/badge/reversebox) ![PyPI - Downloads](https://img.shields.io/pypi/dm/ReverseBox) ![GitHub License](https://img.shields.io/github/license/bartlomiejduda/ReverseBox) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/bartlomiejduda/ReverseBox) ![GitHub repo size](https://img.shields.io/github/repo-size/bartlomiejduda/ReverseBox) ![PyPI - Version](https://img.shields.io/pypi/v/ReverseBox)
标签:Adler32, BZIP2, Checksum, Compression, CRC算法, Decompression, Encryption, Hashing, Image Parsing, LZ4, LZMA, Python, VPS部署, ZLIB, 二进制分析, 云安全运维, 云资产清单, 代码库, 加密解密, 数据压缩, 文件格式解析, 无后门, 校验和计算, 游戏逆向, 软件分析, 逆向工具, 逆向工程