Karen Posted April 17 Posted April 17 (edited) Hi everyone, I'm running into difficulties with what appears to be a modified GZIP format from a PS2 game(Virtua Cop) and would appreciate some expert help. Inside a container file (CMN.BIN, attached), I found 5 GZIP-compressed . The last four files have standard 1F 8B gzip headers, and I can successfully decompress them using tools like WinRAR to get valid TM2 texture files. The problem lies with the first stream (offset 0x0 to 0x11DF in CMN.BIN, also attached as unknown.bin). Its header starts with 1E 8A. Interestingly, if I add 1 to some bytes in the header starting around offset 0xA (treating FF+1 as 00), I can see what looks like the original filename shar8.tm2. This TM2 format matches the files extracted from the other standard streams, so I believe the filename is correct. The footer also seems present, likely containing the standard CRC32 and ISIZE. I suspect the uncompressed data is a 128x128 8bpp TM2 file (17,472 bytes / 0x4440), but I cannot know the original CRC value. Here's what I've tried without success: Apply +1 to header bytes only, keep the original deflate stream and original footer (CRC+ISIZE). Apply +1 to header bytes and deflate stream bytes, apply +1 to CRC bytes, keep original ISIZE bytes. Apply +1 to header bytes and deflate stream bytes, keep original CRC and ISIZE bytes. All these attempts failed, often resulting in checksum errors when trying to test/decompress the resulting file with WinRAR, even though WinRAR could sometimes recognize the (+1 adjusted) filename and timestamp correctly from the modified header. I also tried scanning CMN.BIN for raw deflate streams using methods similar to those described in offzip tutorials (like the one on reshax.com: https://reshax.com/topic/1063-offzip-deflatezlib-scanning-and-extraction/), but that didn't yield a working result for this specific stream either. Could anyone shed some light on this potential GZIP modification or suggest how to correctly decompress unknown.bin? I've attached the container CMN.BIN and the extracted stream unknown.bin. Any help or insights would be greatly appreciated! Thanks. compressed.zip Edited April 17 by Karen
BloodRaynare Posted April 17 Posted April 17 (edited) Please specify the game name And also for some reason unknown.bin is asking for password so can you provide that one too? Edited April 17 by BloodRaynare
Karen Posted April 17 Author Posted April 17 48 minutes ago, BloodRaynare said: Please specify the game name And also for some reason unknown.bin is asking for password so can you provide that one too? Sorry, I used WinRAR for compression... I forgot that my settings had a default password enabled. I have already modified it so it doesn't have a password anymore. The game is Virtua Cop for the PS2, and I've already added it to the post. Thanks for your reply.
Solution wq223 Posted Saturday at 05:12 PM Solution Posted Saturday at 05:12 PM On 4/17/2025 at 3:16 PM, Karen said: Sorry, I used WinRAR for compression... I forgot that my settings had a default password enabled. I have already modified it so it doesn't have a password anymore. The game is Virtua Cop for the PS2, and I've already added it to the post. Thanks for your reply. Just fix the first 256 bytes, turn its value +1, (FF) back 00 I wrote a script that can fix your file You can perform repair tests or download the fixed version If the test is not problematic, mark the reply as a solution import gzip import shutil import sys import os from pathlib import Path def modify_and_decompress(input_file, output_folder): Path(output_folder).mkdir(parents=True, exist_ok=True) with open(input_file, 'rb') as f: data = bytearray(f.read()) for i in range(min(256, len(data))): data[i] = (data[i] + 1) % 256 temp_file = os.path.join(output_folder, "temp_modified.gz") with open(temp_file, 'wb') as f: f.write(data) try: output_file = os.path.join(output_folder, "decompressed_output") with gzip.open(temp_file, 'rb') as f_in: with open(output_file, 'wb') as f_out: shutil.copyfileobj(f_in, f_out) print(f"Success! Decompressed file saved to: {output_file}") except gzip.BadGzipFile: print("Error: Invalid gzip format or decompression failed") finally: if os.path.exists(temp_file): os.remove(temp_file) if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: python gz.py <input_file> <output_folder>") sys.exit(1) input_path = sys.argv[1] output_dir = sys.argv[2] modify_and_decompress(input_path, output_dir) repair.zip
Karen Posted Sunday at 04:04 AM Author Posted Sunday at 04:04 AM 10 hours ago, wq223 said: Just fix the first 256 bytes, turn its value +1, (FF) back 00 I wrote a script that can fix your file You can perform repair tests or download the fixed version If the test is not problematic, mark the reply as a solution import gzip import shutil import sys import os from pathlib import Path def modify_and_decompress(input_file, output_folder): Path(output_folder).mkdir(parents=True, exist_ok=True) with open(input_file, 'rb') as f: data = bytearray(f.read()) for i in range(min(256, len(data))): data[i] = (data[i] + 1) % 256 temp_file = os.path.join(output_folder, "temp_modified.gz") with open(temp_file, 'wb') as f: f.write(data) try: output_file = os.path.join(output_folder, "decompressed_output") with gzip.open(temp_file, 'rb') as f_in: with open(output_file, 'wb') as f_out: shutil.copyfileobj(f_in, f_out) print(f"Success! Decompressed file saved to: {output_file}") except gzip.BadGzipFile: print("Error: Invalid gzip format or decompression failed") finally: if os.path.exists(temp_file): os.remove(temp_file) if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: python gz.py <input_file> <output_folder>") sys.exit(1) input_path = sys.argv[1] output_dir = sys.argv[2] modify_and_decompress(input_path, output_dir) repair.zip 9.46 kB · 1 download Thanks, it really worked! It looks like I hadn't figured out exactly which part needed the +1 before. Thanks again for your help! 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now