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

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Subir archivos a un ftp
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 3 Ir Abajo Respuesta Imprimir
Autor Tema: Subir archivos a un ftp  (Leído 7,876 veces)
RED_HORSE

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Subir archivos a un ftp
« en: 23 Abril 2006, 20:25 pm »

  Bueno es algo por poco tiempo no lo pude aprender vien y querria si alguien me puede mostrar ejemplos simples de como hacerlo.
  Se los agradecería que fuera lo mas simple posible ;D ;D


En línea

Red Mx
Rojito
Colaborador
***
Desconectado Desconectado

Mensajes: 3.649


Viva México Cabrones...


Ver Perfil WWW
Subir archivos a un ftp
« Respuesta #1 en: 23 Abril 2006, 21:28 pm »

Bueno no se si lo quieras hacer por Vb por que no entendi pero bueno


Ya que tienes tu cuenta en un hosting desde una ventana en windows por "  ftp.nombre.com " si estas en miarroba seria ftp.miarroba.com de ahi entras le das click derecho en iniciar sesion pones tu nombre de usuario contraseña despues copeas y pegas tus archivos que quieres subir y ya estaran en internet.


Bueno no se si era esto lo que buscabas es algo confuso o tu dises desde una aplicacion VB nop entiendo


En línea

Desarrollar Malware Es Causa De Cancer...
TaN€R


Desconectado Desconectado

Mensajes: 2.599


Amo el foro!


Ver Perfil WWW
Re: Subir archivos a un ftp
« Respuesta #2 en: 23 Abril 2006, 21:40 pm »

Si, la verdad que se ha explicado como un libro cerrado  :D,
pero supongo que lo que querrá es saber como hacer un ftp en visual basic¿
En línea

Meg


Desconectado Desconectado

Mensajes: 462



Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #3 en: 23 Abril 2006, 21:54 pm »

se a explicado mas o menos supongo k kerra decir hacer un programa k escoja un archivo y subirlo a un ftp ami tambien me interesaria un codigo k haga eso para ponerlo en mi troyano en vb supongo k no tiene k ser muy dificil
En línea

SheKeL_C$


Desconectado Desconectado

Mensajes: 549


_-=[Sh3K3L_C$]=-_


Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #4 en: 23 Abril 2006, 23:21 pm »

Este code le tenia por elpc pero no se kien l puso  :rolleyes: :rolleyes:

Código:
'Declaraciones
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Const INTERNET_DEFAULT_FTP_PORT = 21
Const INTERNET_SERVICE_FTP = 1
Const PassiveConnection As Boolean = True
Const INTERNET_FLAG_PASSIVE = &H8000000
Const FTP_TRANSFER_TYPE_UNKNOWN = &H0


Private Sub Form_Load()
Dim hConnection, hOpen, Num As Long

'Subir el archivo a un ftp

