Click to See Complete Forum and Search --> : get the socket of a program?


linkstack
September 12th, 2009, 12:30 AM
Hi,everyone!

I'm using winsock2.Can I get the socket of a program?such as ICQ, if ICQ is running now,can I get the socket of ICQ?

I want to use the socket of ICQ to send packet to ICQ server,because my own packet sent to ICQ server didn't work...

Richard.J
September 12th, 2009, 05:43 AM
no, you can't

linkstack
September 12th, 2009, 08:08 AM
thanks for your reply:)

but why can't my own packet work while the packet sent by ICQ program worked properly(although the DATA part of my own packet is the same as the DATA part of the packet sent by ICQ program)?

PS:the source port of my own packet is different from the source port of the packet sent by ICQ program.

Richard.J
September 12th, 2009, 02:02 PM
I don't know the specifics of the ICQ protocol, but if you are not able to successfully send a message to the server, I assume that your message is not well formattted.
Get yourself the wireshark (http://www.wireshark.org/) and compare the packets you send to the successful ones.

linkstack
September 13th, 2009, 01:36 AM
I noticed that the packet sent by ICQ is encrypted,so I select wyvern(a game whose packet isn't encrypted) for test.

this is the packet sent by wyvern:
0000 00 30 88 12 f0 bb 00 19 66 25 5d eb 88 64 11 00 .0......f%]..d..
0010 0a 40 00 37 00 21 45 00 00 35 f9 e6 40 00 80 06 .@.7.!E..5..@...
0020 40 9b 7b 85 13 ca cf e5 61 0c 12 56 08 ae 34 e6 @.{.....a..V..4.
0030 6f b5 5f 20 fb 5e 50 18 fb 32 41 0e 00 00 00 0b o._ .^P..2A.....
0040 61 72 72 6f 77 5f 72 69 67 68 74 arrow_right

and this is the packet sent by me:
0000 00 30 88 12 f0 bb 00 19 66 25 5d eb 88 64 11 00 .0......f%]..d..
0010 0a 40 00 37 00 21 45 00 00 35 f9 dc 40 00 80 06 .@.7.!E..5..@...
0020 40 a5 7b 85 13 ca cf e5 61 0c 13 24 08 ae e0 ea @.{.....a..$....
0030 b7 7d 9e be 35 73 50 18 ff ff cd f3 00 00 00 0b .}..5sP.........
0040 61 72 72 6f 77 5f 72 69 67 68 74 arrow_right



I noticed that these properties of the packet sent by wyvern is different from the packet sent by me:

Identification(in Internet Protocol):
0xf9e6(sent by wyvern) 0xf9dc(sent by me)

Header Checksum(in Internet Protocol):
0x409b(sent by wyvern) 0x40a5(sent by me)

Souce Port(in Transmission Control Protocol):
4964(sent by wyvern) 4900(sent by me)

Sequence Number(in Transmission Control Protocol):
14(sent by wyvern) 1(sent by me)

Acknowledgement Number(in Transmission Control Protocol):
555(sent by wyvern) 1(sent by me)

Window Size(in Transmission Control Protocol):
64306(sent by wyvern) 65535(sent by me)

Checksum(in Transmission Control Protocol):
0x410e(sent by wyvern) 0xcdf3(sent by me)



should I change all these properties?

Richard.J
September 13th, 2009, 04:10 AM
you don't need to change these properties, most of them are calculated by the TCP stack.
You should concentrate on the content of the message and check where the differences are.
And if ICQ is encrypted, are you sure you are using the correct algorithm to encrypt your message?

linkstack
September 13th, 2009, 08:54 AM
I even don't know how to decrypt them(packet sent by ICQ)...

But I thought the content of message in the two packets(one is sent by me,another is sent by wyvern) is same,maybe I'm wrong?(I really know little about network programming...)

here is the Data field summary of the two packets:

(mine)
Data (13 bytes)
Data: 000B6172726F775F7269676874
Length: 13



(wyvern)
Data (13 bytes)
Data: 000B6172726F775F7269676874
Length: 13



What should I do? thank you for helping me so much!:)

Richard.J
September 13th, 2009, 01:08 PM
if you want to communicate with another application, you need to know about the protocol that is being used. It is not enough just to send a message that looks like one you capture on the net. The server's reaction might depend on the current state it is in. So if you send the packet you mention the server might discard it because it is not allowed at that moment.
So the first step must be to learn the protocol.

linkstack
September 13th, 2009, 09:41 PM
oh,I see. I'll try that now.

thank you SO MUCH!!!:)