]>
Commit | Line | Data |
---|---|---|
9de3ca7e | 1 | /* |
2 | * aim_login.c | |
3 | * | |
4 | * This contains all the functions needed to actually login. | |
5 | * | |
6 | */ | |
7 | ||
a25832e6 | 8 | #include <faim/aim.h> |
9de3ca7e | 9 | |
10 | ||
11 | /* | |
12 | * FIXME: Reimplement the TIS stuff. | |
13 | */ | |
14 | #ifdef TIS_TELNET_PROXY | |
15 | #include "tis_telnet_proxy.h" | |
16 | #endif | |
17 | ||
18 | /* | |
24286d93 | 19 | * send_login(int socket, char *sn, char *password) |
9de3ca7e | 20 | * |
21 | * This is the initial login request packet. | |
22 | * | |
23 | * The password is encoded before transmition, as per | |
24 | * encode_password(). See that function for their | |
25 | * stupid method of doing it. | |
26 | * | |
9de3ca7e | 27 | */ |
a25832e6 | 28 | int aim_send_login (struct aim_session_t *sess, |
29 | struct aim_conn_t *conn, | |
30 | char *sn, char *password, struct client_info_s *clientinfo) | |
9de3ca7e | 31 | { |
a25832e6 | 32 | u_char *password_encoded = NULL; /* to store encoded password */ |
9de3ca7e | 33 | int curbyte=0; |
34 | ||
35 | struct command_tx_struct newpacket; | |
36 | ||
37 | if (conn) | |
38 | newpacket.conn = conn; | |
39 | else | |
a25832e6 | 40 | newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); |
9de3ca7e | 41 | |
24286d93 | 42 | newpacket.commandlen = 4 + 4+strlen(sn) + 4+strlen(password) + 6; |
43 | ||
9de3ca7e | 44 | if (clientinfo) |
45 | { | |
46 | if (strlen(clientinfo->clientstring)) | |
24286d93 | 47 | newpacket.commandlen += 4+strlen(clientinfo->clientstring); |
48 | newpacket.commandlen += 6+6+6; | |
9de3ca7e | 49 | if (strlen(clientinfo->country)) |
24286d93 | 50 | newpacket.commandlen += 4+strlen(clientinfo->country); |
9de3ca7e | 51 | if (strlen(clientinfo->lang)) |
24286d93 | 52 | newpacket.commandlen += 4+strlen(clientinfo->lang); |
9de3ca7e | 53 | } |
24286d93 | 54 | newpacket.commandlen += 6; |
9de3ca7e | 55 | |
56 | newpacket.data = (char *) calloc (1, newpacket.commandlen ); | |
57 | newpacket.lock = 1; | |
58 | newpacket.type = 0x01; | |
59 | ||
60 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000); | |
61 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001); | |
62 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001); | |
63 | curbyte += aimutil_put16(newpacket.data+curbyte, strlen(sn)); | |
64 | curbyte += aimutil_putstr(newpacket.data+curbyte, sn, strlen(sn)); | |
65 | ||
66 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002); | |
67 | curbyte += aimutil_put16(newpacket.data+curbyte, strlen(password)); | |
68 | password_encoded = (char *) malloc(strlen(password)); | |
69 | aim_encode_password(password, password_encoded); | |
70 | curbyte += aimutil_putstr(newpacket.data+curbyte, password_encoded, strlen(password)); | |
71 | free(password_encoded); | |
72 | ||
73 | curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0001); | |
24286d93 | 74 | |
9de3ca7e | 75 | if (clientinfo) |
76 | { | |
77 | if (strlen(clientinfo->clientstring)) | |
78 | { | |
79 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x0003); | |
80 | curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->clientstring)); | |
81 | curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring)); | |
82 | } | |
83 | curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0017, 0x0001); | |
84 | curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0018, 0x0001); | |
85 | curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x001a, 0x0013); | |
86 | if (strlen(clientinfo->country)) | |
87 | { | |
88 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x000e); | |
89 | curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->country)); | |
90 | curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->country, strlen(clientinfo->country)); | |
91 | } | |
24286d93 | 92 | if (strlen(clientinfo->lang)) |
9de3ca7e | 93 | { |
94 | curbyte += aimutil_put16(newpacket.data+curbyte, 0x000f); | |
95 | curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->lang)); | |
96 | curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->lang, strlen(clientinfo->lang)); | |
97 | } | |
98 | } | |
99 | ||
100 | curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0009, 0x0015); | |
101 | ||
102 | newpacket.lock = 0; | |
a25832e6 | 103 | aim_tx_enqueue(sess, &newpacket); |
9de3ca7e | 104 | |
105 | return 0; | |
106 | } | |
9de3ca7e | 107 | |
108 | /* | |
109 | * int encode_password( | |
110 | * const char *password, | |
111 | * char *encoded | |
112 | * ); | |
113 | * | |
114 | * This takes a const pointer to a (null terminated) string | |
115 | * containing the unencoded password. It also gets passed | |
116 | * an already allocated buffer to store the encoded password. | |
117 | * This buffer should be the exact length of the password without | |
118 | * the null. The encoded password buffer IS NOT NULL TERMINATED. | |
119 | * | |
120 | * The encoding_table seems to be a fixed set of values. We'll | |
121 | * hope it doesn't change over time! | |
122 | * | |
123 | */ | |
a25832e6 | 124 | int aim_encode_password(const char *password, u_char *encoded) |
9de3ca7e | 125 | { |
126 | u_char encoding_table[] = { | |
127 | 0xf3, 0xb3, 0x6c, 0x99, | |
128 | 0x95, 0x3f, 0xac, 0xb6, | |
129 | 0xc5, 0xfa, 0x6b, 0x63, | |
130 | 0x69, 0x6c, 0xc3, 0x9f | |
131 | }; | |
132 | ||
133 | int i; | |
134 | ||
135 | for (i = 0; i < strlen(password); i++) | |
136 | encoded[i] = (password[i] ^ encoding_table[i]); | |
137 | ||
138 | return 0; | |
139 | } | |
140 | ||
141 | ||
142 | ||
143 |