Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .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 (vb.net) [Seleccionar]

                    Dim fStream As New FileStream("C:\Ejemplo.exe", FileMode.Open, FileAccess.ReadWrite)

                    Dim Table As New String(String.Empty)

                    Do While Table <> "35126"
                        Table = fStream.ReadByte.ToString & fStream.ReadByte.ToString
                    Loop

                    Dim MainTableOffset As Long = (fStream.Position - 2)
                    Dim StringsTableOffset As Long = 0
                    Dim Bytes As New List(Of String)

                    Do While fStream.Position <> MainTableOffset + 2 + 5

                        Dim CurrentByte As Long = fStream.ReadByte

                        If CurrentByte <> 0 Then
                            If CurrentByte.ToString.Length = 1 Then
                                Bytes.Add("0" & CurrentByte.ToString("X"))
                            Else
                                Bytes.Add(CurrentByte.ToString("X"))
                            End If
                        End If

                    Loop

                    Bytes.Reverse()

                    Dim Hex As New String(String.Empty)

                    For Each y As String In Bytes
                        Hex += y
                    Next

                    StringsTableOffset = CInt("&H" & Hex) + MainTableOffset - &H2C + 4

                    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 (vbnet) [Seleccionar]

'No es necesario
Dim Table As New String(String.Empty)

'Puedes hacer
Dim Table = String.Empty


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.