Author | Message | Time |
---|---|---|
LockesRabb | What exactly is Protocol Version? Banner ID? Banner extension? And how do I get the remote filetime? The reason why I'm trying to do this is because I want to be able to download icons.bni... After reading the BNETFTP docs on BNETDocs, I'm still confused... Is this the proper sequence: C -> S 0x02 C -> S: (WORD) Length of this message (WORD) Protocol Version (DWORD) Platform ID (DWORD) Product ID (DWORD) Banner ID (DWORD) BannerExtension S -> C: (DWORD) Server Token C -> S: (DWORD) Starting position (facilitates resuming) (FILETIME) Local filetime (DWORD) Client Token (DWORD) Key Length (DWORD) Key's product value (DWORD) Key's public value (DWORD) Unknown (Always 0) (DWORD[5]) CD key data (STRING) Filename If invalid key, server disconnects. If valid, then: S -> C: (DWORD) Length of this message (not including file data) (DWORD) File size (DWORD) Banner ID (DWORD) Banner Extension (FILETIME) Remote Filetime (STRING) Filename (VOID) File data ------------------------------------------- Thanks in advance for any assistance, and for reading this! | September 19, 2005, 1:43 AM |
UserLoser. | banner id and extension come from SID_CHECKAD, protocol version = 2, iirc it says that on the page | September 19, 2005, 1:51 AM |
LockesRabb | Ah alright, I don't want to download the banners, just want to download icons.bni... How would this be done? | September 19, 2005, 2:00 AM |
UserLoser. | [quote author=Kyro link=topic=12851.msg128650#msg128650 date=1127095208] Ah alright, I don't want to download the banners, just want to download icons.bni... How would this be done? [/quote] First, try using the other protocol because using this one isn't necessary for icons.bni | September 19, 2005, 2:06 AM |
LockesRabb | I decided to just take a wild guess, and try experimenting to see if I could figure it out. Still couldn't. Could you guys be so kind as to take a gander at my code, and point out any errors? The following code is in my bnetftp module. The bnetftp socket passes along events and data to this module. This stuff is mainly for just downloading icons.bni. [code]Public Sub FTPDownload(Data As String, Optional Completed As Boolean = False) Static DownloadBuffer As String Dim HeaderLen As Long Dim Unknown As Long Dim FileSize As Long Dim RemoteFileTime As Long Dim FileName As String Dim FileData As String Dim Trash As Long, Trash2 As String If Completed = False Then AddC vbWhite, "Downloading..." DownloadBuffer = DownloadBuffer & Data Else AddC vbWhite, "Download Complete. Extracting file..." FTPDeBuf.SetData DownloadBuffer HeaderLen = FTPDeBuf.rWORD Unknown = FTPDeBuf.rWORD FileSize = FTPDeBuf.rDWORD Trash = FTPDeBuf.rDWORD 'Banners ID Trash = FTPDeBuf.rDWORD 'Banners File Extension Trash2 = FTPDeBuf.rFILETIME 'Remote filetime FileName = FTPDeBuf.rNTString Open FileName For Output As #1 Print #1, FTPDeBuf.GetData Close If FileLen(FileName) = FileSize Then AddC vbGreen, "Extract Success!" Else Kill FileName AddC vbRed, "Extract Failure!" AddC vbRed, "Data Dump: " AddC vbRed, "-----------" AddC vbRed, "FileName: " & FileName AddC vbRed, "Downloaded File size is " & FileLen(File) & " bytes." AddC vbRed, "Server stated the file size would be " & FileSize & "." End If End If End Sub Public Sub FTPConnected() AddC vbWhite, "Connected to FTP! Sending request..." DMBot.bftp.SendData &H2 'Protocol: bnFTP With FTPBuf .Clear .InsertDWORD &H1 .InsertDWORD CLng("&H" & Replace(StrToHex("IX86"), " ", vbNullString)) 'IX86 .InsertDWORD CLng("&H" & Replace(StrToHex(BNETClient), " ", vbNullString)) 'SEXP .InsertDWORD &H0 'Banners ID .InsertDWORD &H0 'Bannkers File Extension .InsertDWORD &H0 'Start position in file (for resuming) .InsertDWORD &H0 'Filetime of local file .InsertNTString "icons.bni" .SendPacket DMBot.bftp, , 2 End With End Sub Public Sub FTPConnect() AddC vbWhite, "Connecting to BNET FTP..." DMBot.bftp.RemoteHost = BNETServer DMBot.bftp.RemotePort = BNETPort If DMBot.bftp.State = sckConnected Then DMBot.bftp.Close End If DMBot.bftp.Connect End Sub [/code] Thanks in advance for any tips! | September 19, 2005, 2:56 PM |
LockesRabb | Using a packet logger, I was able to see the differences between Arta's BNFTP program, and mine. When I compare the packet to the bnetdoc bnftp protocol, it doesn't match. I'm trying to make sense of it, but I'm having a hard time. Here's the packets I logged from both my bot and Arta's BNFTP program. Keep in mind, Arta's is working, and mine isn't working. [code]DMBot 02 04 05 B4 01 01 04 02 | ...'.... 02 00 28 00 01 00 00 00 36 38 58 | ..(.....68X 49 4C 54 52 44 00 00 00 00 00 00 | ILTRD...... 00 00 01 00 00 00 00 00 00 00 69 | ..........i 63 6F 6E 73 2E 62 6E 69 00 | cons.bni. BNFTP CL Prog 02 04 05 B4 01 01 04 02 | ...'.... 02 2A 00 00 01 36 38 58 49 4C 54 | .*...68XILT 52 44 00 00 00 00 00 00 00 00 00 | RD......... 00 00 00 00 00 00 00 00 00 00 00 | ........... 69 63 6F 6E 73 2E 62 6E 69 00 | icons.bni.[/code] From what I can see, I got this bit wrong: [code]00 28 00 01 00 00 00[/code] where it should be: [code]2A 00 00 01[/code] What am I doing wrong? And also, what does DRTL mean? I know that part is the product id, but for which game? I'm guessing d2lod? | September 20, 2005, 3:50 PM |
Arta | Use version one of the protocol. It's much simpler. http://bnetdocs.valhallalegends.com/content.php?Section=d&id=9 | September 20, 2005, 4:00 PM |
LockesRabb | Already am, upon an earlier suggestion. This is my current code: [code]Public Sub FTPConnected() AddC vbWhite, "Connected to FTP! Sending request..." AddC vbWhite, BNETClient DMBot.bftp.SendData &H2 'Protocol: bnFTP With FTPBuf .Clear .InsertDWORD &H1 .InsertDWORD CLng("&H" & Replace(StrToHex("IX86"), " ", vbNullString)) 'IX86 .InsertDWORD CLng("&H" & Replace(StrToHex("DRTL"), " ", vbNullString)) 'SEXP .InsertDWORD &H0 'Banners ID .InsertDWORD &H0 'Bannkers File Extension .InsertDWORD &H1 'Start position in file (for resuming) .InsertDWORD &H0 'Filetime of local file .InsertNTString "icons.bni" .SendPacket DMBot.bftp, , 2 End With AddC vbWhite, "File request sent." End Sub[/code] And also I noticed you used DRTL-- whereas before I used SEXP- I changed mine to DRTL, but I don't think that makes much difference since it's just product ID-- what is DRTL? | September 20, 2005, 4:04 PM |
Arta | Diablo Retail. Your version is wrong: [quote] Version 1 of bnFTP actually has a version of 0x100 (256). It seems likely that it was originally coded with the bytes in the wrong order (in the message, 00 10 instead of 01 00). [/quote] Also, it should be a WORD, not a DWORD. Your message length looks wrong too, but your message log is hard to read, so I didn't check. I assume '.SendPacket' is setting the length in the message? | September 20, 2005, 5:24 PM |
LockesRabb | Yea, using .SendPacket. Here's code for that: [code]Public Function SendPacket(sck As Winsock, Optional PacketID As Long, Optional mode As Integer = 1) As Boolean If sck.State = sckConnected Then If mode = 1 Then 'Game mode sck.SendData Chr(&HFF) & Chr(PacketID) & MakeWORD(Len(Buffer) + 4) & Buffer ElseIf mode = 2 Then 'bnFTP mode sck.SendData MakeWORD(Len(Buffer) + 2) & Buffer AddC vbCyan, "BNFTP Packet Sent! Packet: " & MakeWORD(Len(Buffer) + 2) & Buffer End If SendPacket = True End If Clear End Function[/code] And I fixed version, changed version from dword to word. Here's new code: [code]Public Sub FTPConnected() AddC vbWhite, "Connected to FTP! Sending request..." AddC vbWhite, BNETClient DMBot.bftp.SendData &H2 'Protocol: bnFTP With FTPBuf .Clear .InsertWORD &H100 .InsertDWORD CLng("&H" & Replace(StrToHex("IX86"), " ", vbNullString)) 'IX86 .InsertDWORD CLng("&H" & Replace(StrToHex("DRTL"), " ", vbNullString)) 'SEXP .InsertDWORD &H0 'Banners ID .InsertDWORD &H0 'Bannkers File Extension .InsertDWORD &H1 'Start position in file (for resuming) .InsertDWORD &H0 'Filetime of local file .InsertNTString "icons.bni" .SendPacket DMBot.bftp, , 2 End With AddC vbWhite, "File request sent." End Sub[/code] I packet logged it to see if it was finally right-- wasn't. I think I'm messing up somewhere- most likely in the packet length, but I'm not sure. [code]C -> S 02 04 05 B4 01 01 04 02 | ...'.... S -> C 02 04 05 AC 01 01 04 02 | ...¬.... C -> S 02 00 28 00 00 01 00 00 36 38 58 | ..(.....68X C -> S 49 4C 54 52 44 00 00 00 00 00 00 | ILTRD...... C -> S 00 00 01 00 00 00 00 00 00 00 69 | ..........i C -> S 63 6F 6E 73 2E 62 6E 69 00 | cons.bni.[/code] Hmmm... Definitely gotta be the packet length. But I assumed MakeWORD(Len(Buffer) + 2) & Buffer would be sufficent-- or is the packet length byte NOT included in the packet length when getting packet length? A second, let me experiment with that by changing it to MakeWORD(Len(Buffer)) & Buffer... [code]C -> S 02 04 05 B4 01 01 04 02 | ...'.... S -> C 02 04 05 AC 01 01 04 02 | ...¬.... C -> S 02 00 26 00 00 01 00 00 36 38 58 | ..&.....68X C -> S 49 4C 54 52 44 00 00 00 00 00 00 | ILTRD...... C -> S 00 00 01 00 00 00 00 00 00 00 69 | ..........i C -> S 63 6F 6E 73 2E 62 6E 69 00 | cons.bni.[/code] Nope, didn't work, it's not giving the same packet as your bnftp program. Any ideas? [Edited to have hex display correctly] | September 20, 2005, 5:42 PM |
Arta | Your length is wrong. It does include the length byte. Everything from the length byte to the end of the filename, including the null terminator. | September 20, 2005, 8:00 PM |
LockesRabb | Duh me! I completely forgot to count the null terminator! In any case, it's outputting data almost exactly as your program, except it's one byte off: [code] 02 00 2A 00 00 01 00 00 36 38 58 | ..*.....68X 49 4C 54 52 44 00 00 00 00 00 00 | ILTRD...... 00 00 01 00 00 00 00 00 00 00 69 | ..........i 63 6F 6E 73 2E 62 6E 69 00 00 00 | cons.bni...[/code] Should be 02 2A, not 02 00 2A... I added: DMBot.bftp.SendData &H0 to the end of the FTPConnected() sub, to act as null terminator for that packet. I also modified the line in SendPacket to send this instead: sck.SendData MakeWORD(Len(Buffer) + 4) & Buffer So close....... | September 20, 2005, 8:48 PM |
Arta | You have two extra 00s between the version and the platform id as well. (Are you sure " DMBot.bftp.SendData &H2" inserts a byte?)This looks weird too: [quote] sck.SendData MakeWORD(Len(Buffer) + 4) & Buffer [/quote] Why +4? Other than that, I can't see anything wrong. As you make your changes, you should check the message log against BnetDocs. It shouldn't be too hard to identify errors! Just look for missing or extra bytes - ones that don't conform to the message spec. | September 20, 2005, 10:26 PM |
LockesRabb | Ah, I didn't notice those extra zero'es... I'll have to look into that. No, DMBot.SendData &H2 just sends that byte directly- it doesn't bother adding to the buffer. In other words, that byte is sent by itself. The +4 is to also include the bytes of the null terminator, and the packet length. I've confirmed I've gotten the packet length down since it matches yours now. I think it has something to do with how my PacketBuffer class works with WORDs, either that, or there's something else I'm missing. When I get home, I'm gunna put in debug code to show me what exactly is going on in the buffer, maybe I can pinpoint where it's bugging. Also I found VB source code on PSC for a packet sniffer, but I don't know if that'd be of any use to you since Etheral's already good enough? I tried using Etheral, I couldn't figure out the filter thing so I just went to PSC, downloaded the packet sniffer I found, and it pretty much serves the same purpose, for much less file space. Limited features though. | September 20, 2005, 10:49 PM |
Arta | Ethereal is better. Learn to use it. The message length plus nullterm is 3 bytes, not 4 - might want to change that. | September 20, 2005, 11:35 PM |
Kp | Also, please use pre tags instead of code tags for your packet dumps. Any decent network sniffer should be outputting dumps in a format which looks much better in pre tags. | September 21, 2005, 1:11 AM |