[Legacy] yowsup cli

Davide Pastore edited this page Oct 19, 2017 · 2 revisions

yowsup-cli is a command line interface to Yowsup library. It provides you with the options of registration, reading/sending messages, and even engaging in an interactive conversation.



usage: yowsup-cli [-h] [-l | -s <phone> <message> | -i <phone>] [-w] [-a] [-k]
	          [-r (sms|voice) | -R code | -e]
	          [--generatepassword input | --decodestring encoded_array]
	          [--help-config] [--v1] [-c file] [-D] [-d] [-v]

yowsup-cli Command line options

optional arguments:
  -h, --help        show this help message and exit
  --help-config     Display info about configuration format
  --v1              If specified, it will force usage of old API in
	                registration calls. Also password field in config will
	                be ignored and will attempt to generate password from
	                specified identity (IMEI/MAC)
  -c file, --config file
	                Path to config file containing authentication info.
	                For more info about config format use --help-config
  -D, --dbus        Start DBUS interface
  -d, --debug       Enable debug messages
  -v, --version     Print version info and exit

Client options:
  -l, --listen      Listen to messages
  -s <phone> <message>, --send <phone> <message>
	                Send message to phone number and close connection.
	                Phone is full number including country code, without
	                '+' or '00'
  -i <phone>, --interactive <phone>
	                Start an interactive conversation with a contact.
	                Phone is full number including country code, without
	                '+' or '00'
  -w, --wait        If used with -s, then connection will not close until
	                server confirms reception of the message
  -a, --autoack     If used with -l or -i, then a message received ack
	                would be automatically sent for received messages
  -k, --keepalive   When used with -l or -i, Yowsup will automatically
	                respond to server's ping requests to keep connection

Registration options:
  -r (sms|voice), --requestcode (sms|voice)
	                Request a registration code from Whatsapp.
  -R code, --register code
	                Register account on Whatsapp using the registration
	                code you received
  -e, --exists      Check if account credentials are valid. WARNING:
                    Whatsapp now changes your password everytime you use
                    this. Make sure you update your config file if the
                    output informs about a password change

Debug tools:
  --generatepassword input
	                Generate password from given string in same way
	                Whatsapp generates it from a given IMEI or MAC Address
  --decodestring encoded_array
	                Decode byte arrays found in decompiled version of
	                Whatsapp. Tested with S40 version. Input should be
	                comma separated without the enclosing brackets.
	                Example: ./yowsup-cli --decodestring

Your Login Credentials

Whatsapp protocol is basically a modified version of XMPP. It uses JID and password for login. Your JID is the phone number you registered with, which is a combination of your phone number and country code. In older versions of Whatsapp, your password was generated from your phone's IMEI in case of Nokia or Android, or from your phone's Wlan MAC Address in case of iOS. yowsup-cli is able to generate the same exact password used by your phone's Whatsapp client for login, which makes you able to login using yowsup-cli and send and receive messages without affecting your Whatsapp's setup on phone. You should save these info in a text file, in the following format:

cc=20  #replace with your country code
phone=20123456789  #full phone number including country code, without '+' or '00'
id=FF:FF:FF:FF:FF:FF  #IMEI or MAC address for iOS
password=PASSWORD #your account's real password. If you don't know it just leave it blank until you do.

If you can't obtain the IMEI/MAC, or using an unsupported phone, or if you have recently updated your phone's Whatsapp client, then this would not work. You will have to register using yowsup, and then enter the password you get. To tell yowsup-cli about your config file, you just pass the path to that file using the -c switch. The config file is used everytime you login, in order to obtain your credentials, and during registration.


Registration is done through 2 steps similar to how it works on official Whatsapp clients. First you request a registration code from Whatsapp:

yowsup-cli --requestcode sms

The code will then be delivered to your phone number via your preferred method (sms/voice). Once you have obtained the code, you proceed with the 2nd step, which is to send that code using --register argument:

yowsup-cli --register 123

Your phone number is the one stored in the config file specified by -c (see what your config file should look like). If you successfully register, WhatsApp will generate a password for you which will be displayed in the command output. You MUST MANUALLY store this password in the same config file you're registered with.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.