library/src/exploitation/ModularExploitation/BP-ModularExploitation.cc
// Load an exploit module into the current session
Load an exploit module into the current session
Load an exploit module into the current session
BP_ERROR_T BP_MEInitExploitModule
(
		P_BP_MODULAR_EXPLOITATION_SESSION session,
		P_BP_EXPLOIT_MODULE               module,
		void                              *mod_user_arguments
)
{
	if(!session)
		return ERR_FAILURE;
	if(!module)
		return ERR_FAILURE;
	if(!session->modules && !session->module_n)
	{
		session->modules = (P_BP_EXPLOIT_MODULE*) tq_calloc(session->tq, sizeof(P_BP_EXPLOIT_MODULE) * 2, 1, BPLN);
		session->module_n = 1;
		session->modules[0] = module;
		module->mod_user_arguments = mod_user_arguments;
		if(module->exploit_init_fn)
		{
			module->exploit_init_fn(NULL);
		}
		module->current_module     = module;
		module->current_session    = session;
		module->mod_status = BP_EXPLOIT_MODULE_STATUS_INITIALIZED;
		module->mod_run_status = BP_EXPLOIT_MODULE_RUN_STATUS_IDLE;
		return ERR_SUCCESS;
	}
	else if(session->modules && session->module_n)
	{
		session->module_n++;
		session->modules = (P_BP_EXPLOIT_MODULE*) tq_realloc(session->tq, (void *) session->modules,  sizeof(P_BP_EXPLOIT_MODULE) * (session->module_n+1), BPLN);
		session->modules[session->module_n-1] = module;
		session->modules[session->module_n] = NULL;
		module->mod_user_arguments = mod_user_arguments;
		if(module->exploit_init_fn)
		{
			module->exploit_init_fn(NULL);
		}
		module->current_module  = module;
		module->current_session = session;
		module->mod_status = BP_EXPLOIT_MODULE_STATUS_INITIALIZED;
		module->mod_run_status = BP_EXPLOIT_MODULE_RUN_STATUS_IDLE;
		return ERR_SUCCESS;
	}
	else 
		return ERR_FAILURE;
	return ERR_FAILURE;
}
BP_ERROR_T BP_MEInitExploitModule ( P_BP_MODULAR_EXPLOITATION_SESSION session , P_BP_EXPLOIT_MODULE module , void * mod_user_arguments ) { if ( ! session ) return ERR_FAILURE ; if ( ! module ) return ERR_FAILURE ; if ( ! session -> modules && ! session -> module_n ) { session -> modules = ( P_BP_EXPLOIT_MODULE * ) tq_calloc ( session -> tq , sizeof ( P_BP_EXPLOIT_MODULE ) * 2 , 1 , BPLN ) ; session -> module_n = 1 ; session -> modules [ 0 ] = module ; module -> mod_user_arguments = mod_user_arguments ; if ( module -> exploit_init_fn ) { module -> exploit_init_fn ( NULL ) ; } module -> current_module = module ; module -> current_session = session ; module -> mod_status = BP_EXPLOIT_MODULE_STATUS_INITIALIZED ; module -> mod_run_status = BP_EXPLOIT_MODULE_RUN_STATUS_IDLE ; return ERR_SUCCESS ; } else if ( session -> modules && session -> module_n ) { session -> module_n ++ ; session -> modules = ( P_BP_EXPLOIT_MODULE * ) tq_realloc ( session -> tq , ( void * ) session -> modules , sizeof ( P_BP_EXPLOIT_MODULE ) * ( session -> module_n + 1 ) , BPLN ) ; session -> modules [ session -> module_n - 1 ] = module ; session -> modules [ session -> module_n ] = NULL ; module -> mod_user_arguments = mod_user_arguments ; if ( module -> exploit_init_fn ) { module -> exploit_init_fn ( NULL ) ; } module -> current_module = module ; module -> current_session = session ; module -> mod_status = BP_EXPLOIT_MODULE_STATUS_INITIALIZED ; module -> mod_run_status = BP_EXPLOIT_MODULE_RUN_STATUS_IDLE ; return ERR_SUCCESS ; } else return ERR_FAILURE ; return ERR_FAILURE ; }
Load an exploit module into the current session
Load an exploit module into the current session
// ensure we have a session // check if we have any modules loaded, create if necessary, if not -- realloc. // allocate space for 2 pointers // set initial module count to 1 // set pointer to the module in the pointer set // set user arguments before initialization // call module load routine if it exists // set self referential pointers // set status flag in initialization position // set run flag as idle // at this point we can return successfully // increment module count // reallocate pointer array to fit new module // set the module here so the class has reference // nullify the ending pointer since realloc doesn't // set user arguments before initialization // call module load routine if it exists // set self referential pointers // set status flag in initialization position // set run flag as idle // at this point we can return successfully /* in the case of bad data, return here */ // return indicating failure