static uint8_t SetWEPKey(const char *password)
{
    int keyLength = strlen(password);
    DRV_WIFI_WEP_CONTEXT context;
    if (keyLength == WEP104_KEY_LENGTH)
    {
        context.wepSecurityType = DRV_WIFI_SECURITY_WEP_104;
        context.wepKeyLength = 13;
    }
    else
    {
        context.wepSecurityType = DRV_WIFI_SECURITY_WEP_40;
        context.wepKeyLength = 5;
    }
    int wepKeyIndex = 0;
    int keyCharIndex = 0;
    for (keyCharIndex = 0; keyCharIndex < keyLength; keyCharIndex += 2, wepKeyIndex++)
    {
        uint8_t byteValue = ((GetHexValue(password[keyCharIndex]) << 4) + GetHexValue(password[keyCharIndex + 1]));
        context.wepKey[wepKeyIndex] = byteValue; // it contains 4 keys make all the same
        context.wepKey[wepKeyIndex + context.wepKeyLength] = byteValue;
        context.wepKey[wepKeyIndex + (context.wepKeyLength * 2)] = byteValue;
        context.wepKey[wepKeyIndex + (context.wepKeyLength * 3)] = byteValue;
    }
    context.wepKeyType = DRV_WIFI_SECURITY_WEP_OPENKEY;
    DRV_WIFI_SecurityWepSet(&context);
    return context.wepSecurityType;
}
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : GetSpair
* Returned Value : unsigned char, converted hex byte
* Comments       : Gets pair of characters, and converts to hex byte
*
*END*--------------------------------------------------------------------*/
static uint_8
GetSpair
    (
        /* [IN] the array to parse */
        uint_8 *arr,
        /* [IN] point to array data */
        uint_8 point
    )
{
    /* Body */
    uint_8 ch;
    uint_8 upper,lower;
    ch = arr[point];
    upper = (uint_8)(GetHexValue(ch));
    if(upper == 0xFF)
    {
        /* Not a proper S19 file */
        S19FileDone = TRUE;
    } /* EndIf */
    upper = (uint_8)(upper << 4);
    ch=arr[point+1];
    lower= (uint_8)(GetHexValue(ch));
    if(lower == 0xFF)
    {
        /* Not a proper S19 file */
        S19FileDone = TRUE;
    } /* EndIf */
    return (uint_8)(upper | lower);
} /* EndBody */
Example #3
0
EFI_STATUS
ConvertToBuffer(
  UINT16  *String,
  UINT8   *Data
  )
{
  UINT8      TempData1;
  UINT8      TempData2;
  EFI_STATUS Status;

  if(*(String+1) == '\0'){
    Status = GetHexValue(*String, Data);
    if(EFI_ERROR(Status)){
      return EFI_INVALID_PARAMETER;
    }
    return EFI_SUCCESS;
  }

  if(EFI_ERROR(GetHexValue(*String, &TempData1)) || EFI_ERROR(GetHexValue((*(String+1)), &TempData2))){
    return EFI_INVALID_PARAMETER;
  }
  *Data = (TempData1 << 0x04 | TempData2);

  return EFI_SUCCESS;
}
Example #4
0
DWORD ReadPage(HANDLE m_hProcess, DWORD dwBaseAddr, char* Value)
{
	//读取1页内存
	BYTE arBytes[4096];
	if (!::ReadProcessMemory(m_hProcess, (LPVOID)dwBaseAddr, arBytes, 4096, NULL))
	{
		//此页不可读
		return (DWORD) - 1;
	}
	else
	{
		//
		//unsigned char key[] = {0x80, 0x7f, 0x49, 0x00};
		unsigned char Value2[1024];
		strcpy((char*)Value2, Value);
		int len = GetHexValue((char*)Value2);
		//getchar();
		//注释这两行是低效的算法
		//char key[] = {0x80, 0x7f, 0x49, 0x00};
		//int len = 4;
		//if (memstr(key, len, (char*)arBytes, 4096) != 0) return memstr(key, len, (char*)arBytes, 4096) - (unsigned char*)arBytes;
		//else return -1;

		//开始sunday算法
		long *charStep = setCharStep(Value2, len);
		return sundaySearch(arBytes, Value2, charStep, 4096, len);
	}
	return (DWORD) - 1;	//不会执行到此处
}