Título: FiletoString Function [VB6]
Publicado por: The Swash en 8 Abril 2010, 22:29 pm
Option Explicit '-------------------------------------------------------------------------------------------- ' Function : FiletoString ' Coder : The Swash ' References And Constans : API-Guide ' DateTime : 08/04/2010 '--------------------------------------------------------------------------------------------
'Shlwapi.dll Private Declare Function PathFileExistsA Lib "shlwapi.dll" (ByVal pszPath As String) As Long
'Kernel32.dll Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateFileA Lib "kernel32" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
'Constants Const FILE_SHARE_READ = &H1 Const OPEN_EXISTING = 3 Const GENERIC_READ = &H80000000 Const FILE_SHARE_WRITE = &H2 Public Function FiletoString(sFile As String) As String Dim hFile As Long Dim hFSize As Long Dim bvBuff() As Byte Dim hBytes As Long Dim hRead As Long
If PathFileExistsA(sFile) > 0 Then hFile = CreateFileA(sFile, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0) If hFile > 0 Then hFSize = GetFileSize(hFile, 0) ReDim bvBuff(1 To hFSize) hRead = ReadFile(hFile, bvBuff(1), UBound(bvBuff), hBytes, 0&) If hRead > 0 Then FiletoString = StrConv(bvBuff, vbUnicode) End If End If End If Call CloseHandle(hFile) End Function Call: Dim sFile As String sFile = FiletoString(File path) Disculpen por la descripcion xD, esta funcion permite obtener las strings de un ejecutable, usado mucho en el mundo del malware pero tambien se puede usar para muchas otras cosas :D
Título: Re: FiletoString Function [VB6]
Publicado por: Shell Root en 8 Abril 2010, 22:29 pm
Descripción?
Título: Re: FiletoString Function [VB6]
Publicado por: The Swash en 8 Abril 2010, 22:49 pm
Descripcion puesta en el post prinicipal, siendo exactos esto permite obtener todas las strings del archivo, hay muchos uso que se les puede dar como inyectar en memoria(uso de RunPE), Encryptar, editar, usar para escribir otro archivo, etc..
Título: Re: FiletoString Function [VB6]
Publicado por: Karcrack en 8 Abril 2010, 23:13 pm
No obtiene las cadenas de un ejecutable... sino que obtiene un fichero en forma de cadena... no es muy buena idea... si el fichero pesa mas de 64KB no cabra en un String. http://support.microsoft.com/kb/104554/es De todas formas es mucho codigo, se puede hacer sin APIs, simplemente con las sentencias de VB... Open etc... Otra cosa, no es necesario que compruebes si existe el fichero, porque si usas CreateFile() con OPEN_EXISTING y no existe el fichero devolverá -1 (INVALID_HANDLE_VALUE), y en err.LastDllError sera igual a 2 (ERROR_FILE_NOT_FOUND)...
Título: Re: FiletoString Function [VB6]
Publicado por: BlackZeroX en 9 Abril 2010, 06:55 am
Call CloseHandle(hFile)
debe ir despues de ReadFile(), aun ta mal. faltan toques jeje
Dulces Lunas!¡.
|