Yowsup: How can i send message by using phone number witch already being registered?

Created on 6 Aug 2019  路  16Comments  路  Source: tgalal/yowsup

Now we cant register by yowsup,so i registered a account by ios whatsapp application,
Then i logged on and send some message by whatsapp app.
The problem is how can i use this phone number to send message by yowsup?
there is not password thing.just a phone number and Verification Code to logging.
Guys,What should i do?

Most helpful comment

~/.config/yowsup/[phone]/config.json reads:

{
  "__version__": 1,
  "cc": "[countrycode]",
  "client_static_keypair": "...",
  "edge_routing_info": "...",
  "expid": "...",
  "fdid": "...",
  "id": "...",
  "mcc": "[mcc]",
  "mnc": "[mnc]",
  "phone": "[phone]",
  "pushname": "[yourname]",
  "server_static_public": "...",
  "sim_mcc": "000",
  "sim_mnc": "000"
}

Alternative, keyval format:
https://github.com/tgalal/yowsup/blob/f14a03fb780410ab949bc76855b2039e65866b7d/yowsup-cli#L23-L40

Where is that saved?
https://github.com/tgalal/yowsup/blob/f14a03fb780410ab949bc76855b2039e65866b7d/yowsup/common/tools.py#L85-L108

I'd love people reading code and/or learning at least Python before asking.

All 16 comments

how can i get client static keypair?
please give me some help

I don't think you can. It's probably encrypted in your app data folder somewhere or in the db...

With iOS I'm not aware of a way, but if you have a rooted Android device available, you can pull the values and axolotl.db from there.

I can't remember the exact location though, you'll have to find that yourself.

With iOS I'm not aware of a way, but if you have a rooted Android device available, you can pull the values and axolotl.db from there.

I can't remember the exact location though, you'll have to find that yourself.

