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

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15
41  Programación / .NET (C#, VB.NET, ASP) / Re: Algun interesado en crear un Autoclicker. Con patrones en: 14 Octubre 2012, 22:10 pm
interesante,,tengo disponibilidad horario soy de argentina y en lo que guste podemos hacer!
42  Programación / .NET (C#, VB.NET, ASP) / Re: Enviar un ENTER por Winsock en: 27 Agosto 2012, 01:05 am
envia el usuario y un daato cm WinsockClient.SendData Usuario & "enter" 'Enter
y lo lees en donde recibe el winsok y lo ejecutas..
43  Programación / .NET (C#, VB.NET, ASP) / Re: [pliss] copiar matriz de byte en una estructura en: 20 Enero 2012, 04:34 am
leo pruebo y te digo, gracias, la verdad no encontre pero lo mas seguro busque mal.
44  Programación / .NET (C#, VB.NET, ASP) / [pliss] copiar matriz de byte en una estructura en: 19 Enero 2012, 21:47 pm
hola amigos quisiera saber y de que manera podria copiar una matriz de byte en una estructura, intente con marshall pero me da error, y se que rtlmovememory podria pero quisiera ver algo que sea nativo.gracias
45  Programación / .NET (C#, VB.NET, ASP) / Re: Guardar imagen en una carpeta desde un PictureBox VB.NET en: 30 Diciembre 2011, 23:20 pm
espacio de nombres ! "Drawing.Image" de hay lee algo por la red y problema resuelto en dos lineas
46  Programación / .NET (C#, VB.NET, ASP) / Re: Spammer V2.0 Renovado servidor SMTP en: 16 Octubre 2011, 22:20 pm
busca expresiones regulares para validar mail! pero igual esta bueno! y no lo probe
47  Programación / .NET (C#, VB.NET, ASP) / Problema con Modulo de clase en: 10 Octubre 2011, 01:36 am
Hola a todos amigos ! les cuento e creado esa clase (son dos), para el uso de socket, pero tengo un problema cuando voy a hacer uso de los eventos ! al mostrarlos me aparecen como privados y me da error en listview y demas cosas, que podra ser ? o estoy haciendo algo mal?

Código
  1. Imports System.Text
  2. Imports System.IO
  3. Imports System.Net
  4. Imports System.Net.Sockets
  5. Namespace Network
  6.    Public Class Cliente
  7.        Implements IDisposable
  8. #Region " Declaraciones "
  9.        Private Socket As Socket
  10.        Private CallBackHandler As AsyncCallback
  11.        Private ClientList As ArrayList = ArrayList.Synchronized(New ArrayList())
  12.        Private objEndPoint As IPEndPoint
  13.        Private ID As Integer = 0
  14.        Private BufData As Byte() = New Byte(65536) {}
  15.        Public Event DatosRecibidos(ByVal Datos() As Byte, ByVal SocketID As Integer)
  16.        Public Event ErrorCatched(ByVal msg As String)
  17.        Public Event Desconectado()
  18.        Public Event Conectado(ByVal SocketID As Integer)
  19. #End Region
  20.  
  21. #Region " Procedimientos "
  22.        Public Sub Conectar(ByVal vsIp As String, ByVal viPuerto As Integer)
  23.            Try
  24.                If Socket IsNot Nothing Then
  25.                    If Socket.Connected Then
  26.                        Call Desconectar()
  27.                    End If
  28.                End If
  29.                Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  30.                Socket.NoDelay = True
  31.                Socket.DontFragment = False
  32.                Socket.LingerState.Enabled = True
  33.                Socket.LingerState.LingerTime = 100
  34.                Socket.SendBufferSize = 65536
  35.                Socket.ReceiveBufferSize = 65536
  36.                Dim endpoint As Net.IPEndPoint
  37.                endpoint = New IPEndPoint(IPAddress.Parse(vsIp), viPuerto)
  38.                Socket.Connect(endpoint)
  39.  
  40.                If Socket.Connected Then
  41.                    objEndPoint = CType(Socket.RemoteEndPoint, IPEndPoint)
  42.                    Call EsperaDeDatos()
  43.                End If
  44.            Catch ex As SocketException
  45.                RaiseEvent ErrorCatched(ex.Message)
  46.            End Try
  47.        End Sub
  48.        Public Sub Desconectar()
  49.            Try
  50.                If Socket IsNot Nothing Then
  51.                    If Socket.Connected Then
  52.                        Socket.Disconnect(True)
  53.                    End If
  54.                    Socket.Close()
  55.                    Socket = Nothing
  56.                End If
  57.                RaiseEvent Desconectado()
  58.            Catch SE As SocketException
  59.                RaiseEvent ErrorCatched(SE.Message)
  60.            End Try
  61.        End Sub
  62.        Public Sub Desconectar(ByVal SocketID As Integer)
  63.            DropClient(GetSocketPacket(SocketID), False, False)
  64.        End Sub
  65.        Public Function EnviarMensaje(ByVal SocketID As Integer, ByVal Datos() As Byte) As Boolean
  66.  
  67.            Try
  68.                If GetSocketPacket(SocketID).mClientSocket.Connected Then
  69.                    GetSocketPacket(SocketID).mClientSocket.Send(Datos)
  70.                    Return (True)
  71.                Else
  72.                    Return (False)
  73.                End If
  74.            Catch
  75.                Return (False)
  76.            End Try
  77.        End Function
  78.  
  79.        Public Function EnviarMensaje(ByVal SocketID As Integer, ByVal Mensaje As String) As Boolean
  80.            Try
  81.                If GetSocketPacket(SocketID).mClientSocket.Connected Then
  82.                    Dim NetStream As New NetworkStream(GetSocketPacket(SocketID).mClientSocket)
  83.  
  84.                    Dim SocketStream As New StreamWriter(NetStream)
  85.                    SocketStream.Write(Mensaje)
  86.  
  87.                    SocketStream.Flush()
  88.                    Return (True)
  89.                Else
  90.                    Return (False)
  91.                End If
  92.            Catch
  93.                Return (False)
  94.            End Try
  95.        End Function
  96.  
  97.  
  98. #End Region
  99.  
  100. #Region " Procedimientos Privados "
  101.        Private Sub EsperaDeDatos()
  102.            Try
  103.                If CallBackHandler Is Nothing Then
  104.                    CallBackHandler = New AsyncCallback(AddressOf OnDataReceived)
  105.                End If
  106.                Dim socketId As Integer = 1
  107.                If ClientList.Count > 0 Then
  108.                    socketId = TryCast(ClientList(ClientList.Count - 1), SocketPacket).mSocketID + 1
  109.                End If
  110.                Dim ConnectedClient As New SocketPacket(Socket, socketId)
  111.                ClientList.Add(ConnectedClient)
  112.                ID += 1
  113.                Socket.BeginReceive(BufData, 0, BufData.Length, SocketFlags.None, CallBackHandler, Socket)
  114.                RaiseEvent Conectado(ConnectedClient.mSocketID)
  115.            Catch SE As SocketException
  116.                RaiseEvent ErrorCatched(SE.Message)
  117.            Catch E As Exception
  118.                RaiseEvent ErrorCatched(E.Message)
  119.            End Try
  120.        End Sub
  121.        Private Sub OnDataReceived(ByVal Asyn As IAsyncResult)
  122.            Try
  123.                Dim ConnectedClient As SocketPacket = DirectCast(Asyn.AsyncState, SocketPacket)
  124.                If Not ConnectedClient.mClientSocket.Connected Then
  125.                    Return
  126.                End If
  127.                Dim CollectedDataLength As Integer = Socket.EndReceive(Asyn)
  128.                If CollectedDataLength = 0 Then
  129.                    If ConnectedClient.mClientSocket.Connected Then
  130.                        ConnectedClient.mClientSocket.Disconnect(False)
  131.                    End If
  132.                    ConnectedClient.mClientSocket.Close()
  133.  
  134.                    RaiseEvent Desconectado()
  135.                Else
  136.                    RaiseEvent DatosRecibidos(BufData, ConnectedClient.mSocketID)
  137.                    EsperaDeDatos()
  138.                End If
  139.            Catch generatedExceptionName As ObjectDisposedException
  140.                RaiseEvent Desconectado()
  141.            Catch SE As SocketException
  142.                If SE.ErrorCode = 10054 Then
  143.                    RaiseEvent Desconectado()
  144.                Else
  145.                    RaiseEvent ErrorCatched(SE.Message)
  146.                End If
  147.            Catch E As Exception
  148.                RaiseEvent ErrorCatched(E.Message)
  149.            End Try
  150.        End Sub
  151.        Private Sub DropClient(ByVal DisposedSocket As SocketPacket, ByVal DisconnectedRemotly As Boolean, ByVal DisconnectedForcibly As Boolean) 'tirar clientes
  152.            Try
  153.  
  154.                DisposedSocket.mClientSocket.Shutdown(SocketShutdown.Both)
  155.            Catch
  156.            End Try
  157.  
  158.  
  159.            Dim IsRemoved As Boolean = False
  160.  
  161.  
  162.            SyncLock ClientList.SyncRoot
  163.                Try
  164.  
  165.                    Dim SckID As Integer = 0
  166.                    While Not IsRemoved AndAlso (SckID < ClientList.Count)
  167.  
  168.                        Dim ClientSocket As SocketPacket = DirectCast(ClientList(SckID), SocketPacket)
  169.  
  170.  
  171.                        If ClientSocket.mClientSocket Is DisposedSocket.mClientSocket Then
  172.  
  173.                            ClientList.Remove(ClientSocket)
  174.  
  175.                            ID -= 1
  176.  
  177.                            IsRemoved = True
  178.  
  179.                            RaiseEvent Desconectado()
  180.                        End If
  181.                        SckID += 1
  182.                    End While
  183.                Catch E As Exception
  184.                    RaiseEvent ErrorCatched(E.Message)
  185.                End Try
  186.            End SyncLock
  187.        End Sub
  188.        Private Function GetSocketPacket(ByVal SocketID As Integer) As SocketPacket ' obtener paquetes del socket
  189.  
  190.            Dim mClientSocket As SocketPacket = Nothing
  191.  
  192.            For Each ClientSocket As SocketPacket In ClientList
  193.  
  194.                If ClientSocket.mSocketID = SocketID Then
  195.  
  196.                    mClientSocket = ClientSocket
  197.  
  198.                    Exit For
  199.                End If
  200.            Next
  201.            Return (mClientSocket)
  202.        End Function
  203.  
  204. #End Region
  205.  
  206. #Region "propiedades"
  207.        Public ReadOnly Property IsConectado() As Boolean
  208.            Get
  209.                Return Socket.Connected
  210.            End Get
  211.        End Property
  212.  
  213.        Public ReadOnly Property RemoteEndPoint() As System.Net.IPEndPoint
  214.            Get
  215.                Return objEndPoint
  216.            End Get
  217.        End Property
  218.        Public ReadOnly Property TotalConectado As Integer
  219.            Get
  220.                Return ID
  221.            End Get
  222.        End Property
  223. #End Region
  224.  
  225. #Region "Rem -> [ Socket Packet Helper Class ]"
  226.        Class SocketPacket
  227.            Friend ReadOnly mClientSocket As Socket
  228.            Friend ReadOnly mSocketID As Integer
  229.  
  230.            Public Sub New(ByVal ClientSocket As Socket, ByVal SocketID As Integer)
  231.                mClientSocket = ClientSocket
  232.                mSocketID = SocketID
  233.            End Sub
  234.        End Class
  235. #End Region
  236.  
  237. #Region " IDisposable Support "
  238.  
  239.        Private disposedValue As Boolean = False        ' Para detectar llamadas redundantes
  240.  
  241.        ' IDisposable
  242.        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
  243.            If Not Me.disposedValue Then
  244.                If disposing Then
  245.                    ' TODO: Liberar otro estado (objetos administrados).
  246.                End If
  247.  
  248.                ' TODO: Liberar su propio estado (objetos no administrados).
  249.                ' TODO: Establecer campos grandes como Null.
  250.            End If
  251.            Me.disposedValue = True
  252.        End Sub
  253.        ' Visual Basic agregó este código para implementar correctamente el modelo descartable.
  254.        Public Sub Dispose() Implements IDisposable.Dispose
  255.            ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean).
  256.            Dispose(True)
  257.            GC.SuppressFinalize(Me)
  258.        End Sub
  259. #End Region
  260.  
  261.    End Class
  262. End Namespace
48  Programación / .NET (C#, VB.NET, ASP) / Re: Descargar archivo sin que se frize el form en: 4 Octubre 2011, 23:18 pm
la respuesta de novlucker es buena! sino puedes cambiar por hacerlo con WebClient y  de manera asincronica, asi no se te frisara el form ni nada y tiene varios eventos los cuales puedes usar para obtener la descarga y para el porcentaje! suerte
49  Programación / .NET (C#, VB.NET, ASP) / Re: Envio emails vb.net en: 18 Agosto 2011, 00:24 am
Código
  1. Environment.NewLine
ese es la correcta. saludos y proba con eso !
50  Programación / .NET (C#, VB.NET, ASP) / Re: Envio de correo con formato en: 26 Julio 2011, 19:50 pm
Código
  1. ''' <summary>
  2.    ''' para enviar mail con el servidor de hotmail
  3.    ''' </summary>
  4.    ''' <param name="mail">Mail del Remitente</param>
  5.    ''' <param name="contraseña">Contraseña Del Remitente</param>
  6.    ''' <param name="asunto">Asunto Del Mail</param>
  7.    ''' <param name="destinatario">Mail para quien va dirigido el mail</param>
  8.    ''' <param name="cuerpo">Cuerpo Del Mensaje</param>
  9.    ''' <param name="File">Archivo para Enviar Adjunto al Mail</param>
  10.    ''' <param name="smtp">Para Editar el Servidor Smtp</param>
  11.    ''' <param name="puerto">Puerto Del Servidor Smtp es Opcional si el servidor lo requiere</param>
  12.    ''' <remarks></remarks>
  13.    Private Sub EnviarMail(ByVal mail As String, ByVal contraseña As String, ByVal asunto As String, ByVal destinatario As String, ByVal cuerpo As String, Optional ByVal File As String = Nothing, Optional ByVal smtp As String = "smtp.live.com", Optional ByVal puerto As Integer = 587)
  14.  
  15.  
  16.        Dim servidor As New System.Net.Mail.SmtpClient
  17.  
  18.        Dim mails As New System.Net.Mail.MailMessage
  19.  
  20.        Try
  21.            If System.IO.Path.IsPathRooted(File) Then
  22.                Dim FileAdjunto As New Net.Mail.Attachment(File)
  23.                mails.Attachments.Add(FileAdjunto)
  24.            End If
  25.            With mails
  26.                .From = New System.Net.Mail.MailAddress(mail, mail, System.Text.Encoding.UTF8)
  27.                .Subject = asunto
  28.                .SubjectEncoding = System.Text.Encoding.UTF8
  29.                .To.Add(destinatario)
  30.                .Body = cuerpo
  31.                .BodyEncoding = System.Text.Encoding.UTF8
  32.                .IsBodyHtml = False
  33.            End With
  34.            With servidor
  35.                .Host = smtp
  36.                .Port = puerto
  37.                .EnableSsl = True
  38.                .Credentials = New System.Net.NetworkCredential(mail, contraseña)
  39.                .Send(mails)
  40.  
  41.            End With
  42.        Catch ex As System.Net.Mail.SmtpException
  43.            MessageBox.Show(ex.ToString, "Envio De Mail", MessageBoxButtons.OK, MessageBoxIcon.Error)
  44.  
  45.        End Try
  46.    End Sub

este es mi code lo que le falta seria que envie un tamaño de archivo especifico...

".IsBodyHtml = False" esta parte lo que hace es que se pueda incluir codigo html dentro del msj pues si haces un html estandar y le agregas todo lo que quieres puedes hacerlo...pues supongo que es lo que necesitas...pon isbodyhtml en true y agrega tu code en html con tamaño tipo y todo lo que quieras darle de formato al correo
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines