I need help with my proxy support code, it keeps saying that "Request rejected or failed." for every proxy that i put on, i tried my proxy on MadChat to make sure it works, and it does. Here is my code, see if you can find anything wrong with it please.
Connecting to the proxie:
Winsock.Connect "218.58.74.200", 1080
Parsing the proxie:
Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Static strBuffer As String
Dim strTemp As String, lngLen As Long
Winsock.GetData strTemp, vbString
Select Case Mid(strTemp, 1, 2)
Case Chr(&H0) & Chr(&H5A)
AddC "SOCK: Request Granted" & vbNewLine, vbGreen
SendHeader
Send1E
Exit Sub
Case Chr(&H0) & Chr(&H5B)
AddC "SOCK: Request Rejected Or Failed" & vbNewLine, vbRed
WS.Close
Case Chr(&H0) & Chr(&H5C)
AddC "SOCK: Request Rejected Because SOCKS server cannot IDENT on the client" & vbNewLine, vbRed
WS.Close
Case Chr(&H0) & Chr(&H5D)
AddC "SOCK: Request Rejected Because the Client Program and the ID Report Different User-IDs" & vbNewLine, vbRed
WS.Close
strBuffer = strBuffer & strTemp
While Len(strBuffer) > 4
lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
If Len(strBuffer) < lngLen Then Exit Sub
parsep (Left(strBuffer, lngLen))
strBuffer = Mid(strBuffer, lngLen + 1)
Wend
End Select
End Sub
Connected to the proxie:
Private Sub winsock_connect()
On Error Resume Next
Dim str As string
splt = Split(varServer, ".")
For i = 0 To UBound(splt)
str = str & Chr(CStr(splt(i)))
Next i
Winsock.SendData Chr(&H4) & Chr(&H1) & Chr(&H17) & Chr(&HE0) & str & "anonymous" & Chr(&H0)
Setup1
AddC "BNET: Connected!" & vbNewLine, vbGreen
End Sub
If anyone can help, please do. =/
You'll need to look over the SOCKSv4 (http://archive.socks.permeo.com/protocol/socks4.protocol) and the SOCKSv5 (http://archive.socks.permeo.com/rfc/rfc1928.txt) protocols.
That kind of doesn't answer why my code doesn't work, but thankyou.
on the contrary if you read it it probally will.
Hm, my bot locks up now when i connect, this is some weird shit. =/
Just a thought... packetlog MadChat. Maybe instead of sending "anonymous" as the username, it just sends a blank, or something like that.
why wouldn't it send anon?
Quote from: shadypalm88 on May 17, 2004, 10:15 PM
Just a thought... packetlog MadChat. Maybe instead of sending "anonymous" as the username, it just sends a blank, or something like that.
It should since it's right there in the code.
Quote from: Inner on May 17, 2004, 08:05 PM
Winsock.SendData Chr(&H4) & Chr(&H1) & Chr(&H17) & Chr(&HE0) & str & "anonymous" & Chr(&H0)
You need to add a check in your Connect event handler to check to see if the server is an IP or a domain name. If it's a domain name, resolve it.
I made a post about SOCKS4 in the VB section, if you go search.
Second, you're DataArrival is pretty fucked up lol
It should be
Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
Static strBuffer As String
Dim strTemp As String, lngLen As Long
Winsock.GetData strTemp, vbString
Select Case Mid(strTemp, 1, 2)
Case Chr(&H0) & Chr(&H5A)
addC "SOCK: Request Granted" & vbNewLine, vbGreen
SendHeader
Send1E
Exit Sub
Case Chr(&H0) & Chr(&H5B)
addC "SOCK: Request Rejected Or Failed" & vbNewLine, vbRed
WS.Close
Case Chr(&H0) & Chr(&H5C)
addC "SOCK: Request Rejected Because SOCKS server cannot IDENT on the client" & vbNewLine, vbRed
WS.Close
Case Chr(&H0) & Chr(&H5D)
addC "SOCK: Request Rejected Because the Client Program and the ID Report Different User-IDs" & vbNewLine, vbRed
WS.Close
End Select
strBuffer = strBuffer & strTemp
While Len(strBuffer) >= 4
lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
If Len(strBuffer) < lngLen Then Exit Sub
parsep (Left(strBuffer, lngLen))
strBuffer = Mid(strBuffer, lngLen + 1)
Wend
End Sub
FuZZ, i did your dataarrival and it keeps saying that my proxie is not connecting like it was before =/
Quote from: FuzZ on May 18, 2004, 02:44 PM
You need to add a check in your Connect event handler to check to see if the server is an IP or a domain name. If it's a domain name, resolve it.
The winsock control does that for you.
Bleh, i really need this, does anyone know what is wrong with that damn code!!?! I've tried so many things and it just does NOT want to work.
Quote from: Inner on May 18, 2004, 05:28 PM
Bleh, i really need this, does anyone know what is wrong with that damn code!!?! I've tried so many things and it just does NOT want to work.
http://botdev.valhallalegends.com/documents/vbsocks5.html
HTH
This should work.
Public bDProxy as boolean ' in some module. '
bDProxy = False before you try to connect and you want to use a proxy.
Private Sub sckBNET_DataArrival(ByVal bytesTotal As Long)
Dim strTemp As String, intLen As Integer
sckBNET.GetData strTemp, vbString, bytesTotal
If strUseProxy = "1" And bDProxy = False Then
If strSOCKS = "SOCKS4" Then
Select Case Mid$(strTemp, 1, 2)
Case Chr(&H0) & Chr(&H5A)
AddC frmMain.rtfChat, vbGreen, "SOCKS4 Request Granted"
bDProxy = True
Call Send0x50
Case Chr(&H0) & Chr(&H5B)
AddC frmMain.rtfChat, vbRed, "SOCKS4 Request Rejected Or Failed"
sckBNET.Close
Case Chr(&H0) & Chr(&H5C)
AddC frmMain.rtfChat, vbRed, "SOCKS4 Request Rejected Because SOCKS server cannot IDENT on the client"
sckBNET.Close
Case Chr(&H0) & Chr(&H5D)
AddC frmMain.rtfChat, vbRed, "SOCKS4 Request Rejected Because the Client Program and the ID Report Different User-IDs"
sckBNET.Close
End Select
End If
Exit Sub
End If
And then the rest of your winsock_dataarrival code here.
Quote from: Inner on May 17, 2004, 08:11 PM
That kind of doesn't answer why my code doesn't work, but thankyou.
If you actually
read the SOCKS documentation I showed you, you'd notice that you're sending the port in the entirely wrong format.
You'll need to use Winsocks htons() function to convert the server port into network byte order before sending it to the SOCKS server.
Quote from: LoRd[nK] on May 18, 2004, 06:56 PM
Quote from: Inner on May 17, 2004, 08:11 PM
That kind of doesn't answer why my code doesn't work, but thankyou.
If you actually read the SOCKS documentation I showed you, you'd notice that you're sending the port in the entirely wrong format.
You'll need to use Winsocks htons() function to convert the server port into network byte order before sending it to the SOCKS server.
Well in this case I doubt that is causing the problem here but it could be.
Quote from: BinaryzL on May 18, 2004, 06:57 PM
Quote from: LoRd[nK] on May 18, 2004, 06:56 PM
Quote from: Inner on May 17, 2004, 08:11 PM
That kind of doesn't answer why my code doesn't work, but thankyou.
If you actually read the SOCKS documentation I showed you, you'd notice that you're sending the port in the entirely wrong format.
You'll need to use Winsocks htons() function to convert the server port into network byte order before sending it to the SOCKS server.
Well in this case I doubt that is causing the problem here but it could be.
Ofcourse it is. If the incorrect server port is entered, the proxy will always fail to connect to the server.
I got it working properly, thanks to all of you, especially Binary, thanks alot.