Guest User

$kype for Linux: script to change ver. 4.2 to 4.3

a guest
Aug 22nd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. This Python script will switch the $kype version for the (Linux) Debian version
  4. from 4.2 to 4.3 allowing clients which are unable to connect to connect again.
  5.  
  6. Real credit for this solution actually goes to Debian mailing list user Hans.
  7. See: https://lists.debian.org/debian-user/2014/08/msg01190.html
  8. Thanks Hans :-)
  9.  
  10. This is just a script which tries to automate the steps.
  11.  
  12. Instructions:
  13.    - Make sure you have $kype 4.2 for Linux installed
  14.    - Save the script in any directory (e.g. home) with any name e.g. sky.py
  15.    - Run the script with: python sky.py
  16.    - If everything went well you should have a binary file called zkype
  17.    in the same directory where the script was run
  18.    - Launch the file with ./zkype and try to log-in
  19.    - Optional: replace the original $kype binary with the new one
  20.  
  21. The script has been (very limitedly) tested on Debian Jessie amd64.
  22.  
  23. Script by: Darrell Standing
  24.  
  25. WARNING: This script is provided for educational and learning purpouses only.
  26. Any illegal activity is not endorsed. Author takes no responsibility for misuse
  27. The script is provided as is. Use at your own risk!
  28. M$ fk.u.!
  29.  
  30. """
  31. import subprocess
  32. import sys
  33. import os
  34. import stat
  35. from distutils.spawn import find_executable
  36.  
  37. def zkype_ver_detect(bin_path):
  38.     """Detect zkype version and extract the version string"""
  39.     skype_output = subprocess.check_output([bin_path, '--version'])
  40.     ver = skype_output[:skype_output.find("\n")]
  41.     ver = ver.replace("Skype ","")
  42.     return ver
  43.  
  44. # Search for skype executable in default path
  45. orig_zkype_bin_path = find_executable('skype')
  46. if find_executable == None:
  47.     print("Error: Could not find skype executable.")
  48.     print(("Searching in the following paths: %s") % (os.environ['PATH']))
  49.     print('Please make sure skype is installed')
  50.     sys.exit()
  51.  
  52. # Detect verion and extract version string
  53. print("Detecting $kype version...\n")
  54. new_zkype_bin_path = './zkype'
  55. ver_string = zkype_ver_detect(orig_zkype_bin_path)
  56. if ver_string.find("4.2") < 0:
  57.     print(("""$kype version seems different than 4.2
  58.            Reported version is %s") %""") %
  59.             (ver_string)
  60.             )
  61.     sys.exit()
  62. else:
  63.     print(("OK. Found version %s\n") % ver_string)
  64.  
  65. # Open and read the original zkype binary file
  66. print(("Opening original binary file at %s..." % orig_zkype_bin_path))
  67. zkype_file = open(orig_zkype_bin_path, 'rb')
  68. orig_content = zkype_file.read()
  69. zkype_file.close()
  70.  
  71. # Replace version string, changing 4.2 to 4.3
  72. print("Replacing version...")
  73. new_version = ver_string.replace('4.2','4.3')
  74. new_content = orig_content.replace(ver_string, new_version)
  75.  
  76. # Write to new binary file
  77. print(("Creating new binary file: %s" % new_zkype_bin_path))
  78. new_file = open(new_zkype_bin_path, 'wb')
  79. new_file.write(new_content)
  80. new_file.close()
  81.  
  82. # Make the new file executable
  83. print("Making new file executable")
  84. os.chmod(new_zkype_bin_path, stat.S_IXUSR)
  85.  
  86. # Test newly reprted version...
  87. print("Testing version...")
  88. ver_reported = zkype_ver_detect(new_zkype_bin_path)
  89. print(("Reported version is now %s") % ver_reported)
  90. if ver_reported.find('4.3') >= 0:
  91.     print('OK. Looks good!')
  92.     print("Try running the new binary %s and logging in") % new_zkype_bin_path
  93. else:
  94.     print("Ouch.. Something went wrong?")
Advertisement
Add Comment
Please, Sign In to add comment