Visual C++'da üretilen dll güvenilir midir ?

Başlatan AsHeS, 19 Haziran 2014, 16:04:27

AsHeS

Visual Studio'da C++ geliştireceğim bir dll dosyası mevcut ilgili dosyayı C# ile tasarlanan GUI ile birlikte kullanılacak. Şimdi sorum şu Visual C++'dan çıkan dll dosyası .net dll leri gibi hızlıca decompile edilebilir mi ?
GCC ile ortaya çıkardığımız C++ dll leri içinde aynı soru geçerlidir.

Ayrıca Java'da metod var mıdır aynı kod güvenliği işini yapmak için.

barisertekin

Normal C++ için hiç bir zaman ana koda geri dönüş yapılamayacağını söylüyorlar. Ama Visual C++ için bir şey söylemem zor. C# gibi önce ara dile (IL) çevrilip oradan çalışma zamanında makine koduna çevriliyor.

Elemanın biri C#'ı decompile için kullandığımız reflector programı ile C++ decompile etmeyi denemiş olmamış. Aşağıda onu soruyor.

Soru : I am able to decompile .net dll files with reflector. But in reflector we can't decompile c++ dll files.


Cevap 1 : It's not that easy. C++ gets translated into (sometimes) very optimized machine code.
There's a detailed article on http://www.codeproject.com/Articles/4210/C-Reverse-Disassembly containing more information.


Cevap 2 : Unlike CLR languages, C++ does not compile into CIL or any sort of bytecode. Moreover, C++ compilers do not store metadata so it's almost impossible to restore original code (custom types, classes, etc).

ahmets

Daha güvenilir ama .net dll'leri gibi kolayca olmasa da hepsi decompile edilebilir.
Decompile edenin tecrübesi, kullandığı tool'lar ve harcanan zaman en önemli etkenler.
Bu konuda Java ile .net'i birbirine eşit düşünebilirsiniz.

Fikir vermesi için W7 System32 klasöründeki user32.dll'i ida pro ile açtım.
GetMessageA fonksiyonuna gelip hex-rays ile tek tuşa basarak otomatik decompile ettim ,sonuç aşağıda:

BOOL __stdcall GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
{
  UINT v4; // ecx@1
  char *v5; // edi@3
  int v6; // eax@4
  int v8; // esi@14
  int v9; // esi@21
  unsigned __int16 v10; // bx@21
  BOOL wMsgFilterMina; // [sp+14h] [bp+10h]@3

  v4 = wMsgFilterMax;
  if ( (wMsgFilterMax | wMsgFilterMin) & 0xFFFE0000 )
  {
    if ( wMsgFilterMax != -1 || wMsgFilterMin & 0xFFFE0000 )
    {
      sub_7DC73687(87);
      return 0;
    }
    v4 = 0;
  }
  if ( !*(_QWORD *)(*(_DWORD *)(__readfsdword(24) + 3952) + 2224)
    || (wMsgFilterMin || v4) && (wMsgFilterMin > 0x102 || v4 < 0x102) )
  {
    v5 = (char *)&lpMsg->wParam;
    wMsgFilterMina = sub_7DC678C2((char)lpMsg, hWnd, wMsgFilterMin, v4);
    if ( sub_7DC67B79(lpMsg->message, (LPCWSTR)&lpMsg->wParam) )
    {
      v6 = *(_DWORD *)v5;
      if ( *(_BYTE *)qword_7DCD0138 & 2 && (lpMsg->message == 204 || lpMsg->message == 258) )
      {
        if ( v6 & 0xFF00 )
        {
          if ( v6 >= 0 )
          {
            v9 = *(_DWORD *)(__readfsdword(24) + 3952) + 2208;
            v10 = BYTE1(v6) | (unsigned __int16)((unsigned __int8)v6 << 8);
            sub_7DCAFF19(v9, (int)lpMsg);
            *(_DWORD *)(v9 + 20) = 0;
            *(_DWORD *)(v9 + 16) = v10 >> 8;
            *(_DWORD *)v5 = (unsigned __int8)v10;
            return wMsgFilterMina;
          }
          v6 = (unsigned __int16)v6;
        }
        else
        {
          v6 = (unsigned __int8)v6;
        }
        *(_DWORD *)v5 = v6;
        return wMsgFilterMina;
      }
    }
    else
    {
      wMsgFilterMina = 0;
    }
  }
  else
  {
    v8 = *(_DWORD *)(__readfsdword(24) + 3952) + 2208;
    sub_7DCC0969((int)lpMsg, v8);
    *(_DWORD *)(v8 + 16) = 0;
    *(_DWORD *)(v8 + 20) = 0;
    wMsgFilterMina = 1;
  }
  return wMsgFilterMina;
}

Daha temiz çeviri yapması için bazı pluginler var ve piyasaya çıkmayan daha gelişmiş reverse engineering toolları olduğunu düşünüyorum.