library/src/exploitation/Utilities/PHP/GadgetGenerators/BP-PHPGadgetGenerators.cc
// Adds arguments to a gadget.  Max php symbol length set to 256 bytes.
Adds arguments to a gadget.  Max php symbol length set to 256 bytes.
Adds arguments to a gadget . Max php symbol length set to 256 bytes .
BP_ERROR_T BP_PHPGadgetAddRuntimeArgument
(
		P_BP_PHP_GADGET        gadget,
		BP_GADGET_ARG_TYPE     type,
		char                   *arg_php_symbol
)
{
	if(!gadget)
		return ERR_FAILURE;
	if(!type)
		return ERR_FAILURE;
	if(!arg_php_symbol)
		return ERR_FAILURE;
	if(!gadget->runtime_tq)
	{
		gadget->runtime_tq = BP_CreateLinkL("PHP Gadget Runtime Allocator", BP_TRUE);
	}
	P_BP_LINKL tq = gadget->runtime_tq;
	gadget->arguments = (P_BP_PHP_GADGET_ARG) tq_realloc(tq, gadget->arguments, sizeof(BP_PHP_GADGET_ARG) * (gadget->arguments_n+1), BPLN);
	if(!gadget->arguments)
		return ERR_FAILURE;
	memset(&gadget->arguments[gadget->arguments_n], 0x00, sizeof(BP_PHP_GADGET_ARG));
	gadget->arguments[gadget->arguments_n].arg_php_symbol = (char *) tq_strndup(tq, arg_php_symbol, 256, BPLN);
	gadget->arguments[gadget->arguments_n].arg_required_for_run = BP_TRUE;
	gadget->arguments[gadget->arguments_n].type = type;
	gadget->arguments[gadget->arguments_n].arg_has_been_set = BP_FALSE;
	gadget->arguments_n++;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_PHPGadgetAddRuntimeArgument ( P_BP_PHP_GADGET gadget , BP_GADGET_ARG_TYPE type , char * arg_php_symbol ) { if ( ! gadget ) return ERR_FAILURE ; if ( ! type ) return ERR_FAILURE ; if ( ! arg_php_symbol ) return ERR_FAILURE ; if ( ! gadget -> runtime_tq ) { gadget -> runtime_tq = BP_CreateLinkL ( " " , BP_TRUE ) ; } P_BP_LINKL tq = gadget -> runtime_tq ; gadget -> arguments = ( P_BP_PHP_GADGET_ARG ) tq_realloc ( tq , gadget -> arguments , sizeof ( BP_PHP_GADGET_ARG ) * ( gadget -> arguments_n + 1 ) , BPLN ) ; if ( ! gadget -> arguments ) return ERR_FAILURE ; memset ( & gadget -> arguments [ gadget -> arguments_n ] , 0x00 , sizeof ( BP_PHP_GADGET_ARG ) ) ; gadget -> arguments [ gadget -> arguments_n ] . arg_php_symbol = ( char * ) tq_strndup ( tq , arg_php_symbol , 256 , BPLN ) ; gadget -> arguments [ gadget -> arguments_n ] . arg_required_for_run = BP_TRUE ; gadget -> arguments [ gadget -> arguments_n ] . type = type ; gadget -> arguments [ gadget -> arguments_n ] . arg_has_been_set = BP_FALSE ; gadget -> arguments_n ++ ; return ERR_SUCCESS ; }
Adds arguments to a gadget.
Adds arguments to a gadget .
// create runtime tail queue allocator if unset // set runtime allocator for ease of use // create space for arguments // initialize memory as 0x00, this is to make valgrind shut up about uninitialized // data. // set php symbol by using strndup // mark gadget as required (default) // set gadget data type // set flag indicating that the argument has been set // increment the gadget count // return failure if we were unable to build the argument