/pidgin/main: dc0aea0981c0: HTTP: get rid of old oscar client ve...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Thu Jul 18 08:45:37 EDT 2013


Changeset: dc0aea0981c00fc313325b37b1f4946467be84e1
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-07-18 14:45 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/dc0aea0981c0

Description:

HTTP: get rid of old oscar client verification code with its terrible http implementation

diffstat:

 libpurple/protocols/oscar/family_oservice.c |  147 -------------------------
 libpurple/protocols/oscar/oscar.c           |  160 ----------------------------
 libpurple/protocols/oscar/oscar.h           |    5 -
 3 files changed, 0 insertions(+), 312 deletions(-)

diffs (truncated from 370 to 300 lines):

diff --git a/libpurple/protocols/oscar/family_oservice.c b/libpurple/protocols/oscar/family_oservice.c
--- a/libpurple/protocols/oscar/family_oservice.c
+++ b/libpurple/protocols/oscar/family_oservice.c
@@ -889,151 +889,6 @@ aim_srv_set_dc_info(OscarData *od)
 	byte_stream_destroy(&bs);
 }
 
-/**
- * Starting this past week (26 Mar 2001, say), AOL has started sending
- * this nice little extra SNAC.  AFAIK, it has never been used until now.
- *
- * The request contains eight bytes.  The first four are an offset, the
- * second four are a length.
- *
- * The offset is an offset into aim.exe when it is mapped during execution
- * on Win32.  So far, AOL has only been requesting bytes in static regions
- * of memory.  (I won't put it past them to start requesting data in
- * less static regions -- regions that are initialized at run time, but still
- * before the client receives this request.)
- *
- * When the client receives the request, it adds it to the current ds
- * (0x00400000) and dereferences it, copying the data into a buffer which
- * it then runs directly through the MD5 hasher.  The 16 byte output of
- * the hash is then sent back to the server.
- *
- * If the client does not send any data back, or the data does not match
- * the data that the specific client should have, the client will get the
- * following message from "AOL Instant Messenger":
- *    "You have been disconnected from the AOL Instant Message Service (SM)
- *     for accessing the AOL network using unauthorized software.  You can
- *     download a FREE, fully featured, and authorized client, here
- *     http://www.aol.com/aim/download2.html"
- * The connection is then closed, receiving disconnect code 1, URL
- * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.
- *
- * Note, however, that numerous inconsistencies can cause the above error,
- * not just sending back a bad hash.  Do not immediatly suspect this code
- * if you get disconnected.  AOL and the open/free software community have
- * played this game for a couple years now, generating the above message
- * on numerous ocassions.
- *
- * Anyway, neener.  We win again.
- *
- */
-/* Subtype 0x001f - Client verification */
-static int
-memrequest(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
-{
-	int ret = 0;
-	aim_rxcallback_t userfunc;
-	guint32 offset, len;
-	GSList *tlvlist;
-	char *modname;
-
-	offset = byte_stream_get32(bs);
-	len = byte_stream_get32(bs);
-	tlvlist = aim_tlvlist_read(bs);
-
-	modname = aim_tlv_getstr(tlvlist, 0x0001, 1);
-
-	purple_debug_info("oscar", "Got memory request for data at 0x%08x (%u bytes) of requested %s\n", offset, len, modname ? modname : "aim.exe");
-
-	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-		ret = userfunc(od, conn, frame, offset, len, modname);
-
-	g_free(modname);
-	aim_tlvlist_free(tlvlist);
-
-	return ret;
-}
-
-/* Subtype 0x0020 - Client verification reply */
-int
-aim_sendmemblock(OscarData *od, FlapConnection *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag)
-{
-	ByteStream bs;
-	aim_snacid_t snacid;
-
-	if (!od || !conn)
-		return -EINVAL;
-
-	byte_stream_new(&bs, 2+16);
-
-	byte_stream_put16(&bs, 0x0010); /* md5 is always 16 bytes */
-
-	if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */
-
-		byte_stream_putraw(&bs, buf, 0x10);
-
-	} else if (buf && (len > 0)) { /* use input buffer */
-		PurpleCipherContext *context;
-		guchar digest[16];
-
-		context = purple_cipher_context_new_by_name("md5", NULL);
-		purple_cipher_context_append(context, buf, len);
-		purple_cipher_context_digest(context, digest, sizeof(digest));
-		purple_cipher_context_destroy(context);
-
-		byte_stream_putraw(&bs, digest, 0x10);
-
-	} else if (len == 0) { /* no length, just hash NULL (buf is optional) */
-		PurpleCipherContext *context;
-		guchar digest[16];
-		guint8 nil = '\0';
-
-		/*
-		 * I'm not sure if we really need the empty append with the
-		 * new MD5 functions, so I'll leave it in, just in case.
-		 */
-		context = purple_cipher_context_new_by_name("md5", NULL);
-		purple_cipher_context_append(context, &nil, 0);
-		purple_cipher_context_digest(context, digest, sizeof(digest));
-		purple_cipher_context_destroy(context);
-
-		byte_stream_putraw(&bs, digest, 0x10);
-
-	} else {
-
-		/*
-		 * This data is correct for AIM 3.5.1670.
-		 *
-		 * Using these blocks is as close to "legal" as you can get
-		 * without using an AIM binary.
-		 *
-		 */
-		if ((offset == 0x03ffffff) && (len == 0x03ffffff)) {
-
-#if 1 /* with "AnrbnrAqhfzcd" */
-			byte_stream_put32(&bs, 0x44a95d26);
-			byte_stream_put32(&bs, 0xd2490423);
-			byte_stream_put32(&bs, 0x93b8821f);
-			byte_stream_put32(&bs, 0x51c54b01);
-#else /* no filename */
-			byte_stream_put32(&bs, 0x1df8cbae);
-			byte_stream_put32(&bs, 0x5523b839);
-			byte_stream_put32(&bs, 0xa0e10db3);
-			byte_stream_put32(&bs, 0xa46d3b39);
-#endif
-
-		} else
-			purple_debug_warning("oscar", "sendmemblock: unknown hash request\n");
-
-	}
-
-	snacid = aim_cachesnac(od, SNAC_FAMILY_OSERVICE, 0x0020, 0x0000, NULL, 0);
-	flap_connection_send_snac(od, conn, SNAC_FAMILY_OSERVICE, 0x0020, snacid, &bs);
-
-	byte_stream_destroy(&bs);
-
-	return 0;
-}
-
 /*
  * Subtype 0x0021 - Receive our extended status
  *
@@ -1113,8 +968,6 @@ snachandler(OscarData *od, FlapConnectio
 		return motd(od, conn, mod, frame, snac, bs);
 	else if (snac->subtype == 0x0018)
 		return hostversions(od, conn, mod, frame, snac, bs);
-	else if (snac->subtype == 0x001f)
-		return memrequest(od, conn, mod, frame, snac, bs);
 	else if (snac->subtype == 0x0021)
 		return aim_parse_extstatus(od, conn, mod, frame, snac, bs);
 
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -53,8 +53,6 @@
 #include "oscar.h"
 #include "peer.h"
 
-#define AIMHASHDATA "https://pidgin.im/aim_data.php3"
-
 static guint64 purple_caps =
 	OSCAR_CAPABILITY_CHAT
 		| OSCAR_CAPABILITY_BUDDYICON
@@ -113,7 +111,6 @@ static int purple_parse_mtn        (Osca
 static int purple_parse_locaterights(OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_buddyrights(OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_genericerr (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int purple_memrequest       (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_selfinfo         (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_popup            (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_parseerr     (OscarData *, FlapConnection *, FlapFrame *, ...);
@@ -694,7 +691,6 @@ oscar_login(PurpleAccount *account)
 	oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_RIGHTSINFO, purple_parse_locaterights, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, purple_parse_genericerr, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, purple_selfinfo, 0);
-	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, purple_memrequest, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_REDIRECT, purple_handle_redirect, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_MOTD, purple_parse_motd, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_POPUP, 0x0002, purple_popup, 0);
@@ -847,162 +843,6 @@ oscar_close(PurpleConnection *gc)
 	purple_debug_info("oscar", "Signed off.\n");
 }
 
-/* XXX - Should use purple_util_fetch_url for the below stuff */
-struct pieceofcrap {
-	PurpleConnection *gc;
-	unsigned long offset;
-	unsigned long len;
-	char *modname;
-	int fd;
-	FlapConnection *conn;
-	unsigned int inpa;
-};
-
-static void damn_you(gpointer data, gint source, PurpleInputCondition c)
-{
-	struct pieceofcrap *pos = data;
-	OscarData *od = purple_connection_get_protocol_data(pos->gc);
-	char in = '\0';
-	int x = 0;
-	unsigned char m[17];
-	GString *msg;
-
-	while (read(pos->fd, &in, 1) == 1) {
-		if (in == '\n')
-			x++;
-		else if (in != '\r')
-			x = 0;
-		if (x == 2)
-			break;
-		in = '\0';
-	}
-	if (in != '\n') {
-		char buf[256];
-		g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly.  "
-				"If so, check %s for updates."),
-				oscar_get_ui_info_string("website", PURPLE_WEBSITE));
-		purple_notify_warning(pos->gc, NULL,
-							_("Unable to get a valid AIM login hash."),
-							buf);
-		purple_input_remove(pos->inpa);
-		close(pos->fd);
-		g_free(pos);
-		return;
-	}
-	if (read(pos->fd, m, 16) != 16)
-	{
-		purple_debug_warning("oscar", "Could not read full AIM login hash "
-				"from " AIMHASHDATA "--that's bad.\n");
-	}
-	m[16] = '\0';
-
-	msg = g_string_new("Sending hash: ");
-	for (x = 0; x < 16; x++)
-		g_string_append_printf(msg, "%02hx ", m[x] & 0xFF);
-	g_string_append(msg, "\n");
-	purple_debug_misc("oscar", "%s", msg->str);
-	g_string_free(msg, TRUE);
-
-	purple_input_remove(pos->inpa);
-	close(pos->fd);
-	aim_sendmemblock(od, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
-	g_free(pos);
-}
-
-static void
-straight_to_hell(gpointer data, gint source, const gchar *error_message)
-{
-	struct pieceofcrap *pos = data;
-	gchar *buf;
-	gssize result;
-
-	pos->fd = source;
-
-	if (source < 0) {
-		buf = g_strdup_printf(_("You may be disconnected shortly.  "
-				"If so, check %s for updates."),
-				oscar_get_ui_info_string("website", PURPLE_WEBSITE));
-		purple_notify_warning(pos->gc, NULL,
-							_("Unable to get a valid AIM login hash."),
-							buf);
-		g_free(buf);
-		g_free(pos->modname);
-		g_free(pos);
-		return;
-	}
-
-	buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
-			pos->offset, pos->len, pos->modname ? pos->modname : "");
-	result = send(pos->fd, buf, strlen(buf), 0);
-	if (result != strlen(buf)) {
-		if (result < 0)
-			purple_debug_error("oscar", "Error writing %" G_GSIZE_FORMAT
-					" bytes to fetch AIM hash data: %s\n",
-					strlen(buf), g_strerror(errno));
-		else
-			purple_debug_error("oscar", "Tried to write %"
-					G_GSIZE_FORMAT " bytes to fetch AIM hash data but "
-					"instead wrote %" G_GSSIZE_FORMAT " bytes\n",
-					strlen(buf), result);
-	}
-	g_free(buf);
-	g_free(pos->modname);
-	pos->inpa = purple_input_add(pos->fd, PURPLE_INPUT_READ, damn_you, pos);
-	return;
-}
-



More information about the Commits mailing list