static void login_open_cb(PnNode *conn, gpointer data) { MsnNexus *nexus = data; MsnSession *session; const char *username, *password; char *req, *head, *tail; guint32 ctint; GIOStatus status = G_IO_STATUS_NORMAL; g_return_if_fail(conn); g_signal_handler_disconnect(conn, nexus->open_handler); nexus->open_handler = 0; session = nexus->session; username = msn_session_get_username(session); password = msn_session_get_password(session); ctint = strtoul((char *) g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200; head = g_strdup_printf("GET %s HTTP/1.1\r\n" "Authorization: Passport1.4 OrgVerb=GET,OrgURL=%s,sign-in=%s", nexus->login_path, (char *) g_hash_table_lookup(nexus->challenge_data, "ru"), purple_url_encode(username)); tail = g_strdup_printf("lc=%s,id=%s,tw=%s,fs=%s,ru=%s,ct=%" G_GUINT32_FORMAT ",kpp=%s,kv=%s,ver=%s,tpf=%s\r\n" "User-Agent: MSMSGS\r\n" "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n", get_key(nexus->challenge_data, "lc"), get_key(nexus->challenge_data, "id"), get_key(nexus->challenge_data, "tw"), get_key(nexus->challenge_data, "fs"), get_key(nexus->challenge_data, "ru"), ctint, get_key(nexus->challenge_data, "kpp"), get_key(nexus->challenge_data, "kv"), get_key(nexus->challenge_data, "ver"), get_key(nexus->challenge_data, "tpf"), nexus->login_host); req = g_strdup_printf("%s,pwd=%s,%s\r\n", head, purple_url_encode(password), tail); g_free(head); g_free(tail); status = pn_node_write(conn, req, strlen(req), NULL, NULL); if (status != G_IO_STATUS_NORMAL) { msn_session_set_error(nexus->session, MSN_ERROR_AUTH, _("nexus stream error")); } g_free(req); }
void login_connect_cb(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond) { MsnNexus *nexus; MsnSession *session; char *username, *password; char *request_str, *head, *tail; char *buffer = NULL; guint32 ctint; nexus = data; g_return_if_fail(nexus != NULL); session = nexus->session; g_return_if_fail(session != NULL); msn_session_set_login_step(session, PECAN_LOGIN_STEP_GET_COOKIE); username = g_strdup(purple_url_encode(msn_session_get_username(session))); password = g_strdup(purple_url_encode(msn_session_get_password(session))); ctint = strtoul((char *)g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200; head = pecan_strdup_printf( "GET %s HTTP/1.1\r\n" "Authorization: Passport1.4 OrgVerb=GET,OrgURL=%s,sign-in=%s", nexus->login_path, (char *)g_hash_table_lookup(nexus->challenge_data, "ru"), username); tail = pecan_strdup_printf( "lc=%s,id=%s,tw=%s,fs=%s,ru=%s,ct=%" G_GUINT32_FORMAT ",kpp=%s,kv=%s,ver=%s,tpf=%s\r\n" "User-Agent: MSMSGS\r\n" "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n", nexus_challenge_data_lookup(nexus->challenge_data, "lc"), nexus_challenge_data_lookup(nexus->challenge_data, "id"), nexus_challenge_data_lookup(nexus->challenge_data, "tw"), nexus_challenge_data_lookup(nexus->challenge_data, "fs"), nexus_challenge_data_lookup(nexus->challenge_data, "ru"), ctint, nexus_challenge_data_lookup(nexus->challenge_data, "kpp"), nexus_challenge_data_lookup(nexus->challenge_data, "kv"), nexus_challenge_data_lookup(nexus->challenge_data, "ver"), nexus_challenge_data_lookup(nexus->challenge_data, "tpf"), nexus->login_host); buffer = pecan_strdup_printf("%s,pwd=XXXXXXXX,%s\r\n", head, tail); request_str = pecan_strdup_printf("%s,pwd=%s,%s\r\n", head, password, tail); pecan_log ("sending: [%s]", buffer); g_free(buffer); g_free(head); g_free(tail); g_free(username); g_free(password); nexus->write_buf = request_str; nexus->written_len = 0; nexus->read_len = 0; nexus->written_cb = nexus_login_written_cb; nexus->input_handler = purple_input_add(gsc->fd, PURPLE_INPUT_WRITE, nexus_write_cb, nexus); nexus_write_cb(nexus, gsc->fd, PURPLE_INPUT_WRITE); return; }