File "/home/steck/whatsappMy/yowsup/yowsup/layers/protocol_media/layer.py", line 41, in recvMessageStanza
if mediaNode.getAttributeValue("type") == "image":
AttributeError: 'NoneType' object has no attribute 'getAttributeValue'
DATA
Decrypt body:
yowsup/layers/axolotl/layer.py:
def handleWhisperMessage(self, node):
encMessageProtocolEntity = EncryptedMessageProtocolEntity.fromProtocolTreeNode(node)
```
whisperMessage = WhisperMessage(serialized=encMessageProtocolEntity.getEncData())
sessionCipher = self.getSessionCipher(encMessageProtocolEntity.getFrom(False))
plaintext = sessionCipher.decryptMsg(whisperMessage)
if encMessageProtocolEntity.getVersion() == 2:
plaintext = self.unpadV2Plaintext(plaintext)
//PRINT DECRYPT BODY
print plaintext
//
bodyNode = ProtocolTreeNode("body", data = plaintext)
node.addChild(bodyNode)
self.toUpper(node)
```
Link to my file
https://mmi488.whatsapp.net/d/0QVa5QLVNRiH0HZ_gU-W5FbzX-4/AhbVJi2WS1Yia7EklnoFua1fwMezYiqzH4BQsv53_63Z.enc ┴�K\←c��� *�/R���Zc�T㡪Z│ܒM���O·�┘┌��±b�c�H�─�π─U��┌\└ǎ�K91b��←?:◆�;±�⎺��cM&RF���_�M��1���┤4?���d��K'E��̏�
@jlguardi on your comments in #1387 you mentioned a more proper integration of this code into the Yowsup layers - can you clarify? also here is a cleaner version of the code with some of the node attributes corrected:
I'm using transwhat with yowsup. I can send messages, get also ackn.
messages but no hooks back in conversations. People can read my messages
but can't reply to me. messages wont be received.
Traceback (most recent call last):
File "/usr/local/bin/yowsup-cli", line 4, in
èèimportèè('pkgèresources').runèscript('yowsup2==2.4.48',
'yowsup-cli')
File
"/usr/local/lib/python2.7/dist-packages/pkgèresources/èèinitèè.py",
line 726, in runèscript
self.require(requires)é0ê.runèscript(scriptèname, ns)
File
"/usr/local/lib/python2.7/dist-packages/pkgèresources/èèinitèè.py",
line 1484, in runèscript
exec(code, namespace, namespace)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/EGG-INFO/scripts/yowsup-cli",
line 323, in
if not parser.process():
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/EGG-INFO/scripts/yowsup-cli",
line 227, in process
self.startCmdline()
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/EGG-INFO/scripts/yowsup-cli",
line 255, in startCmdline
stack.start()
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/demos/cli/stack.py",
line 25, in start
self.stack.loop(timeout = 0.5, discrete = 0.5)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/stacks/yowstack.py",
line 187, in loop
asyncore.loop(_args, *_kwargs)
File "/usr/lib/python2.7/asyncore.py", line 216, in loop
pollèfun(timeout, map)
File "/usr/lib/python2.7/asyncore.py", line 156, in poll
read(obj)
File "/usr/lib/python2.7/asyncore.py", line 87, in read
obj.handleèerror()
File "/usr/lib/python2.7/asyncore.py", line 83, in read
obj.handleèreadèevent()
File "/usr/lib/python2.7/asyncore.py", line 449, in handleèreadèevent
self.handleèread()
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/network/layer.py",
line 86, in handleèread
self.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/network/layer.py",
line 94, in receive
self.toUpper(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/èèinitèè.py",
line 59, in toUpper
self.èèupper.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/stanzaregulator/layer.py",
line 28, in receive
self.processReceived()
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/stanzaregulator/layer.py",
line 48, in processReceived
self.toUpper(oneMessageData)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/èèinitèè.py",
line 59, in toUpper
self.èèupper.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/auth/layerècrypt.py",
line 63, in receive
self.toUpper(payload)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/èèinitèè.py",
line 59, in toUpper
self.èèupper.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/coder/layer.py",
line 35, in receive
self.toUpper(node)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/èèinitèè.py",
line 59, in toUpper
self.èèupper.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/logger/layer.py",
line 14, in receive
self.toUpper(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/èèinitèè.py",
line 59, in toUpper
self.èèupper.receive(data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py",
line 118, in receive
self.onMessage(protocolTreeNode)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py",
line 140, in onMessage
self.handleEncMessage(protocolTreeNode)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py",
line 225, in handleEncMessage
self.handleWhisperMessage(node)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py",
line 271, in handleWhisperMessage
encMessageProtocolEntity =
EncryptedMessageProtocolEntity.fromProtocolTreeNode(node)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/protocolentities/messageèencrypted.py",
line 53, in fromProtocolTreeNode
encNode.data.encode('latin-1') if sys.versionèinfo >= (3,0) else
encNode.data)
File
"/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/protocolentities/messageèencrypted.py",
line 24, in setEncProps
assert encType in "pkmsg", "msg"
AssertionError: msg
@jlguardi i've been having an issue w the branch around axolotl's layer, and the handlePreKeyWhisperMessage function.
can you do me a favor and run the echo client and tell me if you get errors?
when the layer sends the media message to handlePreKeyWhisperMessage function, with the code exactly how it is in the encrypted-media branch, and i run the echo client, i get infinite output, looks like this:
ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag.
ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag.
ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag.
ERROR:yowsup.layers.axolotl.layer:Truncated message.
ERROR:yowsup.layers.axolotl.layer:Truncated message.
ERROR:yowsup.layers.axolotl.layer:Truncated message.
ERROR:yowsup.layers.axolotl.layer:Tag had invalid wire type.
ERROR:yowsup.layers.axolotl.layer:Truncated message.
ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag.
when i essentially replicate the actions of handlePreKeyWhisperMessage into handleWhisperMessage, things seem to work fine.
my workaround is this:
if node.getChild("enc")["v"] == "2" and node["from"] not in self.v2Jids:
self.v2Jids.append(node["from"])
if node.getChild("enc")["type"] == "pkmsg":
self.handlePreKeyWhisperMessage(node)
elif node.getChild("enc")["type"] == "msg" and node.getChild("enc")["mediatype"] == "image":
self.handleWhisperMessage(node) #what should this be!?
else:
self.handleWhisperMessage(node)
..
def handleWhisperMessage(self, node):
encMessageProtocolEntity = EncryptedMessageProtocolEntity.fromProtocolTreeNode(node)
whisperMessage = WhisperMessage(serialized=encMessageProtocolEntity.getEncData())
sessionCipher = self.getSessionCipher(encMessageProtocolEntity.getFrom(False))
plaintext = sessionCipher.decryptMsg(whisperMessage)
if encMessageProtocolEntity.getVersion() == 2:
plaintext = self.unpadV2Plaintext(plaintext)
if node.getAttributeValue("type") == 'text':
bodyNode = ProtocolTreeNode("body", data = plaintext)
if node.getAttributeValue("type") == 'media':
# get preview
pos = plaintext.upper().find(binascii.unhexlify('ffd8ffe0'.upper()))
preview = plaintext[pos:] if pos > 0 else ""
#decode schema from encrypted message
media = encrypted_media_pb2.Media()
media.ParseFromString(plaintext)
#logger.debug("compare: " + str(plaintext[pos:] != media.thumbnail))
bodyNode = ProtocolTreeNode("media", data = preview)
bodyNode.setAttribute("type", node.getChild("enc").getAttributeValue("mediatype"))
bodyNode.setAttribute("size", str(media.length))
bodyNode.setAttribute("width", str(media.width))
bodyNode.setAttribute("height", str(media.height))
bodyNode.setAttribute("encoding", "unknown")
bodyNode.setAttribute("caption", media.caption)
bodyNode.setAttribute("mimetype", media.mimetype)
bodyNode.setAttribute("filehash", base64.b64encode(media.sha256))
bodyNode.setAttribute("url", media.url)
bodyNode.setAttribute("refkey", base64.b64encode(media.refkey))
bodyNode.setAttribute("file", "wat")
node.addChild(bodyNode)
self.toUpper(node)
by the way, there is also an error being thrown (somewhere, due to a logger.debug line) because the node's file attribute was not being set. i added that line in. you may want to commit that to the branch
@payamazadi Ups I read now your comment. Meet me at IRC (yowsup@chat.noip.me) if you prefer.
I have just patched file token and reordered due to msg encrypted media wasn't managed.
btw, great work on this refactor, it works great now out of the box with the echo demo and the code is pretty clean. i can help refactor some of that too
Receiving of decrypted images is no more possible. All receveid images are still encrypted, implemented your method message.getMediaContent(). Are there any open issues?
File "/home/steck/whatsappMy/yowsup/yowsup/layers/protocol_media/layer.py", line 41, in recvMessageStanza if mediaNode.getAttributeValue("type") == "image": AttributeError: 'NoneType' object has no attribute 'getAttributeValue'
from axolotl.kdf.hkdfv3 import HKDFv3 from axolotl.util.byteutil import ByteUtil in layer.py
sry, didn't see the full thing. got it, it's downloading for me now too!! very nice!!!
We did a good job =)
Sound good! can someone arrange a pull request with the full fix for image encryption?? thank you all for the effort
@jlguardi on your comments in #1387 you mentioned a more proper integration of this code into the Yowsup layers - can you clarify? also here is a cleaner version of the code with some of the node attributes corrected:
turning in for the night!
@payamazadi I'm integrating in the layers. Thx for the work of last hours!
somebody could to merge all patch in 1 thread :) I'm lost :)
@bdbais jlguardi/master for all but encrypted_media and we have a branch for tha propose (https://github.com/jlguardi/yowsup/tree/encrypted_media)
cloned, builded, installed, very good, it works! :) thanks @jlguardi and @payamazadi !
@bdbais how it works? i can apparently send messages but wont get ack. in my client and can'T receive messages
@jlguardi the encrypted_media branch is already working? supporting encrypted media completely?
@yniv not yet! It's just a proof of concept. I need to adapt to layers but WIP.
I checked and pulled last master but it won't work :(
Am 25.03.2016 um 12:30 schrieb jlguardi:
Who adapts the code in layers? I'm doing this, slowly
I adapted the code in layers. While I test. But it works! )
I GOT IT!!!!
Well, I've adapted images at least. Other media would be soon. It's not too clean code but I'll refactor slowly.
Check my branch jlguardi/encrypted_media
I have included a new method in all downloadable medias: getMediaContent which gets the file and decrypts it if necessary.
Just tested with images. Video crashes all other media, not tested!
Fixed Video!!!
@jodersus I've done a little differently but this also works well)
Thanks to all! branch can be closed) Patches are ready
Missing location and audio. I'll port them tonight. But I'll merge to master now.
Messages still not receiving .. are u also working on this?
Am 25.03.2016 um 16:49 schrieb jlguardi:
@thundergreen Messages? Please, refer issue (if any) with logs.
I'm using transwhat with yowsup. I can send messages, get also ackn. messages but no hooks back in conversations. People can read my messages but can't reply to me. messages wont be received.
My debug of transwhat doesn't show that much.
Am 25.03.2016 um 18:20 schrieb jlguardi:
Open a new issue and post logs of yowsup-cli with your credentials in debug mode.
never used cli..... will try it. how to enable the debug mode?
Am 25.03.2016 um 18:36 schrieb jlguardi:
yowsup-cli demos -y -d -l phonewithcc:password
Am 25.03.2016 um 18:52 schrieb jlguardi:
@thundergreen group encrypted messages aren't supported yet.
@jlguardi i've been having an issue w the branch around axolotl's layer, and the handlePreKeyWhisperMessage function.
can you do me a favor and run the echo client and tell me if you get errors?
when the layer sends the media message to handlePreKeyWhisperMessage function, with the code exactly how it is in the encrypted-media branch, and i run the echo client, i get infinite output, looks like this: ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag. ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag. ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag. ERROR:yowsup.layers.axolotl.layer:Truncated message. ERROR:yowsup.layers.axolotl.layer:Truncated message. ERROR:yowsup.layers.axolotl.layer:Truncated message. ERROR:yowsup.layers.axolotl.layer:Tag had invalid wire type. ERROR:yowsup.layers.axolotl.layer:Truncated message. ERROR:yowsup.layers.axolotl.layer:Unexpected end-group tag.
when i essentially replicate the actions of handlePreKeyWhisperMessage into handleWhisperMessage, things seem to work fine.
my workaround is this:
by the way, there is also an error being thrown (somewhere, due to a logger.debug line) because the node's file attribute was not being set. i added that line in. you may want to commit that to the branch
@payamazadi Ups I read now your comment. Meet me at IRC (yowsup@chat.noip.me) if you prefer. I have just patched file token and reordered due to msg encrypted media wasn't managed.
@jlguardi thanks for that. #1406 i'm in the IRC which they posted as being on freenode. what do you use / how do i get on it?
btw, great work on this refactor, it works great now out of the box with the echo demo and the code is pretty clean. i can help refactor some of that too
hey guys @payamazadi @jlguardi what is the branch to be used?
hey guys can u please help ? which branch should be used?
Tomorrow I'll share my code. I do not use yowsup-cli. I use my cli. I write only for personal use, but I can share code.
Screenshot )
It is very convenient to use with the phone via ssh
New version with media and group messages!!! There are too many issues and I don't know where to report.
My branch https://github.com/jlguardi/yowsup/ works with personal/group text/media. Sending isn't encrypted in groups but works with plain send.
Test it and enjoy it (if it works).
@jlguardi which patch fix receiving encrypted image? thanks
@jlguardi Great stuff! Many thanks for your great efforts. Which branch should we use? master or encrypted_media?
@jodersus master. See my wiki for some details.
@jlguardi I am using your master currently. Could you tell me how to decrypt downloaded media files?
@bartoszhernas message.getMediaContent() returns unencrypted media but just images work for now, WIP.
@jlguardi You are a life saver. Thanks a lot. Will check it out
Receiving of decrypted images is no more possible. All receveid images are still encrypted, implemented your method message.getMediaContent(). Are there any open issues?
Are there any open issues? All receveid images are still encrypted in most recent branch...
Hello guys,
So is there any piece of news? Is it possible now to open the decrypted images?
So, what needs to be done to get all of this trogether?
v3.2.0