Create a gist now

Instantly share code, notes, and snippets.

@dequis /patch.py
Last active Nov 1, 2017

What would you like to do?
MSN ApplicationId binary patcher for pidgin/bitlbee/etc - OBSOLETE now that pidgin/bitlbee have the correct fix - READ THE COMMENTS!
#!/usr/bin/env python
"""
MSN ApplicationId patcher for pidgin/bitlbee/whatever
(because you're too lazy to rebuild the whole thing.)
Usage examples:
python patch.py /usr/sbin/bitlbee
python patch.py /usr/lib/purple-2/libmsn.so
It will output the modified file to the current directory.
Backup the original file and replace it with the new version.
If you're lucky, it will work.
If not, don't be lazy and rebuild it.
"""
import os
import sys
import mmap
import shutil
WLM_2008_ID = b"CFE80F9D-180F-4399-82AB-413F33A1FA11" # blocked
WLM_2009_ID = b"AAD9B99B-58E6-4F23-B975-D9EC1F9EC24A" # blocked
WLM_2012_ID = b"484AAC02-7F59-41B7-9601-772045DCC569" # working, may be buggy
SKYPE_ID = b"F6D2794D-501F-443A-ADBE-8F1490FF30FD" # working, may be buggy
# "buggy" means you may show up as offline to others - test talking with a contact!
## you can try switching these around!
OLD_ID = WLM_2008_ID
NEW_ID = SKYPE_ID
## examples (remove # from the relevant lines)
## use the WLM 2012 key instead (may work better for you)
#OLD_ID = WLM_2008_ID
#NEW_ID = WLM_2012_ID
## if you want to patch an already patched binary to use 2012 instead of 2009:
#OLD_ID = WLM_2009_ID
#NEW_ID = WLM_2012_ID
def main():
if len(sys.argv) < 2:
print(__doc__.strip())
return
filename = sys.argv[1]
out_filename = os.path.abspath(os.path.basename(filename) + ".out")
shutil.copy(filename, out_filename)
print("Writing to " + out_filename)
fd = os.open(out_filename, os.O_RDWR | getattr(os, 'O_BINARY', 0))
map = mmap.mmap(fd, 0, access=mmap.ACCESS_WRITE)
changes = 0
offset = map.find(OLD_ID)
while offset != -1:
print("Found old ID at offset: %d (0x%x)" % (offset, offset))
map.seek(offset)
map.write(NEW_ID)
changes += 1
offset = map.find(OLD_ID)
if not changes:
print("Not found")
else:
print("%s IDs changed" % changes)
if __name__ == '__main__':
main()

This works like a charm, thank you!

Owner

dequis commented Nov 12, 2014

This patch is now obsolete given that there are better fixes in pidgin/bitlbee.

See also: http://ismsndeadyet.com/

Explanation of what's going on, by messengergeek

Correct fix: Upgrade your clients!

These fixes solve the problem of showing offline to some users, not just the login.

Pidgin/libpurple: 2.10.11 was released on 2014-11-23

BitlBee: use bzr revision 1064 (diff). For users of the public server, testing.bitlbee.org is already updated to this revision.

.


Older information follows

Known issues of this patch

You may appear as offline to other contacts with this patch, and chat may work only one-way. It's tied to accounts somehow - YMMV. It works flawlessly for some accounts, and fails for others. Please test if you can successfully have a conversation with other contacts.

Alternate solution: msn-pecan

For pidgin/adium/libpurple users only, install msn-pecan, which uses an even older version of the protocol (MSNP12) which handles contact lists in a different, much simpler way. This was reported to fix issues for almost all users.

Workaround through outlook.com

Potential workaround for the issues of showing offline to others / one-way chat.

  1. Sign in to http://outlook.com with your msn account details (doesn't matter if it's not an outlook/hotmail email address)
  2. Let the webchat connect
  3. Connect with bitlbee/pidgin/adium/whatever
  4. Close outlook.com
  5. You should be able to use it normally now.

Instructions for pidgin on windows

  • Download to a file called patch.py using the raw link
  • Install python (either 2.7 or 3.4 will do)
  • Find pidgin's libmsn.dll in your system (may also work with other binaries)
  • Copy it to the same directory as patch.py
  • Open a cmd.exe
  • Use the cd command to navigate to the directory with patch.py and libmsn.dll (cd c:\users\blah\blah)
  • Run python patch.py libmsn.dll. You might need to use a full path like C:\python27\python.exe instead of just python.
  • See if the output looks legit enough.
  • Backup the original libmsn.dll, overwrite the one that you found earlier with the new libmsn.dll.out

Gist confirmed to work for Pidgin 2.10.10 on windows 7.

semeion commented Nov 12, 2014

Thanks!

Owner

dequis commented Nov 13, 2014

The WLM 2009 ID got blocked, it seems.

Found a new one, from skype: F6D2794D-501F-443A-ADBE-8F1490FF30FD. Testing atm.

EDIT: added as part of the script, just change the NEW_ID line to NEW_ID = SKYPE_ID

zmx commented Nov 13, 2014

Confirmed to work for Adium 1.5.10 on Mac OS X 10.10

python patch.py /Applications/Adium.app/Contents/Frameworks/libpurple.framework/Versions/Current/libpurple

nbennke commented Nov 13, 2014

Confirmed to work fine for Pidgin 2.10.10 Ubuntu 14.04.

cbenard commented Nov 13, 2014

Worked but then got blocked. Updated to use the Skype ID from dequis and search for the 2009 to replace and patched. Works again, for now.

Pidgin 2.10.10. Windows 7.

MKEbrew commented Nov 13, 2014

Pidgin 2.10.10. Windows 7. Skype ID gives me one-way chat only. People get my messages but see me as offline and cannot respond.

Worked with Pidgin 2.10.10 on Windows 7. Thanks!

Owner

dequis commented Nov 13, 2014

Issues of appearing offline to other contacts have been reported for both the 2012 and skype IDs, which is why they are marked as 'buggy'. First time I hear of one-way chat, though.

It's tied to accounts in some way, so YMMV. It works flawlessly for some accounts, and fails for others.

EDIT: potential workaround a few comments down vvv

Thanks, it works well, at least for now. I hope we will not have to patch every days though...

Chronia commented Nov 13, 2014

I can't get this to work for pidgin 2.10.10 on windows 7. I have followed the instructions, run python and the patch and it still doesn't not connect my msn accounts. I am not sure where to put the skype id, I have tried putting it in the 2009 slot and in the skype id slot I have tried changing new to skype_id instead of the msn on, but not luck. Help please? What do i need to change in the patch.py file and where to get this to work?

Worked for Adium 1.5.10 on OS X 10.9.3

Unfortunately, as some others have said, I don't seem to get messages from other users, but they do see my messages.

Owner

dequis commented Nov 14, 2014

Potential workaround for the issues of showing offline to others / one-way chat.

  1. Sign in to http://outlook.com with your msn account details (doesn't matter if it's not an outlook/hotmail email address)
  2. Let the webchat connect
  3. Connect with bitlbee/pidgin/adium/whatever
  4. Close outlook.com
  5. You should be able to use it normally now.
Owner

dequis commented Nov 14, 2014

New workaround idea, for pidgin/adium/libpurple users only, install msn-pecan, which uses an even older version of the protocol (MSNP12) which handles contact lists in a different, much simpler way.

https://code.google.com/p/msn-pecan/

To install MSN Pecan on Ubuntu I can do:

sudo apt-get install msn-pecan

Does anyone know of a build of the Adium plugin...? The project website doesn't seem to supply a recent build...

MKEbrew commented Nov 14, 2014

Pecan worked for me (for now). Pidgin 2.10.10 on windows 7.

Thanks!

Could really use an Adium version too. Tried to install the patch on my machine via terminal but it still won't let me log in.
If anyone could direct mac users such as myself on how to install MSN pecan it would be greatly appreciated.

Following @zmx instructions and copying the patch's output file to /Applications/Adium.app/Contents/Frameworks/libpurple.framework/Versions/Current and replace libpurple worked for Adium (1.5.10) on OSX.

jorgelf commented Nov 14, 2014

Thanks, mate!! Worked like a charm on Ubuntu with my pidgin 2.10.3.

Owner

dequis commented Nov 17, 2014

Bitlbee users: bzr revision 1064 (diff) includes fixes for the problem of showing offline. For users of the public server, testing.bitlbee.org is already updated to this revision.

These should arrive to pidgin's hg soon, and we'll have to do something about distributing those because a patch won't cut it this time.

dimir commented Nov 24, 2014

Thanks, worked perfectly well with patching libpurple (/usr/lib/purple-2/libmsn.so) that pidgin uses.

Debian Wheezy (7.6), libpurple 2.10.9, pidgin 2.10.9.

My steps were:

stop pidgin
$ mkdir /tmp/pidgin-patch
$ cd /tmp/pidgin-patch
$ wget https://gist.githubusercontent.com/dequis/77b478f35f93f64ac640/raw/164ea64b8db31f1d6d2aecb9b4a20e9b84b29770/patch.py
$ chmod +x patch.py
$ sudo cp /usr/lib/purple-2/libmsn.so /usr/lib/purple-2/libmsn.so.orig
$ sudo cp /usr/lib/purple-2/libmsn.so .
$ ./patch.py libmsn.so

(the output was:

Writing to /home/vl/tmp/pidgin/libmsn.so.out
Found old ID at offset: 260506 (0x3f99a)
Found old ID at offset: 262293 (0x40095)
Found old ID at offset: 263445 (0x40515)
Found old ID at offset: 265053 (0x40b5d)
Found old ID at offset: 266165 (0x40fb5)
Found old ID at offset: 267301 (0x41425)
Found old ID at offset: 268517 (0x418e5)
Found old ID at offset: 269965 (0x41e8d)
Found old ID at offset: 271125 (0x42315)
Found old ID at offset: 272421 (0x42825)
Found old ID at offset: 273709 (0x42d2d)
Found old ID at offset: 274869 (0x431b5)
Found old ID at offset: 276197 (0x436e5)
Found old ID at offset: 277221 (0x43ae5)
14 IDs changed)

$ sudo cp libmsn.so.out /usr/lib/purple-2/libmsn.so
start pidgin

Owner

dequis commented Nov 25, 2014

Pidgin/libpurple users: 2.10.11 was released yesterday, includes fixes for the problem of showing offline. Upgrade to it instead of using this patch!

MKEbrew commented Dec 5, 2014

Getting "connection refused" this morning with Pidgin 2.10.11 (Windows 7).

cbenard commented Dec 5, 2014

Getting "connection refused" this morning too. Coworkers are getting the same thing. 2.10.10 (patched) and 2.10.11.

cbenard commented Dec 5, 2014

MSN-pecan is also giving "connection refused". Maybe they finally shut it down.

bengalih commented Dec 8, 2014

This patch worked for me Win 7 with 2.10.10 for a bit. Now I've got the issue again "connection refused" to MSN. Upgraded to 2.10.11 and still having it.

Does anyone know if pidgin devs are still aware of the issue and if there is a tracking bug for it?

UPDATE: They are aware on their IRC channel.
Directs you to:
http://ismsndeadyet.com/

Seems to work by enabling HTTP method in advanced for account.

cbenard commented Dec 8, 2014

bengalih's recommendation worked for me. HTTP method works again.

I can also confirm that this latest change (select Connect via HTTP under Options) re-enables for my patched version of Adium (https://gist.github.com/dequis/77b478f35f93f64ac640#comment-1337726).

HTTP method - works for me. (australia)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment