Antivirus!

Started by
5 comments, last by ShitFire 19 years, 2 months ago
yes i am trying to make a antivirus on vb.net ! i want to check datas and whole folders for datas with a surten string in its code (like "i hate go to school" for i love you virus) if got a code here but it doesnt work for me (vb.net) could be that its for vb 6.0 :( here is the code : Private Sub Command1_Click() Dim sData As String, sFilename As String, sVirus As String sFilename = "c:\eicar.com" 'Dateiname zum scannen ' EICAR-Test Virus Code! ' mehr unter: http://www.eicar.org/anti_virus_test_file.htm sVirus = "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" sData = GetFile(sFilename) 'Datei einlesen und in sData speichern ' Datei nach "Virus" durchsuchen If InStr(1, sData, sVirus, vbBinaryCompare) > 0 Then MsgBox "'" & sFilename & "' ist mit dem EICAR-Test Virus infiziert!", vbCritical, "Alarm!!!" Else MsgBox "Datei ist sauber.", vbInformation, "OK" End If End Sub Public Function GetFile(ByVal sFilename As String) As String ' Datei schnell einlesen 'On Error Resume Next Dim DateiLen As Long, nFileHandle As Integer nFileHandle = FreeFile Open sFilename For Binary Shared As #nFileHandle GetFile = String$(LOF(1), 0) Get #nFileHandle, , GetFile Close #nFileHandle End Function could someone write this for vb.net ? thanks i would be REALLY happy :=)
Advertisement
Quote:Original post by ShitFire
yes i am trying to make a antivirus on vb.net !

i want to check datas and whole folders for datas with a surten string in its code (like "i hate go to school" for i love you virus)

if got a code here but it doesnt work for me (vb.net) could be that its for vb 6.0 :(

here is the code :

Private Sub Command1_Click()
Dim sData As String, sFilename As String, sVirus As String

sFilename = "c:\eicar.com" 'Dateiname zum scannen

' EICAR-Test Virus Code!
' mehr unter: http://www.eicar.org/anti_virus_test_file.htm
sVirus = "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"

sData = GetFile(sFilename) 'Datei einlesen und in sData speichern

' Datei nach "Virus" durchsuchen
If InStr(1, sData, sVirus, vbBinaryCompare) > 0 Then
MsgBox "'" & sFilename & "' ist mit dem EICAR-Test Virus infiziert!", vbCritical, "Alarm!!!"
Else
MsgBox "Datei ist sauber.", vbInformation, "OK"
End If

End Sub

Public Function GetFile(ByVal sFilename As String) As String
' Datei schnell einlesen
'On Error Resume Next
Dim DateiLen As Long, nFileHandle As Integer
nFileHandle = FreeFile
Open sFilename For Binary Shared As #nFileHandle
GetFile = String$(LOF(1), 0)
Get #nFileHandle, , GetFile
Close #nFileHandle
End Function




could someone write this for vb.net ?

thanks i would be REALLY happy :=)


I think you're going have a very hard time making an effective antivirus program (least one that doesn't take several hours to complete a scan) without a low level disk access library. planetsourcecode.com has examples of how to return the filenames of all the files under a given directory and how traverse a drives directory structure so you can scan subfolders etc.
cant u tell me how the code here would work for .net ?

thanks for helping :) first i want to know how to write the thing written un top
Quote:Original post by ShitFire
cant u tell me how the code here would work for .net ?

thanks for helping :) first i want to know how to write the thing written un top


I don't code in VB.NET so I couldn't really tell you. The functions used in your example code are pretty fundamental so it shouldn't be hard to find tutorial for VB.NET. If you're having trouble with VB6 side I can help.

I've found three sites you may find helpful:
VB.NET Heaven[http://www.vbdotnetheaven.com/Sections/Tutorials.asp] Specificly this section [http://www.vbdotnetheaven.com/Code/Apr2003/006.asp] titled VB.NET for VB6 developers.

Programming Tutorials[http://www.programmingtutorials.com/vbnet.aspx]

...the Complete VB.NET Tutorial[http://visualbasic.about.com/od/learnvbnet/a/blecvbsbs0104.htm]
Patrick
ok thx ! il try to help myself as soon as i get home :)

can any1 else solve this in the meantime ? would be great!

thx
Why on earth could you possibly want to do such a thing? You do know that there are free anti-virus programs out there right? And they detect hundreds of times more viruses, at ten times the speed of anything you are considering writing (No one who is serious about creating an anti-virus program would ever write the detection engine in VB).

Not to mention, it's not a very safe thing to be doing, putting viruses onto your PC, to detect them. You'd want to keep the PC completely isolated, and reformat when you're done.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
well i just wanna do that ok?

please people ! i just wanna know this code in vb.net :)

thanks

edit: is there any free vb compiler for vb 6.0 or vb 5.0 ?

This topic is closed to new replies.

Advertisement