library/src/buffer_analysis/ASCII/BP-BufferAnalysisASCII.cc
// display an ascii string structure (found within buff analysis)
display an ascii string structure (found within buff analysis)
display an ascii string structure ( found within buff analysis )
BP_ERROR_T BP_DisplayBufferAnalysisASCIIString(P_BP_BUFFER_ANALYSIS_ASCII_STRINGS buff_string, BP_BOOL display_string_data)
{
	if(!buff_string)
		return ERR_FAILURE;
	if(buff_string->marked_as_restricted == BP_TRUE)
		return ERR_FAILURE;
	printf("\n\t [+] Analyzed String (%p)", buff_string);
	printf("\n\t     position in analyzed buffer:  %zu", buff_string->position_in_analyzed_buffer);
	printf("\n\t     string length:                %zu", buff_string->string_length);
	printf("\n\t     address of string in buffer:  %p",  buff_string->address_of_string_in_buffer);
	printf("\n\t     match_flags_enabled:          %s",  buff_string->match_flags_enabled ? "yes" : "no");
	if(buff_string->restricted_characters)
	{
		printf("\n\t     restricted_characters:        %p",  buff_string->restricted_characters);
		printf("\n\t     restricted_characters_n:      %u",  buff_string->restricted_characters_n);
	}
	if(buff_string->string_terminator)
	{
		printf("\n\t     string_terminator:            %p",  buff_string->string_terminator);
		printf("\n\t     string_terminator_length:     %u",  buff_string->string_terminator_length);
	}
	BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS empty_flags;
	BP_ZERO_STACK(empty_flags);
	if(memcmp(&empty_flags, &buff_string->string_flags, sizeof(empty_flags)) != 0)
	{
		if(buff_string->string_flags.is_unix_file_path)
			printf("\n\t     flags.is_unix_file_path");
		if(buff_string->string_flags.is_url)
			printf("\n\t     flags.is_url");
		if(buff_string->string_flags.is_host_url)
			printf("\n\t     flags.is_host_url");
		if(buff_string->string_flags.is_base_url)
			printf("\n\t     flags.is_base_url");
		if(buff_string->string_flags.is_script_url)
			printf("\n\t     flags.is_script_url");
		if(buff_string->string_flags.is_path_url)
			printf("\n\t     flags.is_path_url");
		if(buff_string->string_flags.is_dynamic_so)
			printf("\n\t     flags.is_dynamic_so");
		if(buff_string->string_flags.exists_as_file_on_filesystem)
			printf("\n\t     flags.exists_as_file_on_filesystem");
		if(buff_string->string_flags.exists_as_file_on_filesystem_and_is_readable)
			printf("\n\t     flags.exists_as_file_on_filesystem_and_is_readable");
		if(buff_string->string_flags.exists_as_file_on_filesystem_and_is_writable)
			printf("\n\t     flags.exists_as_file_on_filesystem_and_is_writable");
	}
	if(display_string_data == BP_TRUE)
	{
		char *display_string = (char *) bpcalloc(buff_string->string_length+5, 1);
		memcpy(display_string, buff_string->address_of_string_in_buffer, buff_string->string_length);
		printf("\n\t     STRING DATA: %s", display_string);
		bpfree(display_string);
	}
	printf("\n");
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DisplayBufferAnalysisASCIIString ( P_BP_BUFFER_ANALYSIS_ASCII_STRINGS buff_string , BP_BOOL display_string_data ) { if ( ! buff_string ) return ERR_FAILURE ; if ( buff_string -> marked_as_restricted == BP_TRUE ) return ERR_FAILURE ; printf ( " \n \t " , buff_string ) ; printf ( " \n \t " , buff_string -> position_in_analyzed_buffer ) ; printf ( " \n \t " , buff_string -> string_length ) ; printf ( " \n \t " , buff_string -> address_of_string_in_buffer ) ; printf ( " \n \t " , buff_string -> match_flags_enabled ? " " : " " ) ; if ( buff_string -> restricted_characters ) { printf ( " \n \t " , buff_string -> restricted_characters ) ; printf ( " \n \t " , buff_string -> restricted_characters_n ) ; } if ( buff_string -> string_terminator ) { printf ( " \n \t " , buff_string -> string_terminator ) ; printf ( " \n \t " , buff_string -> string_terminator_length ) ; } BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS empty_flags ; BP_ZERO_STACK ( empty_flags ) ; if ( memcmp ( & empty_flags , & buff_string -> string_flags , sizeof ( empty_flags ) ) != 0 ) { if ( buff_string -> string_flags . is_unix_file_path ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_url ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_host_url ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_base_url ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_script_url ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_path_url ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . is_dynamic_so ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . exists_as_file_on_filesystem ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . exists_as_file_on_filesystem_and_is_readable ) printf ( " \n \t " ) ; if ( buff_string -> string_flags . exists_as_file_on_filesystem_and_is_writable ) printf ( " \n \t " ) ; } if ( display_string_data == BP_TRUE ) { char * display_string = ( char * ) bpcalloc ( buff_string -> string_length + 5 , 1 ) ; memcpy ( display_string , buff_string -> address_of_string_in_buffer , buff_string -> string_length ) ; printf ( " \n \t " , display_string ) ; bpfree ( display_string ) ; } printf ( " \n " ) ; return ERR_SUCCESS ; }
display an ascii string structure (found within buff analysis)
display an ascii string structure ( found within buff analysis )
// return immediately if it's restricted // printf("\n\t     match_flags:                  %p",  buff_string->match_flags); // printf("\n\t     match_flags_how:              %zu", buff_string->match_flags_how); // create empty flags for compare // if we have flags, go ahead and display flags // display string data if necessary // allocate temporary space // copy in data // actually display string] // destroy temporary space // display trailing newline // return indicating success