Are you sure the client key is in there? I looked through the axolotl.db from my phone but it doesn't appear like there is anything that resembles the client static key...
(btw it's in data/com.whatsapp/databases together with the msgstore.db and other stuff)

I'm gonna guess that you opened that file as the SQLite3 (Android variant) it is, and not as a text or binary file.

I'm gonna guess that you opened that file as the SQLite3 (Android variant) it is, and not as a text or binary file.

Of course. But the only table in the db that looked somehow interesting to me were the prekeys that yowsup also downloads right after registration.

I just checked, apparently I found client_static_keypair and server_static_public in data/com.whatsapp/shared_prefs/keystore.xml

I just checked, apparently I found client_static_keypair and server_static_public in data/com.whatsapp/shared_prefs/keystore.xml

nice I somehow missed that.
I'll try to copy the preshared keys from the app axolot.db into yowsup's db and put in the correct app version,hash etc. See if I can login with yowsup that way...

@Neolysion If you manage to do it correctly can you make a short how-to for dummies?
Basically I already opened the keystore.xml previously and saw the values, however it is a bit unclear as to how to populate the yowsup config (where?) so that I can actually start and try including it in the spectrum2 config...

~/.config/yowsup/[phone]/config.json reads:

{
  "__version__": 1,
  "cc": "[countrycode]",
  "client_static_keypair": "...",
  "edge_routing_info": "...",
  "expid": "...",
  "fdid": "...",
  "id": "...",
  "mcc": "[mcc]",
  "mnc": "[mnc]",
  "phone": "[phone]",
  "pushname": "[yourname]",
  "server_static_public": "...",
  "sim_mcc": "000",
  "sim_mnc": "000"
}

Alternative, keyval format:
https://github.com/tgalal/yowsup/blob/f14a03fb780410ab949bc76855b2039e65866b7d/yowsup-cli#L23-L40

Where is that saved?
https://github.com/tgalal/yowsup/blob/f14a03fb780410ab949bc76855b2039e65866b7d/yowsup/common/tools.py#L85-L108

I'd love people reading code and/or learning at least Python before asking.

Hi guys, sorry for reopening the topic, but I've got the keyspair from this file data/com.whatsapp/shared_prefs/keystore.xml and I tried to use convert it to BASE64 but the code complained about the length. Is there something I'm doing wrong here?

@bryanjhv I got the same error as @samy-mohsen: ValueError: Wrong length: 86 with the command to send a message yowsup-cli demos -s CCYYYYYYYYY hello --config-phone CCXXXXXXXXX where CC is the country code, X are my phone number digits (without the unnecessary first digit "0") and Y are the phone number digits of someone else.
I tried with the JSON format in ~/.config/yowsup/CCXXXXXXXXX/config.json and the keyval format in ~/.config/yowsup/CCXXXXXXXXX/config.yo.
I converted the client_static_keypair found in the file shared_prefs/keystore.xml of the official Android WhatsApp client with the base64 Linux command like this:
echo -n "XXX" | base64
Which displayed the base64 on 2 lines. So I removed the new line character to make it fit on one line in the yowsup config file.
In the config file, I only added the fields cc, phone, pushname, client_static_keypair like in the keyval example, is that enough? (I don't have the other fields and don't know how to get them, someone asked the question here also: https://github.com/tgalal/yowsup/issues/2829#issuecomment-508004084)
By the way I think there is a bug in the keyval example because there is a quote at the end of the client_static_keypair but I did not find one before (I guess quotes are not needed in the keyval format so I did not use them).

Please at least share the stack trace. A simple GitHub search for "wrong length" returned no code matches so it might be from some of Yowsup's dependencies, would be useful to see. Apart from that, other error that I can think of is that the "echo" command must go with single quotes instead of double to avoid shell expansion, escaping and those things. Regarding the keyval example, I don't remember it correctly but I think quotes are needed (at the start and the end of the string) because it contains an "=" sign which could be misinterpreted by the parser (note: I might be wrong).

@bryanjhv here is the stack trace:

Traceback (most recent call last):
  File "/usr/local/bin/yowsup-cli", line 679, in <module>
    if not parser.process():
  File "/usr/local/bin/yowsup-cli", line 546, in process
    super(DemosArgParser, self).process()
  File "/usr/local/bin/yowsup-cli", line 206, in process
    self._config = self._config_manager.load(config_phone)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/manager.py", line 52, in load
    return self.load_path(fpath)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/manager.py", line 85, in load_path
    return self.load_data(datadict)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/manager.py", line 93, in load_data
    return ConfigSerialize(Config).deserialize(datadict)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/base/serialize.py", line 26, in deserialize
    data = transform.reverse(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/transforms/props.py", line 34, in reverse
    key, val = target(key, val) if type(target) == types.FunctionType else (key, target)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/config/v1/serialize.py", line 33, in <lambda>
    "client_static_keypair": lambda key, val: (key, KeyPair.from_bytes(base64.b64decode(val))),
  File "/home/user/.local/lib/python2.7/site-packages/consonance/structs/keypair.py", line 54, in from_bytes
    keypair = X25519KeyPair.from_bytes(data)
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/dh/x25519/keypair.py", line 19, in from_bytes
    raise ValueError("Wrong length: %d" % len(data))
ValueError: Wrong length: 86

If I use single quotes instead of double quotes with echo, the base64 result is the same.
The error is also displayed if I use quotes in the keyval config file.

Here are the links relevant to the stack trace you provided.
https://github.com/tgalal/yowsup/blob/v3.2.3/yowsup/config/v1/serialize.py#L33
https://github.com/tgalal/consonance/blob/0.1.2/consonance/structs/keypair.py#L54
https://github.com/tgalal/dissononce/blob/0.34.3/dissononce/dh/x25519/keypair.py#L18-L19

After looking at keystore.xml file from WhatsApp, looks like it's already in base64 format but missing the required padding, which means adding = until the string length is 88 (as per https://stackoverflow.com/a/32140193 and given that keypair needs to have a length of 64).

Here's a script which could help (just adds the required "=" padding):

# save as pad.py and run:
# python pad.py '[keypair]'

from sys import argv, exit
from base64 import b64decode

if len(argv) != 2:
    print('ERROR: Missing keypair.')
    exit(1)

value = argv[1]
if len(value) > 88:
    print('ERROR: Invalid keypair.')
    exit(1)

print(value + (88 - len(value)) * '=')

NOTE: This does not guarantee that it will work or even be a valid one. I'm just helping with the validation. WhatsApp is banning most accounts so be careful, I'm not held responsible for you getting banned or someting, neither I am affiliated with someone here.

@bryanjhv thanks, since I don't use Android / iOS on my smartphone, I registered my phone number with the official WhatsApp Android app on my laptop using Anbox (it works using Android x86 in VirtualBox also). I read that they ban people who register with yowsup but anyway I don't really use WhatsApp since they don't provide a standalone web version that works without Android / iOS app.

The keypair was indeed already in base64 format, I just had to add 2 equals.
Now I get this error when trying to send a message with yowsup, do you have an idea what's wrong?

yowsup-cli  v3.2.0
yowsup      v3.2.3

Copyright (c) 2012-2019 Tarek Galal
http://www.openwhatsapp.org

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate


I 2020-04-18 14:49:13,910 yowsup.layers.network.layer - Connecting to e11.whatsapp.net:443
I 2020-04-18 14:49:14,057 yowsup.axolotl.manager - Loaded 812 unsent prekeys
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/noise/workers/handshake.py", line 36, in run
    self._protocol.start(self._stream, self._client_config, self._s, self._rs)
  File "/home/user/.local/lib/python2.7/site-packages/consonance/protocol.py", line 82, in start
    result = handshake.perform(client_config, stream, s, rs)
  File "/home/user/.local/lib/python2.7/site-packages/consonance/handshake.py", line 84, in perform
    cipherstatepair = self._start_handshake_xx(stream, client_payload, dissononce_s)
  File "/home/user/.local/lib/python2.7/site-packages/consonance/handshake.py", line 107, in _start_handshake_xx
    s=s
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/extras/processing/handshakestate_forwarder.py", line 13, in initialize
    return self._handshakestate.initialize(handshake_pattern, initiator, prologue, s, e, rs, re, psks)
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/extras/processing/handshakestate_guarded.py", line 89, in initialize
    return self._handshakestate.initialize(handshake_pattern, initiator, prologue, s, e, rs, re, psks)
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/processing/impl/handshakestate.py", line 64, in initialize
    self._symmetricstate.mix_hash(prologue)
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/processing/impl/symmetricstate.py", line 74, in mix_hash
    self._h = self._hashfn.hash(self._h + data)
  File "/home/user/.local/lib/python2.7/site-packages/dissononce/hash/sha256.py", line 14, in hash
    digest.update(data)
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/hashes.py", line 92, in update
    raise TypeError("data must be bytes.")
TypeError: data must be bytes.

Update: @tgalal could it mean that yowsup does not work anymore because WhatsApp changed its API? I often see updates for the Android app that requires the user to download the new version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mannemvamsi picture mannemvamsi  路  4Comments

bzero picture bzero  路  3Comments

EliasinnKamachoo picture EliasinnKamachoo  路  3Comments

gabrieldesousah picture gabrieldesousah  路  4Comments

Realitaetsverlust picture Realitaetsverlust  路  4Comments