Opening a .IOP File

10/30/2019 04:08 LepEatWorld#1
So, I currently tried to open an IOP file but for some reason I cant seem to you know... get it open. I'm able to open it as a Zip, but if I do the file contains 0bites. When I open it with Notepad++ it's kind of encrypted? Not sure at this point. But when I open it with [Only registered and activated users can see links. Click Here To Register...] it shows me the files inside and then it stops and shows me the Zip files instead... [Only registered and activated users can see links. Click Here To Register...]

This is an example of the files that should be inside the IOP.

Thanks for the help in advance to whoever can help.
10/30/2019 21:51 elmarcia#2
Quote:
Originally Posted by LepEatWorld View Post
So, I currently tried to open an IOP file but for some reason I cant seem to you know... get it open. I'm able to open it as a Zip, but if I do the file contains 0bites. When I open it with Notepad++ it's kind of encrypted? Not sure at this point. But when I open it with [Only registered and activated users can see links. Click Here To Register...] it shows me the files inside and then it stops and shows me the Zip files instead... [Only registered and activated users can see links. Click Here To Register...]

This is an example of the files that should be inside the IOP.

Thanks for the help in advance to whoever can help.
Edit: Sorry im late, made python script instead

The file is PK, means with zlib can be unpacked, but its a modified PK format, it has the following file format

|4 bytes | 1 byte |0xD bytes| 4 bytes | 4 bytes | 4 bytes | variable size bytes | variable size bytes|
|PK SIGNATURE|filenamelen|unknown |compressed_size|uncompressed_size| unk2 | filename | data |


Code:
import zlib
import os

f = open("rs.iop","rb")

#zlib header
pkHeader = b"\x50\x4b\x03\x04"

print("Unpacking...")

while True:
    header = f.read(4)
    if header != pkHeader:
        break
    filenamelen = int.from_bytes(f.read(1),byteorder="little")
    #skip bytes
    f.read(0xD)
    filesize = int.from_bytes(f.read(4),byteorder="little")
    #skip bytes
    f.read(8)
    filename = f.read(filenamelen).decode("utf-8")
    if filesize == 0:
        try:
            os.mkdir(filename)
        except:
            pass
    else:
        fo = open(filename,"wb")
        print(filename)
        data = f.read(filesize)
        try:
            decompressed = zlib.decompress(data,-15)
            fo.write(decompressed)
        except:
            #can't uncompress data, write plain
            fo.write(data)
        fo.close()

f.close()

print("Done!")
10/31/2019 13:01 LepEatWorld#3
Thanks for the help, haven’t tested it yet since I havent had time but I’ll check it tomorrow after Halloween ���� Thanks again.
10/31/2019 15:22 elmarcia#4
Np, if you need to pack it again will need to figure out unknown bytes, i assume 4 of them is for CRC the file name len is 2bytes not 1 like i said, but used one cause max path is 255. And make a script for the reverse process.

[Only registered and activated users can see links. Click Here To Register...]