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


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [SRC] Deshabilitar WFP [Windows File Protection]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: [SRC] Deshabilitar WFP [Windows File Protection]  (Leído 7,892 veces)
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
[SRC] Deshabilitar WFP [Windows File Protection]
« en: 14 Febrero 2009, 18:26 pm »

Esta técnica pone Fin al Hilo SFC Watcher que continuamente espera y responde a la notificación de cambio de directorio o acciones que se señalan.
Para ello SFC_OS.DLL  nos brinda una función sin nombre que podemos exportar con el  ordinal 2: SfcTerminateWatcherThread .. Esta API no acepta parámetros y hace exactamente lo que su nombre implica. Sin embargo, hay una sola manera de usar esta función: Esta debe ser invocada en el proceso que creó el SFC Watcher Thread: winlogon.exe.

Para ello debemos inyectar, y llamar a la función desde el propio Winlogon

Este code deja deshabilitada la Protección hasta el proximo reinicio. pudiendo de esta forma modificar los ficheros del sistema que protege WFP, espero les sea de utilidad.


Código
  1. '---------------------------------------------------------------------------------------
  2. ' Module        : mDisableWFP
  3. ' Fecha         : 15/02/2009 12:10
  4. ' Autor         : XcryptOR
  5. ' Proposito     : Deshabilita la WFP (Windows File Protection)Hasta el proximo Reinicio
  6. ' SO            : Windows XP Sp1, Sp2, Sp3
  7. '---------------------------------------------------------------------------------------
  8.  
  9. Declare Function OpenProcessToken Lib "advapi32.dll" ( _
  10. ByVal ProcessHandle As Long, _
  11. ByVal DesiredAccess As Long, _
  12. TokenHandle As Long) As Long
  13.  
  14. Declare Function CloseHandle Lib "kernel32.dll" ( _
  15. ByVal hObject As Long) As Long
  16.  
  17. Declare Function GetCurrentProcess Lib "kernel32.dll" () As Long
  18.  
  19. Declare Function AdjustTokenPrivileges Lib "advapi32.dll" ( _
  20. ByVal TokenHandle As Long, _
  21. ByVal DisableAllPrivileges As Long, _
  22. ByRef NewState As TOKEN_PRIVILEGES, _
  23. ByVal BufferLength As Long, _
  24. PreviousState As Any, _
  25. ReturnLength As Long) As Long
  26.  
  27. Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" ( _
  28. ByVal lpSystemName As String, _
  29. ByVal lpName As String, _
  30. lpLuid As LUID) As Long
  31.  
  32. Declare Function CreateToolhelp32Snapshot Lib "kernel32.dll" ( _
  33. ByVal dwFlags As Long, _
  34. ByVal th32ProcessID As Long) As Long
  35.  
  36. Declare Function Process32First Lib "kernel32.dll" ( _
  37. ByVal hSnapshot As Long, _
  38. lppe As PROCESSENTRY32) As Long
  39.  
  40. Declare Function Process32Next Lib "kernel32.dll" ( _
  41. ByVal hSnapshot As Long, _
  42. lppe As PROCESSENTRY32) As Long
  43.  
  44. Declare Function OpenProcess Lib "kernel32.dll" ( _
  45. ByVal dwDesiredAccess As Long, _
  46. ByVal bInheritHandle As Long, _
  47. ByVal dwProcessId As Long) As Long
  48.  
  49. Declare Function CreateRemoteThread Lib "kernel32.dll" ( _
  50. ByVal hProcess As Long, _
  51. ByRef lpThreadAttributes As Any, _
  52. ByVal dwStackSize As Long, _
  53. ByVal StartAddress As Long, _
  54. ByRef lpParameter As Any, _
  55. ByVal dwCreationFlags As Long, _
  56. ByRef lpThreadId As Long) As Long
  57.  
  58. Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" ( _
  59. ByVal lpLibFileName As String) As Long
  60.  
  61. Declare Function GetProcAddress Lib "kernel32.dll" ( _
  62. ByVal hModule As Long, _
  63. ByVal OrdinalNumber As Long) As Long
  64.  
  65. Declare Function FreeLibrary Lib "kernel32.dll" ( _
  66. ByVal hLibModule As Long) As Long
  67.  
  68. Declare Function WaitForSingleObject Lib "kernel32.dll" ( _
  69. ByVal hHandle As Long, _
  70. ByVal dwMilliseconds As Long) As Long
  71.  
  72. Const TOKEN_ALL_ACCESS = 983551
  73. Const PROCESS_ALL_ACCESS = &H1F0FFF
  74. Const TH32CS_SNAPPROCESS As Long = &H2
  75. Const INFINITE = &HFFFF&
  76.  
  77. Type LUID
  78.        LowPart             As Long
  79.        HighPart            As Long
  80. End Type
  81.  
  82. Type LUID_AND_ATTRIBUTES
  83.        pLuid               As LUID
  84.        Attributes          As Long
  85. End Type
  86.  
  87. Type TOKEN_PRIVILEGES
  88.        PrivilegeCount      As Long
  89.        Privileges(1)       As LUID_AND_ATTRIBUTES
  90. End Type
  91.  
  92. 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 * 260
  103. End Type
  104.  
  105. Sub Main()
  106.  
  107.    SetPrivilegies
  108.  
  109.    If DisableWFP = True Then
  110.        MsgBox "Se ha deshabilitado la WFP, hasta el proximo reinicio."
  111.    Else
  112.        MsgBox "Error al abrir winlogon! no se puede desactivar WFP"
  113.    End If
  114.  
  115.  
  116. End Sub
  117.  
  118. '==============================================================================
  119. '================ OBTENER PID (PROCESS ID) DEL NOMBRE =========================
  120. '==============================================================================
  121. Public Function GetPid(szProcess As String)
  122.    On Error Resume Next
  123.  
  124.    Dim Pid         As Long
  125.    Dim l           As Long
  126.    Dim l1          As Long
  127.    Dim l2          As Long
  128.    Dim Ol          As Long
  129.    Dim pShot       As PROCESSENTRY32
  130.  
  131.    l1 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
  132.    pShot.dwSize = Len(pShot)
  133.    l2 = Process32Next(l1, pShot)
  134.    Do While l2
  135.        If InStr(pShot.szExeFile, szProcess) <> 0 Then
  136.            Pid = pShot.th32ProcessID
  137.            GetPid = Pid
  138.        End If
  139.        l2 = Process32Next(l1, pShot)
  140.    Loop
  141.    l = CloseHandle(l1)
  142.  
  143. End Function
  144. '==============================================================================
  145. '=========================== OBTENER PRIVILEGIOS ==============================
  146. '==============================================================================
  147. Sub SetPrivilegies()
  148.  
  149.    Dim hToken      As Long
  150.    Dim pLuid       As LUID
  151.    Dim TokenPriv   As TOKEN_PRIVILEGES
  152.  
  153.    If OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, hToken) = 0 Then
  154.        End
  155.    End If
  156.  
  157.    LookupPrivilegeValue vbNullString, "SeDebugPrivilege", pLuid
  158.  
  159.    With TokenPriv
  160.        .PrivilegeCount = 1
  161.        .Privileges(0).pLuid = pLuid
  162.        .Privileges(0).Attributes = 2
  163.    End With
  164.  
  165.    AdjustTokenPrivileges hToken, 0, TokenPriv, Len(TokenPriv), ByVal 0&, ByVal 0&
  166.    CloseHandle hToken
  167.  
  168. End Sub
  169. '==============================================================================
  170. '==== DESHABILITAR LA WFP (WINDOWS FILE PROTECTION) HASTA PROXIMO REINICIO ====
  171. '==============================================================================
  172.  
  173. Function DisableWFP() As Boolean
  174.  
  175.    Dim LoadDll     As Long
  176.    Dim hProcess    As Long
  177.    Dim RemThread   As Long
  178.    Dim SfcTerminateWatcherThread  As Long
  179.  
  180.    hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, GetPid("winlogon.exe"))
  181.  
  182.    If hProcess = 0 Then
  183.        DisableWFP = False
  184.        End
  185.    End If
  186.  
  187.    LoadDll = LoadLibrary("SFC_OS.DLL")          'sfc_os.dll
  188.    SfcTerminateWatcherThread = GetProcAddress(LoadDll, 2)      'Api SfcTerminateWatcherThread ordinal:#2 de sfc_os.dll
  189.    RemThread = CreateRemoteThread(hProcess, ByVal 0&, 0, ByVal SfcTerminateWatcherThread, ByVal 0&, 0, ByVal 0&)
  190.  
  191.    WaitForSingleObject RemThread, INFINITE
  192.    CloseHandle hProcess
  193.    FreeLibrary LoadDll
  194.    DisableWFP = True
  195.  
  196. End Function
  197.  


