Valhalla Legends Forums Archive | Battle.net Bot Development | Proxy Support Help

AuthorMessageTime
Inner
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. =/
May 18, 2004, 1:05 AM
LoRd
You'll need to look over the SOCKSv4 and the SOCKSv5 protocols.
May 18, 2004, 1:08 AM
Inner
That kind of doesn't answer why my code doesn't work, but thankyou.
May 18, 2004, 1:11 AM
Forged
on the contrary if you read it it probally will.
May 18, 2004, 1:12 AM
Inner
Hm, my bot locks up now when i connect, this is some weird shit. =/
May 18, 2004, 1:37 AM
shadypalm88
Just a thought... packetlog MadChat. Maybe instead of sending "anonymous" as the username, it just sends a blank, or something like that.
May 18, 2004, 3:15 AM
Forged
why wouldn't it send anon?
May 18, 2004, 4:42 AM
BinaryzL
[quote author=shadypalm88 link=board=17;threadid=6853;start=0#msg60601 date=1084850154]
Just a thought... packetlog MadChat. Maybe instead of sending "anonymous" as the username, it just sends a blank, or something like that.
[/quote]

It should since it's right there in the code.

[quote author=Inner link=board=17;threadid=6853;start=0#msg60563 date=1084842306]
[code]Winsock.SendData Chr(&H4) & Chr(&H1) & Chr(&H17) & Chr(&HE0) & str & "anonymous" & Chr(&H0)[/code]
[/quote]
May 18, 2004, 3:43 PM
FuzZ

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
[code]
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
[/code]
May 18, 2004, 7:44 PM
Inner
FuZZ, i did your dataarrival and it keeps saying that my proxie is not connecting like it was before =/
May 18, 2004, 8:13 PM
Eli_1
[quote author=FuzZ link=board=17;threadid=6853;start=0#msg60690 date=1084909453]

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.
[/quote]

The winsock control does that for you.
May 18, 2004, 10:22 PM
Inner
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.
May 18, 2004, 10:28 PM
Tuberload
[quote author=Inner link=board=17;threadid=6853;start=0#msg60721 date=1084919327]
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]

http://botdev.valhallalegends.com/documents/vbsocks5.html

HTH
May 18, 2004, 10:50 PM
BinaryzL
This should work.

Public bDProxy as boolean ' in some module. '

bDProxy = False before you try to connect and you want to use a proxy.

[code]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[/code]

And then the rest of your winsock_dataarrival code here.
May 18, 2004, 11:50 PM
LoRd
[quote author=Inner link=board=17;threadid=6853;start=0#msg60565 date=1084842705]
That kind of doesn't answer why my code doesn't work, but thankyou.
[/quote]
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.
May 18, 2004, 11:56 PM
BinaryzL
[quote author=LoRd[nK] link=board=17;threadid=6853;start=0#msg60737 date=1084924585]
[quote author=Inner link=board=17;threadid=6853;start=0#msg60565 date=1084842705]
That kind of doesn't answer why my code doesn't work, but thankyou.
[/quote]
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]

Well in this case I doubt that is causing the problem here but it could be.
May 18, 2004, 11:57 PM
LoRd
[quote author=BinaryzL link=board=17;threadid=6853;start=15#msg60738 date=1084924677]
[quote author=LoRd[nK] link=board=17;threadid=6853;start=0#msg60737 date=1084924585]
[quote author=Inner link=board=17;threadid=6853;start=0#msg60565 date=1084842705]
That kind of doesn't answer why my code doesn't work, but thankyou.
[/quote]
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]

Well in this case I doubt that is causing the problem here but it could be.
[/quote]

Ofcourse it is. If the incorrect server port is entered, the proxy will always fail to connect to the server.
May 19, 2004, 12:02 AM
Inner
I got it working properly, thanks to all of you, especially Binary, thanks alot.
May 19, 2004, 2:23 AM

Search