コード例 #1
0
void commandLoop(RainbowTable_t * rainbowTable, char * password) {
	char line[MAX_LINE_LEN] = {0};
	byte_t hash[MAX_LINE_LEN] = {0}; /* The hash is never longer than its string representation */
	uint_t hashLen = 0;		

	/* Treat the user's submitted requests until told to quit */
	for(;;) {
		bool_t found = FALSE;

		if (!readPrompt(line) || (0 == strcmp(line, "quit"))) {
			return;
		}

		hashLen = (uint_t) hexa2binary(line, hash, sizeof(hash));
		if (-1 == hashLen) {
			fprintf(stderr, "Non hexa\n");
			continue;
		}
		
		if (!queryExaustiveTable(rainbowTable, hash, hashLen, &found)) {
			/* An error has occured and a message has already been printed */
			return;
		}
		if (found) {
			printf("Try to login with password \"%s\"\n", password);
		} else {
			printf("Sorry but this hash doesn't appears in pre-processing\n");
		}
	}
}
コード例 #2
0
ファイル: exhaustive_query.c プロジェクト: KWMalik/tau
/*
 * read a line from the user and handle the command (either a hash or "quit")
 */
static void user_input_loop(DEHT * deht, unsigned int digest_size)
{
	char line[MAX_INPUT_BUFFER];
	unsigned char digest[MAX_DIGEST_LENGTH_IN_BYTES];
	char * cmd, * rcmd;

	while (1) {
		printf(">> ");
		if (fgets(line, sizeof(line)-1, stdin) == NULL) {
			break; /* EOF */
		}
		cmd = line;
		/* remove leading whitespace */
		while (*cmd == ' ' || *cmd == '\t') {
			cmd++;
		}
		/* remove trailing whitespace */
		for (rcmd = cmd + strlen(cmd) - 1; *rcmd == ' ' || *rcmd == '\t' ||*rcmd == '\n'; rcmd--) {
			*rcmd = '\0';
		}
		if (*cmd == '\0') {
			continue; /* empty line */
		}
		if (strcasecmp(cmd, "quit") == 0) {
			break; /* quit cleanly */
		}
		if (hexa2binary(cmd, digest, digest_size) < 0) {
			if (strlen(cmd) > digest_size) {
				printf("Too long\n");
			}
			else {
				printf("Non hexa\n");
			}
			continue;
		}
		find_password_for_digest(deht, digest, digest_size);
	}
}