elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Descargar archivos creandolos de de forma oculta.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: Descargar archivos creandolos de de forma oculta.  (Leído 5,456 veces)
Scratz


Desconectado Desconectado

Mensajes: 318



Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #10 en: 22 Agosto 2007, 22:30 pm »

Perfecto, Hades. Sencillo y muy útil. Ahora tengo otra duda... ¿Como mato un archivo oculto? Con la función Kill no puedo... no hace nada.


« Última modificación: 22 Agosto 2007, 23:21 pm por Scratz » En línea

\\... The Revolution Is Comming ...//
~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #11 en: 23 Agosto 2007, 01:48 am »

Prueva con la api DeleteFile. La descripcion de la api guide:

Citar
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long

· lpFileName
Points to a null-terminated string that specifies the file to be deleted.

Y el ejemplo:

Código
  1. 'This program needs a Dialog box, named CDBox1
  2. '  (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
  3. '   and select Microsoft Common Dialog control)
  4. Private Type FILETIME
  5.    dwLowDateTime As Long
  6.    dwHighDateTime As Long
  7. End Type
  8. Private Type SHFILEOPSTRUCT
  9.    hWnd As Long
  10.    wFunc As Long
  11.    pFrom As String
  12.    pTo As String
  13.    fFlags As Integer
  14.    fAborted As Boolean
  15.    hNameMaps As Long
  16.    sProgress As String
  17. End Type
  18. Private Type SYSTEMTIME
  19.    wYear As Integer
  20.    wMonth As Integer
  21.    wDayOfWeek As Integer
  22.    wDay As Integer
  23.    wHour As Integer
  24.    wMinute As Integer
  25.    wSecond As Integer
  26.    wMilliseconds As Integer
  27. End Type
  28. Private Const GENERIC_WRITE = &H40000000
  29. Private Const OPEN_EXISTING = 3
  30. Private Const FILE_SHARE_READ = &H1
  31. Private Const FILE_SHARE_WRITE = &H2
  32. Private Const FO_DELETE = &H3
  33. Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
  34. Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As Long) As Long
  35. Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
  36. Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
  37. Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
  38. Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
  39. Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (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
  40. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  41. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
  42. Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
  43. Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
  44. Private Sub Form_Load()
  45.    'KPD-Team 1998
  46.    'URL: http://www.allapi.net/
  47.    'E-Mail: KPDTeam@Allapi.net
  48.    Dim lngHandle As Long, SHDirOp As SHFILEOPSTRUCT, lngLong As Long
  49.    Dim Ft1 As FILETIME, Ft2 As FILETIME, SysTime As SYSTEMTIME
  50.    'Set the dialog's title
  51.    CDBox.DialogTitle = "Choose a file ..."
  52.    'Raise an error when the user pressed cancel
  53.    CDBox.CancelError = True
  54.    'Show the 'Open File'-dialog
  55.    CDBox.ShowOpen
  56.    'Create a new directory
  57.    CreateDirectory "C:\KPD-Team", ByVal &H0
  58.    'Copy the selected file to our new directory
  59.    CopyFile CDBox.filename, "C:\KPD-Team\" + CDBox.FileTitle, 0
  60.    'Rename the file
  61.    MoveFile "C:\KPD-Team\" + CDBox.FileTitle, "C:\KPD-Team\test.kpd"
  62.    'Open the file
  63.    lngHandle = CreateFile("C:\KPD-Team\test.kpd", GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
  64.    'Get the file's size
  65.    MsgBox "The size of the selected file is" + Str$(GetFileSize(lngHandle, lngLong)) + " bytes."
  66.    'Get the fil's time
  67.    GetFileTime lngHandle, Ft1, Ft1, Ft2
  68.    'Convert the file time to the local file time
  69.    FileTimeToLocalFileTime Ft2, Ft1
  70.    'Convert the file time to system file time
  71.    FileTimeToSystemTime Ft1, SysTime
  72.    MsgBox "The selected file was created on" + Str$(SysTime.wMonth) + "/" + LTrim(Str$(SysTime.wDay)) + "/" + LTrim(Str$(SysTime.wYear))
  73.    'Close the file
  74.    CloseHandle lngHandle
  75.    'Delete the file
  76.    DeleteFile "C:\KPD-Team\test.kpd"
  77.    With SHDirOp
  78.        .wFunc = FO_DELETE
  79.        .pFrom = "C:\KPD-Team"
  80.    End With
  81.    'Delete the directory
  82.    SHFileOperation SHDirOp
  83.    End
  84. End Sub

Aunke me parece mucho ejemplo para lo es la api en si xDD

Si tampoco lo consigues borrar con la api siempre puedes cambiar el atributo oculto del archivo (lo dejas en normal) y ya lo borras con kill  :P


En línea

Scratz


Desconectado Desconectado

Mensajes: 318



Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #12 en: 23 Agosto 2007, 11:55 am »

Ehm... sí, mejor lo devuelvo a normal y lo mato con kill. Ese ejemplo da miedo, y seguro que también errores para adaptarlo a mi programa =S
En línea

\\... The Revolution Is Comming ...//
Lambda


Desconectado Desconectado

Mensajes: 371



Ver Perfil WWW
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #13 en: 23 Agosto 2007, 13:18 pm »

simplemente mete la declaracion

Código
  1. Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long

y Llamala asi

Código
  1. DeleteFile "archivoaborrar.extension"

no tiene mas misterio
En línea

kichan


Desconectado Desconectado

Mensajes: 372


Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #14 en: 23 Agosto 2007, 14:24 pm »

Por Dios  como tener miedo de utilizar las Apis si gracias a ello el programa se vuelve mas sofisticado por decirlo de algun modo, ademas ganamos en velocidad y no tiene ninguna dificultad declararlas y usuarlas..
lo que pasa, es que estas tan acostumbrado a las malas tecniucas de programacion que enseña el basic..

en fin...

saludos.
En línea

~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #15 en: 23 Agosto 2007, 14:37 pm »

Ehm... sí, mejor lo devuelvo a normal y lo mato con kill. Ese ejemplo da miedo, y seguro que también errores para adaptarlo a mi programa =S

Jajaja si ya te habia dicho yo q:

Citar
Aunke me parece mucho ejemplo para lo es la api en si xDD

Solo tienes q hacer lo q te dice Lambda, fijate en la explicacion de la api (la primera cita de mi anterior post ;))
En línea

Scratz


Desconectado Desconectado

Mensajes: 318



Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #16 en: 23 Agosto 2007, 17:48 pm »

Gracias a todos. Pero mi miedo a las apis se debe a que...

Código
  1. Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long



Muchas veces tengo errores con las declaraciones, y no entiendo por qué  :-\

Por eso prefiero ir a lo fácil.
En línea

\\... The Revolution Is Comming ...//
~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #17 en: 23 Agosto 2007, 18:02 pm »

Es por q la estas poniendo en un form, asi declarada hiria en un modulo. Para ponerla en un form tienes q hacerlo asi (ya te dejo un ejemplo completo)

Código
  1. Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
  2.  
  3. Private Sub Form_Load()
  4. DeleteFile "C:\hola.txt"
  5. End Sub
En línea

kichan


Desconectado Desconectado

Mensajes: 372


Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #18 en: 23 Agosto 2007, 18:05 pm »

De partida deberias perderle el miedo

esque solo tienes un problema de declaracion,,,
porque no creo que de sintaxis en las apis
siempre es preferible meterlas dentro de un modulo..
no en el general form
« Última modificación: 23 Agosto 2007, 18:17 pm por kichan » En línea

Scratz


Desconectado Desconectado

Mensajes: 318



Ver Perfil
Re: Descargar archivos creandolos de de forma oculta.
« Respuesta #19 en: 23 Agosto 2007, 19:15 pm »

Es por q la estas poniendo en un form, asi declarada hiria en un modulo. Para ponerla en un form tienes q hacerlo asi (ya te dejo un ejemplo completo)

Código
  1. Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
  2.  
  3. Private Sub Form_Load()
  4. DeleteFile "C:\hola.txt"
  5. End Sub

Bien, gracias. No sabía eso =/ Perdón por mi torpeza. Demos este post por acabado ;P
En línea

\\... The Revolution Is Comming ...//
Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines