|
You last visited: Today at 15:07
Advertisement
I am sorry for asking about packets again but...
Discussion on I am sorry for asking about packets again but... within the CO2 Private Server forum part of the Conquer Online 2 category.
10/13/2012, 01:28
|
#1
|
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 177
|
I am sorry for asking about packets again but...
I think i got an explanation for you to understand what i need well
if a game sends a packet like this
22 00 11 00 6D 79 75 73 65 72 6E 61 6D 65 00 00 00 00 00 00 6D 79 70 61 73 73 77 6F 72 64 00 00 00 00 00 00
Length , Header, Username, Password
How actually was something like this written in the client code ?
i think it is not just Encoding.ASCII.GetByte("Of some string values");!!!
assuming i want to create and send a packet like the above given those credentials
Username : Test
Password : Test
how could i generate a packet with the same structure as the above but with the given data ?
I am sorry if my question is weird.
|
|
|
10/13/2012, 02:05
|
#2
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
|
i think it's simply a login button method
it takes the acc/pass strings
then it calls another method which maybe we will call it do_login
do_login takes (acc,pass) as parameters
it convert them to bytes , add to them length and type
then call send method , send method add a seal maybe ? then send it by calling the networking class ?
if im about to create a client ill do tho , but what about another programming ? prolly may not do the same thing but in the end we will get the same result
so it's not a rule , it's completely up to you on how to generate a packet with a pre-made packet structure
you really need to look at pro4never proxy tutorial of unit 3 (as far as i remember it was unit 3)
he really did explain alot of methods of how to generate a packet with 3 different ways (including warper which i personally use , but it sometimes takes alot of parameters) , others using class for each packet to getvariable/create it , there is so many ways , check out good sources for better methods
wish that answer what you asking for
|
|
|
10/13/2012, 14:05
|
#3
|
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 177
|
Quote:
Originally Posted by go for it
i think it's simply a login button method
it takes the acc/pass strings
then it calls another method which maybe we will call it do_login
do_login takes (acc,pass) as parameters
it convert them to bytes , add to them length and type
then call send method , send method add a seal maybe ? then send it by calling the networking class ?
if im about to create a client ill do tho , but what about another programming ? prolly may not do the same thing but in the end we will get the same result
so it's not a rule , it's completely up to you on how to generate a packet with a pre-made packet structure
you really need to look at pro4never proxy tutorial of unit 3 (as far as i remember it was unit 3)
he really did explain alot of methods of how to generate a packet with 3 different ways (including warper which i personally use , but it sometimes takes alot of parameters) , others using class for each packet to getvariable/create it , there is so many ways , check out good sources for better methods
wish that answer what you asking for
|
You nearly hit the point yeah i want to know how could i add the username and password after converting them to bytes to the length and the type to form a full packet ! that's it
|
|
|
10/13/2012, 17:34
|
#4
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
|
i think i got your point
there is many ways like block copy , for example copying all bytes u need in one big byte then send them
but my fav way is the warrper (duno why but i really like this way)
well lets create a byte array in the very first
lets call it packet__17 ?
okay now we need to create methods to write stuff in the packet with certain array with all types
what i mean with all types ? to be able to write strings and ints/uints/short/ushort/long/pla/pla/pla
(ill copy this from the trinity source/ pro4never proxy , same at both)
for better understanding you should really learn from pro4never proxy (it's small so it's less scary than trinity source , but both will give u the same amount of information)
read/write to byte array
Code:
public class ReadWrite
{
public static byte[] ReadBytes(byte[] data, int start, int count)
{
try
{
if (start + count > data.Length)
return new byte[0];
else
{
byte[] info = new byte[count];
for (int i = 0; i < count; i++)
info[i] = data[i + start];
return info;
}
}
catch { return new byte[0]; }
}
public static string ReadString(byte[] data, int start, int length)
{
try
{
return Encoding.ASCII.GetString(ReadBytes(data, start, length));
}
catch { return ""; }
}
public static void WriteString(string arg, int offset, byte[] buffer)
{
try
{
if (buffer.Length >= offset + arg.Length)
{
unsafe
{
#if UNSAFE
fixed (byte* Buffer = buffer)
{
ushort i = 0;
while (i < arg.Length)
{
*((byte*)(Buffer + offset + i)) = (byte)arg[i];
i++;
}
}
#else
ushort i = 0;
while (i < arg.Length)
{
buffer[(ushort)(i + offset)] = (byte)arg[i];
i = (ushort)(i + 1);
}
#endif
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public static void WriteBool(bool Value, int offset, byte[] buffer)
{
try
{
if (Value)
buffer[offset] = (byte)(1);
else
buffer[offset] = (byte)(0);
}
catch (Exception e)
{
Console.WriteLine("offset: " + offset + " value " + Value);
Console.WriteLine(e);
}
}
public static void WriteByte(byte arg, int offset, byte[] buffer)
{
try
{
buffer[offset] = (byte)(arg);
}
catch (Exception e)
{
Console.WriteLine("offset: " + offset + " value " + arg);
Console.WriteLine(e);
}
}
public static void WriteUInt16(ushort arg, int offset, byte[] buffer)
{
try
{
if (buffer.Length >= offset + sizeof(ushort))
{
unsafe
{
#if UNSAFE
fixed (byte* Buffer = buffer)
{
*((ushort*)(Buffer + offset)) = arg;
}
#else
buffer[offset] = (byte)(arg);
buffer[offset + 1] = (byte)(arg >> 8);
#endif
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public static void WriteUInt32(uint arg, int offset, byte[] buffer)
{
try
{
if (buffer.Length >= offset + sizeof(uint))
{
unsafe
{
#if UNSAFE
fixed (byte* Buffer = buffer)
{
*((uint*)(Buffer + offset)) = arg;
}
#else
buffer[offset] = (byte)(arg);
buffer[offset + 1] = (byte)(arg >> 8);
buffer[offset + 2] = (byte)(arg >> 16);
buffer[offset + 3] = (byte)(arg >> 24);
#endif
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public static void WriteUInt64(ulong arg, int offset, byte[] buffer)
{
try
{
if (buffer.Length >= offset + sizeof(ulong))
{
unsafe
{
#if UNSAFE
fixed (byte* Buffer = buffer)
{
*((ulong*)(Buffer + offset)) = arg;
}
#else
buffer[offset] = (byte)(arg);
buffer[offset + 1] = (byte)(arg >> 8);
buffer[offset + 2] = (byte)(arg >> 16);
buffer[offset + 3] = (byte)(arg >> 24);
buffer[offset + 4] = (byte)(arg >> 32);
buffer[offset + 5] = (byte)(arg >> 40);
buffer[offset + 6] = (byte)(arg >> 48);
buffer[offset + 7] = (byte)(arg >> 56);
#endif
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
example of me sending a packet
Code:
public void __Packet10010(/*uint Entity_ID,*/ ushort coordx, ushort coordy/*, ushort jump_type*/ , GameUser roleer , string type , string sendto , ushort oldx , ushort oldy)
{
// if (Olddt + 10000 > dt && Olddt != 0) return;
// else
// {
byte[] data;
data = new byte[46];
ReadWrite.WriteString("username", 40, data); //this line just added to show you that you can write strings too inside the packet
ReadWrite.WriteUInt16(0x0026, 0, data); // packet length
ReadWrite.WriteUInt16(0x271A, 2, data); //packet number
ReadWrite.WriteUInt32(0x010DB6F9, 4, data); //packet attacker UID // 0x000F50C0
ReadWrite.WriteUInt16(coordx, 8, data); //packet current coordx
ReadWrite.WriteUInt16(coordy, 10, data); //packet current coordy
ReadWrite.WriteUInt16(oldx, 24, data); //old coordx <<< edited
ReadWrite.WriteUInt16(oldy, 26, data); //old coordy
if (type == "normal")
{
ReadWrite.WriteUInt32(137, 20, data); //packet type of jump
}
else { ReadWrite.WriteUInt32(156, 20, data); } //packet type of jump
// Console.WriteLine("jump packet from : (" + BitConverter.ToString(data, 24, 2) + "," + BitConverter.ToString(data, 26, 2) + ") to (" + BitConverter.ToString(data, 8, 2) + "," + BitConverter.ToString(data, 10, 2) + ")");
if (sendto == "server")
{
roleer.SendToServer(data);
}
else
{
roleer.SendToClient(data);
}
// Olddt = dt;
// }
}
that was the whole read write class , this is an example of generaldata/jumping packet , added to it ReadWrite.WriteString(string string , int offset , byte[] byte_array) for better understanding
you may type in hex with 0x or in dec like coordx and coordy
wish that is what you searching for , but i really want you to read , just read , pro4never proxy or trinity base , it will answer all your questions , enjoy mate
umm was to forget , about the block copy , here is an example
Buffer.BlockCopy(byte[] source_array , int source_offset , byte[] destination , int destination_offset , int count(the number of bytes to copy) );
here is an example in action at splitting packets
Code:
byte[] Packet = new byte[(Length + 8)];
Buffer.BlockCopy(data, 0, Packet, 0, (Length + 8));
byte[] _buffer = new byte[(data.Length - (Length + 8))];
Buffer.BlockCopy(data, (Length + 8), _buffer, 0, (data.Length - (Length + 8)));
data = _buffer;
ReadWrite.WriteString("TQClient", (Packet.Length - 8), Packet);
HandleClient(Packet);
|
|
|
10/13/2012, 17:57
|
#5
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,205
Received Thanks: 4,107
|
I'm not sure how well I explained it, but you can always check the thread I made about packets.
|
|
|
|
Similar Threads
|
[Release] +5500 Packets structure , client/packets constants
10/07/2012 - CO2 PServer Guides & Releases - 10 Replies
edit : if u know nothing about packets go to this post first
explaining what is packets , and explaining a packet with details and everything
http://www.elitepvpers.com/forum/co2-pserver-disc ussions-questions/2162344-packets-packets-packets. html#post19074533
i start making my very own packet structure to use them on my new proxy but i thought of ripping them from the source
so yeah the following packets is ripped of trinity base source
right now im just providing the packets structure...
|
[REQUEST] packets send list , or anyway to sniff send packets
08/10/2012 - Kal Online - 16 Replies
hey everyone , as mentioned , i wanna know if anyone got a complete send packets lists or anyway i can sniff send packets , thanks in advance
|
[Packets] Wie änder ich flyff packets?
07/16/2011 - Flyff Private Server - 19 Replies
HeyHo,
Ich würde sehr gerne wissen wie man die Flyff Packets ändert...
ich denke mal Zahlen ändern werden nicht ausreichen oder?
|
how to use packets?
07/26/2009 - Kal Online - 12 Replies
how to use packet hack and where to download them?
lg master
|
Packets
05/18/2009 - CO2 Private Server - 2 Replies
How can I get the correct packets from the client?
|
All times are GMT +1. The time now is 15:07.
|
|