Programación General > Visual Basic 6.0 e inferiores

 Inyección En Vb

<< < (2/4) > >>

martinss:

--- Cita de: "JuanK" --- totalmente de acuerdo, creo que estas un tanto desubicado.

Seria bueno que nos dijeras como son los intentos que has hecho.
--- Fin de la cita ---
uno de los codigos que he probado a sido este pero da error a la hora de inyectar:


--- Código: Text ---Option Explicit Public hModule          As LongPublic hProcess         As LongPublic dwSize           As LongPublic dwPid            As LongPublic dwBytesWritten   As LongPublic dwTid            As Long Public SE               As SECURITY_ATTRIBUTES Public Const PAGE_READONLY              As Long = &H2Public Const PAGE_READWRITE             As Long = &H4Public Const PAGE_EXECUTE               As Long = &H10Public Const PAGE_EXECUTE_READ          As Long = &H20Public Const PAGE_EXECUTE_READWRITE     As Long = &H40Public Const MEM_RELEASE                As Long = &H8000Public Const MEM_COMMIT                 As Long = &H1000Public Const MEM_RESERVE                As Long = &H2000Public Const MEM_RESET                  As Long = &H80000Public Const STANDARD_RIGHTS_REQUIRED   As Long = &HF0000Public Const SYNCHRONIZE                As Long = &H100000Public Const PROCESS_ALL_ACCESS         As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)Public Const INFINITE                   As Long = &HFFFFFF Public Type SECURITY_ATTRIBUTES       nLength                 As Long       lpSecurityDescriptor    As Long       bInheritHandle          As LongEnd Type Private Declare Function VirtualAllocEx Lib &#34;kernel32&#34; (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As LongPrivate Declare Function VirtualFreeEx Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As LongPublic Declare Function CreateRemoteThread Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As LongPublic Declare Function FindWindow Lib &#34;user32&#34; Alias &#34;FindWindowA&#34; (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Declare Function GetWindowThreadProcessId Lib &#34;user32&#34; (ByVal hWnd As Long, lpdwProcessId As Long) As LongPublic Declare Function OpenProcess Lib &#34;kernel32&#34; (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPublic Declare Function WriteProcessMemory Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPublic Declare Function GetModuleHandle Lib &#34;kernel32&#34; Alias &#34;GetModuleHandleA&#34; (ByVal lpModuleName As String) As LongPublic Declare Function GetProcAddress Lib &#34;kernel32&#34; (ByVal hModule As Long, ByVal lpProcName As String) As LongPublic Declare Function WaitForSingleObject Lib &#34;kernel32&#34; (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPublic Declare Function CloseHandle Lib &#34;kernel32&#34; (ByVal hObject As Long) As Long Sub Main()Inject App.Path & &#34;&#092;Ejemplo.dll&#34;, &#34;Notepad&#34;End Sub Public Function Inject(szDll As String, szTargetWindowClassName As String) As BooleanDim hWnd        As LongDim k32LL       As LongDim Thread      As Long    SE.nLength = Len(SE)   SE.lpSecurityDescriptor = False      'Encontrar la ventana y abrir el proceso   hWnd = FindWindow(szTargetWindowClassName, vbNullString)   GetWindowThreadProcessId hWnd, dwPid   hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, dwPid)   If hProcess = 0 Then GoTo Inject_Error   k32LL = GetProcAddress(GetModuleHandle(&#34;kernel32.dll&#34;), &#34;LoadLibraryA&#34;)      'Reservamos memoria   hModule = VirtualAllocEx(hProcess, 0, LenB(szDll), MEM_COMMIT, PAGE_READWRITE)   If hModule = 0 Then GoTo Inject_Error   WriteProcessMemory hProcess, ByVal hModule, ByVal szDll, LenB(szDll), dwBytesWritten      Thread = CreateRemoteThread(hProcess, SE, 0, ByVal k32LL, ByVal hModule, 0, dwTid)   If Thread = 0 Then GoTo Inject_Error      'Clean up a bit   WaitForSingleObject Thread, 100   VirtualFreeEx hProcess, hModule, 0&, MEM_RELEASE   CloseHandle Thread Exit Function Inject_Error:   Inject = False   MsgBox &#34;error&#34;   Exit FunctionEnd Function 

Eternal Idol:
¿Y en que consiste el "AntiCheat" sino es la DLL? Si tu codigo no es el inyector ni el inyectado ... ¿Que hace realmente?

¿De ese codigo que pusiste que no te funciona exactamente?

martinss:

--- Cita de: "Eternal Idol" --- ¿Y en que consiste el "AntiCheat" sino es la DLL? Si tu codigo no es el inyector ni el inyectado ... ¿Que hace realmente?

¿De ese codigo que pusiste que no te funciona exactamente?
--- Fin de la cita ---
la DLL es la que tiene que autentificar con el servidor... osea, verifica que cada player que entre al servidor tenga el anticheat activado  :)

y el programa se encarga de las detecciones de cheats...  :comp:

