|
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()
ConnStep = ConnStep + 1
Exit Function
End If
If Asc(Mid(RevBuffer, 2, 1)) = 0 And Form1.Check1.Value = 0 Then
Form1.Label8.Caption = "连接目标服务器成功!" '无验证的最后一步,代理回复第二字节为 00 成功,其余值为失败
ConnStep = -1
Form2.Show
Exit Function
End If
If Asc(Mid(RevBuffer, 2, 1)) <> 0 And Form1.Check1.Value = 0 Then
MsgBox "连接目标服务器失败!", 48, "错误" '无验证的最后一步,代理回复第二字节为 00 成功,其余值为失败
ConnStep = 0
Form1.Winsock1.Close
Exit Function
End If
Case 4 '只有有验证才会用到这一步
If Asc(Mid(RevBuffer, 2, 1)) <> 0 Then
MsgBox "sock5代理连接目标服务器失败!", 48, "错误"
ConnStep = 0
Form1.Winsock1.Close
Exit Function
Else
Form1.Label8.Caption = "连接目标服务器成功!"
ConnStep = -1
Form2.Show
Exit Function
End If
End Select
End If
If ProxyType = 2 Then '@@@@@@@@@@@@@@@@@@@@@@@@HTTP1.1代理
If PStep = 1 Then '无用户名密码验证
If Form1.Check1.Value = 0 Then
HTTPHeader = "CONNECT " & Form1.Text5.Text & ":" & Form1.Text6.Text & _
" HTTP/1.1" & Chr(13) & Chr(10) & "Host: " & Form1.Text5.Text & ":" & Form1.Text6.Text & Chr(13) & Chr(10) & Chr(13) & Chr(10)
ConnStep = PStep + 1
Form1.Winsock1.SendData HTTPHeader
Exit Function
End If
If Form1.Check1.Value = 1 Then ' 有用户名密码验证
HTTPHeader = "CONNECT " & Form1.Text5.Text & ":" & Form1.Text6.Text & _
" HTTP/1.1" & Chr(13) & Chr(10) & "Host: " & Form1.Text5.Text & ":" & _
Form1.Text6.Text & Chr(13) & Chr(10) & "Authorization: Basic " & StrtoBase64(Form1.Text3.Text & _
":" & Form1.Text4.Text) & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Proxy-Authorization: Basic " & _
StrtoBase64(Form1.Text3.Text & ":" & Form1.Text4.Text) & Chr(13) & Chr(10) & Chr(13) & Chr(10)
' Chr(13) & Chr(10) 能否直接用vbCrLf ? 我不知道
Debug.Print HTTPHeader
ConnStep = PStep + 1
Form1.Winsock1.SendData HTTPHeader
Exit Function
End If
End If
If PStep = 2 Then '代理服务器回复,格式:HTTP/[代理版本] [状态代码] [状态说明]
If LCase(Left(RevBuffer, 4)) = "http" And Mid(" 200 ", 1) <> 0 Then '状态代码为 200 为成功 |