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

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  API RtlSetProcessIsCritical
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: API RtlSetProcessIsCritical  (Leído 6,876 veces)
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
API RtlSetProcessIsCritical
« en: 11 Noviembre 2008, 23:41 pm »

Bueno este code hace uso de un API nativa de NTDLL.dll la cual setea nuestro proceso como un proceso critico del sistema al igual que winlogon o csrss, bueno el resultado de terminar nuestro proceso dara como resultado la BSOD (Blue Screen Of Death) de windows, espero les sea de utilidad, aplicandolo a nuestra especie viral haria que nuestro proceso no se pudiera terminar. casi interminable.

Codigo del Form:

Código
  1. '*************************************************************************
  2. '*************************************************************************
  3. ' Uso de RtlSetProcessIsCritical para setear nuestro proceso, como proceso
  4. ' critico del sistema: del mismo modo que csrss.exe o winlogon
  5. ' XcryptOR - Made In Colombia
  6. '**************************************************************************
  7. '*************************************************************************
  8. Private Sub Form_Load()
  9. On Error Resume Next
  10. ObtenerPrivilegios SE_DEBUG_NAME ' obtiene privilegios de Debugeo
  11. Call RtlSetProcessIsCritical(0, 0, 1) ' setea nuestro proceso como Proceso Critico
  12. End Sub
  13.  

Codigo Modulo:

Código
  1. Option Explicit
  2.  
  3. Private Const ANYSIZE_ARRAY = 1
  4. Private Const TOKEN_ADJUST_PRIVILEGES = &H20
  5. Private Const TOKEN_QUERY = &H8
  6. Private Const SE_PRIVILEGE_ENABLED = &H2
  7.  
  8. Private Type LUID
  9.    LowPart As Long
  10.    HighPart As Long
  11. End Type
  12. Private Type LUID_AND_ATTRIBUTES
  13.        pLuid As LUID
  14.        Attributes As Long
  15. End Type
  16. Private Type TOKEN_PRIVILEGES
  17.    PrivilegeCount As Long
  18.    Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
  19. End Type
  20.  
  21.  
  22. Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
  23. Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLUID As LUID) As Long
  24. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  25. Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
  26.  
  27.  
  28.  
  29. Public Const SE_DEBUG_NAME As String = "SeDebugPrivilege"
  30.  
  31.  
  32. Public Declare Function RtlSetProcessIsCritical Lib "ntdll.dll" (ByVal NewValue As Boolean, ByVal OldValue As Boolean, ByVal WinLogon As Boolean)
  33.  
  34. Public Function ObtenerPrivilegios(ByVal privilegio As String) As Long
  35.  
  36. Dim lpLUID As LUID
  37. Dim lpToken As TOKEN_PRIVILEGES
  38. Dim lpAntToken As TOKEN_PRIVILEGES
  39. Dim hToken As Long
  40. Dim hProcess As Long
  41. Dim res As Long
  42.  
  43. hProcess = GetCurrentProcess()
  44. res = OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken)
  45. If res = 0 Then
  46.    Exit Function
  47. End If
  48. res = LookupPrivilegeValue(vbNullString, privilegio, lpLUID)
  49. If res = 0 Then
  50.    Exit Function
  51. End If
  52. With lpToken
  53.    .PrivilegeCount = 1
  54.    .Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
  55.    .Privileges(0).pLuid = lpLUID
  56. End With
  57.  
  58. res = AdjustTokenPrivileges(hToken, False, lpToken, Len(lpToken), lpAntToken, Len(lpAntToken))
  59. If res = 0 Then
  60.    Exit Function
  61. End If
  62. ObtenerPrivilegios = res
  63. End Function
  64.  

saludos


« Última modificación: 15 Noviembre 2008, 02:10 am por XcryptOR » En línea



carlitrosss6

Desconectado Desconectado

Mensajes: 18


You know you're right.


Ver Perfil
Re: API RtlSetProcessIsCritical
« Respuesta #1 en: 6 Junio 2009, 03:57 am »

Funciona de maravilla,pero còmo se podrìa revertir esto?Es decir,quitarle el privilegio de "Critico" al proceso?

Saludos!


En línea

Arriba Mèxico!!
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: API RtlSetProcessIsCritical
« Respuesta #2 en: 6 Junio 2009, 04:10 am »

sabes esta api no es reversible, deberias probar este code que hizo SqUeEzEr, que es similar al mio, aqui te lo dejo, espero te sea de utilidad.

Código
  1. Public Function MakeCritical(Phandle As Long, Value As Boolean)


si le asignas verdadero sera un proceso critico y para revertirlo llama a la funcion con el valor false. es un muy buen uso del API NtSetInformationProcess, puedes hacer un hook al cierre del sistema para hacer que tu proceso se vuelva No Critico al cierre de windows.

saludos

Código
  1. 'Native api NtSetInformationProcess by SqUeEzEr
  2. Option Explicit
  3. Private Const ANYSIZE_ARRAY = 1
  4. Private Const TOKEN_ADJUST_PRIVILEGES = &H20
  5. Private Const TOKEN_QUERY = &H8
  6. Private Const SE_PRIVILEGE_ENABLED = &H2
  7.  
  8. Private Type LUID
  9.    LowPart As Long
  10.    HighPart As Long
  11. End Type
  12. Private Type LUID_AND_ATTRIBUTES
  13.        pLuid As LUID
  14.        Attributes As Long
  15. End Type
  16. Private Type TOKEN_PRIVILEGES
  17.    PrivilegeCount As Long
  18.    Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
  19. End Type
  20.  
  21.  
  22. Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
  23. Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLUID As LUID) As Long
  24. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  25. Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
  26.  
  27.  
  28. Public Const SE_CREATE_TOKEN_NAME As String = "SeCreateTokenPrivilege"
  29. Public Const SE_ASSIGNPRIMARYTOKEN_NAME As String = "SeAssignPrimaryTokenPrivilege"
  30. Public Const SE_LOCK_MEMORY_NAME As String = "SeLockMemoryPrivilege"
  31. Public Const SE_INCREASE_QUOTA_NAME As String = "SeIncreaseQuotaPrivilege"
  32. Public Const SE_UNSOLICITED_INPUT_NAME As String = "SeUnsolicitedInputPrivilege"
  33. Public Const SE_MACHINE_ACCOUNT_NAME As String = "SeMachineAccountPrivilege"
  34. Public Const SE_TCB_NAME As String = "SeTcbPrivilege"
  35. Public Const SE_SECURITY_NAME As String = "SeSecurityPrivilege"
  36. Public Const SE_TAKE_OWNERSHIP_NAME As String = "SeTakeOwnershipPrivilege"
  37. Public Const SE_LOAD_DRIVER_NAME As String = "SeLoadDriverPrivilege"
  38. Public Const SE_SYSTEM_PROFILE_NAME As String = "SeSystemProfilePrivilege"
  39. Public Const SE_SYSTEMTIME_NAME As String = "SeSystemtimePrivilege"
  40. Public Const SE_PROF_SINGLE_PROCESS_NAME As String = "SeProfileSingleProcessPrivilege"
  41. Public Const SE_INC_BASE_PRIORITY_NAME As String = "SeIncreaseBasePriorityPrivilege"
  42. Public Const SE_CREATE_PAGEFILE_NAME As String = "SeCreatePagefilePrivilege"
  43. Public Const SE_CREATE_PERMANENT_NAME As String = "SeCreatePermanentPrivilege"
  44. Public Const SE_BACKUP_NAME As String = "SeBackupPrivilege"
  45. Public Const SE_RESTORE_NAME As String = "SeRestorePrivilege"
  46. Public Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"
  47. Public Const SE_DEBUG_NAME As String = "SeDebugPrivilege"
  48. Public Const SE_AUDIT_NAME As String = "SeAuditPrivilege"
  49. Public Const SE_SYSTEM_ENVIRONMENT_NAME As String = "SeSystemEnvironmentPrivilege"
  50. Public Const SE_CHANGE_NOTIFY_NAME As String = "SeChangeNotifyPrivilege"
  51. Public Const SE_REMOTE_SHUTDOWN_NAME As String = "SeRemoteShutdownPrivilege"
  52. 'THE api we need!
  53. Private Declare Function NtSetInformationProcess Lib "ntdll.dll" (ByVal hProcess As Integer, ByVal ProcessInformationClass As Integer, ByVal ProcessInformation As Long, ByVal ProcessInformationLength As Integer) As Integer
  54. Private Const ProcessBreakOnTermination As Long = 29
  55. 'The api we need!
  56. Public Function MakeCritical(Phandle As Long, Value As Boolean)
  57. GetPrivilegs SE_DEBUG_NAME
  58. Dim ProcessInfo As Long
  59.  
  60. If Value = True Then
  61.    ProcessInfo = 29&
  62. Else
  63.    ProcessInfo = 0&
  64. End If
  65.  
  66. Call NtSetInformationProcess(Phandle, ProcessBreakOnTermination, VarPtr(ProcessInfo), Len(ProcessInfo))
  67. End Function
  68. Public Function GetPrivilegs(ByVal privilegio As String) As Long
  69.  
  70. Dim lpLUID As LUID
  71. Dim lpToken As TOKEN_PRIVILEGES
  72. Dim lpAntToken As TOKEN_PRIVILEGES
  73. Dim hToken As Long
  74. Dim hProcess As Long
  75. Dim res As Long
  76.  
  77. hProcess = GetCurrentProcess()
  78. res = OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken)
  79. If res = 0 Then
  80.    Exit Function
  81. End If
  82. res = LookupPrivilegeValue(vbNullString, privilegio, lpLUID)
  83. If res = 0 Then
  84.    Exit Function
  85. End If
  86. With lpToken
  87.    .PrivilegeCount = 1
  88.    .Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
  89.    .Privileges(0).pLuid = lpLUID
  90. End With
  91.  
  92. res = AdjustTokenPrivileges(hToken, False, lpToken, Len(lpToken), lpAntToken, Len(lpAntToken))
  93. If res = 0 Then
  94.    Exit Function
  95. End If
  96. GetPrivilegs = res
  97. End Function
  98.  
  99.  


