library/src/exploitation/WebExploitation/CommandExecution/BP-WebExploitationCommandExecution.cc
// This routine will attempt to run all command injection tests which are not
// marked as disabled.  Tests are run in parallel based on the provided thread
// count.
This routine will attempt to run all command injection tests which are not
marked as disabled.  Tests are run in parallel based on the provided thread
count.
This routine will attempt to run all command injection tests which are not marked as disabled . Tests are run in parallel based on the provided thread count .
BP_ERROR_T BP_CommandInjectionRunTests(P_BP_WEB_COMMAND_INJECTION_TEST_SESSION cmd_injection_session, size_t thread_count)
{
	if(!cmd_injection_session)
		return ERR_FAILURE;
	P_BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS parameters = (P_BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS) tq_calloc
	(
			cmd_injection_session->tq,
			cmd_injection_session->cmd_injection_test_set_n * sizeof(BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS),
			1,
			BPLN
	);
	size_t test_iter = 0;
	for
	(
			;
			test_iter < cmd_injection_session->cmd_injection_test_set_n;
			test_iter++
	)
	{
		parameters[test_iter].cmd_injection_session = cmd_injection_session;
		parameters[test_iter].test = &cmd_injection_session->cmd_injection_test_set[test_iter];
	}
	void ** parms_as_voids = (void **) tq_calloc
	(
			cmd_injection_session->tq,
			sizeof(void *) * cmd_injection_session->cmd_injection_test_set_n,
			1,
			BPLN
	);
	for
	(
			test_iter = 0;
			test_iter < cmd_injection_session->cmd_injection_test_set_n;
			test_iter++
	)
	{
		parms_as_voids[test_iter] = (void *) &parameters[test_iter];
	}
	size_t * arg_lens = (size_t *) tq_calloc
	(
			cmd_injection_session->tq,
			cmd_injection_session->cmd_injection_test_set_n * sizeof(size_t),
			1,
			BPLN
	);
	size_t size_iter = 0;
	for
	(
			;
			size_iter < cmd_injection_session->cmd_injection_test_set_n;
			size_iter++
	)
	{
		arg_lens[size_iter] = sizeof(void *);
	}
	P_BP_THREAD_MANAGER thread_mgr = BP_CreateThreadManager("command injection assessment mgr", "runs command injection tests");
	size_t thread_iter = 0;
	for
	(
			;
			thread_iter < thread_count;
			thread_iter++
	)
	{
		BP_CreateThread
		(
			thread_mgr,
			BP_CommandInjectionRunTest_thinit,
			NULL,
			0,
			BP_FALSE
		);
	}
	BP_ThreadedDataProcessor
	(
			thread_mgr,
			(void **) parms_as_voids,
			arg_lens,
			cmd_injection_session->cmd_injection_test_set_n-1
	);
	BP_DestroyThreadManager(thread_mgr);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_CommandInjectionRunTests ( P_BP_WEB_COMMAND_INJECTION_TEST_SESSION cmd_injection_session , size_t thread_count ) { if ( ! cmd_injection_session ) return ERR_FAILURE ; P_BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS parameters = ( P_BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS ) tq_calloc ( cmd_injection_session -> tq , cmd_injection_session -> cmd_injection_test_set_n * sizeof ( BP_WEB_COMMAND_INJECTION_THREAD_PARAMETERS ) , 1 , BPLN ) ; size_t test_iter = 0 ; for ( ; test_iter < cmd_injection_session -> cmd_injection_test_set_n ; test_iter ++ ) { parameters [ test_iter ] . cmd_injection_session = cmd_injection_session ; parameters [ test_iter ] . test = & cmd_injection_session -> cmd_injection_test_set [ test_iter ] ; } void * * parms_as_voids = ( void * * ) tq_calloc ( cmd_injection_session -> tq , sizeof ( void * ) * cmd_injection_session -> cmd_injection_test_set_n , 1 , BPLN ) ; for ( test_iter = 0 ; test_iter < cmd_injection_session -> cmd_injection_test_set_n ; test_iter ++ ) { parms_as_voids [ test_iter ] = ( void * ) & parameters [ test_iter ] ; } size_t * arg_lens = ( size_t * ) tq_calloc ( cmd_injection_session -> tq , cmd_injection_session -> cmd_injection_test_set_n * sizeof ( size_t ) , 1 , BPLN ) ; size_t size_iter = 0 ; for ( ; size_iter < cmd_injection_session -> cmd_injection_test_set_n ; size_iter ++ ) { arg_lens [ size_iter ] = sizeof ( void * ) ; } P_BP_THREAD_MANAGER thread_mgr = BP_CreateThreadManager ( " " , " " ) ; size_t thread_iter = 0 ; for ( ; thread_iter < thread_count ; thread_iter ++ ) { BP_CreateThread ( thread_mgr , BP_CommandInjectionRunTest_thinit , NULL , 0 , BP_FALSE ) ; } BP_ThreadedDataProcessor ( thread_mgr , ( void * * ) parms_as_voids , arg_lens , cmd_injection_session -> cmd_injection_test_set_n - 1 ) ; BP_DestroyThreadManager ( thread_mgr ) ; return ERR_SUCCESS ; }
This routine will attempt to run all command injection tests which are not
marked as disabled.
This routine will attempt to run all command injection tests which are not marked as disabled .
// ensure we have a valid session // allocate space for parameters // set all the tests // set the session // set the test // parameters must be passed as voids // set the session // set argument lengths // create a new thread manager to run results with // add threads // run the tests // destroy the thread manager // return indicating success