library/src/exploitation/WebExploitation/BlindSQLiDetection/BP-WebExploitationBlindSQLiDetection.cc
// Generate blind sqli anchor test set.
Generate blind sqli anchor test set.
Generate blind sqli anchor test set .
char * BP_WebAssessmentGenerateBlindSQLiAnchorTestSet
(
		char *                      baseTestURL,
		P_BP_WEB_BLIND_SQLINJ_TEST  test,
		P_BP_HTML_ANCHOR_VAR_LIST   vars,
		P_BP_HTML_ANCHOR_DELIMITERS delims,
		char *                      asciiXSSPayload,
		size_t                      subAtPosition
)
{
	if (!baseTestURL || !vars || !delims)
		return NULL;
	if(!test->testFront)
		return NULL;
	size_t setSize = bpstrlen(baseTestURL);
	if(test->testFront)
		setSize += bpstrlen(test->testFront);
	if(test->testTail)
		setSize += bpstrlen(test->testTail);
	setSize += delims->sLen;
	if(asciiXSSPayload)
		setSize += bpstrlen(asciiXSSPayload);
	P_BP_HTML_ANCHOR_VAR_LIST varsFirst = vars->first;
	for
	(
		vars = vars->first;
		vars;
		vars = vars->next
	)
	{
		setSize += vars->nameLen;
		setSize += vars->contentLen;
		setSize += delims->vLen;
		setSize += delims->nLen;
	}
	vars = varsFirst;
	char *embedStr = (char *) bpcalloc(setSize + 4096, 1);
	if (!embedStr)
		return NULL;
	memcpy(embedStr, baseTestURL, bpstrlen(baseTestURL));
	size_t posCounter = 0;
	memcpy(&embedStr[bpstrlen(embedStr)], delims->startDelimiter, bpstrlen(delims->startDelimiter));
	for
	(
		vars = vars->first;
		vars;
		vars = vars->next
	)
	{
		if (posCounter == subAtPosition)
		{
			snprintf(&embedStr[bpstrlen(embedStr)], setSize, "%s%s%s%s%s", vars->name, delims->valueDelimiter, test->testFront, asciiXSSPayload?asciiXSSPayload:"", test->testTail?test->testTail : "");
		}
		else
		{
			snprintf(&embedStr[bpstrlen(embedStr)], setSize, "%s%s%s", vars->name, delims->valueDelimiter, vars->content);
		}
		strncat(embedStr, delims->nextDelimiter, delims->nLen);
		posCounter++;
	}
	if (embedStr[bpstrlen(embedStr) - 1] == (char) delims->nextDelimiter[0])
		embedStr[bpstrlen(embedStr) - 1] = '\0';
	return embedStr;
}
char * BP_WebAssessmentGenerateBlindSQLiAnchorTestSet ( char * baseTestURL , P_BP_WEB_BLIND_SQLINJ_TEST test , P_BP_HTML_ANCHOR_VAR_LIST vars , P_BP_HTML_ANCHOR_DELIMITERS delims , char * asciiXSSPayload , size_t subAtPosition ) { if ( ! baseTestURL || ! vars || ! delims ) return NULL ; if ( ! test -> testFront ) return NULL ; size_t setSize = bpstrlen ( baseTestURL ) ; if ( test -> testFront ) setSize += bpstrlen ( test -> testFront ) ; if ( test -> testTail ) setSize += bpstrlen ( test -> testTail ) ; setSize += delims -> sLen ; if ( asciiXSSPayload ) setSize += bpstrlen ( asciiXSSPayload ) ; P_BP_HTML_ANCHOR_VAR_LIST varsFirst = vars -> first ; for ( vars = vars -> first ; vars ; vars = vars -> next ) { setSize += vars -> nameLen ; setSize += vars -> contentLen ; setSize += delims -> vLen ; setSize += delims -> nLen ; } vars = varsFirst ; char * embedStr = ( char * ) bpcalloc ( setSize + 4096 , 1 ) ; if ( ! embedStr ) return NULL ; memcpy ( embedStr , baseTestURL , bpstrlen ( baseTestURL ) ) ; size_t posCounter = 0 ; memcpy ( & embedStr [ bpstrlen ( embedStr ) ] , delims -> startDelimiter , bpstrlen ( delims -> startDelimiter ) ) ; for ( vars = vars -> first ; vars ; vars = vars -> next ) { if ( posCounter == subAtPosition ) { snprintf ( & embedStr [ bpstrlen ( embedStr ) ] , setSize , " " , vars -> name , delims -> valueDelimiter , test -> testFront , asciiXSSPayload ? asciiXSSPayload : " " , test -> testTail ? test -> testTail : " " ) ; } else { snprintf ( & embedStr [ bpstrlen ( embedStr ) ] , setSize , " " , vars -> name , delims -> valueDelimiter , vars -> content ) ; } strncat ( embedStr , delims -> nextDelimiter , delims -> nLen ) ; posCounter ++ ; } if ( embedStr [ bpstrlen ( embedStr ) - 1 ] == ( char ) delims -> nextDelimiter [ 0 ] ) embedStr [ bpstrlen ( embedStr ) - 1 ] = ' \0 ' ; return embedStr ; }
Generate blind sqli anchor test set.
Generate blind sqli anchor test set .
// NULL Checks // test front and tail cannot either be null // Add the length of the base url // Add the length of the test // Append size of start delimiter // Save first pointer // Walk var list to calculate the set size // increase the set size by the name length // increase the set size by the content length // increase the set size by the vlen // increase the set size by the nlen // reset pointer // allocate space for the set // copy in the base test url first // variable position counter // copy in start delimiter // Walk var list and fill in data // append next delimiter // increment the position // remove last next delimiter // return allocated string