Esempio n. 1
0
int main(int argc, char *argv[]) {
    struct List *module_list = NULL;
    struct List *file_suffix_list = NULL;
    char path[PATH_MAX_LEN];

    SPC_INIT();

    if(argc != 2) {
        SPC_MSG(LOGERR, "argument count error");
        usage();
        SPC_FREE();
        exit(EXIT_FAILURE);
    }
    memset(path, 0x00, PATH_MAX_LEN);
    strcpy(path, argv[1]);
    SPC_MSG(LOGDBG, argv[1]);

    if(FT_DIR == file_or_dir(path)) {
        traverse(path, module_list, file_suffix_list);
    } else if(FT_FILE == file_or_dir(path)){
        file_process(path, module_list);
    }

    SPC_FREE();
    return 0;
}
Esempio n. 2
0
int
break_outguess(struct ogobj *og, struct arc4_stream *as, iterator *it,
    char **pbuf, int *pbuflen)
{
	u_char state[4];
	static u_char buf[512];
	struct arc4_stream tas = *as;
	int length, seed, need;
	int bits, i, n;

	state[0] = steg_retrbyte(og->coeff, 8, it) ^ arc4_getbyte(as);
	state[1] = steg_retrbyte(og->coeff, 8, it) ^ arc4_getbyte(as);
	state[2] = steg_retrbyte(og->coeff, 8, it) ^ arc4_getbyte(as);
	state[3] = steg_retrbyte(og->coeff, 8, it) ^ arc4_getbyte(as);

	seed = (state[1] << 8) | state[0];
	length = (state[3] << 8) | state[2];

	if (seed > max_seed || length * 8 >= og->bits/2 || length < min_len)
		return (0);

	iterator_seed(it, seed);

	bits = MIN(og->bits, sizeof(og->coeff) * 8);

	n = 0;
	while (iterator_current(it) < bits && length > 0 && n < sizeof(buf)) {
		iterator_adapt(it, og->bits, length);
		buf[n++] = steg_retrbyte(og->coeff, 8, it);
		length--;
	}

	/* For testing the randomness, we need some extra information */
	need = MIN(min_len, sizeof(buf));
	if (n < need || !is_random(buf, n))
		return (0);

	/* Plaintext tests? */
	for (i = 0; i < n; i++)
		buf[i] ^= arc4_getbyte(&tas);

	if (file_process(buf, n) == 0)
		return (0);

	*pbuf = buf;
	*pbuflen = n;

	return (1);
}
Esempio n. 3
0
int
crack_outguess(char *filename, char *word, void *obj)
{
	static u_char oword[57];	/* version 3 marker */
	static int init;
	static struct arc4_stream as;
	static iterator it;
	char *buf;
	int buflen;
	
	struct arc4_stream tas;
	iterator tit;
	struct ogobj *ogob = obj;
	int changed = 0;

	if (strcmp(word, oword)) {
		strlcpy(oword, word, sizeof(oword));
		changed = 1;
		init = 0;
	}

	if (!init || changed) {
		arc4_initkey(&as, word, strlen(word));
		iterator_init(&it, &as);
		init = 1;
	}

	tas = as;
	tit = it;
	if (break_outguess(ogob, &tas, &tit, &buf, &buflen)) {
		int i;
		extern int noprint;
		fprintf(stdout, "%s : outguess[v0.13b](%s)[",
			filename, word);
		noprint = 0;
		file_process(buf, buflen);
		noprint = 1;
		fprintf(stdout, "][");
		for (i = 0; i < 16; i++)
			fprintf(stdout, "%c",
			    isprint(buf[i]) ? buf[i] : '.');
		fprintf(stdout, "]\n");
		return (1);
	}

	return (0);
}
Esempio n. 4
0
int main(int argc, char* argv[]) {
	int opt_scale_x = 2;
	int opt_scale_y = 2;
	int opt_crc = 0;
	int c;

	opterr = 0;

	while ((c =
#ifdef HAVE_GETOPT_LONG
		getopt_long(argc, argv, OPTIONS, long_options, 0))
#else
		getopt(argc, argv, OPTIONS))
#endif
	!= EOF) {
		switch (c) {
			case 'h' :
				usage();
				exit(EXIT_SUCCESS);
			case 'v' :
				version();
				exit(EXIT_SUCCESS);
			case 'k' :
				if (strcmp(optarg, "2") == 0) {
					opt_scale_x = 2;
					opt_scale_y = 2;
				} else if (strcmp(optarg, "3") == 0) {
					opt_scale_x = 3;
					opt_scale_y = 3;
				} else if (strcmp(optarg, "4") == 0) {
					opt_scale_x = 4;
					opt_scale_y = 4;
				} else {
					if (sscanf(optarg, "%dx%d", &opt_scale_x, &opt_scale_y) != 2
						|| opt_scale_x < 1
						|| opt_scale_y < 1
					) {
						printf("Invalid -k option. Valid values are 2, 2x3, 2x4, 3 and 4.\n");
						exit(EXIT_FAILURE);
					}
				}
				break;
			case 'c' :
				opt_crc = 1;
				break;
			default:
				printf("Unknown option `%c'.\n", (char)optopt);
				exit(EXIT_FAILURE);
		} 
	}

	if (optind + 2 != argc) {
		usage();
		exit(EXIT_FAILURE);
	}

	if (file_process(argv[optind], argv[optind+1], opt_scale_x, opt_scale_y, opt_crc) != 0) {
		exit(EXIT_FAILURE);
	}

	return EXIT_SUCCESS;
}
Esempio n. 5
0
int traverse(const char *path, struct List *module_list,
        struct List *file_suffix_list) {

    struct dirent *entry;
    DIR *dirp;
    char current_path[PATH_MAX_LEN];
    struct Stack *stk;
    struct Element *elem;

    memset(current_path, 0x00, PATH_MAX_LEN);
    stk = SPCStack_init();

    if( NULL == (dirp = opendir(path))) {
        SPC_MSG(LOGERR, path);
        SPC_MSG(LOGERR, strerror(errno));
        exit(EXIT_FAILURE);
    }

    elem = SPCStack_new_elem(path, dirp);
    SPCStack_push(stk, elem);

    if(chdir(path) < 0) {
        SPC_MSG(LOGERR, "DIR CHANGE ERROR");
        exit(EXIT_FAILURE);
    }

    while(stk->size != 0) {
        entry = readdir(dirp);
        if(entry == NULL) {
            SPCStack_pop(stk, elem);
            chdir("..");
            closedir(dirp);
            if(stk->tail == NULL) {
                break;
            }
            elem = stk->tail;
            dirp = elem->dirp;
            continue;
        }
        if( 0 == strcmp(entry->d_name,".")
            || (0 == strcmp(entry->d_name,".."))) {
            continue;
        }

        if(FT_DIR == file_or_dir(entry->d_name)) {
            if( NULL == (dirp = opendir(entry->d_name))) {
                SPC_MSG(LOGERR, path);
                SPC_MSG(LOGERR, strerror(errno));
                exit(EXIT_FAILURE);
            }

            elem = SPCStack_new_elem(entry->d_name,dirp);
            SPCStack_push(stk, elem);
            chdir(entry->d_name);
        }else if(FT_FILE == file_or_dir(entry->d_name)) {
            memset(current_path, 0x00, PATH_MAX_LEN);
            SPCStack_get_path(stk, current_path);
            strcat(current_path,"/");
            strcat(current_path,entry->d_name);
            file_process(current_path, module_list);
        }
    }

    return 0;
}