Skip to main content

Tool to Fix Yabinary File

Project description

This is Python Library to fix “Yabinary” file like foremost. The term “Yabinary” in Japanese mean “Dangerous Binary”.
This library can be useful for CTF. It supports Python 2 & 3.

change log

0.2.8
add many signatures
change extract single files to extract many files
0.2.7
bug fix
0.2.6
add get_signature_index(), rewite identify(), extract()
0.2.5
add write()
0.2.4
fix README
0.2.3
change fixYabinary command, import to fy
0.2.2
bug fix
0.2.1
rewrite something, and change how to extend().
0.2.0
can use in command line.

Installation

PyPI

The recommended process is to install the PyPI package, as it allows easily staying update.

$ pip install fixYabinary

github

Download from https://github.com/tkmru/fixYabinary/. Let’s push star!!

Usage

look(file_path)

print Binary like hexdump command.

>> import fy
>> fy.look("./test.png")

           00 01 02 03 04 05 06 07   08 09 0A 0B 0C 0D 0E 0F
0x000000   00 00 00 00 49 45 4e 44   ae 42....

It can be used in command line.

$ fy -l test.png

get(file_path, option)

return Binary data. If option is “f” , you get Formated Binary.
You must not set option.
>> import fy
>> fy.get("./test.png")
0000000049454e44ae42....

>>fy.get("./test.png", "f")
00 00 00 00 49 45 4e 44 ae 42....

write(file_path, binary, option)

This function write new file from binary string.
If option is “l” , set binary list to second arg.
You must not set option.
>> import fy
>> fy.write('test','01ff4c')
>> fy.get('test')
u'01ff4c'

>> fy.write('test',['01','ff','4c'],'l')
>> fy.get('test')
u'01ff4c'

extend(file_path, new_file_path, hex, bytes, option)

make new file that file is extended. extend function intepret that byte is decimal.
option is None or “t” or “b”. option is None by default.
>> import fy
>> fy.get("./test.png", "./extended", "00", 3)

Succeeded in making ./extended.
# 000000 + ./test.png's Binary Data + 000000 in ./extended


>> fy.get("./test.png", "./extended", "00", 3, "t")

Succeeded in making ./extended.
# 000000 + ./test.png's Binary Data in ./extended


>> fy.get("./test.png", "./extended", "00", 3, "b")

Succeeded in making ./extended.
# ./test.png's Binary Data + 000000 in ./extended

It can be used in command line in case option is None.

$ fy -e test.png extended 00 3

identify(file_path)

identify file type in file. return file type.

>> import fy
>> fy.identify("./extended")
./expanded include following FILE SIGNATURES
HEADER
pdf: 10 bytes - 13 bytes
jpg: 131076 bytes - 131078 bytes, 152310 bytes - 152312 bytes, 1352263 bytes - 1352265 bytes

FOOTER
pdf: 2340568 bytes - 2340573 bytes, 2340568 bytes - 2340574 bytes
jpg: 32981 bytes - 32982 bytes, 79754 bytes - 79755 bytes

It can be used in command line.

$ fy -i extended

extract(file_path, new_file_path, start_address, end_address)

cut out binary data, and write it into new file.
If start_address and end_address is str, they are interpreted hex.
If start_address and end_address is int, they are interpreted decimal.
>> import fy
>> fy.extract("./extended", "./result", 4 , 124)
Succeeded in making ./result

and auto detect file in file, and write it into new file.

>> import fy
>> fy.extract("./extended", "./result")
Succeeded in making ./result1.png
Succeeded in making ./result2.png
Succeeded in making ./result2.jpg

It can be used in command line.

$ fy -r extended result 4 124  # set start_address and end_address

$ fy -a extended result        # auto extract file in file

License

MIT License

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) @tkmru

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fixYabinary-0.2.8.tar.gz (7.4 kB view details)

Uploaded Source

Built Distributions

fixYabinary-0.2.8-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

fixYabinary-0.2.8-py2-none-any.whl (12.6 kB view details)

Uploaded Python 2

File details

Details for the file fixYabinary-0.2.8.tar.gz.

File metadata

  • Download URL: fixYabinary-0.2.8.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fixYabinary-0.2.8.tar.gz
Algorithm Hash digest
SHA256 cccbe0277d9c7cd687252ebe1bf2b91cba3f1f06366fbf4cb2de28f886b9a7bc
MD5 08ab0d628ccbe0178c14dde4868516ce
BLAKE2b-256 2d2cb487919ef61e8b349dd18bedf589735c38cc89d6350b0d13ee2bb6ce9755

See more details on using hashes here.

File details

Details for the file fixYabinary-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for fixYabinary-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 cc788b909cffe0566f0a193b4d056cfffc4899f40d4e4c86c29b78ec2065aa2d
MD5 7214fcecbfb757ab4edbcc77247386e9
BLAKE2b-256 424680cfaed85d28828f9b842039c792a1fefcb79a2c9f4c52ece34ae4e7e6f8

See more details on using hashes here.

File details

Details for the file fixYabinary-0.2.8-py2-none-any.whl.

File metadata

File hashes

Hashes for fixYabinary-0.2.8-py2-none-any.whl
Algorithm Hash digest
SHA256 fc793faa503b6c5cddbca09bef4b918daacfb0c3605455bfd1e30e85adf32085
MD5 c77d4b693b9c213a71f445ac5873bbb7
BLAKE2b-256 463445ff30b25bb6fca0d281b096d9b0f83e11cdf3dd1f44b0b577a4c07a0c5a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page