library/src/exploitation/WebExploitation/BP-WebExploitationExploitRequestSets.cc
// runs a select query against a given id and checks for
// the current http status of the request.
runs a select query against a given id and checks for
the current http status of the request.
runs a select query against a given id and checks for the current http status of the request .
size_t BP_WebExploitationRequestSetCheckHTTPStatusForDBID(P_BP_MYSQL_SESSION db_handle, size_t db_id)
{
	if(!db_handle)
		return ERR_FAILURE;
	if(!db_handle->system_hreg)
		return ERR_FAILURE;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(db_handle->system_hreg);
	BP_MySQLSemLock(db_handle);
	MYSQL_STMT * stmt = BP_MySQLPrepareQuery(db_handle, "SELECT http_status_code FROM http_request_log WHERE id = ? LIMIT 0,1;");
	if(!stmt)
	{
		printf("\n [+] Could not prepare statement in BP_WebExploitationRequestSetCheckHTTPStatusForDBID.");
		BP_MySQLSemUnlock(db_handle);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	}
	MYSQL_BIND * params = (MYSQL_BIND *) bpcalloc(sizeof(MYSQL_BIND)*4, 1);
	params[0].buffer_type= MYSQL_TYPE_LONG;
	params[0].buffer = (char *) & db_id;
	params[0].is_null= 0;
	params[0].length = 0;
	if(BP_MySQLBindParameters(stmt, params, db_handle) == ERR_FAILURE)
	{
		printf("\n [+] Bind parameters failed in BP_WebExploitationRequestSetCheckHTTPStatusForDBID.");
		BP_MySQLSemUnlock(db_handle);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	}
	if(BP_MySQLExecuteStatement(stmt, db_handle) == ERR_FAILURE)
	{
		printf("\n [+] Statement failed to execute in BP_WebExploitationRequestSetCheckHTTPStatusForDBID.");
		BP_MySQLSemUnlock(db_handle);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	}
	MYSQL_BIND * result = (MYSQL_BIND *) bpcalloc(sizeof(MYSQL_BIND)*2, 1);
	size_t index = 0;
	result[0].buffer_type = MYSQL_TYPE_LONG;
	if(BP_MySQLBindResult(stmt, result, 1, db_handle) == ERR_FAILURE)
	{
		printf("\n [+] Unable to bind parameters in BP_WebExploitationRequestSetCheckHTTPStatusForDBID");
		BP_MySQLSemUnlock(db_handle);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	}
	if(BP_MySQLStoreResults(stmt, db_handle) == ERR_FAILURE)
	{
		printf("\n [+] Unable to store result");
		BP_MySQLSemUnlock(db_handle);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	}
	size_t i;
	size_t *indexr = NULL;
	if(!BP_MySQLFetchResult(stmt, db_handle))
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ERR_FAILURE);
	indexr = (size_t *) result[0].buffer;
	size_t ret_index = *indexr;
	BP_MySQLCloseStatement(stmt, db_handle);
	stmt = NULL;
	if(params)
		bpfree(params);
	if(result)
		bpfree(result);
	BP_MySQLSemUnlock(db_handle);
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(db_handle->system_hreg, ret_index);
}
size_t BP_WebExploitationRequestSetCheckHTTPStatusForDBID ( P_BP_MYSQL_SESSION db_handle , size_t db_id ) { if ( ! db_handle ) return ERR_FAILURE ; if ( ! db_handle -> system_hreg ) return ERR_FAILURE ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( db_handle -> system_hreg ) ; BP_MySQLSemLock ( db_handle ) ; MYSQL_STMT * stmt = BP_MySQLPrepareQuery ( db_handle , " " ) ; if ( ! stmt ) { printf ( " \n " ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; } MYSQL_BIND * params = ( MYSQL_BIND * ) bpcalloc ( sizeof ( MYSQL_BIND ) * 4 , 1 ) ; params [ 0 ] . buffer_type = MYSQL_TYPE_LONG ; params [ 0 ] . buffer = ( char * ) & db_id ; params [ 0 ] . is_null = 0 ; params [ 0 ] . length = 0 ; if ( BP_MySQLBindParameters ( stmt , params , db_handle ) == ERR_FAILURE ) { printf ( " \n " ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; } if ( BP_MySQLExecuteStatement ( stmt , db_handle ) == ERR_FAILURE ) { printf ( " \n " ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; } MYSQL_BIND * result = ( MYSQL_BIND * ) bpcalloc ( sizeof ( MYSQL_BIND ) * 2 , 1 ) ; size_t index = 0 ; result [ 0 ] . buffer_type = MYSQL_TYPE_LONG ; if ( BP_MySQLBindResult ( stmt , result , 1 , db_handle ) == ERR_FAILURE ) { printf ( " \n " ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; } if ( BP_MySQLStoreResults ( stmt , db_handle ) == ERR_FAILURE ) { printf ( " \n " ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; } size_t i ; size_t * indexr = NULL ; if ( ! BP_MySQLFetchResult ( stmt , db_handle ) ) BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ERR_FAILURE ) ; indexr = ( size_t * ) result [ 0 ] . buffer ; size_t ret_index = * indexr ; BP_MySQLCloseStatement ( stmt , db_handle ) ; stmt = NULL ; if ( params ) bpfree ( params ) ; if ( result ) bpfree ( result ) ; BP_MySQLSemUnlock ( db_handle ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( db_handle -> system_hreg , ret_index ) ; }
runs a select query against a given id and checks for
the current http status of the request.
runs a select query against a given id and checks for the current http status of the request .
// ensure we have a handle and a registry // enter critical section // lock the semaphore before attempting any logging capacity (prevents // thread contention issues) // prepare new sql // debug message // unlock table // leave the critical section and return // allocate space for parameters // set index return parameter // bind parameters // display debug message // unlock the handle // leave the critical section and return // execute query // 1 columns // set local variables // index // result[0].buffer      = (char *)&index; // result[0].is_null     = &is_null[0]; // result[0].length      = (unsigned long *) &length[0]; // result[0].error       = &error[0]; // bind results // attempt to fetch result // destroy statement // destroy if necessary // unlock // return the found index