What format are .tox files stored in?

401 views Asked by At

Specifically, I am looking for a way to start working up some Python 3 or Elixir code open and access the tox_save.tox file for the Tox network client μTox.

Once I figure out how to get pip install pysqlite going on my virtual environment, I'll try poking around at it with that. In the mean time, though, I am hoping someone will respond here or on Github.

My other guess is that it's a plain old C array stored in binary format.

It looks like tox_save.tox could be an encrypted sqlite file.

Before I bust out the ol' hex editor, does anyone know the format for sure?

1

There are 1 answers

0
Mihhail On

It's binary format. Basically storing C structure to a file.

Here's python2 example how to work with it:

import struct
#messenger.c
MESSENGER_STATE_TYPE_NOSPAMKEYS = 1
MESSENGER_STATE_TYPE_NAME = 4
MESSENGER_STATE_TYPE_STATUSMESSAGE = 5

def process_chunk(index, state):
    if index + 8 >= len(state):
        return
    length = struct.unpack_from("<H", state, index)[0]
    new_index = index + length + 8
    data_type = struct.unpack_from("<H", state, index + 4)[0]

    if data_type == MESSENGER_STATE_TYPE_NOSPAMKEYS:
        result = str(state[index + 8:index + 8 + length]).encode('hex')
        print("nospam = {}, public_key = {}, private_key = {}".format(result[0:4],
                                                                      result[4:36],
                                                                      result[36:68]))
    if data_type == MESSENGER_STATE_TYPE_NAME:
        print("User name = {}".format(str(state[index + 8:index + 8 + length])))

    if data_type == MESSENGER_STATE_TYPE_STATUSMESSAGE:
        print("Status = {}".format(str(state[index + 8:index + 8 + length])))

    # ... there's much more data
    process_chunk(new_index, state)


tox_save = open('/tmp/tox_save.tox', 'rb').read()
process_chunk(8, tox_save)