Valhalla Legends Forums Archive | Battle.net Bot Development | I want to learn how to add proxy support

AuthorMessageTime
ChR0NiC
If anyone can recommend any public sources I could look through or teach me how, please by all means.
November 17, 2003, 7:56 AM
Gangz
What kind of connection are you using? BNLS Hash or CSB?
November 17, 2003, 3:45 PM
Grok
[quote author=ChR0NiC link=board=17;threadid=3666;start=0#msg29651 date=1069055795]
If anyone can recommend any public sources I could look through or teach me how, please by all means.
[/quote]

Winsock Programmer's FAQ
http://tangentsoft.net/wskfaq/articles/firewalls.html

See the section on SOCKS.
November 17, 2003, 4:01 PM
Stealth
[quote author=Gangz link=board=17;threadid=3666;start=0#msg29689 date=1069083943]
What kind of connection are you using? BNLS Hash or CSB?
[/quote]

Any type can be routed through a proxy.
November 17, 2003, 10:23 PM
ChR0NiC
BNLS Hash
November 18, 2003, 1:49 AM
Kp
[quote author=ChR0NiC link=board=17;threadid=3666;start=0#msg29867 date=1069120198]
BNLS Hash[/quote]Which is it? Most clients which use BNLS do so to avoid needing to perform local hashing.
November 19, 2003, 10:08 PM
ChR0NiC
My bot uses BNLS but not CSB. It uses BNLS packets
November 21, 2003, 6:06 PM
Dyndrilliac
[quote author=Kp link=board=17;threadid=3666;start=0#msg30160 date=1069279702]
[quote author=ChR0NiC link=board=17;threadid=3666;start=0#msg29867 date=1069120198]
BNLS Hash[/quote]Which is it? Most clients which use BNLS do so to avoid needing to perform local hashing.
[/quote]

I always add hashing incase the BNLS server is down for whatever reason - So mine has both. He probably did the same.
November 21, 2003, 8:00 PM
Maddox
This could have been easily answered by googling "socks protocol." Also, what does this have to do with bot development?
November 21, 2003, 11:55 PM
Maddox
[quote author=warz link=board=17;threadid=3666;start=0#msg30591 date=1069459179]
What doesn't it have to do with bot development? He stated he uses BNLS, so it's obviously for a bot.
[/quote]

That is like saying I use buttons on my bot, so if I have a question about buttons then I should ask on the bot development forum. A better question to ask yourself before posting a question is: if I ask this question on a non-bot related forum, can I get a good answer?
November 22, 2003, 12:17 AM
St0rm.iD
Thus...

Talking to Battle.net isn't bot related, it's networking-related
User databases aren't bot related, they're algorithmns/datastructures
UI for a bot isn't bot related, it's GUI related

etc etc
November 22, 2003, 1:11 AM
TriCk
ChR0NiC ... Sup brO... :P

I have ur solution right here...
For BNLS-Type logon...
Okay on ur Winsock that connects to BNET(not BNLS) under the
Winsock_Connect Sub do this...
[code]
If Form2.Proxy.Value = 0 Then
Send Your Logon Stuff Here (Header, 0x1E/0x50)
ElseIf Form2.Proxy.Value = 1 Then
Dim splt() As String, str As String, i As Integer
varServer = LCase(varServer)
splt = Split(varServer, ".")
For i = 0 To UBound(splt)
str = str & Chr(CStr(splt(i)))
Next i
sck2.SendData Chr(&H4) & Chr(&H1) & Chr(&H17) & Chr(&HE0) & str & "anonymous" & Chr(&H0)
TextAdd "SOCK: Connected!"
End If
[/code]
Then on the Winsock's(BNET), DataArrival Sub

Do...

[code]
If Form2.Proxy.Value = 1 Then
sckBNET.GetData strTemp, vbString
Select Case Mid(strTemp, 1, 2)
Case Chr(&H0) & Chr(&H5A)
TextAdd "SOCK: Request Granted"
SendHeader
>>Send 0x1E/0x50<<
Case Chr(&H0) & Chr(&H5B)
TextAdd "SOCK: Request Rejected Or Failed"
sckBNET.Close
Exit Sub
Case Chr(&H0) & Chr(&H5C)
TextAdd "SOCK: Request Rejected Because SOCKS server cannot IDENT on the client"
sckBNET.Close
Exit Sub
Case Chr(&H0) & Chr(&H5D)
TextAdd "SOCK: Request Rejected Because the Client Program and the ID Report Different User-IDs"
sckBNET.Close
Exit Sub
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
parseBNET (Left$(strbuffer, lnglen))
strbuffer = Mid$(strbuffer, lnglen + 1)
Wend
Else
sckBNET.GetData strTemp, vbString
strbuffer = strbuffer & strTemp
While Len(strbuffer) > 4
lnglen = Val("&H" & StrToHex(StrReverse(Mid(strbuffer, 3, 2))))
If Len(strbuffer) < lnglen Then Exit Sub
parseBNET (Left(strbuffer, lnglen))
strbuffer = Mid(strbuffer, lnglen + 1)
Wend
End If
[/code]

Finally...
On ur parseBNLS Sub(or whatever your's is called)
Under Case &HF for Select Case Asc(Mid$(data, 3, 1))

[code]
Case &HF
If varproduct = "3RAW" Or varproduct = "PX3W" Then
InsertDWORD &H2
sendBNLSPacket &HD
End If
If Form2.Proxy.Value = 1 Then
sckBNET.Close
TextAdd "SOCK: Connecting..."
sckBNET.Connect varProxy, 1080
Else
sckBNET.Close
sckBNET.Connect varServer, 6112
End If
[/code]


**Fixed Spelling ;)
November 22, 2003, 4:56 AM
Stealth
-1 for spitting out code.

People who don't know any Visual Basic should not be attempting to make bots in Visual Basic.

Consider your problem: You want to add proxy support to your bot.

Consider the root of your problem: You don't know how to implement the SOCKS protocol.

Consider the best way to solve your problem: A Google search.

Let's say you've done a few Google searches and found some stuff that was relevant to your situation, but you still can't make heads or tails of it. That would be the prime time to come to these forums and ask your question, mentioning of course that you've actually put some research time into it yourself and aren't just saying "write my program for me!".

If you're not willing to actually LEARN the solution to your problem and are just looking to mooch some working code, I think you don't belong on this forum. Eh. </2AM rant>
November 22, 2003, 8:07 AM
Lenny
"Topic: I want to learn how to add proxy support" - emphasis on LEARN
November 22, 2003, 10:14 AM
Kp
[quote author=TriCk link=board=17;threadid=3666;start=0#msg30639 date=1069476978]
[code]
Case &HF
If varproduct = "3RAW" Or varproduct = "PX3W" Then
InsertDWORD &H2
sendBNLSPacket &HD
End If
If Form2.Proxy.Value = 1 Then
sckBNET.Close
TextAdd "SOCK: Connecting..."
sckBNET.Connect varProxy, 1080
Else
sckBNET.Close
sckBNET.Connect varServer, 6112
End If
[/code][/quote]
I see a couple of things here that could be improved. First, there's no need to sckBNET.Close inside both branches of the if. Move it outside. Second, you're assuming that the bncs will always and only be on port 6112. Third, you could simplify the Connect statement by assigning the port to a variable based on whether proxy support is in effect, then connecting based on that. VB-ish syntax, with some probable errors since I don't actually write VB:

[code]
sckBNET.Close
X = Form2.BNCSPort.Value ' or just X = 6112 if you want to ewwishly hardcode the port
Y = varServer
If Form2.Proxy.Value = 1 Then
TextAdd "SOCK: Connecting..."
X = 1080
Y = varProxy
End If
sckBNET.Connect Y, X[/code]
November 22, 2003, 5:07 PM
Stealth
[quote author=TriCk link=board=17;threadid=3666;start=0#msg30639 date=1069476978]
[code]
sckBNET.Close
X = Form2.BNCSPort.Value
' or just X = 6112 if you want to hardcode the port
Y = varServer
If Form2.Proxy.Value = 1 Then
TextAdd "SOCK: Connecting..."
X = 1080
Y = varProxy
End If
sckBNET.Connect Y, X[/code]
[/quote]

Also, let's talk about meaningful variable names and that magical TAB key. This code is a sloppy mess! Allow me to rewrite it using slightly more meaningful names:

[code]
sckBNET.Close

If Form2.Proxy.Value = 1 Then

TextAdd "SOCK: Connecting..."
lngPort = 1080
strServer = varProxy

Else 'user doesn't want to use a proxy

lngPort = CLng(Form2.BNCSPort.Value) ' or just = 6112 if you want to hardcode the port
strServer = varServer

End If

sckBNET.Connect strServer, lngPort 'Makes much more literal sense than "connect y, x"!
'You connect to the SERVER on the PORT, not the Y on the X.

[/code]

Compare the two blocks of code. Which one is more readable? White space is cheap, the adding tabs and blank lines in your code does not affect the performance of your program but makes things MUCH easier on yourself and other people -- especially if you want help with your code.
November 22, 2003, 8:42 PM
Spht
Picky. The only thing I agreed with was the tabbing. X, Y and Z's are prime variable names in examples!
November 22, 2003, 9:28 PM
Kp
[quote author=Stealth link=board=17;threadid=3666;start=15#msg30722 date=1069533747]Also, let's talk about meaningful variable names and that magical TAB key. This code is a sloppy mess![/quote]

You want to write better in the posting box, go ahead. I didn't see the need to clean up his tabbing style since tabs don't work in the posting box; X and Y are simple variable names, so I picked them in preference to long ones that would be more work to type. Incidentally, I don't find your variable names much better. They're a nuisance to type.
November 22, 2003, 10:18 PM
Stealth
All right, so maybe I was a little harsh. Sorry.. it's been a long week. ::)

[edit] And, I didn't realize that the code you posted was an EXAMPLE; I thought it was his original code. Yeesh, I need to sleep.
November 22, 2003, 10:50 PM

Search