Foro de elhacker.net

Programación => .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
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
  1. Dim pdwSize As Integer
  2.        Dim iRetVal As Integer
  3.        Dim i As Integer
  4.        Dim TcpTableRow As MIB_TCPROW
  5.        Dim pStructPointer As IntPtr = IntPtr.Zero
  6.        Dim iNumberOfStructures As Integer
  7.  
  8.        Form1.dgvtcp.Rows.Clear()
  9.  
  10.        iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)
  11.  
  12.        pStructPointer = Marshal.AllocHGlobal(pdwSize)
  13.        iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)
  14.        iNumberOfStructures = Math.Ceiling((pdwSize - 4) / Marshal.SizeOf(GetType(MIB_TCPROW)))
  15.  
  16. For i = 0 To iNumberOfStructures - 1
  17.            Dim pStructPointerTemp As IntPtr = New IntPtr(pStructPointer.ToInt32() + 4 + (i * Marshal.SizeOf(GetType(MIB_TCPROW))))
  18.  
  19.            TcpTableRow = New MIB_TCPROW()
  20.            With TcpTableRow
  21.                .dwLocalAddr = 0
  22.                .dwState = 0
  23.                .dwLocalPort = 0
  24.                .dwRemoteAddr = 0
  25.                .dwRemotePort = 0
  26.            End With
  27.            'Marshal.PtrToStructure(pStructPointerTemp, TcpTableRow)
  28.            TcpTableRow = CType(Marshal.PtrToStructure(pStructPointerTemp, GetType(MIB_TCPROW)), MIB_TCPROW)
  29.            ' Process each MIB_TCPROW here
  30.            With TcpTableRow
  31.  
  32.                'Aqui desconecto la ip que este conectado a mi
  33.  
  34.                    If GetIpFromLong(.dwRemoteAddr).ToString = "Aqui La Ip" Then
  35.                        .dwState = 12
  36.                        Try
  37.                            SetTcpEntry(TcpTableRow)
  38.                        Catch ex As Exception
  39.                            MessageBox.Show(ex.Message)
  40.                        End Try
  41.                        Exit For
  42.                    End If
  43.  
  44.           End With
  45. Next
  46. Marshal.FreeHGlobal(pStructPointer)
  47.  
  48.  
  49.  

Probado en Windows 8.1