Exemplo n.º 1
0
void LPP_PsarDecoder_Init(void)
{
    if(initialized)
    {
        return;
    }

    zzip_init_io(&psar_handlers, 0);
    psar_handlers.fd.open = &psar_open;
    psar_handlers.fd.close = &psar_close;
    psar_handlers.fd.read = &psar_read;
    psar_handlers.fd.seeks = &psar_seek;
    psar_handlers.fd.filesize = &psar_fsize;

    initialized = 1;
}
Exemplo n.º 2
0
int 
main (int argc, char* argv[])
{
    if (argc <= 1 || argc > 3)
    {
        printf (usage);
        exit (0);
    }

    if (strlen(argv[1]) > 128) {
        fprintf(stderr, "Please provide a filename shorter than 128 chars.\n");
        exit(1);
    }

    /* obfuscate the file */
    {
        int ch;
        FILE* fin;
        FILE* fout;
        fin  = fopen(argv[1], "rb");
        if (!fin) {
            fprintf(stderr, "Can't open input file \"%s\"\n", argv[1]);
            exit(1);
        }
        fout = fopen((argc == 2) ? "obfuscated" : "obfuscated.dat", "wb");
        if (!fout) {
            fprintf(stderr, "Can't open output file \"obfuscated\"\n");
            exit(1);
        }
        while ((ch = fgetc(fin)) != EOF) {
            ch ^= 0x55;
            fputc(ch, fout);
        }
        fclose(fout);
        fclose(fin);
    }

    /* install our I/O hander */
    zzip_init_io(&our_handlers, 0);
    our_handlers.read = &our_read;

    {
#       define argn 2
        ZZIP_FILE* fp;
        char name[256];
        if (argc == 3) {
            sprintf(name, "obfuscated/%s", argv[argn]);
        } else {
            sprintf(name, "obfuscated");
        }
        fp = zzip_open_ext_io (name, O_RDONLY|O_BINARY, ZZIP_PREFERZIP,
			       our_fileext, &our_handlers);

        if (! fp)
        {
            perror (name);
            exit(1);
        }else{
            char buf[17];
            int n;

        /* read chunks of 16 bytes into buf and print them to stdout */
            while (0 < (n = zzip_read(fp, buf, 16)))
            {
                buf[n] = '\0';
#             ifdef STDOUT_FILENO
                write (STDOUT_FILENO, buf, n);
#             else
                fwrite (buf, 1, n, stdout);
#             endif
            }

            if (n == -1) 
                perror (argv[argn]);
        }
    }
    
    return 0;
}