library/src/blockclass/BP-BlockClass.cc
// Loads XSS checks from a newline delimited file.
Loads XSS checks from a newline delimited file.
Loads XSS checks from a newline delimited file .
int Block::LoadXSSChecksFromFile(char *xss_file)
{
	if(!this->webAssessment)
		return ERR_FAILURE;
	if(this->webAssessment->xssChecks)
	{
		BP_DestroyXSSTests(this->webAssessment->xssChecks, this->webAssessment->xssChecksCount);
		this->webAssessment->xssChecks = NULL;
	}
	Block * file_data = new Block();
	file_data->FileGetContents(xss_file);
	if(!file_data->got_contents_size)
	{
		this->AddErrorToStack((char*) "Error in LoadXSSChecksFromFile(): No data in file. (NULL)");
		return ERR_FAILURE;
	}
	if(!strnlen(file_data->got_contents, 2048))
	{
		this->AddErrorToStack((char*) "Error in LoadXSSChecksFromFile(): No data in file.");
		return ERR_FAILURE;
	}
	BP_StringUtils * exploder = new BP_StringUtils(file_data->got_contents);
	exploder->Explode("\n");
	P_BP_WEB_XSS_TEST elements = (P_BP_WEB_XSS_TEST) bpcalloc(sizeof(BP_WEB_XSS_TEST) * (exploder->exploded_count+1) , 1);
	size_t i = 0;
	for(; i < exploder->exploded_count-1; i++)
	{
		elements[i].testFront = bpstrndup(exploder->exploded[i], 2048);
		elements[i].testTail = bpstrdup(" ");
		elements[i].type = BP_WEB_EXPLOIT_TYPE_XSS;
		elements[i].attackLevel = BP_XSS_ATTACK_UNSAFE;
		elements[i].policy = BP_XSS_NONE;
	}
	if(this->webAssessment)
	{
		this->webAssessment->xssChecks      = elements;
		this->webAssessment->xssChecksCount = i;
	}
	if(file_data->file)
		file_data->File_Close();
	delete file_data;
	delete exploder;
	return ERR_SUCCESS;
}
int Block :: LoadXSSChecksFromFile ( char * xss_file ) { if ( ! this -> webAssessment ) return ERR_FAILURE ; if ( this -> webAssessment -> xssChecks ) { BP_DestroyXSSTests ( this -> webAssessment -> xssChecks , this -> webAssessment -> xssChecksCount ) ; this -> webAssessment -> xssChecks = NULL ; } Block * file_data = new Block ( ) ; file_data -> FileGetContents ( xss_file ) ; if ( ! file_data -> got_contents_size ) { this -> AddErrorToStack ( ( char * ) " " ) ; return ERR_FAILURE ; } if ( ! strnlen ( file_data -> got_contents , 2048 ) ) { this -> AddErrorToStack ( ( char * ) " " ) ; return ERR_FAILURE ; } BP_StringUtils * exploder = new BP_StringUtils ( file_data -> got_contents ) ; exploder -> Explode ( " \n " ) ; P_BP_WEB_XSS_TEST elements = ( P_BP_WEB_XSS_TEST ) bpcalloc ( sizeof ( BP_WEB_XSS_TEST ) * ( exploder -> exploded_count + 1 ) , 1 ) ; size_t i = 0 ; for ( ; i < exploder -> exploded_count - 1 ; i ++ ) { elements [ i ] . testFront = bpstrndup ( exploder -> exploded [ i ] , 2048 ) ; elements [ i ] . testTail = bpstrdup ( " " ) ; elements [ i ] . type = BP_WEB_EXPLOIT_TYPE_XSS ; elements [ i ] . attackLevel = BP_XSS_ATTACK_UNSAFE ; elements [ i ] . policy = BP_XSS_NONE ; } if ( this -> webAssessment ) { this -> webAssessment -> xssChecks = elements ; this -> webAssessment -> xssChecksCount = i ; } if ( file_data -> file ) file_data -> File_Close ( ) ; delete file_data ; delete exploder ; return ERR_SUCCESS ; }
Loads XSS checks from a newline delimited file.
Loads XSS checks from a newline delimited file .
// destroy xss checks if they already exist // printf("\n Destroying here?: %p, %u", this->webAssessment->xssChecks, this->webAssessment->xssChecksCount); // retrieve file contents // retrieve file contents // check to make sure we got content // str utils class for exploding data // explode along newlines // allocate space for elements // walk the exploded item list and add checks here // static test front // static test end (space, can't be null) // set the type to sqlinjection // set level to unsafe // change policy to NO POLICY // close file // destroy file data object // destroy exploder object // return indicating success