Mercurial > pidgin
comparison src/protocols/yahoo/yahoo.c @ 9277:185fbd8b5998
[gaim-migrate @ 10080]
I added a util function to turn some binary string into an ASCIIZ string
so I can more easily eyeball it and realize I don't know what it means.
And I added some yahoo code to print out some strings like that.
Actually one of them I do what it means.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 14 Jun 2004 00:54:45 +0000 |
parents | 3e0cd1c6ddc7 |
children | 2401a9ef74a0 |
comparison
equal
deleted
inserted
replaced
9276:9a294bf90cd0 | 9277:185fbd8b5998 |
---|---|
410 if (f) { | 410 if (f) { |
411 f->sms = strtol(pair->value, NULL, 10); | 411 f->sms = strtol(pair->value, NULL, 10); |
412 yahoo_update_status(gc, name, f); | 412 yahoo_update_status(gc, name, f); |
413 } | 413 } |
414 break; | 414 break; |
415 case 197: /* Avatars? */ | |
416 { | |
417 char *decoded, *tmp; | |
418 guint len; | |
419 | |
420 if (pair->value) { | |
421 gaim_base64_decode(pair->value, &decoded, &len); | |
422 if (len) { | |
423 tmp = gaim_str_binary_to_ascii(decoded, len); | |
424 gaim_debug_info("yahoo", "Got key 197, value = %s\n", tmp); | |
425 g_free(tmp); | |
426 } | |
427 g_free(decoded); | |
428 } | |
429 break; | |
430 } | |
415 case 16: /* Custom error message */ | 431 case 16: /* Custom error message */ |
416 { | 432 { |
417 char *tmp = yahoo_string_decode(gc, pair->value, TRUE); | 433 char *tmp = yahoo_string_decode(gc, pair->value, TRUE); |
418 gaim_notify_error(gc, NULL, tmp, NULL); | 434 gaim_notify_error(gc, NULL, tmp, NULL); |
419 g_free(tmp); | 435 g_free(tmp); |
1036 * crypt() was. The only purpose this scheme could serve is to prevent third | 1052 * crypt() was. The only purpose this scheme could serve is to prevent third |
1037 * part clients from connecting to their servers. | 1053 * part clients from connecting to their servers. |
1038 * | 1054 * |
1039 * Sorry, Yahoo. | 1055 * Sorry, Yahoo. |
1040 */ | 1056 */ |
1041 | 1057 |
1042 md5_byte_t result[16]; | 1058 md5_byte_t result[16]; |
1043 md5_state_t ctx; | 1059 md5_state_t ctx; |
1044 | 1060 |
1045 char *crypt_result; | 1061 char *crypt_result; |
1046 char password_hash[25]; | 1062 char password_hash[25]; |
1047 char crypt_hash[25]; | 1063 char crypt_hash[25]; |
1048 char *hash_string_p = g_malloc(50 + strlen(name)); | 1064 char *hash_string_p = g_malloc(50 + strlen(name)); |
1049 char *hash_string_c = g_malloc(50 + strlen(name)); | 1065 char *hash_string_c = g_malloc(50 + strlen(name)); |
1050 | 1066 |
1051 char checksum; | 1067 char checksum; |
1052 | 1068 |
1053 int sv; | 1069 int sv; |
1054 | 1070 |
1055 char result6[25]; | 1071 char result6[25]; |
1056 char result96[25]; | 1072 char result96[25]; |
1057 | 1073 |
1058 sv = seed[15]; | 1074 sv = seed[15]; |
1059 sv = sv % 8; | 1075 sv = sv % 8; |
1060 | 1076 |
1061 md5_init(&ctx); | 1077 md5_init(&ctx); |
1062 md5_append(&ctx, pass, strlen(pass)); | 1078 md5_append(&ctx, pass, strlen(pass)); |
1063 md5_finish(&ctx, result); | 1079 md5_finish(&ctx, result); |
1064 to_y64(password_hash, result, 16); | 1080 to_y64(password_hash, result, 16); |
1065 | 1081 |
1066 md5_init(&ctx); | 1082 md5_init(&ctx); |
1067 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); | 1083 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
1068 md5_append(&ctx, crypt_result, strlen(crypt_result)); | 1084 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
1069 md5_finish(&ctx, result); | 1085 md5_finish(&ctx, result); |
1070 to_y64(crypt_hash, result, 16); | 1086 to_y64(crypt_hash, result, 16); |
1071 | 1087 |
1072 switch (sv) { | 1088 switch (sv) { |
1107 "%c%s%s%s", checksum, password_hash, name, seed); | 1123 "%c%s%s%s", checksum, password_hash, name, seed); |
1108 g_snprintf(hash_string_c, strlen(name) + 50, | 1124 g_snprintf(hash_string_c, strlen(name) + 50, |
1109 "%c%s%s%s", checksum, crypt_hash, name, seed); | 1125 "%c%s%s%s", checksum, crypt_hash, name, seed); |
1110 break; | 1126 break; |
1111 } | 1127 } |
1112 | 1128 |
1113 md5_init(&ctx); | 1129 md5_init(&ctx); |
1114 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); | 1130 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
1115 md5_finish(&ctx, result); | 1131 md5_finish(&ctx, result); |
1116 to_y64(result6, result, 16); | 1132 to_y64(result6, result, 16); |
1117 | 1133 |
1118 md5_init(&ctx); | 1134 md5_init(&ctx); |
1119 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); | 1135 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); |
1120 md5_finish(&ctx, result); | 1136 md5_finish(&ctx, result); |
1121 to_y64(result96, result, 16); | 1137 to_y64(result96, result, 16); |
1122 | 1138 |
1123 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | 1139 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); |
1124 yahoo_packet_hash(pack, 0, name); | 1140 yahoo_packet_hash(pack, 0, name); |
1125 yahoo_packet_hash(pack, 6, result6); | 1141 yahoo_packet_hash(pack, 6, result6); |
1126 yahoo_packet_hash(pack, 96, result96); | 1142 yahoo_packet_hash(pack, 96, result96); |
1127 yahoo_packet_hash(pack, 1, name); | 1143 yahoo_packet_hash(pack, 1, name); |
1128 | 1144 |
1129 yahoo_send_packet(yd, pack); | 1145 yahoo_send_packet(yd, pack); |
1130 | 1146 |
1131 g_free(hash_string_p); | 1147 g_free(hash_string_p); |
1132 g_free(hash_string_c); | 1148 g_free(hash_string_c); |
1133 | 1149 |
1134 yahoo_packet_free(pack); | 1150 yahoo_packet_free(pack); |
1135 | 1151 |
1136 } | 1152 } |
1137 | 1153 |
1138 /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this | 1154 /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this |
1139 * and sending the fix! Thanks guys. */ | 1155 * and sending the fix! Thanks guys. */ |
1140 | 1156 |
1143 struct yahoo_packet *pack = NULL; | 1159 struct yahoo_packet *pack = NULL; |
1144 GaimAccount *account = gaim_connection_get_account(gc); | 1160 GaimAccount *account = gaim_connection_get_account(gc); |
1145 const char *name = gaim_normalize(account, gaim_account_get_username(account)); | 1161 const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
1146 const char *pass = gaim_account_get_password(account); | 1162 const char *pass = gaim_account_get_password(account); |
1147 struct yahoo_data *yd = gc->proto_data; | 1163 struct yahoo_data *yd = gc->proto_data; |
1148 | 1164 |
1149 md5_byte_t result[16]; | 1165 md5_byte_t result[16]; |
1150 md5_state_t ctx; | 1166 md5_state_t ctx; |
1151 | 1167 |
1152 SHA_CTX ctx1; | 1168 SHA_CTX ctx1; |
1153 SHA_CTX ctx2; | 1169 SHA_CTX ctx2; |
1154 | 1170 |
1155 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; | 1171 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; |
1156 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; | 1172 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; |
1157 | 1173 |
1158 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; | 1174 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; |
1159 char *operand_lookup = "+|&%/*^-"; | 1175 char *operand_lookup = "+|&%/*^-"; |
1202 | 1218 |
1203 /* | 1219 /* |
1204 * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 | 1220 * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 |
1205 * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. | 1221 * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. |
1206 */ | 1222 */ |
1207 | 1223 |
1208 magic_ptr = seed; | 1224 magic_ptr = seed; |
1209 | 1225 |
1210 while (*magic_ptr != (int)NULL) { | 1226 while (*magic_ptr != (int)NULL) { |
1211 char *loc; | 1227 char *loc; |
1212 | 1228 |
1307 else { | 1323 else { |
1308 bl = magic[magic_cnt++]; | 1324 bl = magic[magic_cnt++]; |
1309 cl = (cl & 0x0f) << 6; | 1325 cl = (cl & 0x0f) << 6; |
1310 bl = ((bl & 0x3f) + cl) << 6; | 1326 bl = ((bl & 0x3f) + cl) << 6; |
1311 } | 1327 } |
1312 | 1328 |
1313 cl = magic[magic_cnt++]; | 1329 cl = magic[magic_cnt++]; |
1314 bl = (cl & 0x3f) + bl; | 1330 bl = (cl & 0x3f) + bl; |
1315 } else | 1331 } else |
1316 bl = cl; | 1332 bl = cl; |
1317 | 1333 |
1447 | 1463 |
1448 memset(&byte, 0, 6); | 1464 memset(&byte, 0, 6); |
1449 | 1465 |
1450 /* First two bytes of digest stuffed together. | 1466 /* First two bytes of digest stuffed together. |
1451 */ | 1467 */ |
1452 | 1468 |
1453 val = digest2[x]; | 1469 val = digest2[x]; |
1454 val <<= 8; | 1470 val <<= 8; |
1455 val += digest2[x+1]; | 1471 val += digest2[x+1]; |
1456 | 1472 |
1457 lookup = (val >> 0x0b); | 1473 lookup = (val >> 0x0b); |
1590 { | 1606 { |
1591 char *seed = NULL; | 1607 char *seed = NULL; |
1592 char *sn = NULL; | 1608 char *sn = NULL; |
1593 GSList *l = pkt->hash; | 1609 GSList *l = pkt->hash; |
1594 int m = 0; | 1610 int m = 0; |
1595 gchar *buf; | 1611 gchar *buf; |
1596 | 1612 |
1597 | 1613 |
1598 while (l) { | 1614 while (l) { |
1599 struct yahoo_pair *pair = l->data; | 1615 struct yahoo_pair *pair = l->data; |
1600 if (pair->key == 94) | 1616 if (pair->key == 94) |
1601 seed = pair->value; | 1617 seed = pair->value; |
1602 if (pair->key == 1) | 1618 if (pair->key == 1) |
1603 sn = pair->value; | 1619 sn = pair->value; |
1604 if (pair->key == 13) | 1620 if (pair->key == 13) |
1605 m = atoi(pair->value); | 1621 m = atoi(pair->value); |
1606 l = l->next; | 1622 l = l->next; |
1607 } | 1623 } |
1608 | 1624 |
1609 if (seed) { | 1625 if (seed) { |
1610 switch (m) { | 1626 switch (m) { |
1611 case 0: | 1627 case 0: |
1612 yahoo_process_auth_old(gc, seed); | 1628 yahoo_process_auth_old(gc, seed); |
1613 break; | 1629 break; |
1798 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); | 1814 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); |
1799 g_free(buf); | 1815 g_free(buf); |
1800 g_free(decoded_group); | 1816 g_free(decoded_group); |
1801 } | 1817 } |
1802 | 1818 |
1803 #if 0 | |
1804 static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) | 1819 static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) |
1805 { | 1820 { |
1806 GSList *l = pkt->hash; | 1821 GSList *l = pkt->hash; |
1807 char *who = NULL; | 1822 char *who = NULL; |
1808 char *base64 = NULL; | 1823 char *base64 = NULL; |
1809 char *decoded, *escaped; | 1824 char *decoded; |
1810 int len; | 1825 int len; |
1811 | 1826 |
1812 while (l) { | 1827 while (l) { |
1813 struct yahoo_pair *pair = l->data; | 1828 struct yahoo_pair *pair = l->data; |
1814 | 1829 |
1840 } | 1855 } |
1841 | 1856 |
1842 l = l->next; | 1857 l = l->next; |
1843 } | 1858 } |
1844 | 1859 |
1845 if (0 && base64) { | 1860 if (base64) { |
1846 gaim_base64_decode(base64, &decoded, &len); | 1861 gaim_base64_decode(base64, &decoded, &len); |
1847 gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, decoded); | 1862 if (len) { |
1863 char *tmp = gaim_str_binary_to_ascii(decoded, len); | |
1864 gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
1865 g_free(tmp); | |
1866 } | |
1848 g_free(decoded); | 1867 g_free(decoded); |
1849 } | 1868 } |
1850 } | 1869 } |
1851 #endif | |
1852 | 1870 |
1853 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) | 1871 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
1854 { | 1872 { |
1855 switch (pkt->service) { | 1873 switch (pkt->service) { |
1856 case YAHOO_SERVICE_LOGON: | 1874 case YAHOO_SERVICE_LOGON: |
1936 break; | 1954 break; |
1937 case YAHOO_SERVICE_P2PFILEXFER: | 1955 case YAHOO_SERVICE_P2PFILEXFER: |
1938 case YAHOO_SERVICE_FILETRANSFER: | 1956 case YAHOO_SERVICE_FILETRANSFER: |
1939 yahoo_process_filetransfer(gc, pkt); | 1957 yahoo_process_filetransfer(gc, pkt); |
1940 break; | 1958 break; |
1941 #if 0 | |
1942 case YAHOO_SERVICE_PEEPTOPEER: | 1959 case YAHOO_SERVICE_PEEPTOPEER: |
1943 yahoo_process_p2p(gc, pkt); | 1960 yahoo_process_p2p(gc, pkt); |
1944 break; | 1961 break; |
1945 #endif | |
1946 default: | 1962 default: |
1947 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", | 1963 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
1948 "Unhandled service 0x%02x\n", pkt->service); | 1964 "Unhandled service 0x%02x\n", pkt->service); |
1949 break; | 1965 break; |
1950 } | 1966 } |