Changeset 2528cda for protocols


Ignore:
Timestamp:
2010-08-08T15:34:49Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5fecede
Parents:
b890626 (diff), ee6cc94 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging msn-offline branch. A tiny bit of MSNP13, and it works for the first
minute of the session (after that the MSN server finds out the rest of
BitlBee still speaks MSNP8).

Location:
protocols/msn
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/Makefile

    rb890626 r2528cda  
    1313
    1414# [SH] Program variables
    15 objects = msn.o msn_util.o ns.o passport.o sb.o tables.o
     15objects = msn.o msn_util.o ns.o passport.o sb.o soap.o tables.o
    1616
    1717LFLAGS += -r
  • protocols/msn/msn.c

    rb890626 r2528cda  
    103103                        g_free( md->grouplist[--md->groupcount] );
    104104                g_free( md->grouplist );
     105                g_free( md->passport_token );
     106                g_free( md->lock_key );
    105107               
    106108                while( md->grpq )
  • protocols/msn/msn.h

    rb890626 r2528cda  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    4242#define QRY_CODE "Q1P7W2E4J9R8U3S5"
    4343
     44/* This should be MSN Messenger 7.0.0813 */
     45//#define MSNP11_PROD_KEY "CFHUR$52U_{VIX5T"
     46//#define MSNP11_PROD_ID  "PROD0101{0RM?UBW"
     47
     48#define MSNP11_PROD_KEY "O4BG@C7BWLYQX?5G"
     49#define MSNP11_PROD_ID  "PROD01065C%ZFN6F"
     50
    4451#define MSN_SB_NEW         -24062002
    4552
     
    6976       
    7077        int trId;
     78        char *passport_token;
     79        char *lock_key;
    7180       
    7281        GSList *msgq, *grpq;
     
    175184void msn_msgq_purge( struct im_connection *ic, GSList **list );
    176185gboolean msn_set_display_name( struct im_connection *ic, const char *rawname );
     186char *msn_p11_challenge( char *challenge );
    177187
    178188/* tables.c */
  • protocols/msn/msn_util.c

    rb890626 r2528cda  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    2626#include "nogaim.h"
    2727#include "msn.h"
     28#include "md5.h"
    2829#include <ctype.h>
    2930
     
    444445        return msn_write( ic, buf, strlen( buf ) ) != 0;
    445446}
     447
     448unsigned int little_endian( unsigned int dw )
     449{
     450#if defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
     451        return dw;
     452#else
     453        /* We're still not sure if this machine is big endian since the
     454           constants above are not that portable. Don't swap bytes, just
     455           force-compose a 32-bit little endian integer. */
     456        unsigned int ret = 0, i;
     457        char *dst = (char*) (&ret + 1);
     458       
     459        for (i = 0; i < 4; i ++)
     460        {
     461                *(--dst) = dw >> 24;
     462                dw <<= 8;
     463        }
     464       
     465        return ret;
     466#endif
     467}
     468
     469/* Copied and heavily modified from http://tmsnc.sourceforge.net/chl.c */
     470char *msn_p11_challenge( char *challenge )
     471{
     472        char *output, buf[256];
     473        md5_state_t md5c;
     474        unsigned char md5Hash[16], *newHash;
     475        unsigned int *md5Parts, *chlStringParts, newHashParts[5];
     476        long long nHigh = 0, nLow = 0;
     477        int i, n;
     478
     479        /* Create the MD5 hash */
     480        md5_init(&md5c);
     481        md5_append(&md5c, (unsigned char*) challenge, strlen(challenge));
     482        md5_append(&md5c, (unsigned char*) MSNP11_PROD_KEY, strlen(MSNP11_PROD_KEY));
     483        md5_finish(&md5c, md5Hash);
     484
     485        /* Split it into four integers */
     486        md5Parts = (unsigned int *)md5Hash;
     487        for (i = 0; i < 4; i ++)
     488        { 
     489                md5Parts[i] = little_endian(md5Parts[i]);
     490               
     491                /* & each integer with 0x7FFFFFFF */
     492                /* and save one unmodified array for later */
     493                newHashParts[i] = md5Parts[i];
     494                md5Parts[i] &= 0x7FFFFFFF;
     495        }
     496       
     497        /* make a new string and pad with '0' */
     498        n = g_snprintf(buf, sizeof(buf)-5, "%s%s00000000", challenge, MSNP11_PROD_ID);
     499        /* truncate at an 8-byte boundary */
     500        buf[n&=~7] = '\0';
     501       
     502        /* split into integers */
     503        chlStringParts = (unsigned int *)buf;
     504       
     505        /* this is magic */
     506        for (i = 0; i < (n / 4) - 1; i += 2)
     507        {
     508                long long temp;
     509
     510                chlStringParts[i]   = little_endian(chlStringParts[i]);
     511                chlStringParts[i+1] = little_endian(chlStringParts[i+1]);
     512
     513                temp  = (md5Parts[0] * (((0x0E79A9C1 * (long long)chlStringParts[i]) % 0x7FFFFFFF)+nHigh) + md5Parts[1])%0x7FFFFFFF;
     514                nHigh = (md5Parts[2] * (((long long)chlStringParts[i+1]+temp) % 0x7FFFFFFF) + md5Parts[3]) % 0x7FFFFFFF;
     515                nLow  = nLow + nHigh + temp;
     516        }
     517        nHigh = (nHigh+md5Parts[1]) % 0x7FFFFFFF;
     518        nLow = (nLow+md5Parts[3]) % 0x7FFFFFFF;
     519       
     520        newHashParts[0] ^= nHigh;
     521        newHashParts[1] ^= nLow;
     522        newHashParts[2] ^= nHigh;
     523        newHashParts[3] ^= nLow;
     524       
     525        /* swap more bytes if big endian */
     526        for (i = 0; i < 4; i ++)
     527                newHashParts[i] = little_endian(newHashParts[i]);
     528       
     529        /* make a string of the parts */
     530        newHash = (unsigned char *)newHashParts;
     531       
     532        /* convert to hexadecimal */
     533        output = g_new(char, 33);
     534        for (i = 0; i < 16; i ++)
     535                sprintf(output + i * 2, "%02x", newHash[i]);
     536       
     537        return output;
     538}
  • protocols/msn/ns.c

    rb890626 r2528cda  
    783783                char buf[1024];
    784784               
     785                md->passport_token = g_strdup( mad->token );
     786               
    785787                g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, mad->token );
    786788                msn_write( ic, buf, strlen( buf ) );
  • protocols/msn/sb.c

    rb890626 r2528cda  
    2929#include "passport.h"
    3030#include "md5.h"
    31 #include "invitation.h"
     31#include "soap.h"
    3232
    3333static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond );
     
    625625                const struct msn_status_code *err = msn_status_by_number( num );
    626626               
    627                 imcb_error( ic, "Error reported by switchboard server: %s", err->text );
     627                /* If the person is offline, send an offline message instead,
     628                   and don't report an error. */
     629                if( num == 217 )
     630                        msn_soap_oim_send_queue( ic, &sb->msgq );
     631                else
     632                        imcb_error( ic, "Error reported by switchboard server: %s", err->text );
    628633               
    629634                if( err->flags & STATUS_SB_FATAL )
Note: See TracChangeset for help on using the changeset viewer.