library/src/exploitation/WebExploitation/BP-WebExploitation.cc
// prints out a representation of the SQL Test list for use with
// debugging.
prints out a representation of the SQL Test list for use with
debugging.
prints out a representation of the SQL Test list for use with debugging .
void BP_PrintSqlResultList(P_BP_WEB_ASSESSMENT assessment)
{
	if (!assessment)
		return;
	P_BP_WEB_SQLINJ_TEST_RESULT inList = assessment->sqlResults;
	if (!inList)
		return;
	size_t x = 0;
	for
	(
		inList = inList->first;
		inList;
		inList = inList->next
	)
	{
		printf("\n\n\t\t[+] SQL Result:  %p", inList);
		printf("\n\n\t\t Test String: %s", inList->anchorActualTest);
		printf("\n\n\t\t Anchor Pointer:                  %p", inList->anchor);
		printf("\n\t\t Vulnerable Var Position in List: %u", inList->anchorVarPosition);
		printf("\n\t\t Form Input Test Str: %s", inList->actualInputTest);
		printf("\n\t\t Form Pointer:                    %p", inList->form);
		printf("\n\t\t Vulnerable Input Position in List: %u", inList->inputPosition);
		printf("\n\t\t Test Index:                        %i", inList->testIndex);
		size_t x = 0;
		printf("\n\t\t SQL Engines Detected:              ");
		if (inList->engineDetectionCount == 0)
			printf(" No detected engines.");
		for (x = 0; x < inList->engineDetectionCount; x++)
			switch (inList->enginesDetected[x]) {
			case BP_SQLINJ_ENGINE_NONE:
				printf("None Detected (%u), ", inList->targetType);
				break;
			case BP_SQLINJ_ENGINE_MYSQL:
				printf("MYSQL, ");
				break;
			case BP_SQLINJ_ENGINE_MSQL:
				printf("MSQL, ");
				break;
			case BP_SQLINJ_ENGINE_POSTGRES:
				printf("Postgres, ");
				break;
			case BP_SQLINJ_ENGINE_ORACLE:
				printf("Oracle, ");
				break;
			default:
				printf("Unknown Engine Type (%u), ", inList->enginesDetected[x]);
				break;
			}
		printf("\n\t\t Target Type:                       ");
		switch (inList->targetType) {
		case BP_SQLINJ_TARGET_TYPE_NONE:
			printf("No Target Type Set");
			break;
		case BP_SQLINJ_TARGET_TYPE_ANCHOR:
			printf("Anchor");
			break;
		case BP_SQLINJ_TARGET_TYPE_FORM:
			printf("Form");
			break;
		case BP_SQLINJ_TARGET_TYPE_COOKIE:
			printf("Cookie");
			break;
		}
		if (inList->mysqlTestMatchesMade > 0) {
			printf("\n");
			printf("\n\t\t MySQL Signature Matches Found:     %i", inList->mysqlTestMatchesMade);
			printf("\n\t\t MySQL Err Index Matches: ..");
			for (x = 0; x < inList->mysqlTestMatchesMade; x++)
				printf("\n\t[-%u-] %s", inList->mysqlTestMatchIndexes[x], BP_MysqlGetDescriptionFromIndex(assessment->mysqlErrCodes,
						inList->mysqlTestMatchIndexes[x]));
		}
		if (inList->msqlTestMatchesMade > 0) {
			printf("\n");
			printf("\n\t\t MSQL Signature Matches Found:     %i", inList->msqlTestMatchesMade);
			printf("\n\t\t MSQL Err Index Matches: ..");
			for (x = 0; x < inList->msqlTestMatchesMade; x++)
				printf("\n\t[-%u-] %s", inList->msqlTestMatchIndexes[x], BP_MsqlGetDescriptionFromIndex(assessment->msqlErrCodes,
						inList->msqlTestMatchIndexes[x]));
		}
		if (inList->oracleTestMatchesMade > 0) {
			printf("\n");
			printf("\n\t\t Oracle Signature Matches Found:     %i", inList->oracleTestMatchesMade);
			printf("\n\t\t Oracle Err Index Matches: ..");
			for (x = 0; x < inList->oracleTestMatchesMade; x++)
				printf("\n\t[-%u-] %s", inList->oracleTestMatchIndexes[x], BP_OracleGetDescriptionFromIndex(assessment->oracleErrCodes,
						inList->oracleTestMatchIndexes[x]));
		}
		if (inList->odbcTestMatchesMade > 0) {
			printf("\n");
			printf("\n\t\t ODBC Signature Matches Found:     %i", inList->odbcTestMatchesMade);
			printf("\n\t\t ODBC Err Index Matches: ..");
			for (x = 0; x < inList->odbcTestMatchesMade; x++)
				printf("\n\t[-%u-] %s", inList->odbcTestMatchIndexes[x], BP_ODBCGetDescriptionFromIndex(assessment->odbcErrCodes,
						inList->odbcTestMatchIndexes[x]));
		}
		if (inList->postgresTestMatchesMade > 0) {
			printf("\n");
			printf("\n\t\t Postgres Signature Matches Found:     %i", inList->postgresTestMatchesMade);
			printf("\n\t\t Postgres Err Index Matches: ..");
			for (x = 0; x < inList->postgresTestMatchesMade; x++)
				printf("\n\t[-%u-] %s", inList->postgresTestMatchIndexes[x], BP_PostgresGetDescriptionFromIndex(assessment->postgresErrCodes,
						inList->postgresTestMatchIndexes[x]));
		}
		printf("\n\t\t\t first: %p", inList->first);
		printf("\n\t\t\t prev : %p", inList->prev);
		printf("\n\t\t\t next : %p", inList->next);
	}
	return;
}
void BP_PrintSqlResultList ( P_BP_WEB_ASSESSMENT assessment ) { if ( ! assessment ) return ; P_BP_WEB_SQLINJ_TEST_RESULT inList = assessment -> sqlResults ; if ( ! inList ) return ; size_t x = 0 ; for ( inList = inList -> first ; inList ; inList = inList -> next ) { printf ( " \n \n \t \t " , inList ) ; printf ( " \n \n \t \t " , inList -> anchorActualTest ) ; printf ( " \n \n \t \t " , inList -> anchor ) ; printf ( " \n \t \t " , inList -> anchorVarPosition ) ; printf ( " \n \t \t " , inList -> actualInputTest ) ; printf ( " \n \t \t " , inList -> form ) ; printf ( " \n \t \t " , inList -> inputPosition ) ; printf ( " \n \t \t " , inList -> testIndex ) ; size_t x = 0 ; printf ( " \n \t \t " ) ; if ( inList -> engineDetectionCount == 0 ) printf ( " " ) ; for ( x = 0 ; x < inList -> engineDetectionCount ; x ++ ) switch ( inList -> enginesDetected [ x ] ) { case BP_SQLINJ_ENGINE_NONE : printf ( " " , inList -> targetType ) ; break ; case BP_SQLINJ_ENGINE_MYSQL : printf ( " " ) ; break ; case BP_SQLINJ_ENGINE_MSQL : printf ( " " ) ; break ; case BP_SQLINJ_ENGINE_POSTGRES : printf ( " " ) ; break ; case BP_SQLINJ_ENGINE_ORACLE : printf ( " " ) ; break ; default : printf ( " " , inList -> enginesDetected [ x ] ) ; break ; } printf ( " \n \t \t " ) ; switch ( inList -> targetType ) { case BP_SQLINJ_TARGET_TYPE_NONE : printf ( " " ) ; break ; case BP_SQLINJ_TARGET_TYPE_ANCHOR : printf ( " " ) ; break ; case BP_SQLINJ_TARGET_TYPE_FORM : printf ( " " ) ; break ; case BP_SQLINJ_TARGET_TYPE_COOKIE : printf ( " " ) ; break ; } if ( inList -> mysqlTestMatchesMade > 0 ) { printf ( " \n " ) ; printf ( " \n \t \t " , inList -> mysqlTestMatchesMade ) ; printf ( " \n \t \t " ) ; for ( x = 0 ; x < inList -> mysqlTestMatchesMade ; x ++ ) printf ( " \n \t " , inList -> mysqlTestMatchIndexes [ x ] , BP_MysqlGetDescriptionFromIndex ( assessment -> mysqlErrCodes , inList -> mysqlTestMatchIndexes [ x ] ) ) ; } if ( inList -> msqlTestMatchesMade > 0 ) { printf ( " \n " ) ; printf ( " \n \t \t " , inList -> msqlTestMatchesMade ) ; printf ( " \n \t \t " ) ; for ( x = 0 ; x < inList -> msqlTestMatchesMade ; x ++ ) printf ( " \n \t " , inList -> msqlTestMatchIndexes [ x ] , BP_MsqlGetDescriptionFromIndex ( assessment -> msqlErrCodes , inList -> msqlTestMatchIndexes [ x ] ) ) ; } if ( inList -> oracleTestMatchesMade > 0 ) { printf ( " \n " ) ; printf ( " \n \t \t " , inList -> oracleTestMatchesMade ) ; printf ( " \n \t \t " ) ; for ( x = 0 ; x < inList -> oracleTestMatchesMade ; x ++ ) printf ( " \n \t " , inList -> oracleTestMatchIndexes [ x ] , BP_OracleGetDescriptionFromIndex ( assessment -> oracleErrCodes , inList -> oracleTestMatchIndexes [ x ] ) ) ; } if ( inList -> odbcTestMatchesMade > 0 ) { printf ( " \n " ) ; printf ( " \n \t \t " , inList -> odbcTestMatchesMade ) ; printf ( " \n \t \t " ) ; for ( x = 0 ; x < inList -> odbcTestMatchesMade ; x ++ ) printf ( " \n \t " , inList -> odbcTestMatchIndexes [ x ] , BP_ODBCGetDescriptionFromIndex ( assessment -> odbcErrCodes , inList -> odbcTestMatchIndexes [ x ] ) ) ; } if ( inList -> postgresTestMatchesMade > 0 ) { printf ( " \n " ) ; printf ( " \n \t \t " , inList -> postgresTestMatchesMade ) ; printf ( " \n \t \t " ) ; for ( x = 0 ; x < inList -> postgresTestMatchesMade ; x ++ ) printf ( " \n \t " , inList -> postgresTestMatchIndexes [ x ] , BP_PostgresGetDescriptionFromIndex ( assessment -> postgresErrCodes , inList -> postgresTestMatchIndexes [ x ] ) ) ; } printf ( " \n \t \t \t " , inList -> first ) ; printf ( " \n \t \t \t " , inList -> prev ) ; printf ( " \n \t \t \t " , inList -> next ) ; } return ; }
prints out a representation of the SQL Test list for use with
debugging.
prints out a representation of the SQL Test list for use with debugging .
// null check on assessment // Get results pointer from structure and check results pointer // loop iterator // Walk the list // --- ANCHORS ------------------------ // anchor test string // Html anchor entity pointers (only filled out if found in anchor) // position in the variable list for the anchor in which // vulnVar occurs. // --- FORMS ------------------------------- // print out input test string // Html form entity pointers (only filled out if found in form input) // Position in the input list which the vulnInput occurs. // Test index // Walk the sql engine detections // print out the detected engines // target type (anchor, form, or cookie) // number of UNIQUE mysql matches made // number of UNIQUE msql matches made // number of UNIQUE oracle matches made // number of UNIQUE odbc matches made // number of UNIQUE postgres matches made