Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Rigoberta II en 19 Abril 2012, 01:46 am



Título: Traducir de C++ a VB6
Publicado por: Rigoberta II en 19 Abril 2012, 01:46 am
Hola, necesito ver si alguien sabe o conoce algun code parecido a este pero en VB6 ya que esta hecho en C++/C.
Su función es modificar/cambiar/redireccionar la ip del juego por la de localhost ( 127.0.0.1 )

Código:
#include <windows.h>
#include <iostream>
 
using namespace std;
 
void EnableDebugPriv(); //Nos aumentamos los privilegios, para evitar problemas con permisos... (Ring 3)
 
void main() {
 
BYTE newvalue[] = {0x31, 0x00, 0x32, 0x00, 0x37, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //Este es el valor en hexadecimal, de la cadena: 1 2 7 . 0 . 0 . 1 (rellenamos con 0 los numeros del IP antiguo sobrantes)
 
HWND hwnd = FindWindow(0, "Solitario"); //Buscamos la ventana de nuestro juego/proceso (Yo hice la prueba con Solitario)
 
DWORD pid;//Declaramos la variable PID para almacenar el ID de nuestro juego/proceso
 
if(!hwnd) //Si no encontramos la ventana (el handle es nulo)
{
cout << "Error: No se pudo encontrar la ventana!" << endl;
system("pause");
exit(0);
}
else
{
GetWindowThreadProcessId(hwnd, &pid); //Obtenemos el Id del proceso (PID) en base al handle que nos devuelve FindWindow
 
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); //Abrimos el proceso con acceso total (lectura, escritura)
 
if(!hProcess) //Si no encontramos el juego/proceso (...)
{
cout << "Error: No se pudo abrir el handle" << endl;
system("pause");
exit(0);
}
else //En caso contrario
{
if (WriteProcessMemory(hProcess, //Juego/Proceso a modificar
(LPVOID)0x0100700C, //Direccion de memoria a modificar (Que en tu caso, si no es dinamica deberia ser: 0x0028B244)
&newvalue, //Nuevos bytes a cambiar (en tu caso el nuevo IP)
sizeof(newvalue), //Tamano de los bytes a modificar
NULL)) //Este parametro lo podemos dejar nulo
 
cout << "Memoria editada con exito!" << endl; //Exito!
else
cout << "Fallo al editar la memoria!" << endl; //Memoria no existente o protegida
}
CloseHandle(hProcess); //Cerramos el handle abierto anteriormente
}
system("pause");
}
 
void EnableDebugPriv()
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &tkp, sizeof tkp, NULL, NULL);
CloseHandle(hToken);
}


Título: Re: Traducir de C++ a VB6
Publicado por: raul338 en 19 Abril 2012, 01:56 am
Identifica las funciones de windows y solo las conviertes a API con sus respectivos tipos y punteros en las llamadas. Algo tedioso pero simple

FindWindows,  OpenProcess y Tokens, encontrás usos y declaraciones para vb6 en google fácilmente, solo convertí las llamadas


Título: Re: Traducir de C++ a VB6
Publicado por: Rigoberta II en 13 Mayo 2012, 01:11 am
No entiendo como hacer eso..
Necesito redireccionar el ip por el que yo quiero especie de proxy
Ip antigua : la del juego y IP nueva : 127.0.0.1 asi tiene que quedar alguien me ayuda plix?
En lo posible tiene que ser en visual basic 6


Título: Re: Traducir de C++ a VB6
Publicado por: rembolso en 13 Mayo 2012, 02:17 am
mira te e echo un ejemplo muy rapido. no lo e probado, seguro tiene errores pero  es lo q buscas, estoy apurado por irme de joda. cuando llegue te lo mejoro .
Código
  1. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
  2. Declare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long
  3. Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  4. Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
  5. Private Const ProAcceall As Long = &H1F0FFF
  6. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
  7. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  8. Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseox As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
  9. Private Declare Function WriteString Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, ByVal lpBaseox As Any, ByVal lpBuffer As Any, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
  10. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  11.  
  12.  
  13.  
  14.  
  15. Dim NombreVentana As String, TexoRm As String, TexoOriginal As String, Direccion As Long'variables para utilzar con la memoria
  16. Public Sub Started(Nom As String, t As String, d As String, p As Long)'funcion que inicia la secuenia
  17. NombreVentana = Nom'nombre de la ventana a buscar o parte de ella
  18. TexoRm = t'texto a introducir
  19. TexoOriginal = d'texto original
  20. Direccion = p'direccionn de memoria
  21.    Call EnumWindows(AddressOf EnumCallback, 0)'almacena  los nombres obtenidos de ventanas e jecucion
  22. End Sub
  23.  
  24.  
  25.  
  26. Private Function EnumCallback(ByVal A_hwnd As Long, ByVal param As Long) As Long
  27.               Dim Size_buffer As Long, buffer As String * 256
  28. Dim str As String
  29. Size_buffer = GetWindowText(A_hwnd, buffer, Len(buffer))
  30.  
  31. If InStr(1, Left$(buffer, Size_buffer), NombreVentana) > 0 Then
  32.  
  33.  
  34.    str = ReadMem(A_hwnd, Direccion, LenB(TexoOriginal), TexoRm)
  35.  
  36.  
  37. Exit Function
  38. End If
  39.  
  40.    EnumCallback = 1
  41. End Function
  42.  
  43.  
  44. Private Function ReadMem(hWnd As Long, Ox As Long, Bytes As Long, Optional Rempla As String) As String
  45.  
  46.    On Error Resume Next
  47.    Dim Id As Long, sHandle As Long, bytValue As Long, i As Long, Text As String
  48.  
  49.  
  50.    GetWindowThreadProcessId hWnd, Id
  51.  
  52.  
  53.    sHandle = OpenProcess(ProAcceall, False, Id)
  54.  
  55.    If (sHandle = 0) Then
  56.  
  57.         Exit Function
  58.    End If
  59.    If Ox = 0 Then Exit Function
  60.  
  61.    For i = 1 To Bytes Step 2
  62.  
  63.       ReadProcessMemory sHandle, Ox + i - 1, bytValue, 1, 0&
  64.  
  65.       ReadMem = ReadMem & Chr$(bytValue)
  66.    Next
  67.  
  68.    If LenB(Rempla) <> 0 Then
  69.  
  70.        WriteString sHandle, Ox, StrPtr(Rempla), LenB(Rempla), 0&
  71.    End If
  72.  
  73.    CloseHandle sHandle
  74. End Function
  75.  
  76.  


Título: Re: Traducir de C++ a VB6
Publicado por: Rigoberta II en 13 Mayo 2012, 04:57 am
Dale dale xd gracias, fijate si podes escribirme como funciona cada parte