Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hidden BBCode messages

Name: Anonymous 2013-03-04 13:35

[o][/o]=0
[i][/i]=1
check page source

also read this:
http://en.wikipedia.org/wiki/Steganography

Name: () !!Ai4A74t6Ig2AEJF 2013-03-05 15:25

>>36
But then I might get RCE'd by moot: http://blog.volema.com/curl-rce.html
Force of habit, more than anything. I'll keep it in mind.
>>35
Thanks.

Here, I've made the code a bit more EXPERT. Better flow, took out some superfluous stuff.


[#]
#include <stdio.h>
#include <string.h>

#define INMATCH -10
#define BROKEN -20

typedef struct {
    char **table;
    int n; // number of entries
    int s; // byte slices per entry
    int m; // shift factor
} scheme;

int get_match(scheme *entry, char c){

    static int pos = 0;
    static char alive[255] = {0};
    const static char dead[255] = {0};

    char **needles = entry->table;
    int n = entry->n;

    int match = -1;

    for (int i = 0; i < n; ++i){
        if (pos == 0)
            alive[i] = (needles[i][pos] == c);
        else if (alive[i]){
            alive[i] = (needles[i][pos] == c);
            if (alive[i] && needles[i][pos+1] == '\0'){
                match = i;
                break;
            }
        }
    }

    if (memcmp(alive, dead, 255) == 0){
        pos = 0;
        return BROKEN;
    }
    else if (match != -1){
        memset(alive, 0x00, 255);
        pos = 0;
        return match;
    }
    else {
        ++pos;
        return INMATCH;
    }

}

void parse_hidden(scheme *prog, int v, FILE *file, FILE *fout){

#define GETINPUT(z) (z = fgetc(file))

    char parts[1024*16];

    int c = 1, t = BROKEN, b = 0, h = 0;

    do {

        t = get_match(prog, GETINPUT(c));

        if (t == BROKEN){
            if (b != 0 && h != 0){
                int n, o, m, s;

                o = (h > 1) ? 0 : 1;

                n = prog[o].n;
                s = prog[o].s;
                m = prog[o].m;

                if (b >= s){
                fprintf(fout, "\n+----------------- - - -\n|    \n|    ");
                    for (int i = 0, x = 0; i < b; x = 0){
                        for (o = s-1; o >= 0; x = (parts[i++] << (o--*m)) | x);
                        if ((x >= 32 && x <= 126) || x == '\n' || x == '\r')
                            if (fputc(x, fout) == '\n')
                                fprintf(fout, "|    ");
                    }
                }
            }
           
            b = 0;
            h = 0;

            do t = get_match(prog, GETINPUT(c)); while (t == BROKEN && c != EOF);
        }

        while (t == INMATCH)
            t = get_match(prog, GETINPUT(c));

        if (c == EOF) break;
        if (t == BROKEN) continue;

        parts[b++] = t;
        if (t > h) h = t;

    } while (c != EOF);

#undef GETINPUT

    fprintf(fout, "\n+----------------- - - -\n\n");
}

int main(int argc, char **argv){

    char *tableu4[] = {
        "<span class=\"o\"></span>",
        "<i></i>",
        "<b></b>",
        "<u></u>"
    };

    scheme prog[2] =    {
        {
            .table = tableu4,
            .n = 4,
            .s = 4,
            .m = 2
        },
        {
            .table = tableu4,
            .n = 2,
            .s = 8,
            .m = 1
        }
    };

    parse_hidden(prog, 2, stdin, stdout);

    return 0;
}
[/#]


Proper indentation now since I'm at home and not using the crap at work. Works a little better now, too.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List