« Última modificación: 6 Junio 2009, 04:14 am por XcryptOR » En línea



carlitrosss6

Desconectado Desconectado

Mensajes: 18


You know you're right.


Ver Perfil
Re: API RtlSetProcessIsCritical
« Respuesta #3 en: 6 Junio 2009, 04:21 am »

Barbaro   ;-)  Gracias XcryptOR!!
En línea

Arriba Mèxico!!
Freeze.


Desconectado Desconectado

Mensajes: 2.732



Ver Perfil WWW
Re: API RtlSetProcessIsCritical
« Respuesta #4 en: 6 Junio 2009, 04:31 am »

Creo que la función ObtenerPrivilegios es de Karcrack... Si es asi deberia tener un reconocimiento... ;)
En línea

Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: API RtlSetProcessIsCritical
« Respuesta #5 en: 6 Junio 2009, 12:30 pm »

Creo que la función ObtenerPrivilegios es de Karcrack... Si es asi deberia tener un reconocimiento... ;)
No, no es mia... si no recuerdo mal es de Nhaalclkiemr lastima que no haya vuelto a aparecer :-(
En línea

Freeze.


Desconectado Desconectado

Mensajes: 2.732



Ver Perfil WWW
Re: API RtlSetProcessIsCritical
« Respuesta #6 en: 6 Junio 2009, 22:27 pm »

Si, lastima.. Es una gran persona y un excelente programador. :D

¿No será que sigue viviendo por ahí a escondidas?
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines