1. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Hi all,

    I've been doing some tests trying to understand the format of the data contained in the qr codes of cubic ninja.
    I developed a program that extracts the data from them as byte array using open source zxing library.
    The data don't seem to follow any obvious pattern, and it looks like it's compressed. Do you guys know what type of data does it use?

    Edit1:

    This is how the file that I have looks like in hex (the byte array that I extracted from QR):

    [​IMG]

    PD: The QR I used:

    [​IMG]

    Edit2:

    Ok, Cubic Ninja QR-Codes contains a timestamp, so for each level every time you generate a QR-Code you get a new different QR-Code.
    The game allows you to create 3 kinds of levels (Type A, Type B or Type C). I have created an empty A type level and generated two QR-Codes from it, so the only data that can change is the timestamp.

    QR 1:
    Image:
    [​IMG]

    Data:
    [​IMG]

    QR 2:
    Image:
    [​IMG]

    Data:
    [​IMG]

    I uploaded the QR binaries so you can see the data more easily.

    Edit3:
    I got it working, now I can make equivalent and clean QR-Codes. I was getting the bytes as UTF-8 and looks like it should be ISO-8859-1 codification.

    Now the data has quite more sense.

    I'm going to refactor my code to give you my Java QR Extract tool. See you in a while!

    Ok, I made a quick GUI for you (and quite ugly), so you don't have to use console (I didn't take care with GUI errors, so probably the program will throw errors pretty easily if you do strange things).

    About the program
    -------------------------
    Last version: 1.0b

    1. What it does right now:

    Give the program an image input file
    Select where to save the binary output file.
    Press Run
    The program generates a .bin file (it contains the bytes contained in the QR Code) and a clean QR Code.

    2. Objetives

    - Understand the Cubic Ninja QR Format.
    - Understand other games format (AC new leaf is already solved, but there are other games that would be ok to get info about)

    3. Requeriments:

    - Java virtual machine: The program should work in any enviroment with java >= 6, but I've tested it only with oracle java 8 and openjdk 7.

    4. FAQ

    - ¿What do I mean with a clean QR Code?

    You can take a photo with your mobile phone in bad quality and the program will generate a clean and equivalent output image for you.

    - It is broken/ I get error ...

    Please, tell me what you did (Screenshots would be awesome) and I will try to help you

    - Does it only work with Cubic Ninja?

    Right now I've only tested it with Cubic Ninja.

    - The QR Code it generates it's different

    The QR Code it generates contains the same data, it's an equivalent QR-code, QR Codes can vary depending on Size, Mask etc. There are more than many outputs for the same input (they all contain the same data).

    5. Known problems/Errors:

    - It only admits jpg images

    - Sometimes it doesn't recognize the image QR Code

    - Problems with Java 7? (try to use console and if it prints an error post it here!)

    6. Tested on:

    - OpenJDK 7, Oracle Java 8, Oracle Java 7

    - Image types: JPG, PNG

    7.Downloads:

    GUI-Version: https://dl.dropboxusercontent.com/u/4593493/QR_BinExtractor.jar

    Console Version: https://dl.dropboxusercontent.com/u/4593493/QBE_NOGUI.jar
    Use -> java -jar QBE_NOGUI.jar inputFile.jpg outputFile.bin

    Thanks
     
  2. Kaphotics

    Kaphotics badc0ded
    Member

    Joined:
    Sep 10, 2010
    Messages:
    612
    Country:
    United States
  3. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    I'm just taking the data contained in the QR-Code as a byte array. QR-Codes allows many encoding modes, one of them is byte-encoding which I'm using to get the data. Right now the data that I got from the QR is untouched, I did not modify its contents.
    The idea is to understand the format of the QR-Codes to be able to try things, create levels without needing a 3Ds etc.

    PD: The format you posted does not look like the one I posted. My file is much bigger (exactly 1201 bytes). Mii format is 112 bytes... Anyway thanks for trying :lol:
     
  4. NCDyson

    NCDyson Hello Boys...
    Member

    Joined:
    Nov 9, 2009
    Messages:
    278
    Country:
    United States
    its more than likely encrypted. i dunno much about QR codes and the encoding, so it could be something more simple
     
  5. YoshiInAVoid

    YoshiInAVoid GBAtemp Advanced Fan
    Banned

    Joined:
    Jan 10, 2011
    Messages:
    560
    Country:
    Good work. I think you should also post the image of the actual level; and give more examples so we can see the similarities and differences. Just having 1 isn't that useful for reverse engineering.

    I don't think Cubic Ninja is the game. But this is interesting research none the less.
     
  6. lemonmeister

    lemonmeister Member
    Newcomer

    Joined:
    Apr 7, 2013
    Messages:
    18
    Country:
    Italy
    A quick look reveals a recurring pattern, I'd say its just some simple for encryption. Or maybe its just the good old misused aes-ecb
     
  7. gamesquest1

    gamesquest1 Nabnut
    Moderator

    Joined:
    Sep 23, 2013
    Messages:
    15,029
    yeah i noticed an awful lot of EFBFBD

    but then again i have no idea how all this stuff works :lol:
     
  8. hippy dave

    hippy dave BBMB
    Member

    Joined:
    Apr 30, 2012
    Messages:
    5,766
    Country:
    United Kingdom
    From a brief glance I think I've got it worked out - if you XOR the data with 0xb00b you get a nude J-Law selfie.
     
    Margen67, Nurio and piratesephiroth like this.
  9. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Funny, but this is not a funny thread. This is a serious post, try to keep it clean please.

    Yeah, looks like 0xEF 0xBF 0xBD bytes repeats constantly. it's some kind of pattern.

    I will continue experimenting with the files, I will have a look into AES (I have a library I made time ago) and hopefully I can find something interesting.

    Thank guys!

    I updated the main post, keep an eye on it ;)
     
  10. VinsCool

    VinsCool Cattus Incerta Tacitusque
    Moderator

    Joined:
    Jan 7, 2014
    Messages:
    13,790
    Country:
    Canada
    Interesting, if you need help for whatever level editing or any experimentation, I also have the game ;)
     
  11. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Thanks, I just got it working! :P.

    It extracts data from any kind of QR-Code (and maybe others...). it generates a clean image of the QR Code and the byte buffer file.
    I'm going to do some tests and the GUI and I will post it here if I don't find any error meanwhile.
    Later I have to understand the format (the hard part)
     
  12. Cyan

    Cyan GBATemp's lurking knight
    Former Staff

    Joined:
    Oct 27, 2002
    Messages:
    23,148
    Country:
    France
    Elisherer worked on a QR generator/Level editor for multiple games.
    Maybe he could help you with the format.

    look for "Inteligent Level Editor". (old name was Pyramid Level editor, but it's now multi-games)

    Or you could search and accomplish it yourself, it's providing good knowledge to try and understand things.
     
  13. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Just uploaded the first version, I will come back later, I'm going to have dinner :P
     
    VinsCool likes this.
  14. VinsCool

    VinsCool Cattus Incerta Tacitusque
    Moderator

    Joined:
    Jan 7, 2014
    Messages:
    13,790
    Country:
    Canada
    It doesn't work for me. It loads, I select one of your test qr codes (in jpeg format) the I selected the output file ( a test.bin) but if I press "run" it did nothing O.o
     
  15. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Java version problem, it happened to me before too with Java SE 7. I am having dinner, but try with openjdk meanwhile, I will have a look at it later.
     
  16. VinsCool

    VinsCool Cattus Incerta Tacitusque
    Moderator

    Joined:
    Jan 7, 2014
    Messages:
    13,790
    Country:
    Canada
    Okay thanks :)
     
  17. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Ok, I'm back. Let's have a look to that error with Java 7 :wtf:

    Edit:

    Looks like some weird error with "Oracle Java 7 Runtime" and the swing GUI or something like that. I didn't have any problems once I selected another java version or tried by console.
    To reproduce the error and because always is better, I'm uploading a console version. Try with that one, it should work. If it just prints an error post it here so I can fix it. Thanks ^^


    Thank you, I'm looking at the project right now. Does he usually post here? He does xD
     
  18. elisherer

    elisherer I ♥ 3DS
    Member

    Joined:
    Dec 16, 2009
    Messages:
    778
    Country:
    Iceland
    Your QR code decoder is not working well... it tries to translarte the data to text and creates those EFBFBD for unknown letters. (UTF8)
    looks like the last byte changes (suggesting CRC-8?)
    Anyway, There is nothing similiar about the first qr and the last empty ones. I think it might be encrypted even with a xorpad. (if the checksum is xor based it can still be found)

    Edit: BTW, you can use 3ds explorer to extract bin files from QR codes (Tools->QR tool), and there is a XOR tool for XOR operations as well

    Edit2: I'm assuming it isn't compressed because the 3 files you uploaded are aligned to 8 bytes (suggesting int32), needs more qr codes (maybe some more information about what's in there like if there is a title for the empty ones, change it by one letter)
     
  19. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    That files are wrong, I didn't upload new files since I fixed the program (Edit 3).
    These ones I've just upload are good. Take a look at them please.

    edit: Files of the same type (for example typeC_1 and typeC_2) are the same level, only the timestamp changes. In the file you can see four important changes. The first byte, the last byte, and two intervals of 6 and 8 bytes that starts in different places depending of the type of the level.
     

    Attached Files:

  20. clemull
    This message by clemull has been removed from public view by Sicklyboy, Nov 19, 2014, Reason: One word post.
    Nov 19, 2014 Show
  21. jl1990

    OP jl1990 Member
    Newcomer

    Joined:
    Sep 2, 2014
    Messages:
    12
    Country:
    Looks like this can be too useful now :P
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Cubic, Ninja,