Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: TrashAmbishion en 19 Junio 2016, 23:19 PM

Título: Gestionar Sockets Ajenos ??
Publicado por: TrashAmbishion en 19 Junio 2016, 23:19 PM
Lo que quiero hacer es esto

http://www.vbforums.com/showthread.php?503818-RESOLVED-Block-IP

Estoy tratando de llevarlo a .NET si alguien puede ayudar se los agradecere.

Salu2
Título: Re: Gestionar Sockets Ajenos ??
Publicado por: TrashAmbishion en 20 Junio 2016, 19:48 PM
Cita de: TrashAmbishion en 19 Junio 2016, 23:19 PM
Lo que quiero hacer es esto

http://www.vbforums.com/showthread.php?503818-RESOLVED-Block-IP

Estoy tratando de llevarlo a .NET si alguien puede ayudar se los agradecere.

Salu2

Solucionado mas tarde subo como lo hice. Salu2
Título: Re: Gestionar Sockets Ajenos ??
Publicado por: TrashAmbishion en 21 Junio 2016, 07:36 AM
Código (vbnet) [Seleccionar]

Dim pdwSize As Integer
        Dim iRetVal As Integer
        Dim i As Integer
        Dim TcpTableRow As MIB_TCPROW
        Dim pStructPointer As IntPtr = IntPtr.Zero
        Dim iNumberOfStructures As Integer

        Form1.dgvtcp.Rows.Clear()

        iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)

        pStructPointer = Marshal.AllocHGlobal(pdwSize)
        iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)
        iNumberOfStructures = Math.Ceiling((pdwSize - 4) / Marshal.SizeOf(GetType(MIB_TCPROW)))

For i = 0 To iNumberOfStructures - 1
            Dim pStructPointerTemp As IntPtr = New IntPtr(pStructPointer.ToInt32() + 4 + (i * Marshal.SizeOf(GetType(MIB_TCPROW))))

            TcpTableRow = New MIB_TCPROW()
            With TcpTableRow
                .dwLocalAddr = 0
                .dwState = 0
                .dwLocalPort = 0
                .dwRemoteAddr = 0
                .dwRemotePort = 0
            End With
            'Marshal.PtrToStructure(pStructPointerTemp, TcpTableRow)
            TcpTableRow = CType(Marshal.PtrToStructure(pStructPointerTemp, GetType(MIB_TCPROW)), MIB_TCPROW)
            ' Process each MIB_TCPROW here
            With TcpTableRow

                'Aqui desconecto la ip que este conectado a mi
               
                    If GetIpFromLong(.dwRemoteAddr).ToString = "Aqui La Ip" Then
                        .dwState = 12
                        Try
                            SetTcpEntry(TcpTableRow)
                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                        End Try
                        Exit For
                    End If
               
           End With
Next
Marshal.FreeHGlobal(pStructPointer)




Probado en Windows 8.1