Пример #1
0
static void
connect_cb(MsnServConn *servconn)
{
	MsnCmdProc *cmdproc;
	MsnSession *session;
	GaimAccount *account;
	char **a, **c, *vers;
	int i;

	g_return_if_fail(servconn != NULL);

	cmdproc = servconn->cmdproc;
	session = servconn->session;
	account = session->account;

	/* Allocate an array for CVR0, NULL, and all the versions */
	a = c = g_new0(char *, session->protocol_ver - 8 + 3);

	for (i = session->protocol_ver; i >= 8; i--)
		*c++ = g_strdup_printf("MSNP%d", i);

	*c++ = g_strdup("CVR0");

	vers = g_strjoinv(" ", a);

	if (session->login_step == MSN_LOGIN_STEP_START)
		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE);
	else
		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2);

	msn_cmdproc_send(cmdproc, "VER", "%s", vers);

	g_strfreev(a);
	g_free(vers);
}
Пример #2
0
static void
usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
{
	MsnSession *session;
	GaimAccount *account;
	GaimConnection *gc;

	session = cmdproc->session;
	account = session->account;
	gc = gaim_account_get_connection(account);

	if (!g_ascii_strcasecmp(cmd->params[1], "OK"))
	{
		/* OK */
		const char *friendly = gaim_url_decode(cmd->params[3]);

		gaim_connection_set_display_name(gc, friendly);

		msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN);

		msn_cmdproc_send(cmdproc, "SYN", "%s", "0");
	}
	else if (!g_ascii_strcasecmp(cmd->params[1], "TWN"))
	{
		/* Passport authentication */
		char **elems, **cur, **tokens;

		session->nexus = msn_nexus_new(session);

		/* Parse the challenge data. */

		elems = g_strsplit(cmd->params[3], ",", 0);

		for (cur = elems; *cur != NULL; cur++)
		{
				tokens = g_strsplit(*cur, "=", 2);
				g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]);
				/* Don't free each of the tokens, only the array. */
				g_free(tokens);
		}

		g_strfreev(elems);

		msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START);

		msn_nexus_connect(session->nexus);
	}
}
Пример #3
0
static void
xfr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
{
    char *host;
    int port;

    if (strcmp(cmd->params[1], "SB") && strcmp(cmd->params[1], "NS"))
    {
        /* Maybe we can have a generic bad command error. */
        pecan_error ("bad XFR command: params=[%s]", cmd->params[1]);
        return;
    }

    msn_parse_socket(cmd->params[2], &host, &port);

    if (!strcmp(cmd->params[1], "SB"))
    {
        pecan_error ("this shouldn't be handled here");
    }
    else if (!strcmp(cmd->params[1], "NS"))
    {
        MsnSession *session;

        session = cmdproc->session;

        msn_session_set_login_step(session, PECAN_LOGIN_STEP_TRANSFER);

        msn_notification_connect(session->notification, host, port);
    }

    g_free(host);
}
Пример #4
0
static void
nexus_connect_cb(gpointer data, PurpleSslConnection *gsc,
				 PurpleInputCondition cond)
{
	MsnNexus *nexus;
	MsnSession *session;

	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_AUTH);

	nexus->write_buf = g_strdup("GET /rdr/pprdr.asp\r\n\r\n");
	nexus->written_len = 0;

	nexus->read_len = 0;

	nexus->written_cb = nexus_connect_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);
}
Пример #5
0
void
msn_got_login_params(MsnSession *session, const char *login_params)
{
	MsnCmdProc *cmdproc;

	cmdproc = session->notification->cmdproc;

	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);

	msn_cmdproc_send(cmdproc, "USR", "TWN S %s", login_params);
}
Пример #6
0
static void
open_cb (PecanNode *conn,
         MsnNotification *notification)
{
    MsnSession *session;
    PecanCmdServer *cmd_conn;

    g_return_if_fail (conn != NULL);

    pecan_log ("begin");

    session = conn->session;
    cmd_conn = CMD_PECAN_NODE (conn);

    if (session->login_step == PECAN_LOGIN_STEP_START)
        msn_session_set_login_step (session, PECAN_LOGIN_STEP_HANDSHAKE);
    else
        msn_session_set_login_step (session, PECAN_LOGIN_STEP_HANDSHAKE2);

    msn_cmdproc_send (cmd_conn->cmdproc, "VER", "MSNP12 CVR0");

    pecan_log ("end");
}
Пример #7
0
/*when connect, do the SOAP Style windows Live ID authentication */
void
msn_nexus_connect(MsnNexus *nexus)
{
	MsnSession *session = nexus->session;
	const char *username;
	const char *password;
	char *password_xml;
	GString *domains;
	char *request;
	int i;

	MsnSoapMessage *soap;

	purple_debug_info("msn", "Starting Windows Live ID authentication\n");
	msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);

	username = purple_account_get_username(session->account);
	password = purple_connection_get_password(session->account->gc);
	if (g_utf8_strlen(password, -1) > 16) {
		/* max byte size for 16 utf8 characters is 64 + 1 for the null */
		gchar truncated[65];
		g_utf8_strncpy(truncated, password, 16);
		password_xml = g_markup_escape_text(truncated, -1);
	} else {
		password_xml = g_markup_escape_text(password, -1);
	}

	purple_debug_info("msn", "Logging on %s, with policy '%s', nonce '%s'\n",
	                  username, nexus->policy, nexus->nonce);

	domains = g_string_new(NULL);
	for (i = 0; i < nexus->token_len; i++) {
		g_string_append_printf(domains, MSN_SSO_RST_TEMPLATE,
		                       i+1,
		                       ticket_domains[i][SSO_VALID_TICKET_DOMAIN],
		                       ticket_domains[i][SSO_VALID_TICKET_POLICY] != NULL ?
		                           ticket_domains[i][SSO_VALID_TICKET_POLICY] :
		                           nexus->policy);
	}

	request = g_strdup_printf(MSN_SSO_TEMPLATE, username, password_xml, domains->str);
	g_free(password_xml);
	g_string_free(domains, TRUE);

	soap = msn_soap_message_new(NULL, xmlnode_from_str(request, -1));
	g_free(request);
	msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL, TRUE,
	                      nexus_got_response_cb, nexus);
}
Пример #8
0
void
msn_got_login_params(MsnSession *session, const char *login_params)
{
    MsnCmdProc *cmdproc;

    cmdproc = session->notification->cmdproc;

    msn_session_set_login_step(session, PECAN_LOGIN_STEP_AUTH_END);

    {
        gchar **tokens;
        tokens = g_strsplit (login_params, "&", 2);
        session->passport_cookie.t = g_strdup (tokens[0] + 2);
        session->passport_cookie.p = g_strdup (tokens[1] + 2);
        g_strfreev (tokens);
    }

    msn_cmdproc_send(cmdproc, "USR", "TWN S %s", login_params);
}
Пример #9
0
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;


}