library/src/exploitation/WebExploitation/BP-WebExploitation.cc
// Creates an new assessment structure (all flags are required)
Creates an new assessment structure (all flags are required)
Creates an new assessment structure ( all flags are required )
P_BP_WEB_ASSESSMENT BP_CreateWebAssessment
(
		char *                    baseAssessmentURL,
		P_BP_HTTP_SESSION         session,
		P_BP_HTML_FULL_EXTRACTION extraction,
		bool                      genSqlTables,
		bool                      genAppEngineTables,
		bool                      siteLock
)
{
	if (!baseAssessmentURL)
		return NULL;
	if(!BP_StringIsReasonablePrintableString(baseAssessmentURL, bpstrlen(baseAssessmentURL), BP_FALSE, BP_FALSE))
		return NULL;
	P_BP_WEB_ASSESSMENT assessment = (P_BP_WEB_ASSESSMENT) bpcalloc(sizeof(BP_WEB_ASSESSMENT), 1);
	if (!assessment)
		return NULL;
	assessment->baseAssessmentURL = bpstrdup(baseAssessmentURL);
	assessment->statusCodes = BP_GenStatusCodeArray();
	if (!assessment->statusCodes)
		return NULL;
	assessment->fmtTable = BP_WebExploitGenFormatTable();
	if (!assessment->fmtTable)
		return NULL;
	if (extraction)
		assessment->pageExtraction = extraction;
	else
		assessment->performRequiredExtraction = true;
	if (session)
		assessment->session = session;
	else
		assessment->createNewSession = true;
	assessment->randomizeBrowserStrsBetweenRequests = true;
	assessment->maxRetryRequests = 5;
	assessment->failedAssessment = 0;
	assessment->userAgentPoolType = BP_USER_AGENT_POOL_BROWSERS_ONLY;
	assessment->userAgentPool = BP_GenerateBrowserAgentOnlyArray();
	if (!assessment->userAgentPool)
		return NULL;
	assessment->userAgentCount = BP_HTTPUserAgentCount(assessment->userAgentPool);
	assessment->xssChecks      = BP_XSSGenerateArray();
	assessment->xssChecksCount = BP_GetXSSTestCount();
	assessment->xssTestSetId = BP_XSS_TEST_SET_STANDARD;
	assessment->sqlChecks     = BP_SQLGenerateArray();
	assessment->sqlCheckCount = BP_GetSQLTestCount();
	assessment->sqlInjTestSetId = BP_SQLINJ_TEST_SET_STANDARD;
	assessment->maxAnchorPossibilities = 65535;
	assessment->maxFormPossibilities   = 65535;
	assessment->xssPayload = (char *) bpcalloc(bpstrlen("alort(1);") + 5, 1);
	memcpy(assessment->xssPayload, ".", bpstrlen("."));
	assessment->sqlInjectPayload = (char *) bpcalloc(bpstrlen("UNION SELECT 1,2,3;") + 100, 1);
	memcpy(assessment->sqlInjectPayload, ".", bpstrlen("."));
	if (genSqlTables)
	{
		assessment->runMysqlChecks = true;
		assessment->mysqlErrCodes = BP_MysqlGenErrCodeArray();
		if (!assessment->mysqlErrCodes)
			return NULL;
		assessment->mysqlErrCheckCount = BP_MysqlErrCount();
		assessment->mysqlErrChecks = BP_MysqlGenErrTestsFromErrCodeArray(assessment->mysqlErrCodes, assessment->mysqlErrCheckCount, assessment->fmtTable);
		if (!assessment->mysqlErrChecks)
			return NULL;
		assessment->runMsqlChecks = false;
		if(assessment->runMsqlChecks == true)
		{
			assessment->msqlErrCodes = BP_MsqlGenErrCodeArray();
			if (!assessment->msqlErrCodes)
				return NULL;
			assessment->msqlErrCheckCount = BP_MsqlErrCount();
			assessment->msqlErrChecks = BP_MsqlGenErrTestsFromErrCodeArray(assessment->msqlErrCodes, assessment->msqlErrCheckCount, assessment->fmtTable);
		}
		assessment->runODBCChecks = true;
		assessment->odbcErrCodes = BP_ODBCGenErrCodeArray();
		if (!assessment->odbcErrCodes)
			return NULL;
		assessment->odbcErrCheckCount = BP_ODBCErrCount();
		assessment->odbcErrChecks = BP_ODBCGenErrTestsFromErrCodeArray(assessment->odbcErrCodes, assessment->odbcErrCheckCount, assessment->fmtTable);
		assessment->runOracleChecks = true;
		assessment->oracleErrCodes = BP_OracleGenErrCodeArray();
		if (!assessment->oracleErrCodes)
			return NULL;
		assessment->oracleErrCheckCount = BP_OracleErrCount();
		assessment->oracleErrChecks = BP_OracleGenErrTestsFromErrCodeArray(assessment->oracleErrCodes, assessment->oracleErrCheckCount, assessment->fmtTable);
		assessment->runPostgresChecks = true;
		assessment->postgresErrCodes = BP_PostgresGenErrCodeArray();
		if (!assessment->postgresErrCodes)
			return NULL;
		assessment->postgresErrCheckCount = BP_PostgresErrCount();
		assessment->postgresErrChecks = BP_PostgresGenErrTestsFromErrCodeArray
		(
			assessment->postgresErrCodes,
			assessment->postgresErrCheckCount,
			assessment->fmtTable
		);
	}
	if (genAppEngineTables)
	{
		assessment->runAppServerChecks = true;
		assessment->runPhpChecks = true;
		assessment->phpErrCodes = BP_PHPGenErrCodeArray();
		if (!assessment->phpErrCodes)
			return NULL;
		assessment->phpErrCheckCount = BP_PHPErrCount();
		assessment->phpErrChecks = BP_PHPGenErrTestsFromErrCodeArray(assessment->phpErrCodes, assessment->phpErrCheckCount, assessment->fmtTable);
		assessment->runJspChecks = true;
		assessment->jspErrCodes = BP_JSPGenErrCodeArray();
		if (!assessment->jspErrCodes)
			return NULL;
		assessment->jspErrCheckCount = BP_JSPErrCount();
		assessment->jspErrChecks = BP_JSPGenErrTestsFromErrCodeArray(assessment->jspErrCodes, assessment->jspErrCheckCount, assessment->fmtTable);
		assessment->runAspChecks = true;
		assessment->aspErrCodes = BP_ASPGenErrCodeArray();
		if (!assessment->aspErrCodes)
			return NULL;
		assessment->aspErrCheckCount = BP_ASPErrCount();
		assessment->aspErrChecks = BP_ASPGenErrTestsFromErrCodeArray(assessment->aspErrCodes, assessment->aspErrCheckCount, assessment->fmtTable);
		assessment->runCfmChecks = true;
		assessment->cfmErrCodes = BP_CFMGenErrCodeArray();
		if (!assessment->cfmErrCodes)
			return NULL;
		assessment->cfmErrCheckCount = BP_CFMErrCount();
		assessment->cfmErrChecks = BP_CFMGenErrTestsFromErrCodeArray(assessment->cfmErrCodes, assessment->cfmErrCheckCount, assessment->fmtTable);
		assessment->runDnetChecks = true;
		assessment->dnetErrCodes = BP_DNETGenErrCodeArray();
		if (!assessment->dnetErrCodes)
			return NULL;
		assessment->dnetErrCheckCount = BP_DNETErrCount();
		assessment->dnetErrChecks = BP_DNETGenErrTestsFromErrCodeArray(assessment->dnetErrCodes, assessment->dnetErrCheckCount, assessment->fmtTable);
	}
	assessment->http_request_max_retries = 3;
	assessment->first = assessment;
	return assessment;
}
P_BP_WEB_ASSESSMENT BP_CreateWebAssessment ( char * baseAssessmentURL , P_BP_HTTP_SESSION session , P_BP_HTML_FULL_EXTRACTION extraction , bool genSqlTables , bool genAppEngineTables , bool siteLock ) { if ( ! baseAssessmentURL ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( baseAssessmentURL , bpstrlen ( baseAssessmentURL ) , BP_FALSE , BP_FALSE ) ) return NULL ; P_BP_WEB_ASSESSMENT assessment = ( P_BP_WEB_ASSESSMENT ) bpcalloc ( sizeof ( BP_WEB_ASSESSMENT ) , 1 ) ; if ( ! assessment ) return NULL ; assessment -> baseAssessmentURL = bpstrdup ( baseAssessmentURL ) ; assessment -> statusCodes = BP_GenStatusCodeArray ( ) ; if ( ! assessment -> statusCodes ) return NULL ; assessment -> fmtTable = BP_WebExploitGenFormatTable ( ) ; if ( ! assessment -> fmtTable ) return NULL ; if ( extraction ) assessment -> pageExtraction = extraction ; else assessment -> performRequiredExtraction = true ; if ( session ) assessment -> session = session ; else assessment -> createNewSession = true ; assessment -> randomizeBrowserStrsBetweenRequests = true ; assessment -> maxRetryRequests = 5 ; assessment -> failedAssessment = 0 ; assessment -> userAgentPoolType = BP_USER_AGENT_POOL_BROWSERS_ONLY ; assessment -> userAgentPool = BP_GenerateBrowserAgentOnlyArray ( ) ; if ( ! assessment -> userAgentPool ) return NULL ; assessment -> userAgentCount = BP_HTTPUserAgentCount ( assessment -> userAgentPool ) ; assessment -> xssChecks = BP_XSSGenerateArray ( ) ; assessment -> xssChecksCount = BP_GetXSSTestCount ( ) ; assessment -> xssTestSetId = BP_XSS_TEST_SET_STANDARD ; assessment -> sqlChecks = BP_SQLGenerateArray ( ) ; assessment -> sqlCheckCount = BP_GetSQLTestCount ( ) ; assessment -> sqlInjTestSetId = BP_SQLINJ_TEST_SET_STANDARD ; assessment -> maxAnchorPossibilities = 65535 ; assessment -> maxFormPossibilities = 65535 ; assessment -> xssPayload = ( char * ) bpcalloc ( bpstrlen ( " " ) + 5 , 1 ) ; memcpy ( assessment -> xssPayload , " " , bpstrlen ( " " ) ) ; assessment -> sqlInjectPayload = ( char * ) bpcalloc ( bpstrlen ( " " ) + 100 , 1 ) ; memcpy ( assessment -> sqlInjectPayload , " " , bpstrlen ( " " ) ) ; if ( genSqlTables ) { assessment -> runMysqlChecks = true ; assessment -> mysqlErrCodes = BP_MysqlGenErrCodeArray ( ) ; if ( ! assessment -> mysqlErrCodes ) return NULL ; assessment -> mysqlErrCheckCount = BP_MysqlErrCount ( ) ; assessment -> mysqlErrChecks = BP_MysqlGenErrTestsFromErrCodeArray ( assessment -> mysqlErrCodes , assessment -> mysqlErrCheckCount , assessment -> fmtTable ) ; if ( ! assessment -> mysqlErrChecks ) return NULL ; assessment -> runMsqlChecks = false ; if ( assessment -> runMsqlChecks == true ) { assessment -> msqlErrCodes = BP_MsqlGenErrCodeArray ( ) ; if ( ! assessment -> msqlErrCodes ) return NULL ; assessment -> msqlErrCheckCount = BP_MsqlErrCount ( ) ; assessment -> msqlErrChecks = BP_MsqlGenErrTestsFromErrCodeArray ( assessment -> msqlErrCodes , assessment -> msqlErrCheckCount , assessment -> fmtTable ) ; } assessment -> runODBCChecks = true ; assessment -> odbcErrCodes = BP_ODBCGenErrCodeArray ( ) ; if ( ! assessment -> odbcErrCodes ) return NULL ; assessment -> odbcErrCheckCount = BP_ODBCErrCount ( ) ; assessment -> odbcErrChecks = BP_ODBCGenErrTestsFromErrCodeArray ( assessment -> odbcErrCodes , assessment -> odbcErrCheckCount , assessment -> fmtTable ) ; assessment -> runOracleChecks = true ; assessment -> oracleErrCodes = BP_OracleGenErrCodeArray ( ) ; if ( ! assessment -> oracleErrCodes ) return NULL ; assessment -> oracleErrCheckCount = BP_OracleErrCount ( ) ; assessment -> oracleErrChecks = BP_OracleGenErrTestsFromErrCodeArray ( assessment -> oracleErrCodes , assessment -> oracleErrCheckCount , assessment -> fmtTable ) ; assessment -> runPostgresChecks = true ; assessment -> postgresErrCodes = BP_PostgresGenErrCodeArray ( ) ; if ( ! assessment -> postgresErrCodes ) return NULL ; assessment -> postgresErrCheckCount = BP_PostgresErrCount ( ) ; assessment -> postgresErrChecks = BP_PostgresGenErrTestsFromErrCodeArray ( assessment -> postgresErrCodes , assessment -> postgresErrCheckCount , assessment -> fmtTable ) ; } if ( genAppEngineTables ) { assessment -> runAppServerChecks = true ; assessment -> runPhpChecks = true ; assessment -> phpErrCodes = BP_PHPGenErrCodeArray ( ) ; if ( ! assessment -> phpErrCodes ) return NULL ; assessment -> phpErrCheckCount = BP_PHPErrCount ( ) ; assessment -> phpErrChecks = BP_PHPGenErrTestsFromErrCodeArray ( assessment -> phpErrCodes , assessment -> phpErrCheckCount , assessment -> fmtTable ) ; assessment -> runJspChecks = true ; assessment -> jspErrCodes = BP_JSPGenErrCodeArray ( ) ; if ( ! assessment -> jspErrCodes ) return NULL ; assessment -> jspErrCheckCount = BP_JSPErrCount ( ) ; assessment -> jspErrChecks = BP_JSPGenErrTestsFromErrCodeArray ( assessment -> jspErrCodes , assessment -> jspErrCheckCount , assessment -> fmtTable ) ; assessment -> runAspChecks = true ; assessment -> aspErrCodes = BP_ASPGenErrCodeArray ( ) ; if ( ! assessment -> aspErrCodes ) return NULL ; assessment -> aspErrCheckCount = BP_ASPErrCount ( ) ; assessment -> aspErrChecks = BP_ASPGenErrTestsFromErrCodeArray ( assessment -> aspErrCodes , assessment -> aspErrCheckCount , assessment -> fmtTable ) ; assessment -> runCfmChecks = true ; assessment -> cfmErrCodes = BP_CFMGenErrCodeArray ( ) ; if ( ! assessment -> cfmErrCodes ) return NULL ; assessment -> cfmErrCheckCount = BP_CFMErrCount ( ) ; assessment -> cfmErrChecks = BP_CFMGenErrTestsFromErrCodeArray ( assessment -> cfmErrCodes , assessment -> cfmErrCheckCount , assessment -> fmtTable ) ; assessment -> runDnetChecks = true ; assessment -> dnetErrCodes = BP_DNETGenErrCodeArray ( ) ; if ( ! assessment -> dnetErrCodes ) return NULL ; assessment -> dnetErrCheckCount = BP_DNETErrCount ( ) ; assessment -> dnetErrChecks = BP_DNETGenErrTestsFromErrCodeArray ( assessment -> dnetErrCodes , assessment -> dnetErrCheckCount , assessment -> fmtTable ) ; } assessment -> http_request_max_retries = 3 ; assessment -> first = assessment ; return assessment ; }
Creates an new assessment structure (all flags are required)
Creates an new assessment structure ( all flags are required )
// check pointers (session and extraction are unnecessary) // ensure the string is reasonable printable string // Create assessment // Duplicate and store assessment // Generate a new status code array // Generate a format character table to use when parsing // error messages. // ------------------------------------------------- // Extraction and Session variables (if non-null pointers are supplied // those pointers are used, if not, flags are set so that new extractions // are created when the assessment is run. // if we already have an extraction, work with that, if not // set flag indicating we need to perform the extraction. // if we have a session, set it, if not set flag indicating // that we need to create the new session // Enable browser string randomization by default // set maximum number of request timeouts (default 5) // set assessment as non-failed // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% User Agent Settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set the user agent pool type // Use default user agent pool (browsers only) // set user agent counts // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% XSS Check Settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Generate Standard XSS Test Array (LIVE AMMO) // Standard Test Set Identifier // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% SQL Check Settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Generate Standard SQL Injection Test Array (LIVE AMMO) // Standard Test Set // Set caps within the assessment // Set default xss payload // Set default SQL payload // ------------ SQL TABLE GENERATION --------------------- // If we were passed the flag to generate SQL tables, generate them here // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% MySQL Checks %%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set default check value (true) // Generate a Msql Error Code Array (unmodified) // Get the test count // Generates error tests from the array (parsed for sectional testing aka. formats gone) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% MSQL Checks %%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set default check value (true) // Generate a Msql Error Code Array (unmodified) // Get the test count // Generates error tests from the array (parsed for sectional testing aka. formats gone) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% ODBC Checks %%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set default check value (true) // Generate a ODBC Error Code Array (unmodified) // Get the test count // Generates error tests from the array (parsed for sectional testing aka. formats gone) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Oracle Checks %%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set default check value (true) // Generate a ODBC Error Code Array (unmodified) // Get the test count // Generates error tests from the array (parsed for sectional testing aka. formats gone) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Postgres Checks %%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set default check value (true) // Generate a ODBC Error Code Array (unmodified) // Get the test count // Generates error tests from the array (parsed for sectional testing aka. formats gone) // Application Engine Table Generators // Turn on or off the application server checks, the corresponding lower // level checks must be on additionally for them to be run. // ------------------ PHP ----------------------------------- // flag to indicate to run php app checks // Error Table which contains unmodified/unparsed table of errors // number of php error checks which will be performed // Error Checks Related to PHP Used for Identifying PHP Errors // ------------------ JSP ----------------------------------- // flag to indicate to run php app checks // Error Table which contains unmodified/unparsed table of errors // number of jsp error checks which will be performed // Error Checks Related to JSP Used for Identifying PHP Errors // ------------------ ASP ----------------------------------- // flag to indicate to run asp app checks // error code check array // number of asp error checks which will be performed // ------------------ CFM ----------------------------------- // flag to indicate to run asp app checks // error code check array // number of asp error checks which will be performed // set the checks // ------------------ .NET ----------------------------------- // flag to indicate to run asp app checks // error code check array // number of asp error checks which will be performed // set default max retries // set first pointer // return the assessment