Creating Anti Virus software

skyfe

Member
Joined
Jan 16, 2009
Messages
14
Programming Experience
3-5
Hi,

Was wondering how to create Anti virus Software, using Visual Basic .NET. The part I'm interested into is how to scan a file on malware; how can this be done with Visual Basic .NET? Could anyone explain me what codes, functions, to use, and maybe give a little example? (for example to detect a specific easy to detect virus infection)

Thanks in advanced,

Skyfe.
 
Have a giant array of structures storing all "bad files" and the paths they can appear in (use CSV storage). Then loop through all files and if they match, delete them.

I have no idea how you would "scan" a file for a malware infection. Way out of my league :eek:
 
Start with this or similar articles about general knowledge: What is a virus signature? Are they still used?
Internet searches and Wiki searches is also recommended.

About code you should start with FileStream class to read bytes from files.

Here is a very basic algorithm that searches for a virus signature in a file:
VB.NET:
Function detect() As Boolean
    Dim file() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9} 'sample file
    Dim virus() As Byte = {4, 5, 6} 'sample signature

    For ix As Integer = 0 To file.Length - virus.Length
        If file(ix) = virus(0) Then 'found first byte in signature, check rest
            For vx As Integer = 1 To virus.Length - 1
                If file(ix + vx) <> virus(vx) Then
                    Exit For
                ElseIf vx = virus.Length - 1 Then
                    Return True 'virus found
                End If
            Next
        End If
    Next
    Return False 'virus not found
End Function
 
Hi,

Thanks a lot, I'll have a further look into it because as for now the code looks rather complicated to me already (whiel it's a basic example as you said), so will have a look at that link about virus signatures.
 
Last edited by a moderator:
Back
Top