Giter Site home page Giter Site logo

tsukuyomi's Introduction

Tsukuyomi

This is a placeholder for scripts and tools used for Lunii reverse engineering project called Tsukuyomi.

The format of Lunii image content structure is still under ongoing reverse engineering to produce a lunii.ksy file which describe the format of Lunii image in Kaitai Struct, a DSL language that help on dealing with arbitrary binary formats.

For more information about the project please visit hackaday.io project page.

^^Disclaimer^^

Disclaimer

Tsukuyomi scripts and tools try to not alter directly with the Lunii sdcard, Thus it is highly recommended to create a disk dump of the Lunii sdcard and use it as a middle and safe step before writing the final image to your Lunii sdcard.

Also make sure to always keep an original backup of the sdcard, to write it back if anything goes wrong.

So please don't blame on me if you harm your kid's best toy Lunii ๐Ÿ˜‡ !!! USE THIS AT YOUR OWN RISK!!!

Install Tsukuyomi and dependencies

  1. Clone this repo:
$ git clone https://github.com/danksz/tsukuyomi
  1. Install Kaitai Struct Compiler from project repo:
$ sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv 379CE192D401AB61
$ echo "deb https://dl.bintray.com/kaitai-io/debian_unstable jessie main" | sudo tee /etc/apt/sources.list.d/kaitai.list
$ sudo apt-get update
$ sudo apt-get install kaitai-struct-compiler
  1. Install Kaitai Struct Python Runtime library:
$ git clone https://github.com/kaitai-io/kaitai_struct_python_runtime
$ sudo python setup.py install
  1. Compile the Kaitai Struct YAML Lunii description file lunii.ksy to python module using ksc the Kaitai Struct Compiler.
$ cd tsukuyomi/sd-parser
$ kaitai-struct-compiler --target python kaitai-struct/lunii.ksy
  1. Start using scripts sd-lunii-* scripts, create new ones and contribute ;-)

Parse Lunii Image

Execute the sd-lunii-parser.py script to parse a Lunii image to find stories and their belongings embedded media files (Bitmaps and WAV sounds).

cd tsukuyomi/sd-parser
$ ./sd-lunii-parser.py Lunii.img

Mount Lunii Image

Thanks also to another Kaitai Struct project called KaitaiFS we can mount a Lunii image as filesytem and navigate within it like a normal driver by providing only the KSY file.

$ git clone https://github.com/kaitai-io/kaitai_fs
$ cd kaitai_fs
$ sudo python setup.py install
$ cd ../tsukuyomi/sd-parser
$ mkdir mountpoint
$ python3 -m kaitaifs.generic lunii Lunii.img mountpoint

File browser on Lunii image content

(NOT TESTED YET) I believe that we can directly mount the sdcard with:

$ sudo python3 -m kaitaifs.generic /dev/mmcblkX  mountpoint

Extract Stories

Execute sd-lunii-extract-stories.py script to extract from a Lunii image all stories to the folder out-extract.

$ cd tsukuyomi/sd-parser
$ ./sd-lunii-extract-stories.py Lunii.img

Add Stories

To add new stories to the Lunii image, we can use the sd-lunii-concat-stories.py script which create a new Lunii image in out folder containing the base Lunii image and and the stories located in a input folder.

$ cd tsukuyomi/sd-parser
$ ./sd-lunii-concat-stories.py Lunii.img out-extract

Lunii Image Content Visualizer

Thanks to Kaitai Struct Visualizer we can visualize the parsing of a Lunii image content:

$ sudo gem install kaitai-struct-visualizer
$ cd tsukuyomi/sd-parser/kaitai-struct
$ ksv Lunii.img lunii.ksy

ksv on Lunii image content

Please notes that the parsing may takes a very long time and it will eat a very large amount of RAM (in GB!!) depending on how many stories are put in the Lunii image.

tsukuyomi's People

Contributors

danksz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

emfl

tsukuyomi's Issues

Errors with kaitai-struct-compiler and sd-lunii-parser.py

Hi,
First, thanks for your work !
I hope you can help me, I really need to extract the stories from my old Lunii to put them on my new Lunii (I don't have access to my old lunistore account) but I have two errors :

The first error :

kaitai-struct-compiler --target python kaitai-struct/lunii.ksy
lunii: /meta/imports/1:
error: kaitai-struct/wav.ksy:19:1:
error: found duplicate key doc-ref

And the second error (the lunii.img was made with win32diskimager) :

./sd-lunii-parser.py lunii.img
position of content structure: 51200000
position of number of stories: 51661066
Number of stories: 38422
Traceback (most recent call last):
File "/home/biocef/tsukuyomi/sd-parser/./sd-lunii-parser.py", line 26, in
string += story_sep + 'nbr_nodes: {:03}'.format(story.story_info.nbr_nodes)
File "/home/biocef/tsukuyomi/sd-parser/lunii.py", line 55, in story_info
self._m_story_info = self._root.StoryInfoStruct(self._io, self, self._root)
File "/home/biocef/tsukuyomi/sd-parser/lunii.py", line 80, in init
self._read()
File "/home/biocef/tsukuyomi/sd-parser/lunii.py", line 83, in _read
self.nbr_nodes = self._io.read_u2be()
File "/usr/local/lib/python3.9/dist-packages/kaitaistruct-0.10-py3.9.egg/kaitaistruct.py", line 173, in read_u2be
File "/usr/local/lib/python3.9/dist-packages/kaitaistruct-0.10-py3.9.egg/kaitaistruct.py", line 326, in read_bytes
EOFError: requested 2 bytes, but only 0 bytes available

How can I resolve these issues ?

Regards,
Biocef.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.