library/src/exploitation/WebExploitation/CommandExecution/BP-WebExploitationCommandExecution.cc
// Attempt to parse html forms for new targets.
Attempt to parse html forms for new targets.
Attempt to parse html forms for new targets .
BP_ERROR_T BP_CommandInjectionParseHtmlFormsForNewTargets
(
		P_BP_WEB_COMMAND_INJECTION_TEST_SESSION cmd_injection_session,
		P_BP_HTML_FORM_LIST                    forms
)
{
	if(!cmd_injection_session)
		return ERR_FAILURE;
	if(!forms)
		return ERR_FAILURE;
	P_BP_HTML_FORM_LIST form_saved_first = forms->first;
	P_BP_HTML_INPUT_LIST form_input_list = NULL;
	size_t form_test_n = 0;
	for
	(
			forms = forms->first;
			forms;
			forms = forms->next
	)
	{
		if(!forms->inputs)
			continue;
		form_input_list = forms->inputs->first;
		if(!form_input_list)
			continue;
		if(!form_input_list->properties)
			continue;
		for
		(
			;
			form_input_list;
			form_input_list = form_input_list->next
		)
		{
			form_test_n++;
		}
	}
	size_t inital_index = 0;
	if(cmd_injection_session->cmd_injection_test_set_n)
		inital_index = cmd_injection_session->cmd_injection_test_set_n;
	cmd_injection_session->cmd_injection_test_set = (P_BP_WEB_COMMAND_INJECTION_TEST) tq_realloc
	(
		cmd_injection_session->tq,
		cmd_injection_session->cmd_injection_test_set,
		sizeof(BP_WEB_COMMAND_INJECTION_TEST) * (form_test_n + cmd_injection_session->cmd_injection_test_set_n + 1),
		BPLN
	);
	memset
	(
		&cmd_injection_session->cmd_injection_test_set[inital_index],
		0x00,
		sizeof(BP_WEB_COMMAND_INJECTION_TEST) * form_test_n
	);
	P_BP_WEB_COMMAND_INJECTION_TEST test = NULL;
	for
	(
			forms = form_saved_first;
			forms;
			forms = forms->next
	)
	{
		if(!forms->inputs)
			continue;
		form_input_list = forms->inputs->first;
		if(!form_input_list)
			continue;
		if(!form_input_list->properties)
			continue;
		for
		(
			;
			form_input_list;
			form_input_list = form_input_list->next
		)
		{
			test = &cmd_injection_session->cmd_injection_test_set[inital_index];
			test->is_form_test = BP_TRUE;
			test->form       = forms;
			 input
			test->form_input = form_input_list;
			cmd_injection_session->cmd_injection_test_set_n++;
			inital_index++;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_CommandInjectionParseHtmlFormsForNewTargets ( P_BP_WEB_COMMAND_INJECTION_TEST_SESSION cmd_injection_session , P_BP_HTML_FORM_LIST forms ) { if ( ! cmd_injection_session ) return ERR_FAILURE ; if ( ! forms ) return ERR_FAILURE ; P_BP_HTML_FORM_LIST form_saved_first = forms -> first ; P_BP_HTML_INPUT_LIST form_input_list = NULL ; size_t form_test_n = 0 ; for ( forms = forms -> first ; forms ; forms = forms -> next ) { if ( ! forms -> inputs ) continue ; form_input_list = forms -> inputs -> first ; if ( ! form_input_list ) continue ; if ( ! form_input_list -> properties ) continue ; for ( ; form_input_list ; form_input_list = form_input_list -> next ) { form_test_n ++ ; } } size_t inital_index = 0 ; if ( cmd_injection_session -> cmd_injection_test_set_n ) inital_index = cmd_injection_session -> cmd_injection_test_set_n ; cmd_injection_session -> cmd_injection_test_set = ( P_BP_WEB_COMMAND_INJECTION_TEST ) tq_realloc ( cmd_injection_session -> tq , cmd_injection_session -> cmd_injection_test_set , sizeof ( BP_WEB_COMMAND_INJECTION_TEST ) * ( form_test_n + cmd_injection_session -> cmd_injection_test_set_n + 1 ) , BPLN ) ; memset ( & cmd_injection_session -> cmd_injection_test_set [ inital_index ] , 0x00 , sizeof ( BP_WEB_COMMAND_INJECTION_TEST ) * form_test_n ) ; P_BP_WEB_COMMAND_INJECTION_TEST test = NULL ; for ( forms = form_saved_first ; forms ; forms = forms -> next ) { if ( ! forms -> inputs ) continue ; form_input_list = forms -> inputs -> first ; if ( ! form_input_list ) continue ; if ( ! form_input_list -> properties ) continue ; for ( ; form_input_list ; form_input_list = form_input_list -> next ) { test = & cmd_injection_session -> cmd_injection_test_set [ inital_index ] ; test -> is_form_test = BP_TRUE ; test -> form = forms ; test -> form_input = form_input_list ; cmd_injection_session -> cmd_injection_test_set_n ++ ; inital_index ++ ; } } return ERR_SUCCESS ; }
Attempt to parse html forms for new targets.
Attempt to parse html forms for new targets .
// ensure we have sessions // ensure we have forms to parse // save first pointer // form input list used for iterating through forms // the form test count // acquire test count // require inputs // set form input list // must have inputs to add elements // form must have properties (aka the name property) // walk form input list // increase the form test count // set inital index position // attempt to (re)allocate memory // zero new memory // command injection test reference, here for adding code readability // acquire test count // require inputs // set form input list // must have inputs to add elements // must have properties // walk form input list // -- Set Values --------------------- // set test at index // form test // set the form // set the form input // increment test set // increase the form test count // return indicating success