Skip to content

Simple and very specific script to decompress data compressed several times.

Notifications You must be signed in to change notification settings

ShingekiNoChikungunya/matryoshka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What it is

Simple and very specific script to decompress data compressed several times.

The script supports only most commom tools and algorithms, like:

  • bz2
  • gz
  • tar
  • xz
  • zip

Usage

$ chmod 0755 has_pass_zip
$ python decompress.py zip_bomb.something

How to add a new type

You can read the explanation for better understanding or just skip to the instructions.

Brief Explanation


The script starts with the compressed name you passed to it.

On the first loop he will rename it to the generic name last flag, in the function, position_first_flag.

last flag will continuely be used throughout the script. Second step, it will get the type of compressed file by the linux util file, in the function type. The function type will use the static strings defined in utils.py.

After getting the file type, at decompress.py, the file generically named last flag will be renamed to its appropiate extension, eg. last flag.zip in the function redefine_type(utils.py), and then suitably extracted, this takes place in the redefine_type_and_extract function at extractor.py.

Bonus: Some file types are password protected, so we check it and deal with it in each extraction function. Ideally the function redefine_type_and_extract doesn't need to know it.

This finishes an iteraction. We now rename the newly generated file to the generic name last flag, in position_new_flag at decompress.py. And go on again.

Instructions


  1. Get a portion of the compressed file type description string with file util.
  2. Open utils.py and paste it inside a variable.
  3. In utils.py, inside the function type, add an elif statement before the ascii one.
  4. You can return any number, just remember it as we will need it later.
  5. Close utils.py and open extractor.py up.
  6. Now create a function to extract your new type. There are some wrappers to shell commands defined in utils.py that can be helpful and you can take one of the already defined functions as examples. Remembering that we first use the function redefine_type to rename the previously generic name last_flag to the appropriate name, with the extension.
  7. Now to the main part, in the function redefine_type_and_extract add an elif statement before the unknown type, compare if type_ equals your type code. And if so, call your extract function defined in step 6.
  8. That's it.

About

Simple and very specific script to decompress data compressed several times.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published