ntsd

ntsd

ntsd是一個用戶態進程調試工具,從Windows 2000就開始被附隨在System32目錄下。它能夠結束除System、smss.exe、csrss.exe、lsass.exe及各種rootkit程式外所有的程式。但在Windows Vista及以上版本的Windows中不含ntsd,必須手動下載至電腦中才可使用。

基本介紹

  • 中文名:WindowsNT系統調試工具
  • 外文名:Windows NT System Debugger
  • 屬性:進程調試工具
  • 非適用:System、SMSS.EXE、csrss.exe
  • 職責:負責本地賬戶安全
  • 程式名:ntsd.exe
  • 所在路徑:%Windir%\System32\
用來結束進程,詳解,

用來結束進程

Ntsd在Windows中只有System、smss.exe、csrss.exe、lsass.exe和一些rootkit程式不能殺。前兩個是純核心態的,第三個是Win32子系統,ntsd本身需要它。lsass.exe也不要殺掉,它是負責本地賬戶安全的。被調試器附著的進程會隨調試器一起退出,所以可以用來在命令行下終止進程。
打開cmd 後輸入以下命令就可以結束進程:
利用進程PID結束進程
命令格式:ntsd -c q -p pid
命令範例: ntsd -c q -p 4 (結束System進程。當然,System進程是殺不掉的)
範例詳解:System的pid為4,但是如何獲取進程的pid呢?在CMD下輸入TASKLIST就可以獲取當前任務管理器所有進程的PID。或者打開任務管理器,在選單欄,選擇“查看”—“選擇列”,在打開的選擇項視窗中將“PID(進程標識符)”項選擇鉤上,這樣任務管理器的進程中就會多出PID一項了。(PID的分配並不固定,是在進程啟動時由系統隨機分配的,所以進程每次啟動的進程一般都不會一樣。)
或者使用taskkill /pid 1234 /f 也可以達到同樣的效果(但某些程式有簡單的進程保護就結束不了)。
可使用以下批處理,製作一個簡單的結束進程的工具:
=================================================
rem 複製以下內容到記事本,另外儲存為pid.bat
@echo off
mode con cols=30 lines=10
rem 調整視窗大小
color 1e
rem 設定視窗顏色
echo.
set /p t=請輸入進程名:
echo PID NAME& echo ============
for /f "tokens=2 delims=," %%i in ('tasklist /fo csv /fi "imagename eq %t%.exe" /nh') do ntsd -c q -p %%i&echo %%i %t%
pause >nul
exit
=================================================
利用進程名結束進程
命令格式:ntsd -c q -pn ***.exe (***.exe 為進程名,exe不能省)
命令範例:ntsd -c q -pn explorer.exe
另外的能結束進程的DOS命令還有taskkill和tskill命令:
taskkill/f/im ***.exe(***.exe 為進程名,exe不能省)

詳解

有一些高等級的進程,tskill和taskkill或許無法結束,那么我們還有一個更強大的工具,那就是系統debug級的ntsd.準確的說,ntsd是一個系統調試工具,只提供給系統開發級的管理員使用,但是對我們殺掉進程還是很爽的.基本上除了WINDOWS系統自己的管理進程,ntsd幾乎都可以殺掉。NTSD 調試程式在啟動時要求用戶指定一個要連線的進程。使用 TLIST 或 PVIEWER,您可以獲得某個現有進程的進程 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 ]
[-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 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 使執行自動通過第一個斷點
-G使 NTSD 在子程式終止時立即退出o啟用多個進程的調試,默認值為由調試程式衍生的一個進程
-p指定調試由進程 ID 標識的進程
-v產生詳細的輸出。
例如,假設 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[]列出一個或多個斷點。
個人意見,有一個非常重要的參數就是-v參數,我們可以通過它發現一個進程下面掛接了哪些連線庫檔案。有很多病毒,木馬,或者惡意軟體,都喜歡把自己做成動態庫,然後註冊到系統正常程式的載入庫列表中,達到隱藏自己的目的.
首先我們需要設定一下ntsd的輸出重定向,最好是重定向到一個文本檔案,方便我們分析研究.
c:\>set _NT_DEBUG_LOG_FILE_APPEND=c:\pdw.txt
注意,雖然輸出重定向了,但是我們的輸出依然會繼續顯示在螢幕上,而且會進入到debug模式,我們使用-c q參數,就可以避免這個問題.
c:\>ntsd -c q -v notepad.exe
現在我們的pdw.txt檔案中,就可以看見notepad.exe檔案的調試信息.
可以知道,ntsd的軟體終止能力是很好很強大的,一些taskkill都無法終止的軟體(如Student.exe這一類或木馬)可以用ntsd輕易終止
但是它仍有缺點,因為技術在不斷更新,在對付最新的有很強防護的病毒等程式時
,仍建議使用PowerTool,IceSword等ARK工具。可以試一下ntsd拿360,IceSword,nod32等殺軟程式毫無辦法。

相關詞條

熱門詞條

聯絡我們