y ese codigo.. da error cuando hago click en "Inyectar"

http://img156.imageshack.us/img156/7111/dibujole2.jpg

Eternal Idol:
Sigue sonandome rarisimo y la verdad es que la explicacion que das sobre el error es un tanto ridicula ... tenes que decirnos exactamente que parte del codigo falla ... no son mas que unas cuantas lineas.

Por favor asegurate de que la libreria Ejemplo.dll esta donde tiene que estar y el programa es capaz de encontrar la ventana del Notepad (cosa de la cual dudo muchisimo ya que cambia segun el idioma). Seria mejor que usaras una enumeracion de todos los procesos en ejecucion y compararas su nombre con el del CS.

martinss:
la dll tiene que estar en el mismo directorio que el inyector, y el codigo seria asi:

en un Módulo:


--- Código: Text ---Option Explicit Public hModule          As LongPublic hProcess         As LongPublic dwSize           As LongPublic dwPid            As LongPublic dwBytesWritten   As LongPublic dwTid            As Long Public SE               As SECURITY_ATTRIBUTES Public Const PAGE_READONLY              As Long = &H2Public Const PAGE_READWRITE             As Long = &H4Public Const PAGE_EXECUTE               As Long = &H10Public Const PAGE_EXECUTE_READ          As Long = &H20Public Const PAGE_EXECUTE_READWRITE     As Long = &H40Public Const MEM_RELEASE                As Long = &H8000Public Const MEM_COMMIT                 As Long = &H1000Public Const MEM_RESERVE                As Long = &H2000Public Const MEM_RESET                  As Long = &H80000Public Const STANDARD_RIGHTS_REQUIRED   As Long = &HF0000Public Const SYNCHRONIZE                As Long = &H100000Public Const PROCESS_ALL_ACCESS         As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)Public Const INFINITE                   As Long = &HFFFFFF Public Type SECURITY_ATTRIBUTES      nLength                 As Long      lpSecurityDescriptor    As Long      bInheritHandle          As LongEnd Type Private Declare Function VirtualAllocEx Lib &#34;kernel32&#34; (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As LongPrivate Declare Function VirtualFreeEx Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As LongPublic Declare Function CreateRemoteThread Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As LongPublic Declare Function FindWindow Lib &#34;user32&#34; Alias &#34;FindWindowA&#34; (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Declare Function GetWindowThreadProcessId Lib &#34;user32&#34; (ByVal hWnd As Long, lpdwProcessId As Long) As LongPublic Declare Function OpenProcess Lib &#34;kernel32&#34; (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPublic Declare Function WriteProcessMemory Lib &#34;kernel32&#34; (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPublic Declare Function GetModuleHandle Lib &#34;kernel32&#34; Alias &#34;GetModuleHandleA&#34; (ByVal lpModuleName As String) As LongPublic Declare Function GetProcAddress Lib &#34;kernel32&#34; (ByVal hModule As Long, ByVal lpProcName As String) As LongPublic Declare Function WaitForSingleObject Lib &#34;kernel32&#34; (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPublic Declare Function CloseHandle Lib &#34;kernel32&#34; (ByVal hObject As Long) As Long Sub Main()Inject App.Path & &#34;&#092;autentificacion.dll&#34;, &#34;Counter-Strike&#34;End Sub Public Function Inject(szDll As String, szTargetWindowClassName As String) As BooleanDim hWnd        As LongDim k32LL       As LongDim Thread      As Long   SE.nLength = Len(SE)  SE.lpSecurityDescriptor = False   'Encontrar la ventana y abrir el proceso  hWnd = FindWindow(szTargetWindowClassName, vbNullString)  GetWindowThreadProcessId hWnd, dwPid  hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, dwPid)  If hProcess = 0 Then GoTo Inject_Error  k32LL = GetProcAddress(GetModuleHandle(&#34;kernel32.dll&#34;), &#34;LoadLibraryA&#34;)   'Reservamos memoria  hModule = VirtualAllocEx(hProcess, 0, LenB(szDll), MEM_COMMIT, PAGE_READWRITE)  If hModule = 0 Then GoTo Inject_Error  WriteProcessMemory hProcess, ByVal hModule, ByVal szDll, LenB(szDll), dwBytesWritten   Thread = CreateRemoteThread(hProcess, SE, 0, ByVal k32LL, ByVal hModule, 0, dwTid)  If Thread = 0 Then GoTo Inject_Error   'Clean up a bit  WaitForSingleObject Thread, 100  VirtualFreeEx hProcess, hModule, 0&, MEM_RELEASE  CloseHandle Thread Exit Function Inject_Error:  Inject = False  MsgBox &#34;error&#34;  Exit FunctionEnd Function 
Form:


--- Código: Text ---Private Sub Command1_Click()Inject App.Path & &#34;&#092;autentificacion.dll&#34;, &#34;Counter-Strike&#34;End Sub 
cuando hago click en el botón da el error

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

[*] Página Anterior

Ir a la versión completa