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!