Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: ZoNike en 22 Octubre 2008, 22:57 pm



Título: Declarando una Libreria en VB6
Publicado por: ZoNike en 22 Octubre 2008, 22:57 pm
Buenas a todos, abro este post para exponer mi problema.
He conseguido un codigo en C/C++ que lo que hace es cargar una libreria utilizando la funcion LoadLibrary, GetProcAddress y FreeLibrary.
Lo que yo quiero es hacer lo mismo que hace ese codigo en C/C++ pero en VB6, he intentado hacerlo declarando la libreria utilizando (Declare Function "taltal" lib "libreria.dll"), y tambien declarando la funcion LoadLibrary y demas he intentando usarla para cargar la otra libreria.. pero de ningun modo he podido conseguir que funcionase.
El problema esque en mi codigo vb6 me devuelve el string "salida" y el integer "ret" vacios. Me han dicho algo de que debo reservar un espacio de memoria para que la funcion pueda guardar los datos de salida, pero no se como hacerlo..

Aqui os dejo los 2 codigos, el MIO creado en VB6:

Código
  1. Private Declare Function descifrar Lib "Steam.dll" Alias "SteamDecryptDataForThisMachine" _
  2. (ByRef encpwd As String, ByVal encpwdlen As Long, ByRef pwd As String, ByVal pwdlen As Long, ByRef ret As Integer) As Long
  3.  
  4. Private Sub Form_Load()
  5. Dim clave As String
  6. Dim salida As String
  7. Dim ret As Integer
  8.  
  9. clave = "FB438E0EE7653893D139C47160AC11A6E6E5EE661F1AE5D7A83337D0F6CB8972254FB1165DB4F0711F8FFBC07377"
  10.  
  11. descifrar clave, Len(clave), salida, Len(salida), ret
  12.  
  13. MsgBox "Phrase: " & clave & vbCrLf & _
  14.        "Len(Phrase): " & Len(clave) & vbCrLf & vbCrLf & _
  15.        "Password: " & salida & vbCrLf & _
  16.        "Len(Password): " & ret
  17. End
  18. End Sub




y el codigo que encontré en C/C++:

Código
  1. /*
  2. by Luigi Auriemma
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <stdint.h>
  8. #include <windows.h>
  9.  
  10. typedef int (__stdcall *SteamDecryptDataForThisMachine_t)(char *a, int b, char *c, int d, int *e);
  11.  
  12.  
  13. int main(int argc, char *argv[]) {
  14.    SteamDecryptDataForThisMachine_t    SteamDecryptDataForThisMachine;
  15. HANDLE  dll;
  16.    int     len;
  17.    char    pwd[100],
  18.            *encpwd;
  19.  
  20.    if(argc < 2) {
  21.        printf("\n"
  22.            "Usage: %s <encrypted_password>\n"
  23.            "\n", argv[0]);
  24.        exit(1);
  25.    }
  26.    encpwd = argv[1];
  27.  
  28. dll = LoadLibrary("STEAM.DLL");
  29. if(!dll) {
  30.        printf("\nError: the file STEAM.DLL has not been found\n");
  31.        exit(1);
  32.    }
  33.    SteamDecryptDataForThisMachine = (void *)GetProcAddress(dll, "SteamDecryptDataForThisMachine");
  34.    if(!SteamDecryptDataForThisMachine) {
  35.        printf("\nError: the function SteamDecryptDataForThisMachine has not been found\n");
  36.        exit(1);
  37.    }
  38.  
  39.    if(!SteamDecryptDataForThisMachine(encpwd, strlen(encpwd), pwd, sizeof(pwd), &len)) {
  40.        printf("\n  password: %.*s\n", len, pwd);
  41.    } else {
  42.        printf("\nError: you can't decrypt this encrypted password\n");
  43.    }
  44.    FreeLibrary(dll);
  45.    return(0);
  46. }