Ergebnis 1 bis 6 von 6

Baum-Darstellung

  1. #1
    Anfänger
    Registriert seit
    22.07.2008
    Beiträge
    7

    Standard VB.Net Socks5 [Source]

    Code:
    Neue Class erstellen:
    Imports System
    Imports System.IO
    Imports System.Net
    Imports System.Text
    Imports System.Threading
    Imports System.Net.Sockets
    Imports System.Collections.Generic
    
    Public Class Socks5
        Private socksClient As TcpClient
        Private serverClient As TcpClient
        Private SOCKS_VERSION As Byte = 5
        Private SOCKS_NOAUTH As Byte = 0
        Private SOCKS_REPLYSUCCESS As Byte = 0
        Private SOCKS_IPV4ADDR As Byte = 1
        Private SOCKS_DNSNAME As Byte = 3
    
        Public Sub New(ByVal client As TcpClient)
            socksClient = client
        End Sub
    
        Public Sub Work()
            Dim socksClientStream As NetworkStream = socksClient.GetStream()
    
            Dim authFields As Byte() = New Byte(1) {}
            socksClientStream.Read(authFields, 0, 2)
    
            Dim methods As Byte() = New Byte(authFields(1) - 1) {}
            socksClientStream.Read(methods, 0, methods.Length)
    
            Dim selectedAuthMethod As Byte() = {SOCKS_VERSION, SOCKS_NOAUTH}
            socksClientStream.Write(selectedAuthMethod, 0, 2)
            'tu le declare ou le port ? lol jai pas fait attention
            Dim requestFields As Byte() = New Byte(3) {}
            socksClientStream.Read(requestFields, 0, 4)
    
            Dim connection_target As String = ""
            Dim target_port As Integer
            If requestFields(3) = SOCKS_IPV4ADDR Then
                Dim target_data As Byte() = New Byte(3) {}
                socksClientStream.Read(target_data, 0, 4)
                Dim ip As New IPAddress(target_data)
                connection_target = ip.ToString()
            ElseIf requestFields(3) = SOCKS_DNSNAME Then
                Dim domainname_length As Byte() = New Byte(0) {}
                socksClientStream.Read(domainname_length, 0, 1)
                Dim target_data As Byte() = New Byte(domainname_length(0) - 1) {}
                socksClientStream.Read(target_data, 0, domainname_length(0))
                connection_target = Encoding.[Default].GetString(target_data)
            Else
            End If
    
            If connection_target <> "" Then
    
                Dim bintargetport As Byte() = New Byte(1) {}
                socksClientStream.Read(bintargetport, 0, 2)
                Dim tmp_byteorder As Byte() = New Byte(1) {}
                tmp_byteorder(0) = bintargetport(1)
                tmp_byteorder(1) = bintargetport(0)
                target_port = CInt(BitConverter.ToUInt16(tmp_byteorder, 0))
    
                serverClient = New TcpClient(connection_target, target_port)
    
                If serverClient.Connected Then
                    Dim reply As Byte() = New Byte(9) {}
                    reply(0) = SOCKS_VERSION
                    reply(1) = SOCKS_REPLYSUCCESS
                    reply(2) = 0
                    reply(3) = 1
                    Dim ip As String = serverClient.Client.LocalEndPoint.ToString().Split(":"c)(0)
                    Dim ipaddr As IPAddress = IPAddress.Parse(ip)
                    reply(4) = ipaddr.GetAddressBytes()(0)
                    reply(5) = ipaddr.GetAddressBytes()(1)
                    reply(6) = ipaddr.GetAddressBytes()(2)
                    reply(7) = ipaddr.GetAddressBytes()(3)
                    Dim port As UShort = UShort.Parse(serverClient.Client.LocalEndPoint.ToString().Split(":"c)(1))
    
                    reply(8) = BitConverter.GetBytes(DirectCast(port, UInt16))(0)
                    reply(9) = BitConverter.GetBytes(DirectCast(port, UInt16))(1)
                    socksClientStream.Write(reply, 0, 10)
    
                    Dim serverClientStream As NetworkStream = serverClient.GetStream()
                    Dim ioError As Boolean = False
                    While serverClient.Connected AndAlso socksClient.Connected AndAlso Not ioError
                        System.Threading.Thread.Sleep(100)
                        Try
                            If socksClientStream.DataAvailable Then
                                Dim readbuffer As Byte() = New Byte(9999) {}
                                Dim count_read As Integer = socksClientStream.Read(readbuffer, 0, 10000)
                                Dim read_data As Byte() = New Byte(count_read - 1) {}
                                Array.Copy(readbuffer, read_data, count_read)
                                serverClientStream.Write(read_data, 0, read_data.Length)
                            End If
                            If serverClientStream.DataAvailable Then
                                Dim receivebuffer As Byte() = New Byte(9999) {}
                                Dim count_receive As Integer = serverClientStream.Read(receivebuffer, 0, 10000)
                                Dim receive_data As Byte() = New Byte(count_receive - 1) {}
                                Array.Copy(receivebuffer, receive_data, count_receive)
                                socksClientStream.Write(receive_data, 0, receive_data.Length)
                            End If
                        Catch
                            ioError = True
                        End Try
                    End While
    
                    ' try to close connections if yet connected
                    If socksClient.Connected Then
                        socksClient.Close()
                    End If
                    If serverClient.Connected Then
                        serverClient.Close()
                    End If
                Else
                End If
            Else
            End If
        End Sub
    End Class
    
    
    
    Form1 load oder halt einen Call:
    Imports System
    Imports System.IO
    Imports System.Net
    Imports System.Text
    Imports System.Threading
    Imports System.Net.Sockets
    Imports System.Collections.Generic
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim server As New TcpListener(1900) ' donc tu veut transfomer quoi ?
            server.Start()
            While True
                Dim client As TcpClient = server.AcceptTcpClient()
                Dim S As New Socks5(client)
                Dim T As New Thread(New ThreadStart(AddressOf S.Work))
                T.Start()
            End While
        End Sub
    End Class
    Geändert von Sawyer (31.05.2010 um 06:27 Uhr)

Ähnliche Themen

  1. [VB6-Source-Pack] 52 Crypter Source Codes Collection 2010 By Persian
    Von Persian im Forum Komponenten & Source Codes
    Antworten: 11
    Letzter Beitrag: 22.05.2010, 13:30
  2. [VB6-Source] RC4 Crypter Source
    Von Tix im Forum Komponenten & Source Codes
    Antworten: 15
    Letzter Beitrag: 06.11.2008, 20:56
  3. Socks5 usw..
    Von O.x im Forum Anonymität & Proxies
    Antworten: 14
    Letzter Beitrag: 27.09.2008, 08:33

Stichworte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •