Programing Proxy problem.

11/20/2007 01:42 inSertCoiN#16
Quote:
Originally Posted by toreddo View Post
Dont think you can make a standalone client if you know all the packets.
There comes alot more hacking with it. Make it and your in botjail in couple of minutes.

Just preparing you.

Goodluck.
Toreddo
I'm not saying that I will make it but I will keep trying ;) Its a good practice and a new field in which I haven't programed before. Anyway thats why I'm starting with a proxy first ;)

Quote:
Originally Posted by XtremeX-CO View Post
You forgot character ID.
3f4 is the check. 3f2 is just basically a general packet, used for lots of things, including jumping,sitting, exp etc..

assuming u start with the first byte being 0
byte 8-11 are char id.
byte 12-15 are the action.
byte 16,17 are your location (x)
byte 18,19 are your location (y)
byte 20,21 are your direction
byte 22 is the identifier 0x51
I have the ID mate. Actually I have all the info in now and I understand the structure. of that packet. If you see the [Only registered and activated users can see links. Click Here To Register...] you will see that the packet that I have send looks just like the packet which was send by the game client just few seconds before (except the xored time with id bites afcourse).
Thats why I'm lost, everything seems perfectly right but it won't work.
11/20/2007 02:42 XtremeX-CO#17
b[8]=(byte)(id&0xff);
b[9]=(byte)((id&0xff00)>>8);
b[10]=(byte)((id&0xff0000)>>16);
b[11]=(byte)((id&0xff000000)>>24);
b[12]=(byte)(action&0xff);
b[13]=(byte)((action&0xff00)>>8);
b[14]=(byte)((action&0xff0000)>>16);
b[15]=(byte)((action&0xff000000)>>24);
b[16]=(byte)(x&0xFF);
b[17]=(byte)((x&0xFF00)>>8);
b[18]=(byte)(y&0xFF);
b[19]=(byte)((y&0xFF00)>>8);
b[20]=(byte)(dir&0xff);
b[21]=(byte)((dir&0xff00)>>8);
b[22]=(byte)(int)0x51;

hope that helps, aside from the timestamp,size,and id


those empty spots you have should be the action, and like i said, byte 16-19 are coords, and 20+21 are direction
11/20/2007 05:38 bone-you#18
Quote:
Originally Posted by XtremeX-CO View Post
b[8]=(byte)(id&0xff);
b[9]=(byte)((id&0xff00)>>8);
b[10]=(byte)((id&0xff0000)>>16);
b[11]=(byte)((id&0xff000000)>>24);
b[12]=(byte)(action&0xff);
b[13]=(byte)((action&0xff00)>>8);
b[14]=(byte)((action&0xff0000)>>16);
b[15]=(byte)((action&0xff000000)>>24);
b[16]=(byte)(x&0xFF);
b[17]=(byte)((x&0xFF00)>>8);
b[18]=(byte)(y&0xFF);
b[19]=(byte)((y&0xFF00)>>8);
b[20]=(byte)(dir&0xff);
b[21]=(byte)((dir&0xff00)>>8);
b[22]=(byte)(int)0x51;

hope that helps, aside from the timestamp,size,and id


those empty spots you have should be the action, and like i said, byte 16-19 are coords, and 20+21 are direction
That way of setting an array is messy x.x
11/20/2007 12:59 inSertCoiN#19
I don't think my problem is building the packet.
As I said before, I made a test. I have send a sit command using the Conquer2 client and I have capture the packet (I left spaces between the areas of the packet for easier reading):
Quote:
1800 F203 9A7A9522 269C1100 FA000000 D501F200 04005100
A few seconds later I have send my packet, same coordinates and everything.
Quote:
1800 F203 07E28422 269C1100 FA000000 D501F200 00005100
If you see the packets you'll see that they are identical, as they should be (except for the time stamp.) The packet that the Client have send normaly works. But the packet that I have send, which is identical, doesn't work and make Conquer crush after about 10 sec.

So, I've got every aspect of the building the sit packet and I'm 100% sure I'm doing it right. I don't need the sit packet structure or a function how to build it. I need to understand why a perfectly correct packet (I can say that because it looks just like a sit packet send from the Client at same coordinates few seconds earlier) doesn't work when I send it to the server directly throe my proxy.
I hope you understand now what my problem is :D
11/20/2007 15:15 flowerpot!#20
After you inject the packet do you re-encode all following packets? Cause the encryption uses counters which will be incremented for the injected packet.

