library/src/utility/BP-StringUtilities.cc
// Encodes a single character to specified selection
Encodes a single character to specified selection
Encodes a single character to specified selection
char * BP_GenPHPGadgetEncodeUChar(unsigned char val, BP_PHP_GADGET_BUFFER_ENCODE_SELECTOR selector, P_BP_LINKL tq)
{
	if(!selector)
		return NULL;
	char * gen_buff = NULL;
	char * fmt_buff = NULL;
	size_t random_selector = 0;
	switch(selector)
	{
		case BP_PHP_GADGET_BUFFER_ENCODE_ASCII_ONLY:
			return BP_GenUCharAsPHPHex(val, tq);
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_CHR_ONLY:
			return BP_GenUCharAsPHPChr(val, tq);
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_HEX_ONLY:
			return BP_GenUCharAsPHPHex(val, tq);
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_DECIMAL_ONLY:
			return BP_GenUCharAsPHPDecimal(val, tq);
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_HEX_DECIMAL:
			random_selector = BP_GenRandomUnsignedLong(1,3);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPEscapedASCII(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPHex(val, tq);
					break;
				case 3:
					return BP_GenUCharAsPHPDecimal(val, tq);
					break;
				default:
					break;
			}
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_DECIMAL:
			random_selector = BP_GenRandomUnsignedLong(1,2);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPHex(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPDecimal(val, tq);
					break;
				default:
					break;
			}
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_DECIMAL:
			random_selector = BP_GenRandomUnsignedLong(1,2);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPEscapedASCII(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPDecimal(val, tq);
					break;
				default:
					break;
			}
			break;
			case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_CHR:
				random_selector = BP_GenRandomUnsignedLong(1,2);
				switch(random_selector)
				{
					case 1:
						return BP_GenUCharAsPHPEscapedASCII(val, tq);
						break;
					case 2:
						return BP_GenUCharAsPHPChr(val, tq);
						break;
					default:
						break;
				}
				break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_HEX:
			random_selector = BP_GenRandomUnsignedLong(1,2);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPEscapedASCII(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPHex(val, tq);
					break;
				default:
					break;
			}
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_DECIMAL_ORD:
			random_selector = BP_GenRandomUnsignedLong(1,3);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPDecimal(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPHex(val, tq);
					break;
				case 3:
					return BP_GenUCharAsPHPOrd(val, tq);
				default:
					break;
			}
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_ORD:
			random_selector = BP_GenRandomUnsignedLong(1,2);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPHex(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPOrd(val, tq);
				default:
					break;
			}
			break;
		case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_DECIMAL_ORD:
			random_selector = BP_GenRandomUnsignedLong(1,2);
			switch(random_selector)
			{
				case 1:
					return BP_GenUCharAsPHPDecimal(val, tq);
					break;
				case 2:
					return BP_GenUCharAsPHPOrd(val, tq);
				default:
					break;
			}
			break;
		default:
			return NULL;
	}
	return NULL;
}
char * BP_GenPHPGadgetEncodeUChar ( unsigned char val , BP_PHP_GADGET_BUFFER_ENCODE_SELECTOR selector , P_BP_LINKL tq ) { if ( ! selector ) return NULL ; char * gen_buff = NULL ; char * fmt_buff = NULL ; size_t random_selector = 0 ; switch ( selector ) { case BP_PHP_GADGET_BUFFER_ENCODE_ASCII_ONLY : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case BP_PHP_GADGET_BUFFER_ENCODE_CHR_ONLY : return BP_GenUCharAsPHPChr ( val , tq ) ; break ; case BP_PHP_GADGET_BUFFER_ENCODE_HEX_ONLY : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case BP_PHP_GADGET_BUFFER_ENCODE_DECIMAL_ONLY : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_HEX_DECIMAL : random_selector = BP_GenRandomUnsignedLong ( 1 , 3 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPEscapedASCII ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case 3 : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_DECIMAL : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_DECIMAL : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPEscapedASCII ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_CHR : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPEscapedASCII ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPChr ( val , tq ) ; break ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_ASCII_HEX : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPEscapedASCII ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_DECIMAL_ORD : random_selector = BP_GenRandomUnsignedLong ( 1 , 3 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case 3 : return BP_GenUCharAsPHPOrd ( val , tq ) ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_HEX_ORD : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPHex ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPOrd ( val , tq ) ; default : break ; } break ; case BP_PHP_GADGET_BUFFER_ENCODE_RANDOM_DECIMAL_ORD : random_selector = BP_GenRandomUnsignedLong ( 1 , 2 ) ; switch ( random_selector ) { case 1 : return BP_GenUCharAsPHPDecimal ( val , tq ) ; break ; case 2 : return BP_GenUCharAsPHPOrd ( val , tq ) ; default : break ; } break ; default : return NULL ; } return NULL ; }
Encodes a single character to specified selection
Encodes a single character to specified selection
// ensure we have a valid value or selector // set the generated buffer to NULL // random selector used for random cases below // generate value depending on provided data // generates ascii buffer in the 'c' 'd' 'e' format // generates ascii buffer in the chr(decimal) format // generates ascii buffer as 0xff format. // generates an ascii buffer as a normal integer value // generates an ascii buffer which is randomly selected as either // ascii, hex, or decimal. // generates and ascii buffer which is randomly selected between hex // and decimal. // generates an ascii buffer which is either an ascii char, or // a decimal value. // generates an ascii buffer which is either an ascii char, or // a chr(decimal) value // generates an ascii buffer which is either an ascii char, or // an 0xFF hex encoded value. // default case, return NULL // should never get here, values should be returned in the // above switch/case.