|
You last visited: Today at 23:59
Advertisement
are these packets correct?
Discussion on are these packets correct? within the SRO Coding Corner forum part of the Silkroad Online category.
12/13/2010, 19:12
|
#1
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
are these packets correct? Update: problem with reading.
I've been busy creating my own packet sniffer for silkroad. But I don't know if the packets are oke. because I use winPcap to sniff the packets and it has all those headers init so I had to strip them but I don't know if I got them all.
These are the first few packets which I got after I started the launcher.
Thank you
|
|
|
12/13/2010, 19:23
|
#2
|
elite*gold: 0
Join Date: Nov 2010
Posts: 13
Received Thanks: 4
|
These packet is right.
2 byte - data len
2 byte - opcode
2 byte - security bytes
after all packet is data.
You can check your data with and any open source emulator. ^^
|
|
|
12/13/2010, 19:27
|
#3
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
Thank you
|
|
|
12/14/2010, 14:43
|
#4
|
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
|
Or if you don't wanna download anything, just take a look at my packet documentation:
|
|
|
12/14/2010, 15:01
|
#5
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
Oke well I've got a new problem right now. (I didn't want to create a new thread so sorry for the double post)
I'm trying to read the packet size and the opcode but my reader returns in the 4th, 5th and the 7th packet wrong values. the 4th shows a wrong opcode the 5th are both values wrong and the 7th is the size wrong.
This is how it looks like:
as you can see the 4th packet says opcode = ffff9000 which should be 9000 only.
this is a little code snippet of my reader which I use to read the size and opcode. I got these from Jmerlin's sremu2 for just testing if it works.
Code:
template <typename T>
T reading(byte* stream, int& pos, int len)
{
if((int)(pos + sizeof(T)) > (int)len)
return (T)0;
T val = *(T*)&stream[pos];
pos += sizeof(T);
return val;
}
short packetReader::readWord(){
return reading<short>(_buffer,_cur,_size);
}
I'm using this readWord function for the packet size and opcode. I assume that correct.
owh and by the way I'm printing the size and opcode like this:
Code:
packetReader reader((byte*)data, size);
short psize = reader.readWord() + 6;
short opcode = reader.readWord();
short security = reader.readWord();
printf("packet size: %d\n", psize);
printf("opcode: %.4x\n", opcode);
I hope someone could help me with this problem.
thank you
EDIT: @lesderid Yeah I saw your packet documentation it's great But I would like to have something which I can use and update because your documentation would be incorrect if joymax changes something. and I need something to sniff ingame without using a loader or something like that. because most of the packet sniffers are build in loaders so you don't get the first few packets at startup and you have to wait for a new release if joymax updates their opcodes and with this one I ain't got those problems.
btw sorry for my english:P
|
|
|
12/14/2010, 15:05
|
#6
|
elite*gold: 0
Join Date: Nov 2010
Posts: 13
Received Thanks: 4
|
Code:
packetReader reader((byte*)data, size);
short psize = reader.readWord();
short opcode = reader.readWord();
short security = reader.readWord();
printf("packet size: %d\n", psize);
printf("opcode: %.4x\n", opcode);
try like this. ^^ you do not need +6 for psize
edit :
right code(c#)
Code:
ushort datasize = BitConverter.ToUInt16(buff, 0);
ushort read_opcode = BitConverter.ToUInt16(buff, 2);
byte[] buff_ = new byte[datasize];
Array.Copy(buff, 6, buff_, 0, datasize);
like this ^^
|
|
|
12/14/2010, 15:10
|
#7
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
Quote:
Originally Posted by aintx
Code:
packetReader reader((byte*)data, size);
short psize = reader.readWord();
short opcode = reader.readWord();
short security = reader.readWord();
printf("packet size: %d\n", psize);
printf("opcode: %.4x\n", opcode);
try like this. ^^ you do not need +6 for psize
|
Thank you for your quick response.
It didn't solve my problem. I think I need to add + 6 because now I've got 6 bytes more in every packet than psize says. Like that 4th packet It says packet size: 0 but there are 6 bytes in it.
|
|
|
12/14/2010, 16:26
|
#8
|
elite*gold: 0
Join Date: Mar 2009
Posts: 443
Received Thanks: 597
|
Quote:
Originally Posted by sjaakie100
Thank you for your quick response.
It didn't solve my problem. I think I need to add + 6 because now I've got 6 bytes more in every packet than psize says. Like that 4th packet It says packet size: 0 but there are 6 bytes in it.
|
Well, this is how silkroad builts the packets(the header is always 6 bytes big, the green marked)
Code:
struct TPacket
{
[COLOR="Lime"] public ushort size;
public ushort opcode;
public byte securityCount;
public byte securityCRC;[/COLOR]
public fixed byte [COLOR="Red"]data[/COLOR][8096];
}
Code:
short psize = reader.readWord();
this size is not the packet size, its the size of the data.
if you add +6 you add the size of the header, too.so your 4th packet has just no data in it.
|
|
|
12/14/2010, 16:43
|
#9
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
Quote:
Originally Posted by Shadowz75
Well, this is how silkroad builts the packets(the header is always 6 bytes big, the green marked)
Code:
struct TPacket
{
[COLOR="Lime"] public ushort size;
public ushort opcode;
public byte securityCount;
public byte securityCRC;[/COLOR]
public fixed byte [COLOR="Red"]data[/COLOR][8096];
}
Code:
short psize = reader.readWord();
this size is not the packet size, its the size of the data.
if you add +6 you add the size of the header, too.so your 4th packet has just no data in it.
|
Thanks for explaining I get it now .
I still the problem with the reading I think it's just a problem with the reader itself so I'll make my own one too see if that works.
|
|
|
12/14/2010, 19:26
|
#10
|
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
|
Quote:
Originally Posted by sjaakie100
Thanks for explaining I get it now .
I still the problem with the reading I think it's just a problem with the reader itself so I'll make my own one too see if that works.
|
Reader for SRO is kinda easy.
Well, it is in C#. You just inherit the BinaryReader class and you override some functions. (like string reading)
EDIT: My RawPacket and PacketReader class in C# (no support for encryption):
Code:
public class RawPacket
{
public WORD size;
public WORD opcode;
public BYTE _securityCount;
public BYTE _securityCRC;
public BYTE[] data;
/// <summary>
/// RawPacket constructor. Ususally used to read packets.
/// </summary>
/// <param name="buffer">The bytes received.</param>
/// <param name="length">The length of the bytes received.</param>
public RawPacket(BYTE[] buffer, int length)
{
size = BitConverter.ToUInt16(buffer, 0);
opcode = BitConverter.ToUInt16(buffer, 2);
_securityCount = buffer[4];
_securityCRC = buffer[5];
data = new BYTE[length + 1];
Array.Copy(buffer, 6, data, 0, length - 5);
}
/// <summary>
/// RawPacket constructor. Usually used to write packets.
/// </summary>
/// <param name="inputOpcode">The opcode of the packet.</param>
public RawPacket(WORD inputOpcode)
{
size = 0;
opcode = inputOpcode;
_securityCount = 0;
_securityCRC = 0;
data = new BYTE[4096];
}
public BYTE[] GetBytes()
{
BYTE[] tmpBytes = new BYTE[size + 6];
BYTE[] tmpSize = BitConverter.GetBytes(size);
tmpBytes[0] = tmpSize[0];
tmpBytes[1] = tmpSize[1];
BYTE[] tmpOpcode = BitConverter.GetBytes(opcode);
tmpBytes[2] = tmpOpcode[0];
tmpBytes[3] = tmpOpcode[1];
tmpBytes[4] = _securityCount;
tmpBytes[5] = _securityCRC;
Array.Copy(data, 0, tmpBytes, 6, size);
return tmpBytes;
}
};
public class PacketReader : BinaryReader
{
public PacketReader(RawPacket input)
: base(new MemoryStream(input.data)) { }
public WORD ReadWord() { return this.ReadUInt16(); }
public DWORD ReadDWord() { return this.ReadUInt32(); }
public QWORD ReadQWord() { return this.ReadUInt64(); }
public override string ReadString() { return new string(this.ReadChars(this.ReadWord())); }
public string ReadString(WORD length) { return new string(this.ReadChars(length)); }
}
|
|
|
12/14/2010, 19:31
|
#11
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
Quote:
Originally Posted by lesderid
Reader for SRO is kinda easy.
Well, it is in C#. You just inherit the BinaryReader class and you override some functions. (like string reading)
|
I saw it in csremu but i'm using c++ so it's a bit more difficult:P btw when i print my packet like data[3],data[2] I get the right opcodes so it is a reading problem and not a prolbem with the data. I'll tell you guys if I got it working correctly but tips ect. are always welcome
|
|
|
12/14/2010, 20:04
|
#12
|
elite*gold: 0
Join Date: Feb 2008
Posts: 3,777
Received Thanks: 1,455
|
I think C# coding much easier than C++
You can understand things more
You can read the last source files that Xsense uploaded
here
If you read and understand you can get much things and learn alot
|
|
|
12/14/2010, 20:13
|
#13
|
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
|
Quote:
Originally Posted by sjaakie100
I saw it in csremu but i'm using c++ so it's a bit more difficult:P btw when i print my packet like data[3],data[2] I get the right opcodes so it is a reading problem and not a prolbem with the data. I'll tell you guys if I got it working correctly but tips ect. are always welcome
|
Why don't you take a look at the boost library?
AFAIK, they have functions for reading etc. that are easy to adapt.
|
|
|
12/14/2010, 23:14
|
#14
|
elite*gold: 0
Join Date: Dec 2010
Posts: 27
Received Thanks: 1
|
@saif1999 I'm using c++ because I don't like c#. And because It's slower with that whole .net framework stuff. but I'll take a look at the source of Xsense's emu.
@lesderid thanks I'll take a look in that library . because I can't figure out why the data isn't correctly readed. The opcode is now correct (I had to change short in unsigned short) but i don't want to use this reader to read the rest of the packet because it's unreliable if a few packets ain't readed the right way.
|
|
|
12/15/2010, 00:30
|
#15
|
elite*gold: 0
Join Date: Sep 2010
Posts: 134
Received Thanks: 41
|
Quote:
Originally Posted by sjaakie100
I saw it in csremu but i'm using c++ so it's a bit more difficult:P btw when i print my packet like data[3],data[2] I get the right opcodes so it is a reading problem and not a prolbem with the data. I'll tell you guys if I got it working correctly but tips ect. are always welcome
|
You don't need a reader for C++.
Having such a system would be like trying to code Python in C++.
Just take a look . And it's by far worth to read the whole thread... it was one the biggest threads I've seen about private server coding scene.
Hope it helps as it's more related to C++ than C#.
|
|
|
Similar Threads
|
Correct way to do a speedhack.
06/27/2010 - CO2 Programming - 7 Replies
Heya,
I was wondering what changed recently? Because in the earlier patches, this could be done the following way;
if (Client.AutoBot != null)
{
data.TimeStamp = client.LastJump + 900;
}
Done from TQServer->Proxy and TQClient->Proxy
|
Correct me if I'm wrong.
02/05/2010 - General Gaming Discussion - 0 Replies
Correct me if I'm wrong, but there aren't any working wonderspeed and zylon trainers now right?
|
MySro Correct IP
05/18/2009 - SRO Private Server - 1 Replies
Guys can someone give me the correct IP for MySro i searched and tryed some but no result...
Thanks in advance.
|
Pa Correct nmn toh~
08/18/2008 - RF Online - 9 Replies
Sir..pa correct nmn sa makakabasa n2..
ung sinasabi po ng iba na sa Search lng mahahanap ung mga hacks na gusto ko...
san ako mag Search d2 sa forums na toh oh sa iba??
pa correct ^^
|
All times are GMT +2. The time now is 23:59.
|
|