Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: randomcito en 14 Febrero 2010, 14:11 pm



Título: [VB6] Run-time error '40020'
Publicado por: randomcito en 14 Febrero 2010, 14:11 pm
Hola a todos, este es mi primer post... xD

Bueno, estaba haciendo un troyano en VB6 con Winsock 6.0, (todavía no he hecho el server)

Al poner el puerto y de host google, pero tira el error ¬¬
No sé de qué se trata, aquí está el código:

Código:
'CONEXIÓN'
Private Sub Command2_Click()
   Winsock1.RemoteHost = Text3.Text
   Winsock1.RemotePort = Text4.Text
   Winsock1.Close
   Winsock1.Connect
End Sub

Private Sub Winsock1_Connect()
  Text1.Text = Text1.Text & "*** Conexion establecida." & vbCrLf
  Text1.SelStart = Len(Text1.Text)
End Sub

'DESCONEXIÓN POR ERROR'
Private Sub Winsock1_Close()
 'cierra la conexion
   Winsock1.Close
 'mensaje en la ventana
   Text1.SelStart = Len(Text1.Text)
   Text1.Text = Text1.Text & "*** Conexion cerrada por el servidor." & vbCrLf
   Text1.SelStart = Len(Text1.Text)
 End Sub

'DESCONEXIÓN DESDE CLIENTE'
Private Sub Command3_Click()
    Winsock1.Close
    Text1.Text = Text1.Text & "*** Conexion cerrada por el usuario." & vbCrLf
  'desplazamos el scroll
    Text1.SelStart = Len(Text1.Text)
 End Sub
 
 
 'ENVIAR'
 Private Sub Command1_Click()
  'enviamos el contenido de Text2
     Winsock1.SendData Text2.Text & vbCrLf
  'apuntamos al final del contenido del TextBox e
  'insertamos los nuevos datos obtenidos
     Text1.SelStart = Len(Text1.Text)
     Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf
     Text1.SelStart = Len(Text1.Text)
    Text2.Text = ""
 End Sub
 Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim Buffer As String 'variable para guardar los datos
 'obtenemos los datos y los guardamos en una variable
    Winsock1.GetData Buffer
 'apuntamos al final del contenido del TextBox e
 'insertamos los nuevos datos obtenidos
    Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
    Text1.Text = Text1.Text & "Servidor >" & Buffer 'mostramos los datos
    Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
  End Sub


'ERRORES

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
 'cerramos la conexion
   Winsock1.Close
 'mostramos informacion sobre el error
   MsgBox "Error numero " & Number & ": " & Description, vbCritical
End Sub



No sé qué ocurre, alguien sabe algo?
Gracias


Título: Re: [VB6] Run-time error '40020'
Publicado por: Nanoc en 24 Febrero 2010, 01:42 am
Coloca ip y puerto por codigo en lugar de cogerlo por un texbox y vuelve a probar
Código:
   Winsock1.RemoteHost = google.es
   Winsock1.RemotePort = 80


Título: Re: [VB6] Run-time error '40020'
Publicado por: BlackZeroX en 24 Febrero 2010, 02:59 am
Coloca ip y puerto por codigo en lugar de cogerlo por un texbox y vuelve a probar
Código:
   Winsock1.RemoteHost = google.es
   Winsock1.RemotePort = 80


Por seguridad la DNS es entre comillas, el puerto por mi parte me da igual.

Código
  1.  
  2. Winsock1.RemoteHost = "www.google.com.mx"
  3.  
  4.  

pero prueba con este corregí algunas cosillas y te las comente.

Código
  1.  
  2. 'CONEXIÓN'
  3. Private Sub Command2_Click()
  4.    ' antes de cambiar el remotehost y el remoteport hay que cerrar o verificar que este cerrado el socket, o causaria un error lo mas seguro.
  5.   Winsock1.Close
  6.   Winsock1.RemoteHost = Text3.Text
  7.   Winsock1.RemotePort = Val(Text4.Text)
  8.   Winsock1.Connect
  9. End Sub
  10.  
  11. Private Sub Winsock1_Connect()
  12.  Text1.Text = Text1.Text & "*** Conexion establecida." & vbCrLf
  13.  Text1.SelStart = Len(Text1.Text)
  14. End Sub
  15.  
  16. 'DESCONEXIÓN POR ERROR'
  17. Private Sub Winsock1_Close()
  18. 'cierra la conexion
  19.   Winsock1.Close
  20. 'mensaje en la ventana
  21.   Text1.SelStart = Len(Text1.Text)
  22.   Text1.Text = Text1.Text & "*** Conexion cerrada por el servidor." & vbCrLf
  23.   Text1.SelStart = Len(Text1.Text)
  24. End Sub
  25.  
  26. 'DESCONEXIÓN DESDE CLIENTE'
  27. Private Sub Command3_Click()
  28.    Winsock1.Close
  29.    Text1.Text = Text1.Text & "*** Conexion cerrada por el usuario." & vbCrLf
  30.  'desplazamos el scroll
  31.    Text1.SelStart = Len(Text1.Text)
  32. End Sub
  33.  
  34.  
  35. 'ENVIAR'
  36. Private Sub Command1_Click()
  37. '  7 = socket conectado.
  38. If Winsock1.State = 7 Then         '   hay que verificar que exista una conexion actual o causa un error.
  39.  'enviamos el contenido de Text2
  40.     Winsock1.SendData Text2.Text & vbCrLf
  41.  'apuntamos al final del contenido del TextBox e
  42.  'insertamos los nuevos datos obtenidos
  43.     Text1.SelStart = Len(Text1.Text)
  44.     Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf
  45.     Text1.SelStart = Len(Text1.Text)
  46.    Text2.Text = ""
  47. End If
  48. End Sub
  49. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  50.    Dim Buffer As String 'variable para guardar los datos
  51. 'obtenemos los datos y los guardamos en una variable
  52.    Winsock1.GetData Buffer, vbString, 80
  53. 'apuntamos al final del contenido del TextBox e
  54. 'insertamos los nuevos datos obtenidos
  55.    Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
  56.    Text1.Text = Text1.Text & "Servidor >" & Buffer 'mostramos los datos
  57.    Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
  58.  End Sub
  59.  
  60.  
  61. 'ERRORES
  62.  
  63. Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  64. 'cerramos la conexion
  65.   Winsock1.Close
  66. 'mostramos informacion sobre el error
  67.   MsgBox "Error numero " & Number & ": " & Description, vbCritical
  68. End Sub
  69.  
  70.  

Sangrientas Lunas!¡.