Antivirus merupakan sebuah aplikasi yang mana berguna untuk memblokir,
mengkarantina, atau menghapus program jahat berupa virus ataupun worm.
Prinsip kerja dari antivirus ada mendeteksi dengan cara membaca isi
tubuh dari program (scan) dan mendaftarkan isinya disesuaikan dengan
database yang telah di daftarkan, sehingga jika ada program atau
aplikasi yang telah sesuai dengan database yang ada di antivirus itu
maka program tersebut bisa dikatakan virus atau worm, jika tidak maka ia
bukan virus atau worm

.
Pertama-tama Anda buat New Project dahulu di Delphi 7 Anda, kemudian ganti nama (rename)
Form1, menjadi
FormUtama dan save dengan nama
form_utama.pas.
004 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
005 | Dialogs, StdCtrls,Utility_AV, ComCtrls, Menus; |
008 | TFormUtama = class(TForm) |
009 | GroupBox1: TGroupBox; |
010 | rb_scan1: TRadioButton; |
011 | rb_scan2: TRadioButton; |
014 | GroupBox2: TGroupBox; |
015 | lbl_jumlahfile: TLabel; |
019 | btn_tentang: TButton; |
021 | ck_scansubdir: TCheckBox; |
022 | GroupBox3: TGroupBox; |
023 | lv_virlist: TListView; |
029 | procedure btn_tentangClick(Sender: TObject); |
030 | procedure FormCreate(Sender: TObject); |
031 | procedure btn_keluarClick(Sender: TObject); |
032 | procedure btn_scanClick(Sender: TObject); |
033 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
034 | procedure edt_cariClick(Sender: TObject); |
035 | procedure rb_scan2Click(Sender: TObject); |
036 | procedure btn_clsClick(Sender: TObject); |
037 | procedure btn_delvirClick(Sender: TObject); |
040 | Procedure ScanVirus(Semua:Boolean); |
041 | Procedure SaatScanFile (Path:String); |
042 | Procedure TambahList (NamaVirus,Path:String); |
050 | FormUtama: TFormUtama; |
051 | SedangDiScan:Boolean; |
052 | rStartTime : Integer; |
056 | DBaseCRC32Virus : Array [0..2] of String = ('DD7A0BA8','7A014FFF','BDB819EB'); |
057 | DBaseNamaVirus : Array [0..2] of String = ('CodeRed','Moondlight.D','FluBurung'); |
058 | MAX_SCAN : Int64 = 10 * 1024 * 1024; |
067 | function CekUkuranFile(const FileName: string): Int64; |
069 | SearchRec: TSearchRec; |
072 | if FindFirst(FileName, faAnyFile, SearchRec) = 0 then |
074 | Int64Rec(Result).Lo := SearchRec.FindData.nFileSizeLow; |
075 | Int64Rec(Result).Hi := SearchRec.FindData.nFileSizeHigh; |
076 | FindClose(SearchRec); |
080 | Procedure TFormUtama.TambahList (NamaVirus,Path:String); |
086 | lvi := lv_virList.FindCaption(0,Path, false, true, false); |
087 | while Assigned(lvi) do |
089 | if Lowercase(lvi.SubItems[1]) = Lowercase(Path) then exit; |
090 | lvi := lv_virList.FindCaption(lvi.Index, Path, false, false, false); |
094 | lvi := lv_virList.Items.Add; |
095 | lvi.Caption := NamaVirus; |
096 | lvi.SubItems.Add(Path); |
097 | lbl_virus.Caption := 'Jumlah virus ditemukan : ' + IntToStr(Lv_VirList.Items.Count); |
102 | Procedure TFormUtama.SaatScanFile (Path:String); |
109 | ElapsedTime : String; |
112 | ElapsedTime := Format('%.1f', [0.001*(GetTickCount-rStartTime)]); |
114 | Application.ProcessMessages; |
115 | IF (CekUkuranFile(Path) <= MAX_SCAN) Then Begin |
116 | HitungFileCRC32 ( Path, CRC32, TB, Err ); |
117 | CRC32Str := IntToHex(Crc32,8); |
118 | For i:=Low(DBaseCRC32Virus) to High(DBaseCRC32Virus) do |
120 | if (CRC32Str = DBaseCRC32Virus[i]) then TambahList(DBaseNamaVirus[i],Path); |
124 | lbl_jumlahfile.Caption := 'Jumlah file : ' + IntToStr(C); |
125 | lbl_waktu.Caption := 'Waktu tempuh : ' + ElapsedTime; |
126 | mm_status.Lines.Text := Path; |
129 | procedure TFormUtama.btn_tentangClick(Sender: TObject); |
131 | MsgBox(Handle,'Tentang Program', |
132 | 'Gue Antivirus (GAV) ' + #13#10 + |
133 | 'Diprogramkan oleh Ali' + #13#10#13#10 + |
135 | 'E-Mail : ali.programmer@telkom.net' + #13#10#13#10 + |
136 | 'Copyright © Ali Software - Delphi Source Code. All Rights Reserved.', |
140 | procedure TFormUtama.FormCreate(Sender: TObject); |
142 | SedangDiScan := False; |
145 | procedure TFormUtama.btn_keluarClick(Sender: TObject); |
149 | If MsgBox(Handle,'Keluar Program', |
150 | 'Apakah Anda ingin keluar saat program sedang mencari virus ?', |
151 | Question + YesNo) = No Then Exit; |
156 | Procedure TFormUtama.ScanVirus(Semua:Boolean); |
158 | CallBack :TOnCariFile; |
159 | Drives:Array of String; |
163 | CallBack := SaatScanFile; |
167 | If (edt_folder.Text = '') then Begin |
168 | Msgbox(Handle,'Error','Tentukan dulu Folder atau Drive-nya',Critical); |
171 | CariFile(edt_folder.Text,ck_scansubdir.Checked,'*.*',CallBack); |
174 | For i:=Ord('A') to Ord('Z') do |
175 | Case GetDriveType(Pchar(Chr(i) + ':\')) of |
182 | Drives[L-1]:=Chr(i) + ':\'; |
186 | For i:=Low(Drives) to High(Drives) do |
188 | If DriveSiap(Drives[i]) Then |
189 | CariFile(Drives[i],ck_scansubdir.Checked,'*.*',CallBack); |
196 | procedure TFormUtama.btn_scanClick(Sender: TObject); |
200 | If Not SedangDiScan Then |
208 | BerhentiMencari := False; |
210 | rStartTime := GetTickCount; |
213 | SedangDiScan := True; |
214 | btn_scan.Caption := '&Berhenti..'; |
215 | ScanVirus ( rb_scan1.Checked ) ; |
217 | btn_scan.Caption := '&Scan'; |
218 | SedangDiScan := False; |
224 | If MsgBox(Handle,'Scan Virus', |
225 | 'Apakah Anda ingin menghentikan proses scan virus ?', |
226 | Question + YesNo) = Yes Then |
227 | BerhentiMencari := True; |
232 | procedure TFormUtama.FormCloseQuery(Sender: TObject; |
233 | var CanClose: Boolean); |
235 | btn_keluarClick(Sender); |
238 | procedure TFormUtama.edt_cariClick(Sender: TObject); |
242 | Dir := BrowseDialog(Handle,'Cari Folder / Drive'); |
245 | edt_folder.Text := Dir; |
250 | procedure TFormUtama.rb_scan2Click(Sender: TObject); |
252 | edt_folder.Enabled := rb_scan2.Checked ; |
253 | edt_cari.Enabled := rb_scan2.Checked; |
256 | procedure TFormUtama.btn_clsClick(Sender: TObject); |
258 | If (Lv_VirList.Items.Count < 1) then Exit; |
259 | If MsgBox(Handle,'Bersihkan List', |
260 | 'Apakah Anda ingin membersihkan list (tanpa menghapus virus) ?', |
261 | Question + YesNo) = Yes Then |
262 | lv_virlist.Items.Clear; |
265 | procedure TFormUtama.btn_delvirClick(Sender: TObject); |
270 | For i:=0 to Lv_VirList.Items.Count -1 do |
271 | If Lv_VirList.Items[i].Checked then begin |
276 | If Msgbox(Handle,'Perhatian','Pilih salah satu item',Exclamation) = OK Then |
279 | For i:=0 to Lv_VirList.Items.Count -1 do |
280 | If Lv_VirList.Items[i].Checked then begin |
281 | Bisa := DeleteFile(Lv_VirList.Items[i].SubItems[0]); |
283 | If Msgbox(Handle,'Error','File tidak dapat di hapus,' + |
284 | 'kemungkinan windows sedang menjalankannya', |
285 | CRITICAL) = OK Then Exit |
286 | Else Lv_VirList.Items[i].Delete; |
0 komentar:
Posting Komentar