Random Noise

cat /dev/random >> /dev/dsp

Extract SquashFS from TRX file

leave a comment »

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

#define trx_magic 0x30524448 /* "hdr0" */
#define trx_max_len 0x720000
#define trx_no_header 1 /* do not write trx header */

typedef struct {
    uint32_t magic; /* "hdr0" */
    uint32_t len; /* length of file including header */
    uint32_t crc32; /* 32-bit crc from flag_version to end of file */
    uint32_t flag_version; /* 0:15 flags, 16:31 version */
    uint32_t offsets[4]; /* offsets of partitions from start of header */
} trx_header;

trx_header *readtrx(char* file_path)
    FILE *file = fopen(file_path, "rb");

    trx_header *p = malloc(sizeof(trx_header));

    if (file != NULL)
        fread(p, sizeof(trx_header), 1, file);

    return p;

int main(int argc, char **argv)

    if(argc != 2)
        printf("usage: parse_trx <trx filename>\n\n");
        return 0;

    trx_header *p = readtrx(argv[1]);

    printf("flags:\t\t\t\t%d\n",p->flag_version & 0xff);
    printf("version:\t\t\t%d\n",(p->flag_version >> 16));
    printf("lzma loader offset:\t0x%08x\n",p->offsets[0]);
    printf("kernel offset:\t\t0x%08x\n",p->offsets[1]);
    printf("rootfs offset:\t\t0x%08x\n",p->offsets[2]);
    printf("bin header offset:\t0x%08x\n",p->offsets[3]);
    printf("run commands below to extract squashfs from trx");
    printf("dd if=%s skip=%d ibs=1 count=%d of=hsqs\n\n", argv[1], p->offsets[1], (p->len - p->offsets[1]));

    printf("sudo unsquashfs hsqs\n");

    return 0;



Written by Vivek Unune

March 11, 2017 at 9:35 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: