An open API service indexing awesome lists of open source software.

https://github.com/bartlomiejduda/ReverseBox

ReverseBox is a Python package with a set of functions useful in reverse engineering.
https://github.com/bartlomiejduda/ReverseBox

checksum cipher compression crc encryption engineering hash modding modding-tools python reverse reverse-engineering reversebox xentax

Last synced: 7 days ago
JSON representation

ReverseBox is a Python package with a set of functions useful in reverse engineering.

Awesome Lists containing this project

README

          

# Info

**ReverseBox** is a Python package with a set of functions
useful in software reverse engineering.

**Why ReverseBox?**

It's designed to help with:
1. Decompressing / compressing data
2. Decrypting / encrypting data
3. Tedious reverse engineering tasks
e.g. testing different checksum algorithms to find the one that was
used in the software or file format
4. Figuring out file formats
5. Parsing data structures
6. Wrapping functions for input/output operations
7. Searching for raw images

**Who should use ReverseBox?**

Mostly developers and reverse engineers (e.g. file format researchers
or software researchers).

# List of functionalities

* 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 βœ”οΈ (wrapper only)
- 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 βœ”οΈ (wrapper only)

* Compression
- Asobo (TODO) ❌
- BZE/BZZ (TODO) ❌
- BZIP2 βœ”οΈ (wrapper only)
- GZIP (TODO) ❌
- JCALG1 (TODO) ❌
- LZ4 βœ”οΈ (wrapper only)
- LZMA βœ”οΈ (wrapper only)
- LZO / LZO1X βœ”οΈ (wrapper only)
- LZSS (TODO) ❌
- MIO0 βœ”οΈ
- NitroSDK (TODO) ❌
- Oodle (TODO) ❌
- Refpack (EA Games) βœ”οΈ (wrapper only)
- RNC (TODO) ❌
- ZLIB βœ”οΈ (wrapper only)
- PS2 GS Texture Compression βœ”οΈ
- RLE TGA βœ”οΈ
- RLE TGA (reversed condition) βœ”οΈ
- PackBits (Macintosh RLE) βœ”οΈ
- (game-specific) Re:Tiyoruga DAT compression βœ”οΈ
- (game-specific) Intelligent Games Custom Huffman βœ”οΈ
- (game-specific) Executioners RLE βœ”οΈ
- (game-specific) Emergency RLE βœ”οΈ
- (game-specific) Neversoft RLE βœ”οΈ
- (game-specific) Tzar RLE βœ”οΈ
- (game-specific) Leapster RLE βœ”οΈ

* Encryption
- AES (TODO) ❌
- DES (TODO) ❌
- Lucifer / DTD-1 (TODO) ❌
- ROT13 βœ”οΈ
- XOR Cipher (Basic) βœ”οΈ
- XOR Cipher (Basic) Guesser βœ”οΈ
- Hatch Engine Encryption βœ”οΈ
- (game-specific) XOR Cipher (Retro64 ECO) βœ”οΈ
- (game-specific) 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 βœ”οΈ (wrapper only)
- SHA-2 (256 bits) βœ”οΈ (wrapper only)
- MD2 βœ”οΈ (wrapper only)
- MD5 βœ”οΈ (wrapper only)
- Murmur3 βœ”οΈ (wrapper only)
- (game-specific) Hercules (TODO) ❌
- (game-specific) E-racer (TODO) ❌
- (game-specific) 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 βœ”οΈ
- Decoding and encoding images with pixel formats
mentioned in the following table:

| 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 calculation - example

// CRC32 calculation
```
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 output
```
CRC32_INT: 3421780262
CRC32_STR: 0xCBF43926
```

# XOR encryption - example

// 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 output
```
b'\\_^Y'
```

# File Handler - example

// File reading
```
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 Output
```
ABCD
```

# Hash calculation - example

// SHA-1 calculation
```
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 Output
```
SHA-1 hash: b'\x81\xfe\x8b\xfe\x87Wl>\xcb"Bo\x8eW\x84s\x82\x91z\xcf'
```

# Image decoding - example

// DXT1 compressed image decoding

```
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()
```

# More Examples

Need more examples?

Check out list of tools written using 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)
- and more...

# Badges
![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)