|
Exit Function
Case 2 '代理回复
If Asc(Mid(RevBuffer, 2, 1)) = 255 Then 'FF (255) 为失败
MsgBox "连接代理失败!", 64
Form1.Winsock1.Close
ConnStep = 0
Exit Function
End If
If Asc(Mid(RevBuffer, 2, 1)) = 0 And Asc(Mid(RevBuffer, 1, 1)) = 5 Then '若代理回复 05 00 为无验证连接成功
Form1.Label8.Caption = "连接成功!无验证"
ReDim SendByte(0 To 9) As Byte '第二步 无验证 发送连接请求
SendByte(0) = 5
SendByte(1) = 1
SendByte(2) = 0
SendByte(3) = 1
SendByte(4) = GetIPByte(1, DestIP)
SendByte(5) = GetIPByte(2, DestIP)
SendByte(6) = GetIPByte(3, DestIP)
SendByte(7) = GetIPByte(4, DestIP)
SendByte(8) = Int(DestPort / 256) '把10进制端口分成两个字节
SendByte(9) = DestPort Mod 256 '把10进制端口分成两个字节
Form1.Winsock1.SendData SendByte()
ConnStep = ConnStep + 1
Exit Function
End If
If Asc(Mid(RevBuffer, 2, 1)) = 2 And Asc(Mid(RevBuffer, 1, 1)) = 5 Then '第二步 有用户名密码验证 成功为 05 02
Form1.Label8.Caption = "连接成功!有验证"
ReDim SendByte(0 To 2 + Len(UserName) + Len(UserPassword)) As Byte
SendByte(0) = 1
SendByte(1) = Len(UserName)
MemCopy SendByte(2), ByVal UserName, Len(UserName) '将用户名转换
SendByte(2 + Len(UserName)) = Len(UserPassword)
MemCopy SendByte(3 + Len(UserName)), ByVal UserPassword, Len(UserPassword) '将密码转换
Form1.Winsock1.SendData SendByte()
ConnStep = ConnStep + 1
Exit Function
End If
Case 3
If Asc(Mid(RevBuffer, 2, 1)) <> 0 And Form1.Check1.Value = 1 Then '有验证,验证失败 代理回复第二字节为 00 验证成功,其余值为失败
MsgBox "sock5代理校验用户名、密码失败!", 48, "错误"
Form1.Winsock1.Close
ConnStep = 0
Exit Function
End If
If Asc(Mid(RevBuffer, 2, 1)) = 0 And Form1.Check1.Value = 1 Then '有验证,验证成功,回复值第二字节为 00 ,其余值为失败
Form1.Label8.Caption = "连接成功!有验证!"
ReDim SendByte(0 To 9) As Byte '发送连接请求
SendByte(0) = 5
SendByte(1) = 1
SendByte(2) = 0
SendByte(3) = 1
SendByte(4) = GetIPByte(1, DestIP)
SendByte(5) = GetIPByte(2, DestIP)
SendByte(6) = GetIPByte(3, DestIP)
SendByte(7) = GetIPByte(4, DestIP)
SendByte(8) = Int(DestPort / 256) '把10进制端口分成两个字节
SendByte(9) = DestPort Mod 256 '把10进制端口分成两个字节
Form1.Winsock1.SendData SendByte()
上一篇:VB中运用反射原理优化程序代码
下一篇:如何在VB中使用导入API
|