|
852
|
Seguridad Informática / Análisis y Diseño de Malware / Re: Ayuda con Inyector DLL en VB 2008
|
en: 19 Septiembre 2013, 21:35 pm
|
'ESTRUCTURA PROCESS_INFORMATION Private Structure PROCESS_INFORMATION Dim hProcess As Long Dim hThread As Long Dim dwProcessId As Long Dim dwThreadId As Long End Structure 'ESTRUCTURA STARTUPINFO Private Structure STARTUPINFO Dim cb As Long Dim lpReserved As String End Structure 'TIPOS PARA LA CREACION DEL PROCESO Enum PROCESS_CREATION_FLAG As Integer
CREATE_BREAKAWAY_FROM_JOB = &H1000000 CREATE_DEFAULT_ERROR_MODE = &H4000000 CREATE_NEW_CONSOLE = &H10 CREATE_NEW_PROCESS_GROUP = &H200 CREATE_NO_WINDOW = &H8000000 CREATE_PROTECTED_PROCESS = &H40000 CREATE_PRESERVE_CODE_AUTHZ_LEVEL = &H2000000 CREATE_SEPARATE_WOW_VDM = &H800 CREATE_SHARED_WOW_VDM = &H1000 CREATE_SUSPENDED = &H4 CREATE_UNICODE_ENVIRONMENT = &H400 DEBUG_ONLY_THIS_PROCESS = &H2 DEBUG_PROCESS = &H1 DETACHED_PROCESS = &H8 EXTENDED_STARTUPINFO_PRESENT = &H80000 INHERIT_PARENT_AFFINITY = &H10000 NORMAL_PRIORITY_CLASS = &H10
End Enum
'CONSTANTES PARA VIRTUALALLOCEX Const PROCESS_VM_OPERATION = &H8 Const PROCESS_VM_READ = &H10 Const PROCESS_VM_WRITE = &H20 Const PROCESS_ALL_ACCESS = 0
Const MEM_COMMIT = &H1000 Const MEM_RESERVE = &H2000 Const MEM_DECOMMIT = &H4000 Const MEM_RELEASE = &H8000 Const MEM_FREE = &H10000 Const MEM_PRIVATE = &H20000 Const MEM_MAPPED = &H40000 Const MEM_TOP_DOWN = &H100000
Const PAGE_EXECUTE_READWRITE = &H40 Const PAGE_READWRITE = &H4&
'FUNCIONES APIS Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpAppName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Integer, ByVal lpThreadAttributes As Integer, ByVal bInheritHandles As Integer, ByVal dwCreationFlags As Integer, ByVal lpEnvironment As Integer, ByVal lpCurrentDirectory As Integer, ByRef lpStartupInfo As STARTUPINFO, ByRef lpProcessInformation As PROCESS_INFORMATION) As Integer Private Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As IntPtr, ByVal flAllocationType As Integer, ByVal flProtect As Integer) As IntPtr
Public Sub Ejecutar(ByVal Programa As String)
Dim pInfo As PROCESS_INFORMATION Dim sInfo As New STARTUPINFO
Dim Process As Long Dim Memoria As Long
Dim DllLen As Integer = Len(DllName) sInfo.cb = Len(sInfo)
Try
Process = CreateProcessA(vbNullString, Programa, 0, 0, False, PROCESS_CREATION_FLAG.CREATE_SUSPENDED, 0, 0, sInfo, pInfo) Memoria = VirtualAllocEx(pInfo.hProcess, 0, DllLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
Catch e As Exception
MsgBox(e.Message)
End Try
End Sub
Ahora me dice "Desbordamiento"??! Desbordamiento culeao? Me esta por enfermar esto... Odio .NET que portabilidad ni portabilidad... Alguien que quiera probar ese code a ver que pasa.. ? Gracias.. PD: DllName es el nombre de la dll, con extensión y sin ruta, DllLen es el tamaño del texto o sea: "dllvirus.dll" = 12 y Programa es el Exe a inyectar, con ruta y extensión..
Modificado varias horas despues: el valor con el que se rellena el campo hProcess de la estructura PROCESS_INFORMATION esta podrido... algo va mal cuando se llama a la api,, me da un valor super largo y por eso desborda.. Alguna segerencia???
|
|
|
855
|
Seguridad Informática / Análisis y Diseño de Malware / Re: Ayuda con Inyector DLL en VB 2008
|
en: 18 Septiembre 2013, 20:14 pm
|
Bueno,, sigo sin hacer andar esto... Ahora estoy viendo un ejemplo del señor Leandro Ascierto para ocultar procesos del administrador de tareas que utiliza WriteProcessMemory, VirtualAllocEx, OpenProcess... parecido al mio.. pero bueno, cualquier colaboración es bienvenida! Saludos!!
PD: Alguien sabe por que hay tantas definiciones de constantes diferentes para las constantes de las apis ? EJ:
Public Const PROCESS_ALL_ACCESS = &H1F0FFF Public Const PROCESS_ALL_ACCESS = 0 Private Const PROCESS_ALL_ACCESS As Long = 2035711
Son todas validas o que ??? Entiendo que estan en diferentes "formatos" pero siquiera son los mismos valores :/
2 hs despues: Creo que lo que falla es CreateProcess! Siempre retorna 0 y creo que 0 es error...
Ya no se que modificar.... :'|
|
|
|
858
|
Seguridad Informática / Análisis y Diseño de Malware / Ayuda con Inyector DLL en VB 2008
|
en: 18 Septiembre 2013, 02:51 am
|
Bueno, hace 16 Hs que le meto a esto y no puedo encontrar el error,, o mejor dicho, como solucionarlo!! Ahi les va genios... Private Sub BtnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLoad.Click
Dim LoadLibHandle As Integer Dim GetProcHandle As Integer Dim StartUp As New STARTUPINFO Dim ProcessInfo As New PROCESS_INFORMATION Dim DllTam As Integer Dim VirtualRet As Integer
Dim bytes() As Byte bytes = System.Text.Encoding.Unicode.GetBytes(DllName)
Dim Retorno As Integer
LoadLibHandle = LoadLibraryA("kernel32.dll") GetProcHandle = GetProcAddress(LoadLibHandle, "LoadLibraryA")
Retorno = CreateProcess(txtExeF.Text, vbNullString, vbNullString, vbNullString, vbNullString, PROCESS_CREATION_FLAG.CREATE_SUSPENDED, vbNullString, vbNullString, StartUp, ProcessInfo)
DllTam = Len(txtDllName.Text)
VirtualRet = VirtualAllocEx(ProcessInfo.hProcess, vbNullString, DllTam, MEM_COMMIT, PROCESS_ALL_ACCESS) WriteProcessMemory(ProcessInfo.hProcess, VirtualRet, bytes, DllTam, vbNullString)
Try
CreateRemoteThread(ProcessInfo.hProcess, 0, 0, GetProcHandle, VirtualRet, 0, 0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
ResumeThread(ProcessInfo.hProcess)
End Sub
Claro esta que esto es una porcion del codigo,, txtDllName es el textbox que tiene el nombre de la dll, txtExeF es el textbox que tiene la ruta del exe.. El error que me salta es: Intento de leer o escribir en la memoria protegida.. Ya no se que hacer con esto!! Jaja Saludos!!
|
|
|
859
|
Programación / ASM / Re: Ayuda! Problema con MASM Inline
|
en: 30 Agosto 2013, 18:48 pm
|
Perdon por responder tarde.. Ya esta solucionado el problema! Y de paso ya me puedo sumergir en el WinDbg,, a ver si aprendo a depurar de paso jeje Saludos! Gracias!
|
|
|
860
|
Programación / ASM / Re: Ayuda! Problema con MASM Inline
|
en: 28 Agosto 2013, 16:16 pm
|
Fa,, que grandes que son loco!! Hoy lo voy a probar,, Muchas gracias a ambos!! Podrian decirme que herramientas usan para depurar? ASM todavia me cuesta pila, pero saber usar las herramientas es una gran ayuda :p jeje
|
|
|
|
|
|
|