コード例 #1
0
ファイル: interrupt.c プロジェクト: davidecarson/vmxos
void exception_handler_err(unsigned int code, unsigned int err)
{
	puts("\n"); puts(exceptions[code]); puts(" -> error code: "); puts(bin2string(err));
	switch(code)
	{
		case 14: // page fault
			puts("\nCR2   : "); puts(hex2string(vmx_read_cr2())); puts(" = "); puts(bin2string(vmx_read_cr2())); puts("\n");
			break;
	}
	hlt();
}
コード例 #2
0
ファイル: bruteforce.c プロジェクト: BramV/MD5-hash-checker
int main(int argc, char ** argv)
{
	if(argc < 2) {
		printf("Usage: %s <salt> <hash>\n", argv[0]);
		return 1;
	}
	
	unsigned char hash[17];
	if (strlen(argv[2]) == 16 * 2) {
		hex2string(argv[2], hash);
	} else if (strlen(argv[2]) == 16) {
		memcpy(hash, argv[2], strlen(argv[2]) * sizeof(char));
	}
	
	char buff[strlen(argv[1]) + MAX_LENGTH + 1];
	char * const end = buff + MAX_LENGTH * sizeof(char);
	
	memcpy(end, argv[1], strlen(argv[1]) * sizeof(char));
	*(end + strlen(argv[1]) * sizeof(char)) = '\0';
	
	char * iter;
	for (iter = buff; iter < end; iter += sizeof(char)) {
		*(iter) = '\0';
	}
	
	int count;
	for (count = MIN_LENGTH; count < MAX_LENGTH; count++) {
		pid_t pID = fork();
		if(pID == 0){
			if (findText(end - count * sizeof(char), count, hash)) {
				printf("Match found: %s\n", end - count * sizeof(char));
				*end = '\0';
				printf("Matching string: %s\n", end - count * sizeof(char));
				return 0;
			} else {
				printf("Tried all passwords with length %d.\n", count);
				return 1;
			}
		}
	}
	
	for(count = MIN_LENGTH; count < MAX_LENGTH; count++){
		wait(NULL);
		printf("process finished\n");
	}

	return 2;
}
コード例 #3
0
ファイル: dict.c プロジェクト: BramV/MD5-hash-checker
int main(int argc, char ** argv)
{
	if(argc < 3 || argv[3] == NULL) {
		printf("Usage: %s [-i] <salt> <hash> <filename> [filename...]\n", argv[0]);
		return 1;
	}

	bool caseSensitive;
	int argOffset;
	if (!strcmp(argv[1], "-i")) {
		caseSensitive = true;
		argOffset = 1;
		if (argc < 4 || argv[4] == NULL) {
			printf("Usage: %s [-i] <salt> <hash> <filename> [filename...]\n", argv[0]);
			return 1;
		}
		printf("Running case insensitive check...");
	} else {
		caseSensitive = false;
		argOffset = 0;
	}

	unsigned char hash[17];
	if (strlen(argv[2 + argOffset]) == 16 * 2) {
		hex2string(argv[2 + argOffset], hash);
	} else if (strlen(argv[2 + argOffset]) == 16) {
		memcpy(hash, argv[2 + argOffset], strlen(argv[2 + argOffset]) * sizeof(char));
	} else {
		printf("Invalid hash\n");
		return 4;
	}
	
	int count;
	int retVal;
	for (count = argOffset + 3; count < argc; count++) {
		if (argv[count] == NULL) continue;
		printf("Checking dictionary %s\n", argv[count]);
		if (checkFile(argv[count], hash, argv[1 + argOffset], caseSensitive, &retVal)) {
			return 0;
		} else if (retVal != 0) {
			return retVal;
		}
	}
	return 0;
}
コード例 #4
0
ファイル: fckernel.c プロジェクト: jur/smp86xx
static int fip_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)
{
	int i;
	unsigned long cnt;
	const char *ptr = buffer, *end = buffer + count;

	memset(fip_keys, 0, INPUT_TABLE_SIZE);
	fip_key_cnt = 0;

	/* Parse the values */
	for (cnt = i = 0; (i < INPUT_TABLE_SIZE/sizeof(unsigned long)) && (cnt < count); i++) {
		for (; (!isdigit(*ptr)) && (ptr < end); ptr++);  /* skip leading unwanted stuff */
		if (ptr >= end)
			break; /* no more */
		else if ((*ptr == '0') && (__toupper(*(ptr + 1)) == 'X')) 
			ptr = hex2string(&fip_keys[i], ptr + 2);
		else
			ptr = dec2string(&fip_keys[i], ptr);
	}
	fip_key_cnt = i;
	return(count);
}
コード例 #5
0
{
	int retry;
	uint8_t buf[LED_I2C_WRITE_BLOCK_SIZE];
	int i;
	struct lp5521_chip *cdata;
	struct i2c_msg msg[] = {
		{
			.addr = client->addr,
			.flags = 0,
			.len = length + 1,
			.buf = buf,
		}
	};

	dev_dbg(&client->dev, "W [%02X] = %s\n",
			addr, hex2string(data, length));

	cdata = i2c_get_clientdata(client);
	if (length + 1 > LED_I2C_WRITE_BLOCK_SIZE) {
		dev_err(&client->dev, "[LED] i2c_write_block length too long\n");
		return -E2BIG;
	}

	buf[0] = addr;
	for (i = 0; i < length; i++)
		buf[i+1] = data[i];

	mutex_lock(&cdata->led_i2c_rw_mutex);
	hr_msleep(1);
	for (retry = 0; retry < I2C_WRITE_RETRY_TIMES; retry++) {
		if (i2c_transfer(client->adapter, msg, 1) == 1)
コード例 #6
0
int main(int argc, char **argv)
{
    unsigned char *gcm_ivkey, *gcm_ct, *gcm_pt;
    int outlen, rv = 0, final_outlen, decrypt = 1;
    size_t read, actual_size = 0, total_size = INITIAL_BUFFER_SIZE;

    if (argc < 2) {
        fprintf(stderr, "Usage: %s <key> [enc]\n", argv[0]);
        return 1;
    }

    // this means we want to encrypt, not decrypt
    if (argc > 2 && strcmp("enc", argv[2]) == 0)
        decrypt = 0;

    unsigned int byte_length = hex2string(argv[1], &gcm_ivkey);
    unsigned int iv_length;
    if(byte_length == 48) {
        iv_length = 16;
    } else if(byte_length == 44) {
        iv_length = 12;
    } else {
        fprintf(stderr, "Invalid key length %d only 44 or 48 bytes supported\n", byte_length);
        return 1;
    }

    gcm_ct = malloc(total_size);

    while ((read = fread(gcm_ct + actual_size, 1, BYTES_PER_READ, stdin)) > 0) {
        actual_size += read;
        if ((actual_size + BYTES_PER_READ) > total_size) {
            total_size = total_size * 1.5;
            gcm_ct = realloc(gcm_ct,total_size);
        }
    }

    if (actual_size < (decrypt ? 17 : 1)) {
        fprintf(stderr, "File too small for %scryption\n", decrypt ? "de" : "en");
        return 1;
    }

    if(decrypt)
        actual_size -= TAG_LENGTH;

    gcm_pt = malloc(decrypt ? actual_size : (actual_size + TAG_LENGTH));

    EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();

    /* Select cipher */
    if(decrypt)
        EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
    else
        EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);

    /* Set IV length, omit for 96 bits */
    EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, iv_length, NULL);

    if(decrypt) {
        /* Specify key and IV */
        EVP_DecryptInit_ex(ctx, NULL, NULL, gcm_ivkey + iv_length, gcm_ivkey);

        /* Set expected tag value. */
        EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, TAG_LENGTH, gcm_ct + actual_size);

        /* Decrypt plaintext */
        EVP_DecryptUpdate(ctx, gcm_pt, &outlen, gcm_ct, actual_size);

        /* Finalise: note get no output for GCM */
        rv = EVP_DecryptFinal_ex(ctx, gcm_pt, &final_outlen);
    } else {
        /* Specify key and IV */
        EVP_EncryptInit_ex(ctx, NULL, NULL, gcm_ivkey + iv_length, gcm_ivkey);

        /* Encrypt plaintext */
        EVP_EncryptUpdate(ctx, gcm_pt, &outlen, gcm_ct, actual_size);

        /* Finalise: note get no output for GCM */
        rv = EVP_EncryptFinal_ex(ctx, gcm_pt, &final_outlen);

        /* Get expected tag value. */
        EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, TAG_LENGTH, gcm_pt + actual_size);
    }

    EVP_CIPHER_CTX_free(ctx);
    free(gcm_ivkey);
    free(gcm_ct);

    if (rv > 0) {
        // success!
        fwrite(gcm_pt, 1, decrypt ? outlen : (outlen + TAG_LENGTH), stdout);
        free(gcm_pt);
        return 0;
    } else {
        fprintf(stderr, "File integrity check failed\n");
        free(gcm_pt);
        return 1;
    }
}
コード例 #7
0
ファイル: interrupt.c プロジェクト: davidecarson/vmxos
void syscall_handler(unsigned int code)
{
	puts("\nsyscall "); puts(hex2string(code));
}