Jump to content
Returning Members: Password Reset Required ×

Impulse Source 5165 -> Offset calculation issue.


Recommended Posts

Posted

Hi Spirited,

I was experimenting with Impulse's source and encountered an issue that I saw you post about on Epvp (https://www.elitepvpers.com/forum/co2-private-server/1430245-help-impulses-5165-a.html)

It appears that Impulse's source has an index out of range issue when trying to calculate the Junk length:

 try
                           {
                               Client.Exchange = false;

                               Client.Action = 1;
                               ushort position = 7;
                               uint PacketLen = BitConverter.ToUInt32(arg1, position); position += 4;
                               int JunkLen = BitConverter.ToInt32(arg1, position); position += 4; position += (ushort)JunkLen;
                               int Len = BitConverter.ToInt32(arg1, position); position += 4;
                               byte[] pubKey = new byte[Len];
                               for (int x = 0; x < Len; x++)
                                   pubKey[x] = arg1[x + position];
                               string PubKey = System.Text.ASCIIEncoding.ASCII.GetString(pubKey);

                               Client.Cryptography = Client.DHKeyExchance.HandleClientKeyPacket(PubKey, Client.Cryptography);
                           }

I tried using your suggested code:


try
                           {
                               Client.Exchange = false;

                               Client.Action = 1;
                               ushort position = 7;
                               uint PacketLen = BitConverter.ToUInt32(arg1, position);
                               int JunkLen = BitConverter.ToInt32(arg1, position += 4); 
                               int Len = BitConverter.ToInt32(arg1, position += (ushort)(JunkLen + 4));
                               byte[] pubKey = new byte[Len];
                               position += 4;
                               string PubKey = System.Text.ASCIIEncoding.ASCII.GetString(arg1, position, Len);

                               Client.Cryptography = Client.DHKeyExchance.HandleClientKeyPacket(PubKey, Client.Cryptography);
                           }
                           
                           

However the issue persists. Is there any guidance you can provide me with not only solving this but understanding why it would be failing here:

```int Len = BitConverter.ToInt32(arg1, position += (ushort)(JunkLen + 4));```

Thank you for your time.

Posted
Please do not address me specifically when asking questions. I'm not the only member here on this board, though I admit it's been really quiet recently after all the flash eol hit. I'm also not developing for Conquer Online these days... Anyways, have your tried debugging the project and catching the exception? You should be able to see the contents of those variables and the packet buffer. I don't see anything wrong with the code you posted in particular. Would also be helpful to know the length of the packet and check that before making these conversions.
Posted

Sorry about that, I reached out to you specifically because your post on EPvP suggested you had encountered this before. I won't make such direct posts again.

I did try debugging, set a couple of breakpoints and couldn't quite determine why the position variable was jumping so wildly at

position += (ushort)(JunkLen + 4));

When connecting with the clean 5165 client you provided on these forums, along with ConquerLoader 5.2 (And adjusting my date time temporarily to pre-flash EoL) client sends a 276 length packet when logging in. The Junk Len variable being casted to a short and then added to the position variable seems to skyrocket its value. Admittingly, while I know some decent amount of C#, I don't have much experience with bit conversions and working with packets.

uRxfhwZ.png

I understand why the index out of range issue is occurring, position's value skyrockets after the Junk length ushort is added to it. I guess I'm at a disadvantage not knowing what packet this is and what to expect. I've browsed the helpful packet wiki (https://gitlab.com/conquer-online/wiki/-/wikis/Packets/Packets) but was unable to determine which packet we're working with in this section of the code.

Any guidance anyone could provide would be helpful, thank you!

Posted
No worries about the direct mention. I just don't want it to become a reoccurrence is all. So, here's a link to how my skeleton server project handles the packet. Again, it looks pretty similar to how you're handling it already, so I'm a bit confused. You can try doing a packet dump on the buffer and posting it here. If you don't have code for that, here's another link to mine. That'll help me step through the code with you a bit better.
Posted

I've dumped the contents of the packet below, not quite sure how to utilize this information though.


The packet in question
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 					| .[b. |


Buffer:
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 00 00 00 00  00 00 00 00 00 00 00 00  | .[b............. |
0120:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................ |
0130:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................

The rest of the buffer is empty.

Posted

I've dumped the contents of the packet below, not quite sure how to utilize this information though.


The packet in question
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 					| .[b. |


Buffer:
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 00 00 00 00  00 00 00 00 00 00 00 00  | .[b............. |
0120:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................ |
0130:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................

The rest of the buffer is empty.

Hmm.... that doesn't look right. Are you sure your packet is decrypted by that point?

Side note: I'll make a tutorial at some point for packets, byte endianness, and hex dumps.

Posted

I've dumped the contents of the packet below, not quite sure how to utilize this information though.


The packet in question
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 					| .[b. |


Buffer:
0000:  15 94 56 65 D7 13 C4 A5  DF 0F 33 A5 14 CB 75 6F  | ..Ve......3...uo |
0010:  5F 89 B0 22 93 46 F6 E3  D6 00 3E A2 17 C4 78 6C  | _..".F....>...xl |
0020:  56 82 BF 2B 92 43 F5 E0  D9 05 35 AB 16 C1 7F 6D  | V..+.C....5....m |
0030:  59 87 BA 20 9D 4C F8 E1  D0 0E 30 A0 11 C2 72 62  | Y.. .L....0...rb |
0040:  50 88 B1 29 9C 49 FF E6  DB 03 3F A9 10 CF 71 63  | P..).I....?...qc |
0050:  5B 8D BC 26 9F 4A F2 E7  D2 04 3A A6 13 C8 74 60  | [..&.J....:...t` |
0060:  52 86 BB 2F 9E 47 F1 E4  D5 09 31 AF 12 C5 7B 61  | R../.G....1...{a |
0070:  55 8B B6 24 99 40 F4 E5  DC 02 3C A4 1D C6 7E 66  | U..$.@....<...~f |
0080:  5C 8C BD 2D DE 6F 77 3F  5F 70 1E A8 CC A9 FD B3  | \..-.ow?_p...... |
0090:  68 F7 06 1D 9B 4E FE EB  DE 08 36 AA 1F CC 70 64  | h....N....6...pd |
00A0:  5E 8A B7 23 9A 4B FD E8  D1 0D 3D A3 1E C9 77 65  | ^..#.K....=...we |
00B0:  51 8F B2 28 95 44 F0 E9  D8 06 38 A8 19 CA 7A 6A  | Q..(.D....8...zj |
00C0:  58 80 B9 21 94 41 F7 EE  D3 0B 37 A1 18 C7 79 6B  | X..!.A....7...yk |
00D0:  53 85 B4 2E 97 42 FA EF  DA 0C 32 AE 1B C0 7C 68  | S....B....2...|h |
00E0:  5A 8E B3 27 96 4F F9 EC  DD 01 39 A7 1A CD 73 69  | Z..'.O....9...si |
00F0:  5D 83 BE 2C 91 48 FC ED  D4 0A 34 AC 15 CE 76 6E  | ]..,.H....4...vn |
0100:  86 56 67 F7 77 D0 D7 17  DB DD E1 77 C6 19 A7 BD  | .Vg.w......w.... |
0110:  8D 5B 62 F0 00 00 00 00  00 00 00 00 00 00 00 00  | .[b............. |
0120:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................ |
0130:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  | ................

The rest of the buffer is empty.

Hmm.... that doesn't look right. Are you sure your packet is decrypted by that point?

Side note: I'll make a tutorial at some point for packets, byte endianness, and hex dumps.

Hey Spirited, sorry for the delay in responding to you - I actually went looking at the Copsv6 source from your links on this forum. Had a great time messing around and seeing how it handled things - then I came across the copsv6 enhanced source and really liked the upgrades. I was dismayed to see it targeting patch 4330, so I'm in the midst of trying to update the game server to work with Patch 5017. Over-all, I love the general structure of CopsV6Enhanced and found it more enjoyable to pursue upgrading that one than trying to figure out what is going wrong/what I'm doing wrong with Impulse' source.

In the end your packet dump class is helping significantly in figuring this out so I thank you for the time you committed already to helping me.

Posted
All good - As long as you learned something from the experience, that's the best I could have asked for. Have fun with the new server, and feel free to ask questions if you get stuck on something again.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...