Skip to content

Instantly share code, notes, and snippets.

@dequis
Last active December 19, 2017 19:01
Show Gist options
  • Save dequis/77b478f35f93f64ac640 to your computer and use it in GitHub Desktop.
Save dequis/77b478f35f93f64ac640 to your computer and use it in GitHub Desktop.
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()
@dimir
Copy link

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

@dequis
Copy link
Author

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
Copy link

MKEbrew commented Dec 5, 2014

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

@cbenard
Copy link

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
Copy link

cbenard commented Dec 5, 2014

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

@bengalih
Copy link

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
Copy link

cbenard commented Dec 8, 2014

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

@bjdevil21
Copy link

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).

@felipe1982
Copy link

HTTP method - works for me. (australia)

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