• Welcome to Valhalla Legends Archive.
 

[RB] Useing BNLS

Started by Luxer, July 19, 2004, 06:37 PM

Previous topic - Next topic

Luxer

Could somone point me in the right direction? Completly clueless about packets....

Eric

Quote from: Luxer on July 19, 2004, 06:37 PM
Could somone point me in the right direction? Completly clueless about packets....
Search for a copy of the CleanSlateBot ocx.

ChR0NiC

#2
Quote
BNLS Headers
BNLS is the Battle.Net Logon Server, and can be used by bot authors to perform the hashing required during a Battle.net logon. It also allows bot authors to obtain useful information such as the current version byte for a game client, and has provisions for BNCS server emulator authors. It has the following headers:
(WORD)    Packet Length, including this header
(BYTE)      Packet ID
(VOID)      Packet Data

Edit:
Quote
String - Null terminated character array
DWORD - 32 bit unsigned integer
Word - 16 bit unsigned integer
Byte - 8 bit unsigned integer

Edit:
BNLS Protcol Spec <~ This wouldn't hurt either.

Edit:
BNET Docs <~ Has very nice documentation about most of the BNLS packets about three quarters down the page.

Warrior

Im pretty sure Feanor wrote a Tut on Packetlogging try snooping around Clan Exiles Site
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

tA-Kane

Quote from: LoRd[nK] on July 19, 2004, 07:15 PMSearch for a copy of the CleanSlateBot ocx.
Not helpful when you're using a Mac (eg, RB).  :P

Luxor, I just sent a similar email to someone along the same lines (perhaps even he is you?); read this:

Quote1) You need to maintain a "lag buffer", whereas even if packets are lagged (that is, received between multiple DataAvailable events), you still receive them in their full entirety.

This can be accomplished with something like this:

In your BNLSSocket object, create a property:
LagBuffer As String

Then, in your DataAvailable event:
Me.LagBuffer = Me.LagBuffer + Me.ReadAll

Check to see if the length of the LagBuffer property is greater than or equal to the length of the first packet in the buffer. If so, then process the packet. If not, then return from DataAvailable and wait for more data (wait for another DataAvailable event).

After processing the packet, be sure to remove the packet's header and data from the lag buffer, so that you don't process it again.

All of the processing could (should) be done in a loop, in case you receive multiple packets in a single DataAvailable event.


2) You'll also need to be able to convert integers to binary strings and vice versa (that is, add a 32-bit number to a string as 4 bytes as well as read 4 bytes into a 32-bit number). Memory Blocks are useful for such.

Function IntToStr32(Value As Integer) As String
 Dim Mem As MemoryBlock
 
 Mem = NewMemoryBlock(4)
 Mem.Long(0) = Value
 Return Mem.StringValue(0,4)
End Function

Function StrToInt32(Value As String) As Integer
 Dim Mem As MemoryBlock
 
 Mem = NewMemoryBlock(4)
 Mem.StringValue(0,4) = MidB(Value,1,4)
 Return Mem.Long(0)
End Function

Function IntToStr16(Value As Integer) As String
 Dim Mem As MemoryBlock
 
 Mem = NewMemoryBlock(2)
 Mem.Short(0) = Value
 Return Mem.StringValue(0,2)
End Function

Function StrToInt16(Value As String) As Integer
 Dim Mem As MemoryBlock
 
 Mem = NewMemoryBlock(2)
 Mem.StringValue(0,2) = MidB(Value,1,2)
 Return Mem.Shortg(0)
End Function

Function SwapEndian(Value As Integer) As Integer
 Dim A, B As MemoryBlock
 
 A = NewMemoryBlock(4)
 B = NewMemoryBlock(4)
 A.Long(0) = Value
 B.Byte(0) = A.Byte(3)
 B.Byte(1) = A.Byte(2)
 B.Byte(2) = A.Byte(1)
 B.Byte(3) = A.Byte(0)
 Return B.Long(0)
End Function


Note that those simple functions are not enough; you will need to be able to convert integers between little endian and big endian format, as well as know when endian conversion is necessary.


3) Getting packet datas and IDs is simple enough..., here's some code taken (almost) straight from my BNLSSocket object, with a ton of comments added:

Sub BNLSSocket.DataAvailable()
 Dim PacketID, PacketLength, BufferLength As Integer
 Dim Data As String
 
 Me.LagBuffer = Me.LagBuffer + Me.ReadAll
 Me.BufferLength = LenB(Me.LagBuffer)
 
 Do
   If BufferLength < 3 Then
     'Buffer length is less than even a simple header
     'either no packet available, or it's an incomplete packet
     Return
   End If
   ID = AscB(MidB(Me.LagBuffer,3,1))
   PacketLength = StrToInt16(MidB(Me.LagBuffer,1,2))
   #if TargetMacOS
   'Endian conversion is going to be needed for DataLength!
   PacketLength = SwapEndian(PacketLength)
   #endif
   If PacketLength < 3 Then
     Beep
     MsgBox "Sanity failure! Total packet length is less than the length of the header!"
   Else
     If BufferLength >= DataLength Then
       'Lag buffer is long enough to contain the packet
       Data = MidB(Me.LagBuffer, 4, PacketLength-4)
       'why DataLength-4, you ask? Well, Data variable should contain only
       'the packet data, not packet header; so need to remove length of
       'header from total packet length
       
       'Now, remove the packet from the lag buffer
       Me.LagBuffer = MidB(Me.LagBuffer, PacketLength + 1)
       'Now, process the packet
       Me.PacketReceived(ID, Data)
     Else'If BufferLength < DataLength Then
       'Lag buffer is not long enough to contain the packet;
       'Must wait for next DataAvailable event.
       Return
     End If
   End If
   'Make sure BufferLength is still accurate, for next iteration of the loop!
   BufferLength = LenB(Me.LagBuffer)
 Loop
 
Exception Error
 Beep
 MsgBox "Error!"
End Sub


Here's my definition of PacketReceived:

Sub BNLSSocket.PacketReceived(ID As Integer, Data As String)
 'hopefully you can fill this in, eh?
End Sub




All of that should be plenty enough to get you started on BNLS.



--
Thanks,
Keith Bennett, tA-Kane
Author of KaneBot
Battle.net binary bot for Macintosh.
http://linkware.clan-mac.com/kanebot



> From: MacSc <email removed for this post>
> Date: Mon, 19 Jul 2004 17:34:53 -0600
> To: Keith Bennett <[email protected]>
> Subject: Connecting with BNLS using RB
>
> Hey Keith,
> I was wondering if you could give me some tips about BNLS connection. I
> am completely clueless about these packets. Could you help?
>
> */\*\/*/\*\/*/\*\/*/\*\/*/\*\/*/\*\/*/\*\/*/\*\/*/\*\/*/\*\/*
> Thanks,
>
> MacSc
> email removed for this post

So uhh... yeah. Have fun with that.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Luxer

#5
Yep. That was me. Its Broken SHA-1, right? (If I ever want to to do local hashing)

tA-Kane

Quote from: Luxer on July 22, 2004, 12:17 PMYep. That was me.
Neato.
Quote from: Luxer on July 22, 2004, 12:17 PMIts Broken SHA-1, right? (If I ever want to to do ocal hashing)
Yes, but I haven't written it for REALbasic, nor do I know anyone that has. Feel free to try if you want, there's plenty of source code available, and there's one that I wrote for C and use here:
http://www.cubedivision.org/phpBB2/viewtopic.php?t=72
BNCSHashData() would be what you're looking for.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Luxer


eBeL

Quote from: tA-Kane on July 20, 2004, 01:54 AM
Quote from: LoRd[nK] on July 19, 2004, 07:15 PMSearch for a copy of the CleanSlateBot ocx.
Not helpful when you're using a Mac (eg, RB).  :P

Luxor, I just sent a similar email to someone along the same lines (perhaps even he is you?); read this:

{CLIPPED EMAIL}

Keith, That makes absolutly no sense.

tA-Kane

It makes perfect sense to me. What part don't you understand?  :-\
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

shadypalm88

Quote from: eBeL on August 07, 2004, 04:28 PMKeith, That makes absolutly no sense.

Quote from: LoRd[nK] on July 19, 2004, 07:15 PMSearch for a copy of the CleanSlateBot ocx.
CleanSlateBot.ocx is a Visual Basic control (Windows).

Quote from: tA-Kane on July 20, 2004, 01:54 AMNot helpful when you're using a Mac
Therefore, it will not work so well on Macintosh computers.

Quote from: tA-Kane on July 20, 2004, 01:54 AM(eg, RB).  :P
RB = RealBasic = a language/IDE similar to Visual Basic that can be used to write programs for Windows, Mac, and Linux computers.

(Made sense to me. :P)

eBeL

The entire email! Does anyone have a sample -> REALBASIC <- bot I can experiment with? I learn better and faster when I can actually see what is doing what  :-\

MyndFyre

Quote from: eBeL on August 10, 2004, 06:50 PM
The entire email! Does anyone have a sample -> REALBASIC <- bot I can experiment with? I learn better and faster when I can actually see what is doing what  :-\

Chr0nic made a good point in the other post....  Here are my two cents about using source code.

Don't lie.  If you're using source code, use it and modify it as needed.  Give credit to the person who wrote the code, and also ask permission to use it first.

The point of programming is seeing a problem and and answering or fixing it.  Your problem: you want a binary Battle.net bot.  How do you solve it?  By programming.

If you don't want to learn how to solve the problem, I'm sure Kane's bot is nice :)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

eBeL

I would prefer to use someone elses an build off of that until I understand how to do it on my own.

And I also understand what it feels like to have a project idea or application stolen from you.

tA-Kane

Janky has abandoned his JXBot. His source code is (and has been for the last two years) freely available. I have a quick download link on my bot's website.

Even though I'm told that the source code for JXBot doesn't even compile anymore with recent compilers, it wouldn't be hard to make it do so. All it would take is a minimal of effort to remove and/or fix (change?) linked images, language updates, and etc.

Sure, JXBot isn't binary. I'd have to give you a point if you said that. But that doesn't mean that the code base isn't there. It supports a colored chat field (though you'd have to add your own 'Battle.net-style' color parser). Something it has that my KaneBot doesn't is that it has proxy support (though I don't know to what extent). And hey, here's another one-up on my bot: you can write your own commands in JXBot. I'm sure just about everyone would agree JXBot has a better interface than mine  ;)

Sure, the code might not be able to compile. But if you could get it to compile, there's many people out there who liked JXBot more than my bot. Get JXBot to compile, and release it as-is for Carbon (for Mac OS X), and you'd get an instant user base. Then it's just a matter of learning JXBot's code and redoing the connection code to support a binary connection. I could do all of this in two weeks. If I didn't have a job, I could do it in two days. But you see, I'm not interesting in bringing JXBot back. I don't like JXBot, nor do I need it. Why would I work on something which I don't want or need, and won't benefit me in some way?
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com