how to unpack and repack vc .bin file

Discussion in 'Wii - Hacking' started by bp2000, Apr 8, 2009.

  1. bp2000

    bp2000 GBAtemp Regular

    Dec 13, 2008
    United States
    can somebody please tell me how to unpack the content.bin file of a wii vurtual console game
  2. dsfgd

    dsfgd Advanced Member

    May 17, 2008
    Gambia, The
    i can, but i don't think you can understand how to do it.

    things you need:
    - SDkey
    - SDiv
    - PRNGseed key
    - some C / C++ knowledge

    i explain it with Homebrew Channel as content.bin:
    - first you need to read the first 1600 Byte of content.bin and decrypt it with SDkey+SDiv, for decrypting use Openssl, aes_cbc_decrypt
    - then read the decrypted data, you will find on offset 0x08 a 4 Byte unsigned long, in big endian format, this is the size of icon.bin (it should be 0x0000330C = 13068)
    - so now read a buffer of it from 0x640 to 0x394B, decrypt it and you get the icon.bin, now you need the offset to Pre-TMD Header and TMD File
    the calculation is simple: Pre-TMD Header is 1600 + 13068 mod 64 = 14720 = 0x3980
    Pre-TMD Header and TMD file are NOT encrypted.
    first 4 byte are the size of this header (0x00000070 = 112 mod 64 = 128), in this header you can find the size of TMD, but you don't need it, you must read the TMD, so get the size there.

    so TMD is at 0x3A00 and has the size of 556 Byte (mod 64 = 576)
    read the tmd to know where the contents are and how big they are, you will also need the index, to calculate index_iv

    the first content (0x0000) is at offset 0x3C40 and has a size of 638384 Byte (mod 64 = 638400)
    the second content (0x0001) is at offset 0x9FA00 and has a size of 760000 Byte (mod 64 = 760000)

    the index_iv = xxxx & 0x0000000000000000000000000000, xxxx = index, so for the first content, the index_iv is "0x00000000000000000000000000000000"
    so to decrypt it, you need the PRNGseed, as key, the rest is the same as any wad.

    after decrypting you get the same files, (except of the *.tik) as if you unpacked a wad.

    to re-encrypt it, you do exact the same, backwards with aes_cbc_encrypt.....

    this is a fast written, maybe not fully correct tutorial to unpack content.bin files.

    for those who don't know what mod 64 is, it's modulo, and a align of 64 Byte,
    calculation sample:
    13068 mod 64 = 13068 / 64 = 204,1875 = 204 + 1 = 205 *64 = 13120
  3. jinxvorheeze

    jinxvorheeze GBAtemp Advanced Fan

    May 13, 2008
    United States
    This is awsome, now I don't have to make a tutorial. You save me dsfgd!
  4. Johnnyr310

    Johnnyr310 Newbie

    Apr 9, 2009
    United States
    could you make a Video please because i am kinda lost there... thanks man
  5. jinxvorheeze

    jinxvorheeze GBAtemp Advanced Fan

    May 13, 2008
    United States
    I don't think anyone is going to make a video for you. It's not exactly an easy process, and is not something a video is going to help you better understand. Sorry mate.
  6. kornychaos

    kornychaos Organized.

    Jul 7, 2007
    United States
    Is there a way to batch extract the content.bin files/folders from a folder of .WADs and then maybe have a batch .tik ticket file installer?
    This would save me some time from installing via Wad Manager and then swapping SD cards and then using 4.0 to move the channels. Thanks.
  7. Supremekhaoz

    Supremekhaoz Newbie

    May 3, 2009
    United States
    i dont understans this help me i even got original mario vc game to get the key cuse i never had hbc
  8. Aattring

    Aattring Newbie

    Jun 17, 2009
    United States
    I tryed following your instructions. Below is the output:

    Ú?ux;Zû?÷p?SÆ?HAJP ? ?HADP HALP
  9. BillandAlisha

    BillandAlisha GBAtemp Regular

    Dec 10, 2008
    United States
    [​IMG] Just, stop bumping. It's annoying. [​IMG]
  10. nicky041192

    nicky041192 GBAtemp Maniac

    Mar 9, 2008
    5 bumps? wtf. wait for an answer or youll get none. ok?
    use the search function.