library/src/datastructures/BP-BufferUtilities.cc
// prints shellcode styled hexidecimal, given one
// of the above style specifiers
prints shellcode styled hexidecimal, given one
of the above style specifiers
prints shellcode styled hexidecimal given one of the above style specifiers
int PrintShellcodeToStyle(char *sc, int scLen, int style)
{
	int i = 0;
	if(scLen <= 0)
		return ERR_FAILURE;
	switch(style){
		case SC_C_STYLE:
			printf("char shellcode[] = \"");
			break;			
		case SC_C_STYLE_UNSIGNED:
			printf("unsigned char shellcode[] = \"");
			break;			
		case SC_PERL_ARGV:			
			printf("`perl -e 'print(\"");
			break;
		case SC_PERL_SCALAR:			
			printf("$shellcode = \"");
			break;
		default:
			return ERR_FAILURE;
	}
     for(i = 0; i <=scLen; i++){
            printf("\\x%.2x", (unsigned char) sc[i]);
     }
	 switch(style){
		case SC_C_STYLE:
			printf("\";");
			break;			
		case SC_C_STYLE_UNSIGNED:
			printf("\";");
			break;			
		case SC_PERL_ARGV:			
			printf("\");'`");
			break;
		case SC_PERL_SCALAR:			
			printf("\";");
			break;
		default:
			return ERR_FAILURE;
	}
   	printf("\n");
	return ERR_SUCCESS;
}
int PrintShellcodeToStyle ( char * sc , int scLen , int style ) { int i = 0 ; if ( scLen <= 0 ) return ERR_FAILURE ; switch ( style ) { case SC_C_STYLE : printf ( " \" " ) ; break ; case SC_C_STYLE_UNSIGNED : printf ( " \" " ) ; break ; case SC_PERL_ARGV : printf ( " \" " ) ; break ; case SC_PERL_SCALAR : printf ( " \" " ) ; break ; default : return ERR_FAILURE ; } for ( i = 0 ; i <= scLen ; i ++ ) { printf ( " \\ " , ( unsigned char ) sc [ i ] ) ; } switch ( style ) { case SC_C_STYLE : printf ( " \" " ) ; break ; case SC_C_STYLE_UNSIGNED : printf ( " \" " ) ; break ; case SC_PERL_ARGV : printf ( " \" " ) ; break ; case SC_PERL_SCALAR : printf ( " \" " ) ; break ; default : return ERR_FAILURE ; } printf ( " \n " ) ; return ERR_SUCCESS ; }
prints shellcode styled hexidecimal, given one
of the above style specifiers
prints shellcode styled hexidecimal given one of the above style specifiers
// signed char buffer  style // unsigned char buffer style // `perl -e 'print("");'` style // perl $var = "" style // signed char buffer  style // unsigned char buffer style // `perl -e 'print("");'` style // perl $var = "" style