library/src/exploitation/WebExploitation/BP-WebExploitTestResultAnalysis.cc
// Utilizes the data stored within the session in order to attempt a match with
// a given XSS Test. (FORM VERSION)
Utilizes the data stored within the session in order to attempt a match with
a given XSS Test. (FORM VERSION)
Utilizes the data stored within the session in order to attempt a match with a given XSS Test . ( FORM VERSION )
P_BP_WEB_XSS_TEST_RESULT BP_WebAssessmentRunXSSFormMatchCheck(P_BP_WEB_ASSESSMENT assessment, P_BP_WEB_XSS_TEST test, size_t testIndex, size_t runMagicQuotesTest, P_BP_HTML_FORM_LIST form, P_BP_HTML_INPUT_LIST vulnInput, size_t inputVarPosition){
	if(!assessment || !test)
		return NULL;
	P_BP_WEB_XSS_TEST_RESULT result = (P_BP_WEB_XSS_TEST_RESULT) bpcalloc(sizeof(BP_WEB_XSS_TEST_RESULT), 1);
	if(!result)
		return NULL;
	result->first = result;
	result->next = NULL;
	result->prev = NULL;
	result->targetType = BP_XSS_TARGET_TYPE_FORM;
	result->testIndex = testIndex;
	char * standardSearchString = NULL;
	size_t strSize = bpstrlen(assessment->xssPayload);
	strSize += bpstrlen(test->testFront);
	strSize += bpstrlen(test->testTail);
	standardSearchString = (char *) bpcalloc(strSize+4096, 1);
	snprintf(standardSearchString, strSize+1024, "%s%s%s",
			test->testFront, assessment->xssPayload, test->testTail);
	char * standardSearchStringCORRECT = BP_GenNonUnicodeSpaceString(standardSearchString, bpstrlen(standardSearchString));
	char *match = (char *) memmem((void *) assessment->session->page->page_data,
								strnlen(assessment->session->page->page_data, assessment->session->page->page_data_size),
								(void *) standardSearchStringCORRECT,
								bpstrlen(standardSearchStringCORRECT));
	if(match)
		result->match = true;
	char *magicQuoteMatch = NULL;
	char * mgQuoteStr = BP_WebAssessmentGenerateMagicQuoteStrFromStr(standardSearchString);
	char * mgQuoteStrCORRECT = BP_GenNonUnicodeSpaceString(mgQuoteStr, bpstrlen(mgQuoteStr));
	magicQuoteMatch = (char *) memmem((void *) assessment->session->page->page_data,
									strnlen(assessment->session->page->page_data, assessment->session->page->page_data_size),
									(void *) mgQuoteStrCORRECT,
									bpstrlen(mgQuoteStrCORRECT));
	if(magicQuoteMatch)
		result->magicQuotesMatch = true;
	result->form             = form;
	result->vulnInput        = vulnInput;
	result->inputVarPosition = inputVarPosition;
	bpfree(mgQuoteStr);
	bpfree(mgQuoteStrCORRECT);
	bpfree(standardSearchString);
	bpfree(standardSearchStringCORRECT);
	return result;
}
P_BP_WEB_XSS_TEST_RESULT BP_WebAssessmentRunXSSFormMatchCheck ( P_BP_WEB_ASSESSMENT assessment , P_BP_WEB_XSS_TEST test , size_t testIndex , size_t runMagicQuotesTest , P_BP_HTML_FORM_LIST form , P_BP_HTML_INPUT_LIST vulnInput , size_t inputVarPosition ) { if ( ! assessment || ! test ) return NULL ; P_BP_WEB_XSS_TEST_RESULT result = ( P_BP_WEB_XSS_TEST_RESULT ) bpcalloc ( sizeof ( BP_WEB_XSS_TEST_RESULT ) , 1 ) ; if ( ! result ) return NULL ; result -> first = result ; result -> next = NULL ; result -> prev = NULL ; result -> targetType = BP_XSS_TARGET_TYPE_FORM ; result -> testIndex = testIndex ; char * standardSearchString = NULL ; size_t strSize = bpstrlen ( assessment -> xssPayload ) ; strSize += bpstrlen ( test -> testFront ) ; strSize += bpstrlen ( test -> testTail ) ; standardSearchString = ( char * ) bpcalloc ( strSize + 4096 , 1 ) ; snprintf ( standardSearchString , strSize + 1024 , " " , test -> testFront , assessment -> xssPayload , test -> testTail ) ; char * standardSearchStringCORRECT = BP_GenNonUnicodeSpaceString ( standardSearchString , bpstrlen ( standardSearchString ) ) ; char * match = ( char * ) memmem ( ( void * ) assessment -> session -> page -> page_data , strnlen ( assessment -> session -> page -> page_data , assessment -> session -> page -> page_data_size ) , ( void * ) standardSearchStringCORRECT , bpstrlen ( standardSearchStringCORRECT ) ) ; if ( match ) result -> match = true ; char * magicQuoteMatch = NULL ; char * mgQuoteStr = BP_WebAssessmentGenerateMagicQuoteStrFromStr ( standardSearchString ) ; char * mgQuoteStrCORRECT = BP_GenNonUnicodeSpaceString ( mgQuoteStr , bpstrlen ( mgQuoteStr ) ) ; magicQuoteMatch = ( char * ) memmem ( ( void * ) assessment -> session -> page -> page_data , strnlen ( assessment -> session -> page -> page_data , assessment -> session -> page -> page_data_size ) , ( void * ) mgQuoteStrCORRECT , bpstrlen ( mgQuoteStrCORRECT ) ) ; if ( magicQuoteMatch ) result -> magicQuotesMatch = true ; result -> form = form ; result -> vulnInput = vulnInput ; result -> inputVarPosition = inputVarPosition ; bpfree ( mgQuoteStr ) ; bpfree ( mgQuoteStrCORRECT ) ; bpfree ( standardSearchString ) ; bpfree ( standardSearchStringCORRECT ) ; return result ; }
Utilizes the data stored within the session in order to attempt a match with
a given XSS Test.
Utilizes the data stored within the session in order to attempt a match with a given XSS Test .
// Null checks // create new structure // set pointers // type is anchor // set the test index // Non-magic quotes aware search string // increase the string size + size of payload // increase size around test front/tail combo // allocate memory plus some just in case // copy in parameters // Normal String Checks // If the pointer is found, we have a match // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%% MAGIC QUOTE CHECKS %%%%%%%%%%%%%%%%%%%%% // Magic Quote Checks // set match flag // bpfree the standard/magic quote string // return the filled in structure