ntsd强制杀进程
ntsd從Windows 2000開始就是系統(tǒng)自帶的進程調試工具,在system32目錄下。NTSD的功能非常的強大,用法也比較復雜,但如果只用來結束一些進程,那就比較簡單了。在Windows中只有System、SMSS.EXE和CSRSS.EXE不能殺。前兩個是純內核態(tài)的,最后那個是Win32子系統(tǒng),ntsd本身需要它。lsass.exe也不要殺掉,它是負責本地賬戶安全的。被調試器附著(attach)的進程會隨調試器一起退出,所以可以用來在命令行下終止進程。
打開cmd 后輸入以下命令就可以結束進程:
方法一:利用進程的PID結束進程
命令格式:ntsd -c q -p pid
命令范例: ntsd -c q -p 1332 (結束explorer.exe進程)
范例詳解:explorer.exe的pid為1332,但是如何獲取進程的pid呢?在CMD下輸入TASKLIST就可以獲取當前任務管理器所有進程的PID。或者打開任務管理器,在菜單欄,選擇“查看”—“選擇列”,在打開的選擇項窗口中將“PID(進程標識符)”項選擇鉤上,這樣任務管理器的進程中就會多出PID一項了。(PID的分配并不固定,是在進程啟動是由系統(tǒng)隨機分配的,所以進程每次啟動的進程一般都不會一樣。)
方法二:利用進程名結束進程
命令格式:ntsd -c q -pn ***.exe (***.exe 為進程名,exe不能省)
命令范例:ntsd -c q -pn explorer.exe
另外的能結束進程的DOS命令還有taskkill和tskill命令:
命令格式: taskkill /pid 1234 /f ( 也可以達到同樣的效果。)
如果上面這些還不能滿足您的求知欲,下面還有:
ntsd詳解
有一些高等級的進程,tskill和taskkill或許無法結束,那么我們還有一個更強大的工具,那就是系統(tǒng)debug級的ntsd.準確的說,ntsd是一個系統(tǒng)調試工具,只提供給系統(tǒng)開發(fā)級的管理員使用,但是對我們殺掉進程還是很爽的.基本上除了WINDOWS系統(tǒng)自己的管理進程,ntsd都可以殺掉。NTSD 調試程序在啟動時要求用戶指定一個要連接的進程。使用 TLIST 或 PVIEWER,您可以獲得某個現(xiàn)有進程的進程 ID,然后鍵入 NTSD -p pid 來調試這個進程。NTSD 命令行使用如下的句法:
NTSD [options] imagefile
其中,imagefile 是要調試的映像名稱。
用法usage: ntsd [-?] [-2] [-d] [-g] [-G] [-myob] [-lines] [-n] [-o] [-s] [-v] [-w]
? ?? ?? ?? ?[-r BreakErrorLevel]??[-t PrintErrorLevel]
? ?? ?? ?? ?[-hd] [-pd] [-pe] [-pt #] [-pv] [-x | -x{e|d|n|i} <event>]
? ?? ?? ?? ?[-- | -p pid | -pn name | command-line | -z CrashDmpFile]
? ?? ?? ?? ?[-zp CrashPageFile] [-premote transport] [-robp]
? ?? ?? ?? ?[-aDllName] [-c "command"] [-i ImagePath] [-y SymbolsPath]
? ?? ?? ?? ?[-clines #] [-srcpath SourcePath] [-QR \\machine] [-wake <pid>]
? ?? ?? ?? ?[-remote transport:server=name,portid] [-server transport:portid]
? ?? ?? ?? ?[-ses] [-sfce] [-sicv] [-snul] [-noio] [-failinc] [-noshell]
where: -? displays this help text
? ?? ? command-line is the command to run under the debugger
? ?? ? -- is the same as -G -g -o -p -1 -d -pd
? ?? ? -aDllName sets the default extension DLL
? ?? ? -c executes the following debugger command
? ?? ? -clines number of lines of output history retrieved by a remote client
? ?? ? -failinc causes incomplete symbol and module loads to fail
? ?? ? -d sends all debugger output to kernel debugger via DbgPrint
? ?? ?? ? -d cannot be used with debugger remoting
? ?? ?? ? -d can only be used when the kernel debugger is enabled
? ?? ? -g ignores initial breakpoint in debuggee
? ?? ? -G ignores final breakpoint at process termination
? ?? ? -hd specifies that the debug heap should not be used
? ?? ?? ???for created processes.??This only works on Windows Whistler.
? ?? ? -o debugs all processes launched by debuggee
? ?? ? -p pid specifies the decimal process Id to attach to
? ?? ? -pd specifies that the debugger should automatically detach
? ?? ? -pe specifies that any attach should be to an existing debug port
? ?? ? -pn name specifies the name of the process to attach to
? ?? ? -pt # specifies the interrupt timeout
? ?? ? -pv specifies that any attach should be noninvasive
? ?? ? -r specifies the (0-3) error level to break on (SeeSetErrorLevel)
? ?? ? -robp allows breakpoints to be set in read-only memory
? ?? ? -t specifies the (0-3) error level to display (SeeSetErrorLevel)
? ?? ? -w specifies to debug 16 bit applications in a separate VDM
? ?? ? -x sets second-chance break on AV exceptions
? ?? ? -x{e|d|n|i} <event> sets the break status for the specified event
? ?? ? -2 creates a separate console window for debuggee
? ?? ? -i ImagePath specifies the location of the executables that generated
? ?? ?? ? the fault (see _NT_EXECUTABLE_IMAGE_PATH)
? ?? ? -lines requests that line number information be used if present
? ?? ? -myob ignores version mismatches in DBGHELP.DLL
? ?? ? -n enables verbose output from symbol handler
? ?? ? -noio disables all I/O for dedicated remoting servers
? ?? ? -noshell disables the .shell (!!) command
? ?? ? -QR <\\machine> queries for remote servers
? ?? ? -s disables lazy symbol loading
? ?? ? -ses enables strict symbol loading
? ?? ? -sfce fails critical errors encountered during file searching
? ?? ? -sicv ignores the CV record when symbol loading
? ?? ? -snul disables automatic symbol loading for unqualified names
? ?? ? -srcpath <SourcePath> specifies the source search path
? ?? ? -v enables verbose output from debugger
? ?? ? -wake <pid> wakes up a sleeping debugger and exits
? ?? ? -y <SymbolsPath> specifies the symbol search path (see _NT_SYMBOL_PATH)
? ?? ? -z <CrashDmpFile> specifies the name of a crash dump file to debug
? ?? ? -zp <CrashPageFile> specifies the name of a page.dmp file
? ?? ?? ?? ?? ?? ?? ?? ?? ?to use with a crash dump
? ?? ? -remote lets you connect to a debugger session started with -server
? ?? ?? ?? ?? ?must be the first argument if present
? ?? ?? ?? ?? ?transport: tcp | npipe | ssl | spipe | 1394 | com
? ?? ?? ?? ?? ?name: machine name on which the debug server was created
? ?? ?? ?? ?? ?portid: id of the port the debugger server was created on
? ?? ?? ?? ?? ?? ? for tcp use:??port=<socket port #>
? ?? ?? ?? ?? ?? ? for npipe use:??pipe=<name of pipe>
? ?? ?? ?? ?? ?? ? for 1394 use:??channel=<channel #>
? ?? ?? ?? ?? ?? ? for com use:??port=<COM port>,baud=<baud rate>,
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?channel=<channel #>
? ?? ?? ?? ?? ?? ? for ssl and spipe see the documentation
? ?? ?? ?? ?? ?example: ... -remote npipe:server=yourmachine,pipe=foobar
? ?? ? -server creates a debugger session other people can connect to
? ?? ?? ?? ?? ?must be the first argument if present
? ?? ?? ?? ?? ?transport: tcp | npipe | ssl | spipe | 1394 | com
? ?? ?? ?? ?? ?portid: id of the port remote users can connect to
? ?? ?? ?? ?? ?? ? for tcp use:??port=<socket port #>
? ?? ?? ?? ?? ?? ? for npipe use:??pipe=<name of pipe>
? ?? ?? ?? ?? ?? ? for 1394 use:??channel=<channel #>
? ?? ?? ?? ?? ?? ? for com use:??port=<COM port>,baud=<baud rate>,
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?channel=<channel #>
? ?? ?? ?? ?? ?? ? for ssl and spipe see the documentation
? ?? ?? ?? ?? ?example: ... -server npipe:pipe=foobar
? ?? ? -premote transport specifies the process server to connect to
? ?? ?? ?? ???transport arguments are given as with remoting
Environment Variables:
? ? _NT_SYMBOL_PATH=[Drive:][Path]
? ?? ???Specify symbol image path.
? ? _NT_ALT_SYMBOL_PATH=[Drive:][Path]
? ?? ???Specify an alternate symbol image path.
? ? _NT_DEBUGGER_EXTENSION_PATH=[Drive:][Path]
? ?? ???Specify a path which should be searched first for extensions dlls
? ? _NT_EXECUTABLE_IMAGE_PATH=[Drive:][Path]
? ?? ???Specify executable image path.
? ? _NT_SOURCE_PATH=[Drive:][Path]
? ?? ???Specify source file path.
? ? _NT_DEBUG_LOG_FILE_OPEN=filename
? ?? ???If specified, all output will be written to this file from offset 0.
? ? _NT_DEBUG_LOG_FILE_APPEND=filename
? ?? ???If specified, all output will be APPENDed to this file.
? ? _NT_DEBUG_HISTORY_SIZE=size
? ?? ???Specifies the size of a server's output history in kilobytes
Control Keys:
? ???<Ctrl-B><Enter> Quit debugger
? ???<Ctrl-C>? ?? ???Break into Target
? ???<Ctrl-F><Enter> Force a break into debuggee (same as Ctrl-C)
? ???<Ctrl-P><Enter> Debug Current debugger
? ???<Ctrl-V><Enter> Toggle Verbose mode
? ???<Ctrl-W><Enter> Print version information
ntsd: exiting - press enter ---
選項option:
-2打開一個用于調試字符模式的應用程序的新窗口
-d將輸出重定向到調試終端-g 使執(zhí)行自動通過第一個斷點
-G使 NTSD 在子程序終止時立即退出o啟用多個進程的調試,默認值為由調試程序衍生的一個進程
-p指定調試由進程 ID 標識的進程
-v產(chǎn)生詳細的輸出。
例如,假設 inetinfo.exe 的進程 ID 為 104。鍵入命令“NTSD -p 104”將 NTSD 調試程序連接到 inetinfo 進程 (IIS)。也可使用 NTSD 啟動一個新進程來進行調試。例如,NTSD notepad.exe 將啟動一個新的 notepad.exe 進程,并與它建立連接。一旦連接到某個進程,您就可以用各種命令來查看堆棧、設置斷點、轉儲內存,等等。
命令含義~顯示所有線程的一個列表KB 顯示當前線程的堆棧軌跡~*KB顯示所有線程的堆棧軌跡R顯示當前
幀的寄存器輸出U反匯編代碼并顯示過程名和偏移量D[type][< range>]轉儲內存BP設置斷點BC[]清除一個或多個斷點BD[]禁用一個或多個斷點BE[< bp>]啟用一個或多個斷點BL[]列出一個或多個斷點。
個人意見,有一個非常重要的參數(shù)就是-v參數(shù),我們可以通過它發(fā)現(xiàn)一個進程下面掛接了哪些連接庫文件。有很多病毒,木馬,或者惡意軟件,都喜歡把自己做成動態(tài)庫,然后注冊到系統(tǒng)正常程序的加載庫列表中,達到隱藏自己的目的.
首先我們需要設置一下ntsd的輸出重定向,最好是重定向到一個文本文件,方便我們分析研究.
c:\>set _NT_DEBUG_LOG_FILE_APPEND=c:\pdw.txt
注意,雖然輸出重定向了,但是我們的輸出依然會繼續(xù)顯示在屏幕上,而且會進入到debug模式,我們使用-c q參數(shù),就可以避免這個問題.
c:\>ntsd -c q -v notepad.exe
現(xiàn)在我們的pdw.txt文件中,就可以看見notepad.exe文件的調試信息.
打開cmd 后輸入以下命令就可以結束進程:
方法一:利用進程的PID結束進程
命令格式:ntsd -c q -p pid
命令范例: ntsd -c q -p 1332 (結束explorer.exe進程)
范例詳解:explorer.exe的pid為1332,但是如何獲取進程的pid呢?在CMD下輸入TASKLIST就可以獲取當前任務管理器所有進程的PID。或者打開任務管理器,在菜單欄,選擇“查看”—“選擇列”,在打開的選擇項窗口中將“PID(進程標識符)”項選擇鉤上,這樣任務管理器的進程中就會多出PID一項了。(PID的分配并不固定,是在進程啟動是由系統(tǒng)隨機分配的,所以進程每次啟動的進程一般都不會一樣。)
方法二:利用進程名結束進程
命令格式:ntsd -c q -pn ***.exe (***.exe 為進程名,exe不能省)
命令范例:ntsd -c q -pn explorer.exe
另外的能結束進程的DOS命令還有taskkill和tskill命令:
命令格式: taskkill /pid 1234 /f ( 也可以達到同樣的效果。)
如果上面這些還不能滿足您的求知欲,下面還有:
ntsd詳解
有一些高等級的進程,tskill和taskkill或許無法結束,那么我們還有一個更強大的工具,那就是系統(tǒng)debug級的ntsd.準確的說,ntsd是一個系統(tǒng)調試工具,只提供給系統(tǒng)開發(fā)級的管理員使用,但是對我們殺掉進程還是很爽的.基本上除了WINDOWS系統(tǒng)自己的管理進程,ntsd都可以殺掉。NTSD 調試程序在啟動時要求用戶指定一個要連接的進程。使用 TLIST 或 PVIEWER,您可以獲得某個現(xiàn)有進程的進程 ID,然后鍵入 NTSD -p pid 來調試這個進程。NTSD 命令行使用如下的句法:
NTSD [options] imagefile
其中,imagefile 是要調試的映像名稱。
用法usage: ntsd [-?] [-2] [-d] [-g] [-G] [-myob] [-lines] [-n] [-o] [-s] [-v] [-w]
? ?? ?? ?? ?[-r BreakErrorLevel]??[-t PrintErrorLevel]
? ?? ?? ?? ?[-hd] [-pd] [-pe] [-pt #] [-pv] [-x | -x{e|d|n|i} <event>]
? ?? ?? ?? ?[-- | -p pid | -pn name | command-line | -z CrashDmpFile]
? ?? ?? ?? ?[-zp CrashPageFile] [-premote transport] [-robp]
? ?? ?? ?? ?[-aDllName] [-c "command"] [-i ImagePath] [-y SymbolsPath]
? ?? ?? ?? ?[-clines #] [-srcpath SourcePath] [-QR \\machine] [-wake <pid>]
? ?? ?? ?? ?[-remote transport:server=name,portid] [-server transport:portid]
? ?? ?? ?? ?[-ses] [-sfce] [-sicv] [-snul] [-noio] [-failinc] [-noshell]
where: -? displays this help text
? ?? ? command-line is the command to run under the debugger
? ?? ? -- is the same as -G -g -o -p -1 -d -pd
? ?? ? -aDllName sets the default extension DLL
? ?? ? -c executes the following debugger command
? ?? ? -clines number of lines of output history retrieved by a remote client
? ?? ? -failinc causes incomplete symbol and module loads to fail
? ?? ? -d sends all debugger output to kernel debugger via DbgPrint
? ?? ?? ? -d cannot be used with debugger remoting
? ?? ?? ? -d can only be used when the kernel debugger is enabled
? ?? ? -g ignores initial breakpoint in debuggee
? ?? ? -G ignores final breakpoint at process termination
? ?? ? -hd specifies that the debug heap should not be used
? ?? ?? ???for created processes.??This only works on Windows Whistler.
? ?? ? -o debugs all processes launched by debuggee
? ?? ? -p pid specifies the decimal process Id to attach to
? ?? ? -pd specifies that the debugger should automatically detach
? ?? ? -pe specifies that any attach should be to an existing debug port
? ?? ? -pn name specifies the name of the process to attach to
? ?? ? -pt # specifies the interrupt timeout
? ?? ? -pv specifies that any attach should be noninvasive
? ?? ? -r specifies the (0-3) error level to break on (SeeSetErrorLevel)
? ?? ? -robp allows breakpoints to be set in read-only memory
? ?? ? -t specifies the (0-3) error level to display (SeeSetErrorLevel)
? ?? ? -w specifies to debug 16 bit applications in a separate VDM
? ?? ? -x sets second-chance break on AV exceptions
? ?? ? -x{e|d|n|i} <event> sets the break status for the specified event
? ?? ? -2 creates a separate console window for debuggee
? ?? ? -i ImagePath specifies the location of the executables that generated
? ?? ?? ? the fault (see _NT_EXECUTABLE_IMAGE_PATH)
? ?? ? -lines requests that line number information be used if present
? ?? ? -myob ignores version mismatches in DBGHELP.DLL
? ?? ? -n enables verbose output from symbol handler
? ?? ? -noio disables all I/O for dedicated remoting servers
? ?? ? -noshell disables the .shell (!!) command
? ?? ? -QR <\\machine> queries for remote servers
? ?? ? -s disables lazy symbol loading
? ?? ? -ses enables strict symbol loading
? ?? ? -sfce fails critical errors encountered during file searching
? ?? ? -sicv ignores the CV record when symbol loading
? ?? ? -snul disables automatic symbol loading for unqualified names
? ?? ? -srcpath <SourcePath> specifies the source search path
? ?? ? -v enables verbose output from debugger
? ?? ? -wake <pid> wakes up a sleeping debugger and exits
? ?? ? -y <SymbolsPath> specifies the symbol search path (see _NT_SYMBOL_PATH)
? ?? ? -z <CrashDmpFile> specifies the name of a crash dump file to debug
? ?? ? -zp <CrashPageFile> specifies the name of a page.dmp file
? ?? ?? ?? ?? ?? ?? ?? ?? ?to use with a crash dump
? ?? ? -remote lets you connect to a debugger session started with -server
? ?? ?? ?? ?? ?must be the first argument if present
? ?? ?? ?? ?? ?transport: tcp | npipe | ssl | spipe | 1394 | com
? ?? ?? ?? ?? ?name: machine name on which the debug server was created
? ?? ?? ?? ?? ?portid: id of the port the debugger server was created on
? ?? ?? ?? ?? ?? ? for tcp use:??port=<socket port #>
? ?? ?? ?? ?? ?? ? for npipe use:??pipe=<name of pipe>
? ?? ?? ?? ?? ?? ? for 1394 use:??channel=<channel #>
? ?? ?? ?? ?? ?? ? for com use:??port=<COM port>,baud=<baud rate>,
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?channel=<channel #>
? ?? ?? ?? ?? ?? ? for ssl and spipe see the documentation
? ?? ?? ?? ?? ?example: ... -remote npipe:server=yourmachine,pipe=foobar
? ?? ? -server creates a debugger session other people can connect to
? ?? ?? ?? ?? ?must be the first argument if present
? ?? ?? ?? ?? ?transport: tcp | npipe | ssl | spipe | 1394 | com
? ?? ?? ?? ?? ?portid: id of the port remote users can connect to
? ?? ?? ?? ?? ?? ? for tcp use:??port=<socket port #>
? ?? ?? ?? ?? ?? ? for npipe use:??pipe=<name of pipe>
? ?? ?? ?? ?? ?? ? for 1394 use:??channel=<channel #>
? ?? ?? ?? ?? ?? ? for com use:??port=<COM port>,baud=<baud rate>,
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?channel=<channel #>
? ?? ?? ?? ?? ?? ? for ssl and spipe see the documentation
? ?? ?? ?? ?? ?example: ... -server npipe:pipe=foobar
? ?? ? -premote transport specifies the process server to connect to
? ?? ?? ?? ???transport arguments are given as with remoting
Environment Variables:
? ? _NT_SYMBOL_PATH=[Drive:][Path]
? ?? ???Specify symbol image path.
? ? _NT_ALT_SYMBOL_PATH=[Drive:][Path]
? ?? ???Specify an alternate symbol image path.
? ? _NT_DEBUGGER_EXTENSION_PATH=[Drive:][Path]
? ?? ???Specify a path which should be searched first for extensions dlls
? ? _NT_EXECUTABLE_IMAGE_PATH=[Drive:][Path]
? ?? ???Specify executable image path.
? ? _NT_SOURCE_PATH=[Drive:][Path]
? ?? ???Specify source file path.
? ? _NT_DEBUG_LOG_FILE_OPEN=filename
? ?? ???If specified, all output will be written to this file from offset 0.
? ? _NT_DEBUG_LOG_FILE_APPEND=filename
? ?? ???If specified, all output will be APPENDed to this file.
? ? _NT_DEBUG_HISTORY_SIZE=size
? ?? ???Specifies the size of a server's output history in kilobytes
Control Keys:
? ???<Ctrl-B><Enter> Quit debugger
? ???<Ctrl-C>? ?? ???Break into Target
? ???<Ctrl-F><Enter> Force a break into debuggee (same as Ctrl-C)
? ???<Ctrl-P><Enter> Debug Current debugger
? ???<Ctrl-V><Enter> Toggle Verbose mode
? ???<Ctrl-W><Enter> Print version information
ntsd: exiting - press enter ---
選項option:
-2打開一個用于調試字符模式的應用程序的新窗口
-d將輸出重定向到調試終端-g 使執(zhí)行自動通過第一個斷點
-G使 NTSD 在子程序終止時立即退出o啟用多個進程的調試,默認值為由調試程序衍生的一個進程
-p指定調試由進程 ID 標識的進程
-v產(chǎn)生詳細的輸出。
例如,假設 inetinfo.exe 的進程 ID 為 104。鍵入命令“NTSD -p 104”將 NTSD 調試程序連接到 inetinfo 進程 (IIS)。也可使用 NTSD 啟動一個新進程來進行調試。例如,NTSD notepad.exe 將啟動一個新的 notepad.exe 進程,并與它建立連接。一旦連接到某個進程,您就可以用各種命令來查看堆棧、設置斷點、轉儲內存,等等。
命令含義~顯示所有線程的一個列表KB 顯示當前線程的堆棧軌跡~*KB顯示所有線程的堆棧軌跡R顯示當前
幀的寄存器輸出U反匯編代碼并顯示過程名和偏移量D[type][< range>]轉儲內存BP設置斷點BC[]清除一個或多個斷點BD[]禁用一個或多個斷點BE[< bp>]啟用一個或多個斷點BL[]列出一個或多個斷點。
個人意見,有一個非常重要的參數(shù)就是-v參數(shù),我們可以通過它發(fā)現(xiàn)一個進程下面掛接了哪些連接庫文件。有很多病毒,木馬,或者惡意軟件,都喜歡把自己做成動態(tài)庫,然后注冊到系統(tǒng)正常程序的加載庫列表中,達到隱藏自己的目的.
首先我們需要設置一下ntsd的輸出重定向,最好是重定向到一個文本文件,方便我們分析研究.
c:\>set _NT_DEBUG_LOG_FILE_APPEND=c:\pdw.txt
注意,雖然輸出重定向了,但是我們的輸出依然會繼續(xù)顯示在屏幕上,而且會進入到debug模式,我們使用-c q參數(shù),就可以避免這個問題.
c:\>ntsd -c q -v notepad.exe
現(xiàn)在我們的pdw.txt文件中,就可以看見notepad.exe文件的調試信息.
轉載于:https://www.cnblogs.com/rootq/articles/1252286.html
總結
- 上一篇: Http协议(4)—HTTP认证机制
- 下一篇: 医疗:LIS(2)