And Zero, the way you're setting the array is also messy... :D
t_packet_3f2 *p = (t_packet_3f2 *)buf;
p->id = 0x3f2;
p->player_id = pid;
p->x = x;
...

Likewise for parsing the packet. And when TQ updates structures you just have to update a header.
11/20/2007 16:12 inSertCoiN#21
Quote:
Originally Posted by flowerpot! View Post
After you inject the packet do you re-encode all following packets? Cause the encryption uses counters which will be incremented for the injected packet.

And Zero, the way you're setting the array is also messy... :D
t_packet_3f2 *p = (t_packet_3f2 *)buf;
p->id = 0x3f2;
p->player_id = pid;
p->x = x;
...

Likewise for parsing the packet. And when TQ updates structures you just have to update a header.
Yes, after I send the packet I decrypt and re-encrypt every packet with the new encryption counters.
Maybe I'm doing some basic thing wrong... What do you mean by "inject the packet"?
I just encrypt the prepared packet with the current encryption counters and send it to the server from my proxy connection to the game server.

I'll try to explain what I do.
The connections are:
S01 (connection to Conquer client) <> my proxy program <> S02 (connection to game server)

Now, what I simply do is:
Quote:
PreparePacket = "1800F203" & TimeXOR(timeGetTime, MyID) & MyID & "FA000000" & MakeXbt(xcord) & MakeYbt(ycord) & "00005100"
PreparePacket = EncryptSend(PreparePacket)
S02.SendData PreparePacket
1. The "PreparePacket" is correct and matches with the packet that is send by the Conquer Client, so I assembled it correctly.
2. The Encryption functions good, I can see that from my log that I've posted in the 1st post. (packets communication between the Client and server is decrypted/encrypted correctly until I get disconnected. Also the packet that I send is encrypted correctly, I can see that because the server returns the same packet that I have send to the Game Client right after I send it.)
3. Is this the way packets should be send? Directly to the connection to the game server? Is there a way to give the packet to the Game Client so that it sends it himself?
11/20/2007 17:22 flowerpot!#22
Quote:
Originally Posted by inSertCoiN View Post
Yes, after I send the packet I decrypt and re-encrypt every packet with the new encryption counters.
Maybe I'm doing some basic thing wrong... What do you mean by "inject the packet"?
I just encrypt the prepared packet with the current encryption counters and send it to the server from my proxy connection to the game server.

I'll try to explain what I do.
The connections are:
S01 (connection to Conquer client) <> my proxy program <> S02 (connection to game server)

Now, what I simply do is:

1. The "PreparePacket" is correct and matches with the packet that is send by the Conquer Client, so I assembled it correctly.
2. The Encryption functions good, I can see that from my log that I've posted in the 1st post. (packets communication between the Client and server is decrypted/encrypted correctly until I get disconnected. Also the packet that I send is encrypted correctly, I can see that because the server returns the same packet that I have send to the Game Client right after I send it.)
3. Is this the way packets should be send? Directly to the connection to the game server? Is there a way to give the packet to the Game Client so that it sends it himself?
There are some remote command packets that you can send to client to make it do stuff, but probably not enough of them to do everything you want. The only other way to have client do the encryption and sending is by hooking the send function in the client. Not robust cause you'd have to find it each time the binary is updated.

From a proxy perspective, sending to the game server directly here is right. To help debug the problem you could try altering a packet instead of injecting a new one first. e.g. if you get a "wave" packet from client change it to "sit". Or when client sits call your function to make your sit packet and diff it to the one that the client generated.
11/21/2007 17:26 inSertCoiN#23
Quote:
Originally Posted by flowerpot! View Post
From a proxy perspective, sending to the game server directly here is right. To help debug the problem you could try altering a packet instead of injecting a new one first. e.g. if you get a "wave" packet from client change it to "sit". Or when client sits call your function to make your sit packet and diff it to the one that the client generated.
Ok, I used your debugging technique. I made a progress and I'm relay grateful for that. I actually made him sit few times :D, but I still get disconnected.
Here is what I got:
Quote:
("I've separated the bytes for easier reading")