« Última modificación: 14 Febrero 2009, 18:28 pm por XcryptOR » En línea



el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #1 en: 14 Febrero 2009, 18:33 pm »

espectacular, ahora, cuando reinicias , te va a indicar q algo se cambio?
y en esta linea
Código
  1. If DisableWFP = True Then
podrias obviar el = True


saludos


En línea

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

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #2 en: 14 Febrero 2009, 21:14 pm »

No, solo si haces el scaneo de los archivos de sistema mediante el comando sfc /scannow, si no el sistema no se percata de los cambios. saludos Ok, se que se puede olvidar el TRUE, pero lo coloque alli para que se entendiera mejor el code.

saludos  ;D
« Última modificación: 14 Febrero 2009, 21:15 pm por XcryptOR » En línea



seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #3 en: 15 Febrero 2009, 00:55 am »

tambien se puede deshabilitar modificando un valor en el registro no?
En línea

XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #4 en: 15 Febrero 2009, 01:13 am »

Hay un valor en el registro que servia para eso: "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Windows File Protection"  Value name: SFCDisable Value: 0xFFFFFF9D

Pero de esta forma ya no funciona.

saludos
En línea



Littlehorse
All the world's a stage
Colaborador
***
Desconectado Desconectado

Mensajes: 2.714


Nie Dam Sie


Ver Perfil WWW
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #5 en: 15 Febrero 2009, 01:22 am »

Excelente  :)
En línea

An expert is a man who has made all the mistakes which can be made, in a very narrow field.
seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #6 en: 15 Febrero 2009, 01:25 am »

yo decia este registro:

Código:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

tambien hay una api SetSfcFileException que se usa para excluir un archivo de la proteccion...
En línea

XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #7 en: 15 Febrero 2009, 01:37 am »

si tambien habia hecho un code para chequear si un archivo estaba protegido, y tambien desproteger el archivo con SetSfcFileException que lo desprotege por un minuto

Código
  1. Private Declare Function SfcIsFileProtected Lib "sfc.dll" _
  2. (ByVal hRpc As Long, _
  3. ByVal ProtFileName As Long) As Long
  4.  
  5.  
  6. Public Function IsFileProtected(ByVal strFile As String) As Boolean
  7.  
  8.    Dim res         As Long
  9.  
  10.    res = SfcIsFileProtected(0, StrPtr(strFile))
  11.  
  12.    If res = 0 Then
  13.        IsFileProtected = False
  14.        Exit Function
  15.    Else
  16.        IsFileProtected = True
  17.        Exit Function
  18.    End If
  19.  
  20. End Function
  21.  
  22. Sub Main()
  23.    If IsFileProtected("C:\windows\system32\userinit.exe") Then MsgBox "WFP Protect This File"
  24. End Sub
  25.  


y esta para desprotegerlo por un minuto:

Código
  1. Option Explicit
  2. Private Declare Function SfcFileException Lib "sfc_os.dll"  _
  3. Alias "#5" (ByVal dwUnknown0 As Long, _ ByVal pwszFile As Long, _
  4. ByVal dwUnknown1 As Long) As Long
  5.  
  6. Function DisableWFP(strPath As String) As Boolean
  7.    On Error Resume Next
  8.    If SfcFileException(0, StrPtr(strPath), -1) <> 0 Then
  9.        DisableWFP = False
  10.        Exit Function
  11.    End If
  12.    'Aquí puedes colocar el code para reemplazar, eliminar o renombrar el file
  13.    DisableWFP = True
  14. End Function

 


« Última modificación: 15 Febrero 2009, 02:58 am por XcryptOR » En línea



seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #8 en: 15 Febrero 2009, 01:52 am »

en el segundo codigo esta mal indentado el Else con el If...yo lo habia visto aca:

http://www.vbgood.com/viewthread.php?tid=69207
« Última modificación: 15 Febrero 2009, 01:55 am por seba123neo » En línea

XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: [SRC] Deshabilitar WFP [Windows File Protection]
« Respuesta #9 en: 15 Febrero 2009, 02:56 am »

Si, sebaneo tienes toda la razón y como copie el code me equivoque y no era la función que habia modificado, ese es el code del cual saque la declaración del api, y la identacion si estaba mal echa, ya lo corregi, muchas gracias  :D
En línea



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

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Identity Protection AVG
Hacking
yarito 0 2,197 Último mensaje 12 Julio 2011, 21:56 pm
por yarito
¿como deshabilitar la memoria integrada en Windows?
Hardware
cixert 3 5,415 Último mensaje 20 Marzo 2014, 18:11 pm
por cixert
File Governor te ayuda a desbloquear los ficheros en uso de Windows
Noticias
wolfbcn 0 1,131 Último mensaje 21 Julio 2014, 02:28 am
por wolfbcn
Como Deshabilitar Powershell En Windows 10
Seguridad
Flamer 2 6,238 Último mensaje 10 Septiembre 2016, 03:13 am
por Flamer
Windows host file
Windows
TrashAmbishion 1 2,089 Último mensaje 8 Enero 2023, 16:13 pm
por Danielㅤ
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines