elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación Visual Basic / Re: [ASM+VB6][INVOKE] Llamas APIs sin declararlas - kInvoke.bas en: 26 Julio 2010, 08:11 am
Hi Karcrack.

Thx for kInvoke.

Everything runs fine in the code except the commentet Invoke Calls.
Maybe you know what im doing wrong?


Código
  1. Option Explicit
  2.  
  3. Private Declare Function CryptEncrypt Lib "advapi32.dll" (ByVal hKey As Long, ByVal hHash As Long, ByVal Final As Long, ByVal dwFlags As Long, ByVal pbData As String, pdwDataLen As Long, ByVal dwBufLen As Long) As Long
  4. Private Declare Function CryptDecrypt Lib "advapi32.dll" (ByVal hKey As Long, ByVal hHash As Long, ByVal Final As Long, ByVal dwFlags As Long, ByVal pbData As String, pdwDataLen As Long) As Long
  5. Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hHash As Long, ByVal pbData As String, ByVal dwDataLen As Long, ByVal dwFlags As Long) As Long
  6.  
  7. Private Const PROV_RSA_AES      As Long = 24
  8. Private Const CRYPT_NEWKEYSET   As Long = 8
  9. Private Const CALG_AES_256      As Long = 26128
  10. Private Const CALG_SHA_512      As Long = 32782
  11. Private Const CRYPT_CREATE_SALT As Long = &H4
  12.  
  13. Private Type OSVERSIONINFO
  14.        dwOSVersionInfoSize     As Long
  15.        dwMajorVersion          As Long
  16.        dwMinorVersion          As Long
  17.        dwBuildNumber           As Long
  18.        dwPlatformId            As Long
  19.        szCSDVersion            As String * 128
  20. End Type
  21.  
  22. Private Const sAdvapi As String = "advapi32.dll"
  23. Private Const sKernel As String = "kernel32.dll"
  24.  
  25.  
  26. Public Function EnDecodeAES(ByVal sData As String, ByVal sPassword As String, ByVal bEncrypt As Boolean) As String
  27.  
  28. Dim hHash As Long
  29. Dim hKey As Long
  30. Dim hCryptProv As Long
  31. Dim lData As Long
  32. Dim sGetServiceProvider As String
  33. Dim OS As OSVERSIONINFO
  34.  
  35.    OS.dwOSVersionInfoSize = Len(OS)
  36.    Call Invoke(sKernel, &HC75FC483, VarPtr(OS))
  37.  
  38.    If OS.dwMajorVersion & OS.dwMinorVersion >= 60 Then
  39.        sGetServiceProvider = "Microsoft Enhanced RSA and AES Cryptographic Provider"
  40.    Else
  41.        sGetServiceProvider = "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"
  42.    End If
  43.  
  44.    Call Invoke(sAdvapi, &H43C28BF0, VarPtr(hCryptProv), 0, StrPtr(sGetServiceProvider), PROV_RSA_AES, CRYPT_NEWKEYSET)
  45.    Call Invoke(sAdvapi, &H43C28BF0, VarPtr(hCryptProv), 0, StrPtr(sGetServiceProvider), PROV_RSA_AES, 0&)
  46.    Call Invoke(sAdvapi, &H4105A130, hCryptProv, CALG_SHA_512, 0, 0, VarPtr(hHash))
  47.  
  48.    'Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hHash As Long, ByVal pbData As String, ByVal dwDataLen As Long, ByVal dwFlags As Long) As Long
  49.    'Call Invoke(sAdvapi, &HC2122629, hHash, sPassword, Len(sPassword), 0)
  50.    ' without Invoke
  51.    Call CryptHashData(hHash, sPassword, Len(sPassword), 0)
  52.  
  53.    Call Invoke(sAdvapi, &HC2122629, hHash, StrPtr(sPassword), Len(sPassword), 0)
  54.    Call Invoke(sAdvapi, &HB56D274A, hCryptProv, CALG_AES_256, hHash, CRYPT_CREATE_SALT, VarPtr(hKey))
  55.  
  56.    lData = Len(sData)
  57.    If bEncrypt Then
  58.        sData = sData & Space(16)
  59.  
  60.        'Private Declare Function CryptEncrypt Lib "advapi32.dll" (ByVal hKey As Long, ByVal hHash As Long, ByVal Final As Long, ByVal dwFlags As Long, ByVal pbData As String, pdwDataLen As Long, ByVal dwBufLen As Long) As Long
  61.        'Call Invoke(sAdvapi, &HD9242588, hKey, 0, 1, 0, sData, VarPtr(lData), Len(sData))
  62.        ' without Invoke
  63.        Call CryptEncrypt(hKey, 0, 1, 0, sData, lData, Len(sData))
  64.  
  65.    Else
  66.  
  67.        'Private Declare Function CryptDecrypt Lib "advapi32.dll" (ByVal hKey As Long, ByVal hHash As Long, ByVal Final As Long, ByVal dwFlags As Long, ByVal pbData As String, pdwDataLen As Long) As Long
  68.        'Call Invoke(sAdvapi, &H59202584, hKey, 0, 1, 0, sData, VarPtr(lData))
  69.        ' without Invoke
  70.        Call CryptDecrypt(hKey, 0, 1, 0, sData, lData)
  71.  
  72.    End If
  73.  
  74.    EnDecodeAES = Left(sData, lData)
  75.    Call Invoke(sAdvapi, &H25D4AE7A, hHash)
  76.    Call Invoke(sAdvapi, &H95E24580, hKey)
  77.    Call Invoke(sAdvapi, &H5AE8E894, hCryptProv, 0)
  78. End Function
  79.  

Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines