Taskkill.exe tắt process bằng API nào
Trang 1 trong tổng số 1 trang
Taskkill.exe tắt process bằng API nào
Trên máy tui, search *kill*.exe ra 1 đống *kill.exe:
1. kill.exe của WinDbg
2. pskill.exe của SysInternal
3. tskill.exe của MS
4. taskkill.exe của MS
Trong đống trên, pskill là phức tạp nhất, taskkill của MS đứng nhì. Nhưng RE taskkill.exe thì dể hơn vì ta có thể lấy pdb symbol file của nó.
Taskkill.exe được viết = VC++ 2003, viết theo OOP. Chủ đạo của taskkill là class CTaskKill, làm tất tần tật, parse cmd line, kill, kết nối remote machine...
Trên local machine, CTaskKill có 2 method private:
int __thiscall CTaskKill::KillProcessOnLocalSystem(int &)
int __thiscall CTaskKill::ForciblyKillProcessOnLocalSystem(void)
Thông số /F sẽ gọi hàm Forciblyxxx, còn không thì gọi KillProcessxxx
Hàm KillProcessOnLocalSystem chỉ dùng PostMessage với WM_CLOSE tới window của PID hay IM chỉ ra
Hàm ForciblyKillProcessOnLocalSystem thì dùng OpenProcess với param PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION, kiểm tra status của process với hàm API GetExitCodeProcess. Nếu process còn STILL_ACTIVE thì call API TerminateProcess.
Với remote machine, Kill method call private method: int __thiscall CTaskKill::ForciblyKillProcessOnRemoteSystem(void) . Method này dùng WMI command để kill.
1. kill.exe của WinDbg
2. pskill.exe của SysInternal
3. tskill.exe của MS
4. taskkill.exe của MS
Trong đống trên, pskill là phức tạp nhất, taskkill của MS đứng nhì. Nhưng RE taskkill.exe thì dể hơn vì ta có thể lấy pdb symbol file của nó.
Taskkill.exe được viết = VC++ 2003, viết theo OOP. Chủ đạo của taskkill là class CTaskKill, làm tất tần tật, parse cmd line, kill, kết nối remote machine...
Trên local machine, CTaskKill có 2 method private:
int __thiscall CTaskKill::KillProcessOnLocalSystem(int &)
int __thiscall CTaskKill::ForciblyKillProcessOnLocalSystem(void)
Thông số /F sẽ gọi hàm Forciblyxxx, còn không thì gọi KillProcessxxx
Hàm KillProcessOnLocalSystem chỉ dùng PostMessage với WM_CLOSE tới window của PID hay IM chỉ ra
Hàm ForciblyKillProcessOnLocalSystem thì dùng OpenProcess với param PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION, kiểm tra status của process với hàm API GetExitCodeProcess. Nếu process còn STILL_ACTIVE thì call API TerminateProcess.
- Code:
.text:01003447 private: int __thiscall CTaskKill::ForciblyKillProcessOnLocalSystem(void) proc near
.text:01003447 ; CODE XREF: CTaskKill::Kill(int &):loc_100476Dp
.text:01003447
.text:01003447 ExitCode= dword ptr -4
.text:01003447
.text:01003447 push ebp
.text:01003448 mov ebp, esp
.text:0100344A push ecx
.text:0100344B and [ebp+ExitCode], 0
.text:0100344F push esi
.text:01003450 push dword ptr [ecx+58h] ; dwProcessId
.text:01003453 push 0 ; bInheritHandle
.text:01003455 push 401h ; dwDesiredAccess
.text:0100345A call ds:OpenProcess(x,x,x) ; Opens an existing process object.
.text:0100345A
.text:01003460 mov esi, eax
.text:01003462 test esi, esi
.text:01003464 jz short @@TerminateProcess_Failed
.text:01003464
.text:01003466 lea eax, [ebp+ExitCode]
.text:01003469 push eax ; lpExitCode
.text:0100346A push esi ; hProcess
.text:0100346B call ds:GetExitCodeProcess(x,x) ; Retrieves the termination status of the specified process.
.text:0100346B
.text:01003471 test eax, eax
.text:01003473 jnz short @@ProcessStillActive
.text:01003473
.text:01003475 push esi ; hObject
.text:01003476 call ds:CloseHandle(x) ; Closes an open object handle
.text:01003476
.text:0100347C jmp short @@Return_FALSE
.text:0100347C
.text:0100347E ; ---------------------------------------------------------------------------
.text:0100347E
.text:0100347E @@ProcessStillActive: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+2Cj
.text:0100347E cmp [ebp+ExitCode], STILL_ACTIVE
.text:01003485 jz short @@TerminateProcess
.text:01003485
.text:01003487 push esi ; hObject
.text:01003488 call ds:CloseHandle(x) ; Closes an open object handle
.text:01003488
.text:0100348E push SCHED_E_TASK_NOT_RUNNING
.text:01003493 jmp short @@SetComLastError
.text:01003493
.text:01003495 ; ---------------------------------------------------------------------------
.text:01003495
.text:01003495 @@TerminateProcess: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+3Ej
.text:01003495 push 1 ; uExitCode
.text:01003497 push esi ; hProcess
.text:01003498 call ds:TerminateProcess(x,x) ; Terminates the specified process and all of its threads.
.text:01003498
.text:0100349E test eax, eax
.text:010034A0 push esi ; hObject
.text:010034A1 jnz short @@Return_TRUE
.text:010034A1
.text:010034A3 call ds:CloseHandle(x) ; Closes an open object handle
.text:010034A3
.text:010034A9
.text:010034A9 @@TerminateProcess_Failed: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+1Dj
.text:010034A9 call ds:GetLastError() ; Retrieves the calling thread's last-error code value.
.text:010034A9 ; The last-error code is maintained on a per-thread basis.
.text:010034A9
.text:010034AF cmp eax, ERROR_INVALID_PARAMETER
.text:010034B2 jnz short @@Return_FALSE
.text:010034B2
.text:010034B4 push CO_E_NOT_SUPPORTED ; dwErrCode
.text:010034B4
.text:010034B9
.text:010034B9 @@SetComLastError: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+4Cj
.text:010034B9 call ds:SetLastError(x) ; Sets the last-error code for the calling thread.
.text:010034B9
.text:010034BF
.text:010034BF @@Return_FALSE: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+35j
.text:010034BF ; CTaskKill::ForciblyKillProcessOnLocalSystem(void)+6Bj
.text:010034BF call SaveLastError()
.text:010034BF
.text:010034C4 xor eax, eax
.text:010034C6 jmp short @@Return
.text:010034C6
.text:010034C8 ; ---------------------------------------------------------------------------
.text:010034C8
.text:010034C8 @@Return_TRUE: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+5Aj
.text:010034C8 call ds:CloseHandle(x) ; Closes an open object handle
.text:010034C8
.text:010034CE xor eax, eax
.text:010034D0 inc eax
.text:010034D0
.text:010034D1
.text:010034D1 @@Return: ; CODE XREF: CTaskKill::ForciblyKillProcessOnLocalSystem(void)+7Fj
.text:010034D1 pop esi
.text:010034D2 leave
.text:010034D3 retn
.text:010034D3
.text:010034D3 private: int __thiscall CTaskKill::ForciblyKillProcessOnLocalSystem(void) endp
.text:010034D3
Với remote machine, Kill method call private method: int __thiscall CTaskKill::ForciblyKillProcessOnRemoteSystem(void) . Method này dùng WMI command để kill.
Similar topics
» Xác định IP của thư đến bằng Gmail
» Bảo mật hệ thống firewall từ xa bằng SSH
» Code Trojan viết bằng VB
» Hướng dẫn lập trình virus bằng Vbs.
» Debug javascript bằng firefox
» Bảo mật hệ thống firewall từ xa bằng SSH
» Code Trojan viết bằng VB
» Hướng dẫn lập trình virus bằng Vbs.
» Debug javascript bằng firefox
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
27/8/2013, 11:45 am by echcondihoc
» Quản Lí Tiến Trình Dùng Thư Viện PSAPI
11/10/2011, 9:42 pm by CNTT_DH
» xin tai lieu tieng viet
31/8/2011, 6:59 am by bantoisg
» Theo dõi tiến trình
27/8/2011, 5:51 pm by haigaopro01
» Giải pháp Bảo mật của Cisco
17/6/2011, 8:50 am by admin
» Nghiên cứu và đưa ra giải pháp phòng chống tấn công DoS, DDoS (Phần 1)
16/6/2011, 2:32 pm by admin
» Learn to hack !
16/6/2011, 8:49 am by admin
» Giải pháp hệ thống dành cho doanh nghiệp với thiết bị mạng Fortinet (Phần 1)
15/6/2011, 11:12 am by admin
» Ô Long Viên (Tập II)
27/9/2010, 4:56 pm by root
» những ebook về hack tiếng việt cho người mới tìm hiểu.
27/9/2010, 4:54 pm by root