m.4.r.m
یک شنبه 12 خرداد 1392, 00:56 صبح
Option Explicit
Private ConnectHeader(9) As Byte
Private Function Bin2Dec(ByVal Bstring) As Byte
Dim I As Integer
Dim a As String
Dim t As Long
Dim p As Long
For I = 8 To 1 Step -1
a = Mid$(Bstring, I, 1)
t = t + a * 2 ^ p
p = p + 1
Next I
Bin2Dec = t
End Function
Private Sub cmdConnect_Click()
Dim RPort As Double
Dim Spcount As Long
Dim ts As Long
Dim bin2 As String
Dim bin As String
Dim IPpart As Variant
ConnectHeader(0) = 4 '<--------Socks version
ConnectHeader(1) = 1 '<-------- tells socks server we want to connect
RPort = Val(Text1(3).Text)
If RPort = 0 Then
Me.Caption = "No Destport"
Exit Sub
End If
Do Until Spcount = 16
Spcount = Spcount + 1
If RPort > 0 Then
ts = RPort Mod 2
RPort = Int(RPort / 2)
Else
ts = 0
End If
If Spcount > 8 Then
bin2 = ts & bin2
Else
bin = ts & bin
End If
Loop
ConnectHeader(2) = Bin2Dec(bin2)
ConnectHeader(3) = Bin2Dec(bin)
IPpart = Split(Text1(2).Text, ".")
If UBound(IPpart) = 3 Then
ConnectHeader(4) = IPpart(0) '<-------- first section of dest IP
ConnectHeader(5) = IPpart(1) '<-------- second section
ConnectHeader(6) = IPpart(2) '<-------- third
ConnectHeader(7) = IPpart(3) '<-------- fourth
ConnectHeader(8) = 0 '<-------- NULL ??
Else
Me.Caption = "FAIL"
Exit Sub
End If
Socket.Connect Text1(0).Text, Val(Text1(1).Text) '<-- connect to socks server here
End Sub
Private Sub Socket_Connect()
Socket.SendData ConnectHeader '<-- send the header with all the info here
End Sub
Private Sub Socket_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Socket.GetData data
End Sub
Private ConnectHeader(9) As Byte
Private Function Bin2Dec(ByVal Bstring) As Byte
Dim I As Integer
Dim a As String
Dim t As Long
Dim p As Long
For I = 8 To 1 Step -1
a = Mid$(Bstring, I, 1)
t = t + a * 2 ^ p
p = p + 1
Next I
Bin2Dec = t
End Function
Private Sub cmdConnect_Click()
Dim RPort As Double
Dim Spcount As Long
Dim ts As Long
Dim bin2 As String
Dim bin As String
Dim IPpart As Variant
ConnectHeader(0) = 4 '<--------Socks version
ConnectHeader(1) = 1 '<-------- tells socks server we want to connect
RPort = Val(Text1(3).Text)
If RPort = 0 Then
Me.Caption = "No Destport"
Exit Sub
End If
Do Until Spcount = 16
Spcount = Spcount + 1
If RPort > 0 Then
ts = RPort Mod 2
RPort = Int(RPort / 2)
Else
ts = 0
End If
If Spcount > 8 Then
bin2 = ts & bin2
Else
bin = ts & bin
End If
Loop
ConnectHeader(2) = Bin2Dec(bin2)
ConnectHeader(3) = Bin2Dec(bin)
IPpart = Split(Text1(2).Text, ".")
If UBound(IPpart) = 3 Then
ConnectHeader(4) = IPpart(0) '<-------- first section of dest IP
ConnectHeader(5) = IPpart(1) '<-------- second section
ConnectHeader(6) = IPpart(2) '<-------- third
ConnectHeader(7) = IPpart(3) '<-------- fourth
ConnectHeader(8) = 0 '<-------- NULL ??
Else
Me.Caption = "FAIL"
Exit Sub
End If
Socket.Connect Text1(0).Text, Val(Text1(1).Text) '<-- connect to socks server here
End Sub
Private Sub Socket_Connect()
Socket.SendData ConnectHeader '<-- send the header with all the info here
End Sub
Private Sub Socket_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Socket.GetData data
End Sub