Esempio n. 1
0
int add_message(POCSAG_tx *p_tx,uint32_t capcode,uint32_t func,uint8_t *msg, int isNum ) {
	int frame,cw_bit;
	int i;
	uint32_t cw_capcode,cw_mask;
	POCSAG_batch *cur_btch;

	frame = ((capcode & 7) * 2)+1;
	cw_capcode = capcode >> 3;
	cw_capcode <<= 13;
	func &= 3;
	cw_capcode |= func << 11;
	cw_capcode &= 0x7FFFF800;
	cw_capcode=make_csum(cw_capcode);
	cur_btch = p_tx->last;
	cur_btch->data[frame]=cw_capcode;

	frame++;
	cur_btch->data[frame] = 0x80000000;
	if (isNum) cur_btch->data[frame] |= (0x33333 << 11);
	cw_mask = 0x40000000;
	cw_bit = 0;

	for (i = 0; msg[i]; i++) {
		uint8_t mask;
		uint8_t sym = msg[i];
		if (isNum) {
			if (sym >= '0' && sym <= '9') {
				sym -= '0';
			} else {
				switch (sym) {
				case 'U': sym = 0xB; break;
				case ' ': sym = 0xC; break;
				case '-': sym = 0xD; break;
				case ')': sym = 0xE; break;
				case '(': sym = 0xF; break;
				default: continue;
				}
			}
		} else {
			sym &= 0x7F;
		}
		for (mask = 1; mask != (isNum ? 0x10 : 0x80); mask <<= 1) {
			if (cw_bit == 20) {
				cur_btch->data[frame] = make_csum(cur_btch->data[frame]);
				if (++frame == sizeof(cur_btch->data) / sizeof(cur_btch->data[0])) {
					POCSAG_batch *new_btch = create_batch();
					if (new_btch == NULL) return (-1);
					p_tx->last = cur_btch->next = new_btch;
					cur_btch = new_btch;
					frame = 1;
				}
				cur_btch->data[frame] = 0x80000000;
				if (isNum) cur_btch->data[frame] |= (0x33333 << 11);
				cw_mask = 0x40000000;
				cw_bit = 0;
			}

			if (sym & mask) {
				cur_btch->data[frame] |= cw_mask;
			} else {
				cur_btch->data[frame] &= ~cw_mask;
			}
			cw_mask >>= 1;
			cw_bit++;
		}
	}
	if( cw_bit ) cur_btch->data[frame] = make_csum(cur_btch->data[frame]);
	cur_btch->next = p_tx->last = create_batch();

	return 0;
}
Esempio n. 2
0
PUBLIC int new_crack(int format_index, int key_prov_index, int min_lenght, int max_lenght, char* provider_param, callback_funtion psend_message_gui, int use_rules)
{
	sqlite3_stmt* insert_new_atack;
	sqlite3_stmt* insert_batch_attack;
	int i;

	// TODO: Parch--> revisit to make well
	if(key_prov_index == WORDLIST_INDEX && provider_param == NULL)
		return FALSE;

	// Rules support
	if(format_index != LM_INDEX && use_rules)
	{
		if(!add_rules_to_param(provider_param, key_prov_index))
			return FALSE;// No rules
		key_prov_index = RULES_INDEX;
	}

	create_batch(format_index, key_prov_index, min_lenght, max_lenght, provider_param);

	// Save attackdata to db
	if(!is_benchmark)
	{
		sqlite3_prepare_v2(db, "INSERT INTO Attack (Provider,Format,Param,MinLenght,MaxLenght,ResumeArg) VALUES (?,?,?,?,?,?);", -1, &insert_new_atack, NULL);
		sqlite3_prepare_v2(db, "INSERT INTO BatchAttack (BatchID,AttackID) VALUES (?,?);", -1, &insert_batch_attack, NULL);
		for(i = 0; i < num_attack_in_batch; i++)
		{
			batch[i].is_ended = FALSE;
			batch[i].secs_before_this_attack = 0;

			sqlite3_reset(insert_new_atack);
			sqlite3_bind_int64(insert_new_atack, 1, key_providers[batch[i].provider_index].db_id);
			sqlite3_bind_int64(insert_new_atack, 2, formats[batch[i].format_index].db_id);
			sqlite3_bind_text (insert_new_atack, 3, batch[i].params, -1, SQLITE_STATIC);
			sqlite3_bind_int  (insert_new_atack, 4, batch[i].min_lenght);
			sqlite3_bind_int  (insert_new_atack, 5, batch[i].max_lenght);

			key_providers[batch[i].provider_index].resume(batch[i].min_lenght, batch[i].max_lenght, batch[i].params, batch[i].resume_arg, batch[i].format_index);
			batch[i].key_space = num_key_space;
			key_providers[batch[i].provider_index].save_resume_arg(batch[i].resume_arg);
			key_providers[batch[i].provider_index].finish();
			sqlite3_bind_text(insert_new_atack, 6, batch[i].resume_arg, -1, SQLITE_STATIC);

			sqlite3_step(insert_new_atack);
			batch[i].attack_db_id = sqlite3_last_insert_rowid(db);

			// Batch
			sqlite3_reset(insert_batch_attack);
			sqlite3_bind_int64(insert_batch_attack, 1, batch_db_id);
			sqlite3_bind_int64(insert_batch_attack, 2, batch[i].attack_db_id);
			sqlite3_step(insert_batch_attack);
		}
		sqlite3_finalize(insert_new_atack);
		sqlite3_finalize(insert_batch_attack);
	}
	else
	{
		for(i = 0; i < num_attack_in_batch; i++)
		{
			batch[i].is_ended = FALSE;
			batch[i].secs_before_this_attack = 0;

			key_providers[batch[i].provider_index].resume(batch[i].min_lenght, batch[i].max_lenght, batch[i].params, batch[i].resume_arg, batch[i].format_index);
			batch[i].key_space = num_key_space;
			key_providers[batch[i].provider_index].save_resume_arg(batch[i].resume_arg);
			key_providers[batch[i].provider_index].finish();
		}
	}

	//num_keys_served_from_start = 0;
	//num_keys_served_from_save = 0;
	set_num_keys_zero();
	
	void* set_start_time = (void*)TRUE;
	send_message_gui = psend_message_gui;
	HS_NEW_THREAD(begin_crack, set_start_time);

	return TRUE;
}