hOpen = InternetOpen("IE", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
DoEvents
hConnection = InternetConnect(hOpen, "ftp.hostingdelftp.es", INTERNET_DEFAULT_FTP_PORT, "user", "pass", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
DoEvents
FtpSetCurrentDirectory hConnection, "\"
DoEvents
FtpPutFile hConnection, "RUTA de Local del archivo.txt", "nombre_remoto.txt", FTP_TRANSFER_TYPE_UNKNOWN, 0
DoEvents
InternetCloseHandle hConnection
InternetCloseHandle hOpen
End Sub
En línea

RED_HORSE

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #5 en: 23 Abril 2006, 23:22 pm »

  si es hacer una aplicasion en visual bacic que suba y descarga archivos a traves de un servidor ftp ;D

  yo ya consegui subir archivos pero lo de bajar archivos  eso estoy investigando ;D ;D
En línea

RED_HORSE

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #6 en: 24 Abril 2006, 00:27 am »

  bueno si, el codigo que dio saken_c4 funciona pero por ejemplo y coloco este codigo en un formulario con un boton(command1_click) y al presionar el boton envia el archivo al server ftp . ASTA AKI TODO BIEN ;D ;D

  Pero a lo que voy es que cuando intento mandar otro archivo ya no me lo deja mandarlo. La unica forma de poder mandar nuevamente ese archivo es cerrando el formulario(programa) y volviendolo a iniciar por que sera :-( alguien podria decirme una solucion a esto :-( :-( :-( :-( :-( :-( :-( :-(

   ( al presionar una vez el boton)
                 programa==> envia datos al server ftp
  (al presionar por segunda vez el boton)
                 programa==>  no envia el el nuevo dato
  (para que funcione)
                 cierro el programa ==> y alli recien funciona para enviar otros datos pero solo una vex y asi sucesibamente
« Última modificación: 24 Abril 2006, 00:38 am por RED_HORSE » En línea

NYlOn


Desconectado Desconectado

Mensajes: 842


OOOOHHHHHH, TARAGÜIIII xDDDDDD


Ver Perfil WWW
Re: Subir archivos a un ftp
« Respuesta #7 en: 24 Abril 2006, 23:06 pm »

Aca te dejo 2 funciones para subir y bajar archivos de un FTP.

NOTA: NO necesita ningun control OCX.

En un modulo comun ponemos el siguiente codigo:
Código:
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
Declare Function GetProcessHeap Lib "kernel32" () As Long
Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Public Const HEAP_ZERO_MEMORY = &H8
Public Const HEAP_GENERATE_EXCEPTIONS = &H4

Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Long, hpvSource As Any, ByVal cbCopy As Long)

Public Const MAX_PATH = 260
Public Const NO_ERROR = 0
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_OFFLINE = &H1000


Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

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 Const ERROR_NO_MORE_FILES = 18

Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" _
    (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
   
Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _
(ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _
      lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
      ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _
      ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
      ByVal lpszRemoteFile As String, _
      ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" _
    (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
' Initializes an application's use of the Win32 Internet functions
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

' User agent constant.
Public Const scUserAgent = "vb wininet"

' Use registry access settings.
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_OPEN_TYPE_DIRECT = 1
Public Const INTERNET_OPEN_TYPE_PROXY = 3
Public Const INTERNET_INVALID_PORT_NUMBER = 0

Public Const FTP_TRANSFER_TYPE_BINARY = &H2
Public Const FTP_TRANSFER_TYPE_ASCII = &H1
Public Const INTERNET_FLAG_PASSIVE = &H8000000

' Opens a HTTP session for a given site.
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
               
Public Const ERROR_INTERNET_EXTENDED_ERROR = 12003
Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" ( _
    lpdwError As Long, _
    ByVal lpszBuffer As String, _
    lpdwBufferLength As Long) As Boolean

' Number of the TCP/IP port on the server to connect to.
Public Const INTERNET_DEFAULT_FTP_PORT = 21
Public Const INTERNET_DEFAULT_GOPHER_PORT = 70
Public Const INTERNET_DEFAULT_HTTP_PORT = 80
Public Const INTERNET_DEFAULT_HTTPS_PORT = 443
Public Const INTERNET_DEFAULT_SOCKS_PORT = 1080

Public Const INTERNET_OPTION_CONNECT_TIMEOUT = 2
Public Const INTERNET_OPTION_RECEIVE_TIMEOUT = 6
Public Const INTERNET_OPTION_SEND_TIMEOUT = 5

Public Const INTERNET_OPTION_USERNAME = 28
Public Const INTERNET_OPTION_PASSWORD = 29
Public Const INTERNET_OPTION_PROXY_USERNAME = 43
Public Const INTERNET_OPTION_PROXY_PASSWORD = 44

' Type of service to access.
Public Const INTERNET_SERVICE_FTP = 1
Public Const INTERNET_SERVICE_GOPHER = 2
Public Const INTERNET_SERVICE_HTTP = 3

' Opens an HTTP request handle.
Public Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" _
(ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, _
ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long

' Brings the data across the wire even if it locally cached.
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const INTERNET_FLAG_KEEP_CONNECTION = &H400000
Public Const INTERNET_FLAG_MULTIPART = &H200000

Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000

' Sends the specified request to the HTTP server.
Public Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal _
hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As _
String, ByVal lOptionalLength As Long) As Integer


' Queries for information about an HTTP request.
Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" _
(ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, _
ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer

' The possible values for the lInfoLevel parameter include:
Public Const HTTP_QUERY_CONTENT_TYPE = 1
Public Const HTTP_QUERY_CONTENT_LENGTH = 5
Public Const HTTP_QUERY_EXPIRES = 10
Public Const HTTP_QUERY_LAST_MODIFIED = 11
Public Const HTTP_QUERY_PRAGMA = 17
Public Const HTTP_QUERY_VERSION = 18
Public Const HTTP_QUERY_STATUS_CODE = 19
Public Const HTTP_QUERY_STATUS_TEXT = 20
Public Const HTTP_QUERY_RAW_HEADERS = 21
Public Const HTTP_QUERY_RAW_HEADERS_CRLF = 22
Public Const HTTP_QUERY_FORWARDED = 30
Public Const HTTP_QUERY_SERVER = 37
Public Const HTTP_QUERY_USER_AGENT = 39
Public Const HTTP_QUERY_SET_COOKIE = 43
Public Const HTTP_QUERY_REQUEST_METHOD = 45
Public Const HTTP_STATUS_DENIED = 401
Public Const HTTP_STATUS_PROXY_AUTH_REQ = 407

' Add this flag to the about flags to get request header.
Public Const HTTP_QUERY_FLAG_REQUEST_HEADERS = &H80000000
Public Const HTTP_QUERY_FLAG_NUMBER = &H20000000
' Reads data from a handle opened by the HttpOpenRequest function.
Public Declare Function InternetReadFile Lib "wininet.dll" _
(ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer

Public Declare Function InternetWriteFile Lib "wininet.dll" _
        (ByVal hFile As Long, ByVal sBuffer As String, _
        ByVal lNumberOfBytesToRead As Long, _
        lNumberOfBytesRead As Long) As Integer

Public Declare Function FtpOpenFile Lib "wininet.dll" Alias _
        "FtpOpenFileA" (ByVal hFtpSession As Long, _
        ByVal sFileName As String, ByVal lAccess As Long, _
        ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function FtpDeleteFile Lib "wininet.dll" _
    Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _
    ByVal lpszFileName As String) As Boolean
Public Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByVal lBufferLength As Long) As Integer
Public Declare Function InternetSetOptionStr Lib "wininet.dll" Alias "InternetSetOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByVal sBuffer As String, ByVal lBufferLength As Long) As Integer

' Closes a single Internet handle or a subtree of Internet handles.
Public Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer

' Queries an Internet option on the specified handle
Public Declare Function InternetQueryOption Lib "wininet.dll" Alias "InternetQueryOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long) As Integer

' Returns the version number of Wininet.dll.
Public Const INTERNET_OPTION_VERSION = 40

' Contains the version number of the DLL that contains the Windows Internet
' functions (Wininet.dll). This structure is used when passing the
' INTERNET_OPTION_VERSION flag to the InternetQueryOption function.
Public Type tWinInetDLLVersion
    lMajorVersion As Long
    lMinorVersion As Long
End Type

' Adds one or more HTTP request headers to the HTTP request handle.
Public Declare Function HttpAddRequestHeaders Lib "wininet.dll" Alias "HttpAddRequestHeadersA" _
(ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, _
ByVal lModifiers As Long) As Integer

' Flags to modify the semantics of this function. Can be a combination of these values:

' Adds the header only if it does not already exist; otherwise, an error is returned.
Public Const HTTP_ADDREQ_FLAG_ADD_IF_NEW = &H10000000

' Adds the header if it does not exist. Used with REPLACE.
Public Const HTTP_ADDREQ_FLAG_ADD = &H20000000

' Replaces or removes a header. If the header value is empty and the header is found,
' it is removed. If not empty, the header value is replaced
Public Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000

Public Function FtpSubir(Servidor As String, Usuario As String, Contraseña As String, ArchLocal As String, ArchRemoto As String) As Boolean
    Dim hConnection, hOpen As Long
   
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
    hConnection = InternetConnect(hOpen, Servidor, INTERNET_INVALID_PORT_NUMBER, Usuario, Contraseña, INTERNET_SERVICE_FTP, nFlag, 0)
    vBool = FtpPutFile(hConnection, ArchLocal, ArchRemoto, FTP_TRANSFER_TYPE_BINARY, 0)
    FtpSubir = vBool
    InternetCloseHandle hConnection
End Function

Public Function FtpBajar(Servidor As String, Usuario As String, Contraseña As String, ArchRemoto As String, ArchLocal As String, EXE As Boolean) As Boolean
On Error Resume Next
    Dim hConnection, hOpen As Long
   
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
    hConnection = InternetConnect(hOpen, Servidor, INTERNET_INVALID_PORT_NUMBER, Usuario, Contraseña, INTERNET_SERVICE_FTP, nFlag, 0)
    vBool = FtpGetFile(hConnection, ArchRemoto, ArchLocal, False, INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_BINARY, 0)
    FtpBajar = vBool
    InternetCloseHandle hConnection
   
    If EXE = True Then ShellExecute Me.hWnd, "", ArchLocal, "", "", 0
End Function




Las funciones devuelven True o False (dependiendo si se pudo realizar o no la accion deseada).

Un ejemplo para bajar archivos seria:
Código:
MsgBox FtpBajar("200.32.12.4:21", "Mi Usuario", "Mi Contraseña", "Carpeta\Archivo.exe", "C:\Archivo.exe", True)
'El True al final significa que el archivo va a ser ejecutado cuando se termine la descarga

Un ejemplo para subir archivos seria:
Código:
msgbox ftpsubir("200.32.12.4:21","Mi Usuario", "Mi Contrasela", "C:\Archivo.exe", "Carpeta FTP\Archivo.exe")



Espero que te sea de utilidad, saludos.-

« Última modificación: 26 Abril 2006, 01:25 am por NYlOn » En línea

RED_HORSE

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #8 en: 24 Abril 2006, 23:24 pm »

  gracias lo pruebo y te digo ;D ;D ;D
En línea

RED_HORSE

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Subir archivos a un ftp
« Respuesta #9 en: 24 Abril 2006, 23:32 pm »

  Private Function FtpBajar(Servidor As String, Usuario As String, Contraseña As String, ArchRemoto As String, ArchLocal As String, EXE As Boolean) As Boolean

  Me da un errorsaso en ese parte del modulo me podrias pasar el modulo por algun link
     gracias
En línea

Páginas: [1] 2 3 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Python]Subir archivos via FTP
Scripting
Arnau27 1 3,770 Último mensaje 20 Septiembre 2013, 09:57 am
por fallout20xx
subir archivos con bat a ftp
Scripting
binario010101 1 3,540 Último mensaje 17 Octubre 2013, 08:52 am
por Eleкtro
Problema con git subir archivos
GNU/Linux
h3ch1c3r0 0 1,744 Último mensaje 17 Febrero 2018, 22:12 pm
por h3ch1c3r0
subir archivos a mi aplicacion
Java
Beginner Web 2 2,009 Último mensaje 16 Mayo 2019, 21:41 pm
por Beginner Web
Subir varios archivos FTP
PHP
SrTrp 2 2,736 Último mensaje 28 Febrero 2020, 03:30 am
por @XSStringManolo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines