Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: Keyen Night en 13 Marzo 2011, 02:53 am



Título: Obtener dirección y Tamaño de #strings
Publicado por: Keyen Night en 13 Marzo 2011, 02:53 am
Más descriptivo el titulo es imposible :laugh: como puedo obtener el offset y el size de la tabla de metada #strings en un assembly de .net?, creo que tiene que ver con el ManifestModule al cargar un assembly pero no tengo nada concreto...


Título: Re: Obtener dirección y Tamaño de #strings
Publicado por: Keyen Night en 13 Marzo 2011, 04:51 am
No se si sea la forma más facil pero así calcule el offset de #strings XD
Código
  1.                    Dim fStream As New FileStream("C:\Ejemplo.exe", FileMode.Open, FileAccess.ReadWrite)
  2.  
  3.                    Dim Table As New String(String.Empty)
  4.  
  5.                    Do While Table <> "35126"
  6.                        Table = fStream.ReadByte.ToString & fStream.ReadByte.ToString
  7.                    Loop
  8.  
  9.                    Dim MainTableOffset As Long = (fStream.Position - 2)
  10.                    Dim StringsTableOffset As Long = 0
  11.                    Dim Bytes As New List(Of String)
  12.  
  13.                    Do While fStream.Position <> MainTableOffset + 2 + 5
  14.  
  15.                        Dim CurrentByte As Long = fStream.ReadByte
  16.  
  17.                        If CurrentByte <> 0 Then
  18.                            If CurrentByte.ToString.Length = 1 Then
  19.                                Bytes.Add("0" & CurrentByte.ToString("X"))
  20.                            Else
  21.                                Bytes.Add(CurrentByte.ToString("X"))
  22.                            End If
  23.                        End If
  24.  
  25.                    Loop
  26.  
  27.                    Bytes.Reverse()
  28.  
  29.                    Dim Hex As New String(String.Empty)
  30.  
  31.                    For Each y As String In Bytes
  32.                        Hex += y
  33.                    Next
  34.  
  35.                    StringsTableOffset = CInt("&H" & Hex) + MainTableOffset - &H2C + 4
  36.  
  37.                    fStream.Close()


Título: Re: Obtener dirección y Tamaño de #strings
Publicado por: [D4N93R] en 13 Marzo 2011, 15:11 pm
Código
  1. 'No es necesario
  2. Dim Table As New String(String.Empty)
  3.  
  4. 'Puedes hacer
  5. Dim Table = String.Empty
  6.  

Como te acabo de poner en el otro post,  Mete eso dentro de un try catch finally y en el finally cierras el Stream.

PD: No crees doble-posts por favor.

Un saludo!


Título: Re: Obtener dirección y Tamaño de #strings
Publicado por: Keyen Night en 13 Marzo 2011, 15:16 pm
Disculpa por el doble post :-[ Gracias por la recomendación.