Hello,
After tcpclient is connected i must send this packet for login.:
HEXA ASCII
00 33 00 07 00 00 03 B7-24 15 00 00 00 20 66 63 .3.....·$.... fc
66 38 36 34 63 39 61 37-34 39 33 38 39 65 30 39 f864c9a749389e09
63 65 37 39 34 63 62 65-66 39 61 66 30 61 00 05 ce794cbef9af0a..
35 2E 34 2E 34 00 09 00-01 00 00 00 03 50 4E 47 5.4.4........PNG
i sniffed this packet, after i logged manually.
OK. here is my code
int userid = 62333973;
string userid_hex_form = Convert.ToString(userid, 16); \\<---- this will be: 3B72415
string a = "0033000700000";
string b = "00000020";
string c = a + userid_hex_form + b; \\ <---- all this should be: 00 33 00 07 00 00 03 B7-24 15 00 00 00 20
string d = "0005352E342E340009000100000003504E47";
string f = HexAsciiConvert(c);
string g = HexAsciiConvert(d);
try
{
string szData = (f + sSID + g); \\ sSID (sessionid) is the green code, this code changes on every login
byte[] byData = System.Text.Encoding.ASCII.GetBytes(szData);
Int32 port = 8080;
TcpClient client = new TcpClient(sGameServerIp, port);
NetworkStream stream = client.GetStream();
stream.Write(byData, 0, byData.Length);
byData = new Byte[1024];
String responseData = String.Empty;
Int32 bytes = stream.Read(byData, 0, byData.Length);
responseData = System.Text.Encoding.ASCII.GetString(byData, 0, bytes);
}
catch (SocketException e)
{
}
static string HexAsciiConvert(string hex)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hex.Length - 2; i += 2)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hex.Substring(i, 2),
System.Globalization.NumberStyles.HexNumber))));
}
return sb.ToString();
}
but my packet looks like:
00 33 00 07 00 00 03 3F-24 15 00 00 00 20 37 64 .3.....?$.... 7d
65 39 63 37 32 36 62 30-36 34 39 61 63 34 65 37 e9c726b0649ac4e7
65 30 38 32 64 32 37 35-33 62 63 63 33 64 00 05 e082d2753bcc3d..
35 2E 34 2E 34 00 09 00-01 00 00 00 03 50 4E 47 5.4.4........PNG
any ideas?
thx
Loading
Sam HobbsPosted Mar 4, 2012, 6:03 AM
The code I posted seems to have helped you. Did it help you? You seem to have solved the problem of sending the data so now you are working on reading the data. Please accept my reply as the answer if it did help you as it appears.
As I said, please create a new thread for the new question. I think however that it will help you to understand that the solutio of how to access the data depends on the format of the data. It is likely that there is a specified structure; there is a certain number of characters in the data and the data is at a specific location, at least relative to each other. You need to know the format of the data and we do not know that. It is possible that the data is not at a position that is always the same relative to the other data, but it probably is.
andrei hoobaPosted Mar 4, 2012, 5:04 AM
stream.Write(data2, 0, data2.Length);
System.Threading.Thread.Sleep(1000);
//after sending this command(^) i must find those values between galexu and 0|A|CC|2 , but in hexa.
VulpesPosted Mar 3, 2012, 2:24 PM
Given a byte b, you can find its hexadecimal representation as follows:
string hex = b.ToString("X2");
andrei hoobaPosted Mar 3, 2012, 9:03 AM
see bellow a snifed packet, how can i take for example 13 88 value (i need other vaules too.), after that i must convert it as integer (this is not a problem).
ty
andrei hoobaPosted Feb 25, 2012, 6:17 AM
Sam HobbsPosted Feb 23, 2012, 10:56 PM
{{{}{{{}}{}}}}VulpesPosted Feb 23, 2012, 1:45 PM
andrei hoobaPosted Feb 23, 2012, 12:56 PM
VulpesPosted Feb 23, 2012, 12:42 PM
andrei hoobaPosted Feb 23, 2012, 12:16 PM
i got another issue.. i must send this packet: "00 16 00 83 00 00 00 69-00 00 00 68 00 00 00 06 40 59 00 00 00 00 00 00"
if i send it like this:
sSend = "\x00\x16\x00\x83\x00\x00\x00\x69\x00\x00\x00\x68\x00\x00\x00\x06\x40\x59\x00\x00\x00\x00\x00\x00";
data = System.Text.Encoding.Default.GetBytes(sSend);
stream.Write(data, 0, data.Length);
the packet becomes: 00 16 00 3F 00 00 00 69-00 00 00 68 00 00 00 06 40 59 00 00 00 00 00 00
if i encode it as UTF8
it becomes: 00 16 00 C2 83 00 00 00-69 00 00 00 68 00 00 00 06 40 59 00 00 00 00 00-00
also, as ASCII it becomes: 00 16 00 3F 00 00 00 69-00 00 00 68 00 00 00 06 40 59 00 00 00 00 00 00
...
Sam HobbsPosted Feb 22, 2012, 12:55 PM
byte[] byData = System.Text.Encoding.ASCII.GetBytes(szData);
was the problem then I could have found the problem much easier and I would probably have provided the answer. I certainly could have been more helpful.
Note also that if you read Encoding.ASCII Property then it clearly states that it is "for the ASCII (7-bit) character set".
andrei hoobaPosted Feb 22, 2012, 12:04 PM
the packet becomes: 00 33 00 07 00 00 03 C2-B7 24 15 00 00 00 20 .3.....·$....
EDIT:
used : byte[] byData = System.Text.Encoding.Default.GetBytes(szData)
and now it works :)
VulpesPosted Feb 22, 2012, 10:19 AM
Consequently, it gets mapped to character 3F (decimal 63) which is a question mark when converted to ASCII.
Could you use UTF-8 instead?
andrei hoobaPosted Feb 22, 2012, 9:47 AM
well , my application is a console application ..
this line should be :
HEX ASCII
00 33 00 07 00 00 03 B7-24 15 00 00 00 20 .3.....·$....
but my app it sends like this:
00 33 00 07 00 00 03 3F-24 15 00 00 00 20 .3.....?$....
how can i send this packet .. hex (00 33 00 07 00 00 03 B7-24 15 00 00 00 20) or ascii (.3.....·$.... ) to some client?
ty
Sam HobbsPosted Feb 21, 2012, 9:55 PM
Do you know what big-endian and little-endian is? It affects the order in which a processor stores the bytes of numbers that are in a binary format (the format the processor uses) and that consist of more than one byte. That is a typical way for data to be sent /received in an unexpected format. Also ensure that the data is not being sent using Unicode if you are expecting non-Unicode.
Can you tell us what specific line it is that is not doing what you expect? If you can do that then that can save us time.