Example #1
0
bool test_01_masking( )
{
	char mask[4];
	int mask_value;
	char buffer[1024];
	LES_SSL_Context* ctx;

	/* clear buffer */
	memset( buffer , 0 , 1024 );

	/* create context */
	ctx = les_ssl_context_new( );

	mask_value = rand( );

	printf( "Test-01 masking: using masking value %d\n" , mask_value );
	set_32bit( mask_value , mask );

	memcpy( buffer , "This is a test value" , 20 );
	les_ssl_conn_mask_content( ctx , buffer , 20 , mask , 0 );

	if( strncmp( buffer , "This is a test value" , 20 ) == 0 )
	{
		printf( "ERROR: expected to find different values after masking but found the same..\n" );
		return false;
	}

	///* revert changes */
	les_ssl_conn_mask_content( ctx , buffer , 20 , mask , 0 );

	if( strncmp( buffer , "This is a test value" , 20 ) != 0 )
	{
		printf( "ERROR: expected to find SAME values after masking but found the same..\n" );
		return false;
	} /* end if */

	  /* now check transfering these values to the mask */
	if( get_32bit( mask ) != mask_value )
	{
		printf( "ERROR: found failure while reading the mask from from buffer..\n" );
		return false;
	}
	printf( "Test 01 masking: found mask in the buffer %d == %d\n" ,
		get_32bit( mask ) , mask_value );

	les_ssl_ctx_unref( ctx );
	return true;
}
Example #2
0
/*
*				模式说明
*	1、MODE_ARMOP_Code -> 使用ARM指令修改CODE
*	2、MODE_ARMOP_SysCall -> 注释系统调用
*/
int Arm_Moudle(int inFlag){
	static int Mode_Bit = MODE_ARMOPC32_JMP;
	static int ModeOption = 0;
	ea_t _ThisEa = get_screen_ea();
	if (inFlag != Flag_Again)
		if (AskUsingForm_c(ASK_ARM_UI, &ModeOption) == 0)
			return NULL;
	if (MODE_ARMOP_Code == ModeOption){
		if (inFlag != Flag_Again)
			if (AskUsingForm_c(ASK_CODE_UI, &Mode_Bit) == 0)
				return NULL;
		if (MODE_ARMOPC16_JMP == Mode_Bit){
			_ThisEa &= 0xFFFFFFFE;
			patch_long(_ThisEa, 0xE7FE);
		}
		else if (MODE_ARMOPC16_NOP == Mode_Bit){
			_ThisEa &= 0xFFFFFFFE;
			patch_word(_ThisEa, 0xC046);
		}
		else if (MODE_ARMOPC32_JMP == Mode_Bit){
			_ThisEa &= 0xFFFFFFFC;
			patch_long(_ThisEa, 0xEAFFFFFE);
		}
		else if (MODE_ARMOPC32_NOP == Mode_Bit){
			_ThisEa &= 0xFFFFFFFC;
			patch_long(_ThisEa, 0xE1A00000);
		}
	}
	else if(MODE_ARMOP_SysCall == ModeOption){
		//自动获取,
		ulong Sys_No = get_32bit(get_screen_ea()) & 0xFFF;
		if (AskUsingForm_c(ASK_SYSCALL_UI, &Sys_No) == 0)return 0;
		if (SysCall::getName(Sys_No) != NULL){
			set_cmt(get_screen_ea(), SysCall::getName(Sys_No), 1);
		}
	}
	return NULL;
}
BOOL get_vtbl_info(ea_t ea_address, VTBL_info_t &vtbl_info)
{
	flags_t flags = getFlags(ea_address);
	if (!(hasRef(flags) || has_any_name(flags) && (isDwrd(flags) || isUnknown(flags))))
		return(FALSE);
	else
	{
		BOOL is_move_xref = FALSE;
		ea_t ea_code_ref = get_first_dref_to(ea_address);
		if (ea_code_ref && (ea_code_ref != BADADDR))
		{
			do
			{
				if (isCode(getFlags(ea_code_ref)))
				{
					LPCTSTR disasm_line = get_text_disasm(ea_code_ref);
#ifndef __EA64__
					if ((*((PUINT)disasm_line) == 0x20766F6D /*"mov "*/) && (strstr(disasm_line + 4, " offset ") != NULL))
#else
					if ((*((PUINT)disasm_line) == 0x2061656c /*"lea "*/) && (strstr(disasm_line + 4, "rcx") != NULL) && (strstr(disasm_line + 4, "const") != NULL))
#endif
					{
						is_move_xref = TRUE;
						break;
					}
				}

				ea_code_ref = get_next_dref_to(ea_address, ea_code_ref);

			} while (ea_code_ref && (ea_code_ref != BADADDR));
		}
		if (!is_move_xref)
			return(FALSE);

		ZeroMemory(&vtbl_info, sizeof(VTBL_info_t));

		// get_name(BADADDR, ea_address, vtbl_info.vtbl_name, (MAXSTR - 1));
		f_get_ea_name(&vtbl_info.vtbl_name, ea_address);
		ea_t ea_start = vtbl_info.ea_begin = ea_address;
		while (TRUE)
		{
			flags_t index_flags = getFlags(ea_address);
#ifndef __EA64__
			if (!(hasValue(index_flags) && (isDwrd(index_flags) || isUnknown(index_flags))))
#else
			if (!(hasValue(index_flags) && (isQwrd(index_flags) || isUnknown(index_flags)))) 
#endif
				break;
#ifndef __EA64__
			ea_t ea_index_value = get_32bit(ea_address);
#else
			ea_t ea_index_value = get_64bit(ea_address);
#endif

			if (!(ea_index_value && (ea_index_value != BADADDR)))
				break;

			if (ea_address != ea_start)
				if (hasRef(index_flags))
					break;

			flags_t value_flags = getFlags(ea_index_value);
			if (!isCode(value_flags))
				break;
			else
				if (isUnknown(index_flags))
#ifndef __EA64__
					doDwrd(ea_address, sizeof(DWORD));
			ea_address += sizeof(UINT);
#else
					doQwrd(ea_address, sizeof(UINT64));
			ea_address += sizeof(UINT64);
#endif
		};
#ifndef __EA64__
		if ((vtbl_info.methods = ((ea_address - ea_start) / sizeof(UINT))) > 0)
#else
		if((vtbl_info.methods = ((ea_address - ea_start) / sizeof(UINT64))) > 0)
#endif
		{
			vtbl_info.ea_end = ea_address;
			return(TRUE);
		}
		else
			return(FALSE);
	}
}