ASTUCE : IMPOSSIBLE D'ETEINDRE UNE APPLI (PROCESSUS) SOUS ALT CTRL DEL (XP&2000)

AtomWare Messages postés 71 Date d'inscription samedi 28 décembre 2002 Statut Membre Dernière intervention 11 novembre 2004 - 21 janv. 2003 à 23:22
tlsosiris Messages postés 24 Date d'inscription dimanche 18 avril 2004 Statut Membre Dernière intervention 14 mai 2004 - 5 mai 2004 à 21:20
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/5733-astuce-impossible-d-eteindre-une-appli-processus-sous-alt-ctrl-del-xp-2000

tlsosiris Messages postés 24 Date d'inscription dimanche 18 avril 2004 Statut Membre Dernière intervention 14 mai 2004
5 mai 2004 à 21:20
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
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
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As Long

Private Type LUID
LowPart As Long
HighPart As Long
End Type

Private Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As Long
End Type

Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type


Public Const MAX_PATH As Integer = 260
Public Const TH32CS_SNAPPROCESS As Long = 2&

Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * MAX_PATH
End Type


Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Function ProcessTerminate(Optional lProcessID As Long, Optional lHwndWindow As Long) As Boolean
Dim lhwndProcess As Long
Dim lExitCode As Long
Dim lRetVal As Long
Dim lhThisProc As Long
Dim lhTokenHandle As Long
Dim tLuid As LUID
Dim tTokenPriv As TOKEN_PRIVILEGES, tTokenPrivNew As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long

Const PROCESS_ALL_ACCESS &H1F0FFF, PROCESS_TERMINAT &H1
Const ANYSIZE_ARRAY 1, TOKEN_ADJUST_PRIVILEGES &H20
Const TOKEN_QUERY &H8, SE_DEBUG_NAME As String "SeDebugPrivilege"
Const SE_PRIVILEGE_ENABLED = &H2

On Error Resume Next
If lHwndWindow Then
'Get the process ID from the window handle
lRetVal = GetWindowThreadProcessId(lHwndWindow, lProcessID)
End If

If lProcessID Then
'Give Kill permissions to this process
lhThisProc = GetCurrentProcess

OpenProcessToken lhThisProc, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, lhTokenHandle
LookupPrivilegeValue "", SE_DEBUG_NAME, tLuid
'Set the number of privileges to be change
tTokenPriv.PrivilegeCount = 1
tTokenPriv.TheLuid = tLuid
tTokenPriv.Attributes = SE_PRIVILEGE_ENABLED
'Enable the kill privilege in the access token of this process
AdjustTokenPrivileges lhTokenHandle, False, tTokenPriv, Len(tTokenPrivNew), tTokenPrivNew, lBufferNeeded

'Open the process to kill
lhwndProcess = OpenProcess(PROCESS_TERMINAT, 0, lProcessID)

If lhwndProcess Then
'Obtained process handle, kill the process
ProcessTerminate = CBool(TerminateProcess(lhwndProcess, lExitCode))
Call CloseHandle(lhwndProcess)
End If
End If
On Error GoTo 0
End Function

Public Function KillProcessus(nom_process) As String
Dim i As Integer
Dim hSnapshot As Long
Dim uProcess As PROCESSENTRY32
Dim r As Long
Dim nom(1 To 100)
Dim num(1 To 100)
Dim nr As Integer
nr = 0
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapshot = 0 Then Exit Function
uProcess.dwSize = Len(uProcess)
r = ProcessFirst(hSnapshot, uProcess)
Do While r
nr = nr + 1
nom(nr) = uProcess.szexeFile
num(nr) = uProcess.th32ProcessID
r = ProcessNext(hSnapshot, uProcess)
Loop
For i = 1 To nr
If InStr(UCase(nom(i)), UCase(nom_process)) <> 0 Then
ProcessTerminate (num(i))
Exit For
End If
Next i
End Function



hi hi voila la soluce
osiris : au dela du possible
(peut etre tres pratique pour arreter touts les processus du virus sasser ( nommé avserve2)
Vedlen Messages postés 360 Date d'inscription mardi 14 octobre 2003 Statut Membre Dernière intervention 7 septembre 2009
19 mars 2004 à 13:40
Moi ca ne marche pas, lorsque j'exécute le prog j'ai une fenêtre d'alerte qui met: "erreur 70: permission refusée".
cs_Stephane Messages postés 550 Date d'inscription vendredi 5 janvier 2001 Statut Membre Dernière intervention 23 septembre 2006
27 oct. 2003 à 13:06
slu

je trouve aucun interet a ta source, le seul interet d'utiliser cette astuce c'est de faire troyen ou virus, bah j'sui désolé mais les troyens et les virus c de la merde (et je suis poli !) donc aucun intéret.

toi, tu n'as peut être pas l'intension de faire des virus ou autres, mais tout le monde n'est pas comme ca. Perso je connais une autre méthode, mais je ne l'a dit pas.

Voila, faut etre prudent et eviter de donner à des gens mal intentioné des failles (importantes il faut le dire) de window.

a+
cs_Kelpan Messages postés 70 Date d'inscription mercredi 24 avril 2002 Statut Membre Dernière intervention 17 septembre 2006
17 août 2003 à 20:15
Pour ceux qui ont Microsoft Visual C++, ils peuvent toujours utiliser la commande deboguer pour forcer la fermeture de l'appli.
yoman64 Messages postés 962 Date d'inscription samedi 19 janvier 2002 Statut Membre Dernière intervention 2 août 2010 2
15 août 2003 à 20:30
il y a toujours moyen d'effacer le fichier en demarrant en msdos (avant que le fichier soit charger) ou alors l'effacer a partir de linux
Mais dans les deux cas il faut faire appel a un autre os...
Et en effet ,il faudrait verifier le repertoire de windows.
cs_Carnage Messages postés 31 Date d'inscription dimanche 25 août 2002 Statut Membre Dernière intervention 1 février 2008
23 mars 2003 à 00:14
Je confirme pour LSASS, et l'idee est bonne
AtomWare Messages postés 71 Date d'inscription samedi 28 décembre 2002 Statut Membre Dernière intervention 11 novembre 2004
22 janv. 2003 à 22:38
Le mieux est de placer l'application dans Windows.
C'est bizarre qu'il y'ait des erreurs de permission sous 2000/NT.
Enfin, avec CSRSS.EXE, je ne pense pas que ce doit faire des erreures.
Un petit bug avec XP : avec "LSASS.EXE", le style visuel est désactivé (du moins, chez moi ).
Ricks27 Messages postés 79 Date d'inscription mardi 4 juin 2002 Statut Membre Dernière intervention 29 juillet 2005
22 janv. 2003 à 19:17
Je ne doute pas que ce code marche sous Xp (Je ne l'ai pas tester). Par contre sous 2000 et NT, on a des erreurs de permission dû à la sécurité.
cs_Ouneufe Messages postés 60 Date d'inscription mardi 4 septembre 2001 Statut Membre Dernière intervention 19 janvier 2009
22 janv. 2003 à 11:30
bien l'astuce, je vais pouvoir compléter ma "vache folle""
DelphiCool Messages postés 455 Date d'inscription mardi 24 juillet 2001 Statut Membre Dernière intervention 10 mars 2009
22 janv. 2003 à 10:54
le repertoire windows n'est pas forcément c:windows

sur mon PC par exemple c'est different ( volontairement ;-D)

il serait plus sur de recolter le chemin de windows avant de faire la copie
cs_Kirua Messages postés 3006 Date d'inscription dimanche 14 avril 2002 Statut Membre Dernière intervention 31 décembre 2008
22 janv. 2003 à 07:44
ouais ok, ça peut servir. mais bon, évitez qd même de programmer des virus les gars, y a plus intéressant à faire...
AtomWare Messages postés 71 Date d'inscription samedi 28 décembre 2002 Statut Membre Dernière intervention 11 novembre 2004
21 janv. 2003 à 23:22
J'ai fait une erreur, j'ai posté un double. Pas moyen de le suprimmer. J'ai enlevé le contenu. Désolé. C'est ma première source postée ici.
Rejoignez-nous