The package that the game client have send:
1800F203 F63F8606 269C1100 FA000000 D701 F300 0200 5100

The package that I would have send at the exact same time:
1800F203 E9DC9706 269C1100 FA000000 D701 F300 0200 5100
By analyzing this you can see that the only thing that does not match exactly is the time stamp.
I assume thats because I'm using my SystemTime to create the time stamp and the client/server are using the server time to create it??? How do you create the time stamp??
11/21/2007 20:48 XtremeX-CO#24
onTimer(byte b[]) {
if(b[12]==0x1b) ttime=(new Date()).getTime();
}

First you get the timestamp from the timer packet (0x3f1)

Then simply
int timer=(int)((new Date()).getTime()-ttime);

Just convert that to vb, and it should work
11/22/2007 03:38 inSertCoiN#25
Quote:
Originally Posted by XtremeX-CO View Post
onTimer(byte b[]) {
if(b[12]==0x1b) ttime=(new Date()).getTime();
}

First you get the timestamp from the timer packet (0x3f1)

Then simply
int timer=(int)((new Date()).getTime()-ttime);

Just convert that to vb, and it should work
Correct me if I'm wrong but in words it should be something like this:
1.when receiving a time packet, you get the timestamp and write down current system time.
2. When you wanna send packet, to create the timestamp, you just add the (current system time - the system time when you got the time packet) to the (+) timestamp from the time packet.
11/22/2007 06:57 XtremeX-CO#26
Quote:
Originally Posted by inSertCoiN View Post
Correct me if I'm wrong but in words it should be something like this:
1.when receiving a time packet, you get the timestamp and write down current system time.
2. When you wanna send packet, to create the timestamp, you just add the (current system time - the system time when you got the time packet) to the (+) timestamp from the time packet.
Yeah basically, you get the timestamp from the timer packet (0x3f1). Then, create a NEW timestamp, based on th current time, and substract the value you got from the timer packet,so you get the DIFFERENCE in the timestamp. Sorry if i confuse you, let me try and reword it.

Basically
0x3f1 Gives you timestamp - OLDTIME
You create a new timestamp - TIME

Then when you want to send a packet, you do TIMESTAMP=TIME-OLDTIME, so you get the difference between those 2 packets, which will be used in the packet.

once again, sorry Im awful at explaining things :(
11/22/2007 08:11 inSertCoiN#27
Ty mate I finally made it !!! :D Thanks to all who helped me.
OK 1 more final thing and I think I can go on from there...
When I send the "sit" packet, you can see the character siting from other clients, but not from the one on which I forced the packet. How to make my client (the original on which proxy works) get the current character state, so I can see that hes actually seating?
11/22/2007 09:27 XtremeX-CO#28
Hmm, honestly, I never tried lol... didnt need to... but pretty simple... capture the client on another client, then build that packet and send it to client, instead of server... Too lazy to open my iDE, but the packets should be the same, weather you send them to client or server... but theres the other thing, where, just like jump, if you senda packet to client, with your OWN char id, it doesnt do the jump (therefore the need for a refresh packet)
11/22/2007 14:07 inSertCoiN#29
Quote:
Originally Posted by XtremeX-CO View Post
Hmm, honestly, I never tried lol... didnt need to... but pretty simple... capture the client on another client, then build that packet and send it to client, instead of server... Too lazy to open my iDE, but the packets should be the same, weather you send them to client or server... but theres the other thing, where, just like jump, if you senda packet to client, with your OWN char id, it doesnt do the jump (therefore the need for a refresh packet)
Well basically the server does that on hes own. If I send him sit packet, he sends the same sit packet back to the client. The problem is nothing happens then. I mean I actually did sit but I can't see that on my client.
11/22/2007 15:34 Queen-Of-Evil#30
Quote:
Originally Posted by inSertCoiN View Post
Well basically the server does that on hes own. If I send him sit packet, he sends the same sit packet back to the client. The problem is nothing happens then. I mean I actually did sit but I can't see that on my client.
Cant you send a packet from the Proxy to the CO client Manuelly? :confused: Not that I could see why you would want to see yourself autosit,,, except for pleasure sake, Even Net and Caff didnt finish that ^^ Nice to see your getting there though :cool: