PDA

View Full Version : Y! Protocol - Packets



silverhand
سه شنبه 04 تیر 1387, 21:38 عصر
سلام

شايد براتون جالب باشه كه بدونيد، وقتی كه با دوستتون بوسيله ی ياهو چت می كنيد چه اتفاق هایی روی ميده تا اين عمل انجام بشه يا packet های ياهو مسنجر چطوری بين Client و Server رد و بدل میشن و محتوای اونا چيه !؟
اين پست رو با همين هدف دادم كه كسانی كه علاقه دارن درمورد packetهای ياهو مسنجر بيشتر بدونن، از اين پست استفاده كنن.

چيزهای اوليه رو خودتون می دونيد ولی شايد كسی هم باشه كه ندونه! پس ميگم...
پروتكل Yahoo! Messenger يك Application Layer هست كه در اكثر زمان بروی TCP فعال هستش، مگر اينكه خود كاربر و يا دقيق تر بگم، چتر تنظبم كنه كه بروی UDP فعاليت كنه.
البته بروی HTTP هم فعال هست و ارسال و دريافت داره، چطوری !؟ <~ شايد اين اگهی های زير Messenger يا جاهای ديگه شما رو اذيت كرده باشه !!
--- Y!_MSNGR_ads_remover.bat ---
کد:
@ECHO OFF
TITLE Remove ads from Yahoo Messenger 8
> %TEMP%.\noYMads.reg ECHO REGEDIT4
>>%TEMP%.\noYMads.reg ECHO.
>>%TEMP%.\noYMads.reg ECHO [HKEY_CURRENT_USER\Software\Yahoo\Pager\YUrl]
>>%TEMP%.\noYMads.reg ECHO "Messenger Ad"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Webcam Upload Ad"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Webcam Viewer Ad"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Webcam Viewer Ad Big"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Webcam Viewer Ad Medium"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Change Room Banner"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Conf Adurl"="NULL"
>>%TEMP%.\noYMads.reg ECHO "Chat Adurl"="NULL"
REGEDIT /S %TEMP%.\noYMads.reg
DEL %TEMP%.\noYMads.reg
ATTRIB -R "%PROGRAMFILES%\Yahoo!\Messenger\Cache\urls.xml"
ECHO "NULL" >"%PROGRAMFILES%\Yahoo!\Messenger\Cache\urls.xml"
ATTRIB +R "%PROGRAMFILES%\Yahoo!\Messenger\Cache\urls.xml"

--- EOF ---

حالا درمورد packetهای Yahoo! Messenger، كه همون بسته های اطلاعاتی هستند كه به Server ارسال می شه و server هم از اونور، (البته بستگی به نوع درخواست داره) به يك Client ديگه ميفرسته...
شكل مجازي از اين packet بصورت زير هست :
http://mfoxihst.persiangig.com/image/Y%21_Protocol/YMSG-packet.gif



از بالا سمت چپ :‌

YMSG: يك مقدار 4byte هست كه دارای يك رشته ی ثابت هست و در همه نوع packetها تغيير نمی‌كنه. اون رشته YMSG هست. كه برای معرفی packet به سرور استفاده میشه (منم! از مسنجر، مسيج دارم...).

Version: همون وژن Messenger هست، كه دارای مقدار 4byte هست. مثلا : 0x09 0x00 0x00 0x00 . (حتما بايد فضای 4byteی نوشته بشه، با null-byte ).

pkt_len: مخفف Packet Length هست به معنی طول بسته، همينطور كه از اسمش پيداست مقدار طول رشته ی packet رو در بر داره. مقدار فضای 2byte هم بهش اختصاص دهد شده.


سطر بعدی، از چپ :

Service : (بدلبل كمبود جا، شما Serv می بينيد (در عكس)) اينجا opcode قرار می گيره كه به client/server ميگه، چه سرويسی درخواست میشه. مثلا YAHOO_SERVICE_LOGOFF. فقط يادتون باشه كه به هركدوم از سرويس های Yahoo! Messenger يك مقدار مشخص داده شده مثلا برای YAHOO_SERVICE_LOGON مقدار 0x01 تعيين شده.

Status: اونی كه میزاري : pm bedi ignore mishi, busssyyyy badjoor… ،همونه... . وضيعت سرويس درخواست شده رو هم نشون می ده...كه برای درخواست سرويس مقدارش 0 هست.
در اكثر packetها مثل فرستادن پيام و ... مقدار قسمت status، 0 هست. چون قبلا با تغيير status برای clientهای buddylist فرستاده شده، اين امر برای Custom Status صدق ميكنه.

Session_id: از اين قسمت زمانی‌هست كه از HTTP id proxy استفاده بشه، البته مقدار فضاش بايد پر بشه كه خود مسنجر از null-byte استفاده می كنه كه بروی connection اثری نداره... وقتی اولين packet به server ارسال می‌شه مقدارش 0 هست و در جواب، server مقداری برای‌ شما (بهمراه چيز های ديگر كه بستگی به درخواستتون داره) می فرسته
كه در packet بعدی از اون بايد استفاده بشه. ممكن هست چندين بار id، HTTP PROXY شما عوض بشه، كه برای مسايل امنيتی Yahoo! هست...

DATA : يك رشته كه مقدار طولش (فضاش) برابر مقداری هست كه تو pkt_len تعيين شده و شامل: پيام، سرويس درخواستی، تعيين Custom Status و ... هست.
درون DATA كاراكترها بصورت numeric بايد باشند ، مثلا:
کد:
1 = 0x31 , 2 = 0x32 => 21 = 0x3231

و اين رو هم بدونيد كه 0x32 0x31 بصورت 0x3231 خلاصه می شوند كه نشان از آن است كه اين دو باهم يك رقم، كلمه و ... رو می سازند :
کد:
2121 => 0x32313231

salam , khoobi ? => 0x73616c616d 0x2c 0x6b686f6f6269 0x3f

packetهایی كه برای فرستادن يك پيام (PM) به server ارسال میشه بصورت زير است :

- اطلاعاتی كه نشون می ده طرف مقابل در حال type كردن است :
http://mfoxihst.persiangig.com/image/Y%21_Protocol/typing1_pkt.gif


- پيامی كه بايد ارسال شود :
http://mfoxihst.persiangig.com/image/Y%21_Protocol/msg_pkt.GIF


- حالا بايد نشان دهيم كه type كردن قطع شده است :
http://mfoxihst.persiangig.com/image/Y%21_Protocol/typing0_pkt.GIF


*بايد بگم كه در اين ميان يك سری packet از سرور به client می رسه كه ازتون اطلاعاتی مثل : id خودتون، id مخاطب و ...رو سوال می كنه يا حتی ميگه كه شما برای مخاطبتون ignore هستيد يا نه و از اين قبيل.كه خود Yahoo! Messenger بصورت خودكار جواب اونها رو میده.



چگونگی رد و بدل شدن اين packetها هم سخت نيست :

http://mfoxihst.persiangig.com/image/Y%21_Protocol/pkt_con.gif


در تمامی سرويس های Y! Messenger بغير ازYAHOO_SERVICE_P2PFILEXFER كه با فلشهای قرمز نشون داده شده، همه ی packetها از فرستنده به سرور و از سرور به گيرنده ارسال ميشه.

P2PFILEXFER * يك سرويس برای فرستادن فايل بدون واسطه ی سرور (يعنی ازClient به Client) است.

45تا از سرويس های شناخته شده بعلاوه ی opcode آنها :
کد:
YAHOO_SERVICE_LOGON = 0x01
YAHOO_SERVICE_LOGOFF
YAHOO_SERVICE_ISAWAY
YAHOO_SERVICE_ISBACK
YAHOO_SERVICE_IDLE = 0x05
YAHOO_SERVICE_MESSAGE = 0x06
YAHOO_SERVICE_IDACT
YAHOO_SERVICE_IDDEACT
YAHOO_SERVICE_MAILSTAT
YAHOO_SERVICE_USERSTAT = 0x0a
YAHOO_SERVICE_NEWMAIL
YAHOO_SERVICE_CHATINVITE
YAHOO_SERVICE_CALENDAR
YAHOO_SERVICE_NEWPERSONALMAIL
YAHOO_SERVICE_NEWCONTACT = 0x0f
YAHOO_SERVICE_ADDIDENT = 0x10
YAHOO_SERVICE_ADDIGNORE
YAHOO_SERVICE_PING
YAHOO_SERVICE_GROUPRENAME
YAHOO_SERVICE_SYSMESSAGE = 0x14
YAHOO_SERVICE_PASSTHROUGH2 = 0x16
YAHOO_SERVICE_CONFINVITE = 0x18
YAHOO_SERVICE_CONFLOGON
YAHOO_SERVICE_CONFDECLINE = 0x1a
YAHOO_SERVICE_CONFLOGOFF
YAHOO_SERVICE_CONFADDINVITE
YAHOO_SERVICE_CONFMSG
YAHOO_SERVICE_CHATLOGON
YAHOO_SERVICE_CHATLOGOFF = 0x1f
YAHOO_SERVICE_CHATMSG = 0x20
YAHOO_SERVICE_GAMELOGON = 0x28
YAHOO_SERVICE_GAMELOGOFF
YAHOO_SERVICE_GAMEMSG = 0x2a
YAHOO_SERVICE_FILETRANSFER = 0x46
YAHOO_SERVICE_VOICECHAT = 0x4a
YAHOO_SERVICE_NOTIFY = 0x4b
YAHOO_SERVICE_P2PFILEXFER = 0x4d
YAHOO_SERVICE_PEERTOPEER = 0x4f
YAHOO_SERVICE_AUTHRESP = 0x54
YAHOO_SERVICE_LIST = 0x55
YAHOO_SERVICE_AUTH = 0x57
YAHOO_SERVICE_ADDBUDDY = 0x83
YAHOO_SERVICE_REMBUDDY = 0x84
YAHOO_SERVICE_IGNORECONTACT = 0x85
YAHOO_SERVICE_REJECTCONTACT = 0x86

اينم statusها با opcodeهاشون(البته اونایی كه شناخته شده) :
کد:
YAHOO_STATUS_AVAILABLE = 0
YAHOO_STATUS_BRB
YAHOO_STATUS_BUSY
YAHOO_STATUS_NOTATHOME
YAHOO_STATUS_NOTATDESK
YAHOO_STATUS_NOTINOFFICE = 5
YAHOO_STATUS_ONPHONE
YAHOO_STATUS_ONVACATION
YAHOO_STATUS_OUTTOLUNCH
YAHOO_STATUS_STEPPEDOUT = 9
YAHOO_STATUS_INVISIBLE = 12
YAHOO_STATUS_CUSTOM = 99
YAHOO_STATUS_IDLE = 999
YAHOO_STATUS_OFFLINE = 0x5a55aa56
YAHOO_STATUS_TYPING = 0x16


موفق باشيد

Bahram0110
سه شنبه 04 تیر 1387, 22:11 عصر
سلام
بحث خيلي جالبي بود
ممنون مي شم ادامه بدين

mpmsoft
چهارشنبه 05 تیر 1387, 14:53 عصر
دوست عزیز این اطلاعات رو شما از روی سندی بدست آورده اید ؟

یعنی تمامی اطلاعات اول وارد سرور شده و بعد به کلاینت ها میره !

من فکر نمی کنم به این شکل باشه

mohsen57
دوشنبه 10 تیر 1387, 14:40 عصر
پروتكل Yahoo! Messenger يك Application Layer هست كه در اكثر زمان بروی TCP فعال هستش، مگر اينكه خود كاربر و يا دقيق تر بگم، چتر تنظبم كنه كه بروی UDP فعاليت كنه.

مگه از UDP هم میشه استفاده کرد؟!
من یک برنامه کوچک یاهو مسنجر نوشتم و از TCP استفاده کردم ولی با UDP که نمیشه به سرور یاهو کانکت و لاگین شد. اگه میشه توضیح بدین.

silverhand
شنبه 15 تیر 1387, 22:42 عصر
پروتكل Yahoo! Messenger يك Application Layer هست كه در اكثر زمان بروی TCP فعال هستش، مگر اينكه خود كاربر و يا دقيق تر بگم، چتر تنظبم كنه كه بروی UDP فعاليت كنه.

mohsen57
دوشنبه 17 تیر 1387, 14:33 عصر
پروتكل Yahoo! Messenger يك Application Layer هست كه در اكثر زمان بروی TCP فعال هستش، مگر اينكه خود كاربر و يا دقيق تر بگم، چتر تنظبم كنه كه بروی UDP فعاليت كنه.
توضیح بیشتر نمیدی؟:متفکر:

D32.00110
دوشنبه 17 تیر 1387, 17:02 عصر
چه نوع بسته هایی از سرویس YAHOO_SERVICE_P2PFILEXFER استفاده میکنه ؟؟؟

در مورد سرویس YAHOO_SERVICE_P2PFILEXFER میشه بیشتر توضیح بدید ...

persianspam
چهارشنبه 05 اسفند 1388, 10:52 صبح
با سلام.

خیلی مشتاقم که یک مثال هم در این بازه بزنید.(C#.net)

1 - از اساتید کسی کتابخانه پرتکل 16 برای یاهو رو داره ؟
2 - برای ارسال پی ام از چه Packet باید استفاده کرد ؟

aria1o
دوشنبه 08 آذر 1389, 16:06 عصر
با سلام

شاید این کامل تر باشه




http://libyahoo2.sourceforge.net/




Yahoo Messenger Protocol v 9


----------------------------



The Yahoo Messenger Protocol is an application layer protocol running most



of the time over TCP, but in some cases over HTTP as well. Throughout



this document, we will speak about the YMSG packets, after stripping out



any other protocol data, but will mention this other data if it is of


relevance.

This document is incomplete. For anything not mentioned here, refer to the
source of libyahoo2.






















1. The YMSG packet structure



The YMSG packet structure is as follows:



(each byte is represented by 5 spaces in the following diagram,



including the | at the end)


<------- 4B -------><------- 4B -------><---2B--->

+-------------------+-------------------+---------+
| Y M S G | version | pkt_len |
+---------+---------+---------+---------+---------+
| service | status | session_id |
+---------+-------------------+-------------------+
| |
: D A T A :
| 0 - 65535* |
+-------------------------------------------------+






















* 65535 is the theoretical limit, since the length field is two bytes



long. Practically though, the data section does not exceed about 1000



bytes.



All numeric fields are stored in network byte order. i.e. Most


significant byte first.

YMSG - The first four bytes of all packets are always YMSG - the
protocol name.
version - The next four bytes are for the protocol version number.
For version 9, these are 0x09 0x00 0x00 0x00
NOTE: The last three bytes of this may just be padding bytes.
pkt_len - A two byte value, in network byte order, stating how many bytes
are in the _data_ section of the packet. In practice, this
value does not exceed about 1000.
service - This is an opcode that tells the client/server what kind of
service is requested/being responded to. There are 45 known
services. See the services section of this document for a
full listing.
status - In case of a response from the server, indicates the status
of the request (success/failure/etc.). For a request, it is 0
in most cases, except for packets that set the user's status
(set status, typing notify, etc.)
session - The session id is used primarily when connecting through a HTTP
id proxy. It is set in all cases, but has no effect in a direct
connection. When the client sends the first packet, it is 0,
the server responds with a session id that is used by the client
and the server in all further packets. The server may change
the session id, in which case the client must use the new
session id henceforth.
DATA - The data section is pkt_len bytes long and consists of a series
of key/value pairs. All keys are numeric strings. The packet
contains their numeric values in the ASCII character set. e.g.
1 == 0x31, 21 == 0x32 0x31
The maximum number of digits in a key is unknown, although keys
of up to three digits have been seen.
Every key and value is terminated by a two byte sequence of
0xc0 0x80. Some keys may have empty values.
The actual keys sent, and their meanings depend on the service
in use.
e.g. The packet data to send an instant message looks like this:
0x30 0xc080 yahoo_id 0xc080 0x31 0xc080 active_id 0xc080 0x35
0xc080 recipient_id 0xc080 0x3134 0xc080 message_text 0xc080
The 0xc080 byte sequence is a separator. The values 0x30, 0x31,
0x35 and 0x3134 are the keys. Convert them to their ASCII
equivalents and you get 0, 1, 5, 14 (0x3134 == 0x31 0x34)






















2. Services



There are 45 known services at the moment, although more may exist. All



known services are listed below along with the hex values that they



correspond to. Any service without a hex value is one more than the


previous value. i.e. YAHOO_SERVICE_LOGOFF=0x02 and

YAHOO_SERVICE_ISBACK=0x04.
YAHOO_SERVICE_LOGON = 0x01
YAHOO_SERVICE_LOGOFF
YAHOO_SERVICE_ISAWAY
YAHOO_SERVICE_ISBACK
YAHOO_SERVICE_IDLE = 0x05
YAHOO_SERVICE_MESSAGE
YAHOO_SERVICE_IDACT
YAHOO_SERVICE_IDDEACT
YAHOO_SERVICE_MAILSTAT
YAHOO_SERVICE_USERSTAT = 0x0a
YAHOO_SERVICE_NEWMAIL
YAHOO_SERVICE_CHATINVITE
YAHOO_SERVICE_CALENDAR
YAHOO_SERVICE_NEWPERSONALMAIL
YAHOO_SERVICE_NEWCONTACT = 0x0f
YAHOO_SERVICE_ADDIDENT = 0x10
YAHOO_SERVICE_ADDIGNORE
YAHOO_SERVICE_PING
YAHOO_SERVICE_GROUPRENAME
YAHOO_SERVICE_SYSMESSAGE = 0x14
YAHOO_SERVICE_PASSTHROUGH2 = 0x16
YAHOO_SERVICE_CONFINVITE = 0x18
YAHOO_SERVICE_CONFLOGON
YAHOO_SERVICE_CONFDECLINE = 0x1a
YAHOO_SERVICE_CONFLOGOFF
YAHOO_SERVICE_CONFADDINVITE
YAHOO_SERVICE_CONFMSG
YAHOO_SERVICE_CHATLOGON
YAHOO_SERVICE_CHATLOGOFF = 0x1f
YAHOO_SERVICE_CHATMSG = 0x20
YAHOO_SERVICE_GAMELOGON = 0x28
YAHOO_SERVICE_GAMELOGOFF
YAHOO_SERVICE_GAMEMSG = 0x2a
YAHOO_SERVICE_FILETRANSFER = 0x46
YAHOO_SERVICE_VOICECHAT = 0x4a
YAHOO_SERVICE_NOTIFY = 0x4b
YAHOO_SERVICE_P2PFILEXFER = 0x4d
YAHOO_SERVICE_PEERTOPEER = 0x4f
YAHOO_SERVICE_AUTHRESP = 0x54
YAHOO_SERVICE_LIST = 0x55
YAHOO_SERVICE_AUTH = 0x57
YAHOO_SERVICE_ADDBUDDY = 0x83
YAHOO_SERVICE_REMBUDDY = 0x84
YAHOO_SERVICE_IGNORECONTACT = 0x85
YAHOO_SERVICE_REJECTCONTACT = 0x86
Most of the service codes should be self explanatory. Those that aren't
are listed here:
IDACT/IDDEACT - activate/deactivate an identity
NOTIFY - typing/game notification
FILETRASNFER - transfer a file using the yahoo filetransfer server as an
intermediate
P2PFILEXFER - transfer a file between two peers, yahoo server not used
PEERTOPEER - check if peer to peer connections are possible
AUTH - Send initial login packet (username), response contains
challenge string
AUTHRESP - Send response to challenge string, or, if received from
server, contains reason for login failure
LOGON/LOGOFF - a buddy logged in/out






















3. Status codes



The status code is a four byte value. Most status codes are two bytes



long. The status codes (in decimal except for offline and typing) are:



YAHOO_STATUS_AVAILABLE = 0


YAHOO_STATUS_BRB

YAHOO_STATUS_BUSY
YAHOO_STATUS_NOTATHOME
YAHOO_STATUS_NOTATDESK
YAHOO_STATUS_NOTINOFFICE = 5
YAHOO_STATUS_ONPHONE
YAHOO_STATUS_ONVACATION
YAHOO_STATUS_OUTTOLUNCH
YAHOO_STATUS_STEPPEDOUT = 9
YAHOO_STATUS_INVISIBLE = 12
YAHOO_STATUS_CUSTOM = 99
YAHOO_STATUS_IDLE = 999
YAHOO_STATUS_OFFLINE = 0x5a55aa56
YAHOO_STATUS_TYPING = 0x16
You may choose either AVAILABLE or INVISIBLE as your initial login status.
TYPING is used only when sending a TYPING notification packet.






















4. Session states



A Yahoo session has two states, Authentication and Messaging.



4.1. Authentication



The session starts in the authentication state. The client sends the username


to the server. The server responds with a challenge string. The client

responds to this challenge with two response strings. If authentication is
successful, the connection goes into the messaging state, else, an error
response is sent back.
4.2. Messaging state
After successful authentication, the session goes into the messaging state.
The server sends the buddy list, ignore list, identity list and a list of
cookies to the client. These might all be sent in a single packet. It then
sends the list of online buddies along with their status codes. All this is
sent without the client requesting anything.
At this time, any offline messages are also delivered to the client.
In the messaging state, a client may send/receive messages, join conferences,
send/receive files, change state, etc.
Messaging state is terminated when the user goes offline by sending a LOGOFF
packet.






















5. Requests



5.1. Authentication



The first packet sent from the client is the authentication request



packet. This consists of the user's yahoo id, or any identity


corresponding to that yahoo id. The AUTH packet has one key/value pair.

service: YAHOO_SERVICE_AUTH
status: YAHOO_STATUS_AVAILABLE
1: yahoo_id
The server responds with a Challenge string. The client then hashes the
username and password with this challenge string, and sends it back as an
AUTH_RESP packet.
service: YAHOO_SERVICE_AUTHRESP
status: initial login status
0: yahoo_id
6: response_string_1
96: response_string_2
1: active_id






















5.2. Sending a message



service: YAHOO_SERVICE_MESSAGE



status: 0



0: yahoo_id


1: active_id

5: recipient_id
14: message to send
5.3. Send typing start/stop notification
service: YAHOO_SERVICE_NOTIFY
status: YAHOO_STATUS_TYPING
4: active_id
5: recipient_id
13: 1 or 0 depending on whether this is a typing start or stop
packet
14: <space>
49: TYPING /* The literal string */
5.4. Set status
service: YAHOO_SERVICE_ISBACK or YAHOO_SERVICE_ISAWAY
status: the status to set to
10: status_code
if custom_status:
19: custom away message
47: 0 or 1 depending on whether it is away or not






















5.5. Logoff



service: YAHOO_SERVICE_LOGOFF



status: YAHOO_STATUS_AVAILABLE



no key value pairs


5.6. Keep alive - sent every 20 minutes

service: YAHOO_SERVICE_PING
status: YAHOO_STATUS_AVAILABLE
no key value pairs
5.7. Add buddy
service: YAHOO_SERVICE_ADDBUDDY
status: YAHOO_STATUS_AVAILABLE
1: yahoo_id
7: buddy_to_add
65: group to add to
5.8. Remove buddy
service: YAHOO_SERVICE_REMBUDDY
status: YAHOO_STATUS_AVAILABLE
1: yahoo_id
7: buddy_to_remove
65: group to remove from






















5.9. Reject buddy add



service: YAHOO_SERVICE_REJECTCONTACT



status: YAHOO_STATUS_AVAILABLE



1: yahoo_id


7: buddy_to_reject

14: reject message






















-----------------------------------------------------------------------



What? Is that all?



Use the source Luke!



-----------------------------------------------------------------------















[/LTR_INLINE]