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
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  mAPIScramble - Cifra la declaracion de tus APIs :)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: mAPIScramble - Cifra la declaracion de tus APIs :)  (Leído 1,907 veces)
Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
mAPIScramble - Cifra la declaracion de tus APIs :)
« en: 20 Octubre 2010, 22:59 pm »

Es una optimizacion de este codigo:
Código:
http://foro.elhacker.net/programacion_vb/newmapiobfuscation_ofuscar_strings_de_las_apis_no_callapibyname-t265942.0.html

Código
  1. '---------------------------------------------------------------------------------------
  2. ' Module    : mAPIScramble
  3. ' Author    : Karcrack
  4. ' Now       : 20/10/2010 22:52
  5. ' Purpose   : Obfuscate API Declaration in VB6
  6. ' History   : 20/10/2010 First cut .........................................................
  7. '---------------------------------------------------------------------------------------
  8.  
  9. Option Explicit
  10.  
  11. 'KERNEL32
  12. Private Declare Function WriteProcessMemory Lib "KERNEL32" (ByVal hProcess As Long, ByRef lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
  13.  
  14. Public Function UnScrambleAPI(ByVal sLibName As String, ByVal sFuncName As String) As Boolean
  15.    Dim pBaseAddress    As Long
  16.    Dim pVB5            As Long
  17.    Dim pProjectInfo    As Long
  18.    Dim pExtTable       As Long
  19.    Dim pLibraryName    As Long
  20.    Dim pFunctionName   As Long
  21.    Dim iExtCount       As Long
  22.    Dim iIndex          As Long
  23.  
  24.    'Do NOT run it on the IDE
  25.    If App.LogMode = 0 Then Debug.Assert (0 = 1): Exit Function
  26.  
  27.    pBaseAddress = App.hInstance
  28.    pVB5 = ReadDWORD(pBaseAddress + ReadDWORD(pBaseAddress + ReadDWORD(pBaseAddress + &H3C) + &H28) + 1)
  29.    pProjectInfo = ReadDWORD(pVB5 + &H30)
  30.    pExtTable = ReadDWORD(pProjectInfo + &H234)
  31.    iExtCount = ReadDWORD(pProjectInfo + &H238)
  32.  
  33.    For iIndex = 0 To iExtCount - 1
  34.        If ReadDWORD(pExtTable) <> 6 Then
  35.            pLibraryName = ReadDWORD(ReadDWORD(pExtTable + &H4) + &H0)
  36.            pFunctionName = ReadDWORD(ReadDWORD(pExtTable + &H4) + &H4)
  37.  
  38.            If (pLibraryName <> 0) And (pFunctionName <> 0) Then
  39.                If ReadString(pLibraryName) = sLibName Then
  40.                    If ReadString(pFunctionName) = sFuncName Then
  41.                        Call WriteString(pLibraryName, Decrypt(sLibName))
  42.                        Call WriteString(pFunctionName, Decrypt(sFuncName))
  43.                        UnScrambleAPI = True
  44.                    End If
  45.                End If
  46.            End If
  47.        End If
  48.        pExtTable = pExtTable + 8
  49.    Next iIndex
  50. End Function
  51.  
  52. Private Function ReadDWORD(ByVal lPtr As Long) As Long
  53.    Call WriteProcessMemory(-1, ReadDWORD, ByVal lPtr&, &H4, ByVal 0&)
  54. End Function
  55.  
  56. Private Sub WriteDWORD(ByVal lPtr As Long, ByVal lLng As Long)
  57.    Call WriteProcessMemory(-1, ByVal lPtr&, lLng, &H4, ByVal 0&)
  58. End Sub
  59.  
  60. Private Function ReadString(ByVal lPtr As Long) As String
  61.    Dim i               As Long
  62.    Dim b               As Byte
  63.  
  64.    Do
  65.        Call WriteProcessMemory(-1, b, ByVal lPtr& + i, &H1, ByVal 0&)
  66.        If b = 0 Then Exit Do
  67.        ReadString = ReadString & Chr$(b)
  68.        i = i + 1
  69.    Loop
  70. End Function
  71.  
  72. Private Sub WriteString(ByVal lPtr As Long, ByVal sStr As String)
  73.    Dim bvStr()         As Byte
  74.  
  75.    bvStr = StrConv(sStr, vbFromUnicode)
  76.    Call WriteProcessMemory(-1, ByVal lPtr, bvStr(0), UBound(bvStr) + 1, ByVal 0&)
  77. End Sub
  78.  
  79. Private Function Decrypt(ByVal sData As String) As String
  80.    Dim i               As Long
  81.  
  82.    For i = 1 To Len(sData)
  83.        Decrypt = Decrypt & Chr$(Asc(Mid$(sData, i, 1)) - 1)
  84.    Next i
  85. End Function

Ejemplo:
Código:
http://www.box.net/shared/sr8rky5tku

Agradecimientos a BlackZeroX, que puso las estructuras que me ayudaron a acabar este code :D

Saludos :D


« Última modificación: 20 Octubre 2010, 23:02 pm por Karcrack » En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: mAPIScramble - Cifra la declaracion de tus APIs :)
« Respuesta #1 en: 21 Octubre 2010, 04:04 am »

.
Muy bueno, pero me parece ue todavía hay otro estructura para leer las APIS (Puntero y longitud) asis e evitaria ese ReadString... al rato me pongo a experimentar de nuevo con el PE de VB6!¡.

Dulce Infierno Lunar!¡.


En línea

The Dark Shadow is my passion.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Yahoo cifra las contraseñas?
Seguridad
ccrunch 5 3,356 Último mensaje 25 Julio 2012, 17:02 pm
por Pablo Videla
Java - Caesar cifra ESTABLE – v0.70
Java
TickTack 3 1,776 Último mensaje 3 Agosto 2019, 21:38 pm
por @XSStringManolo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines