Hello I'm trying to upload media by yowsup, using RequestUploadIqProtocolEntity but it's not possible because lambda function allways direct to onRequestUploadError, and cant send file ...
Request upload for file /tmp/jpeg.jpg for [email protected] failed
I also tried with yowsupCLI using image send
/image send 5524XXXXXX /tmp/3DCDA9A9436B01F9A3.jfif
ERROR:yowsup.demos.cli.layer:Request upload for file /tmp/3DCDA9A9436B01F9A3.jfif for [email protected] failed
DEBUG:yowsup.layers.logger.layer:rx:
<iq type="error" from="s.whatsapp.net" id="1">
<error text="feature-not-implemented" code="501">
</error>
I too have same problem.
I have the same problem, looks like a problem where whatsapp changed their method..
Just solved part of the issue:
The
If you make the needed changes in iq_requestupload.py and iq_requestupload_result.py (replace "media" with "encr_media", you can get to the upload step.
I could not, however, get the upload to actually work. Server always gives 400 error.
Maybe the server checks if the image is actually encrypted?
Gotta check some of the forks which can actually decrypt the image to see if we can figure out a procedure for encryption.
I'm trying to get the correct POST format from the decompiled java source, with no success.
If anyone has any idea how to proceed, I'd be immensely grateful.
Glad to hear that someone is trying to do something, now I know that is needed to send encryped media, instead of plain text media, as lguardi commented on
Basically, you need to implement the inverse of the send procedure:
- Generate a random key for encryption
- Encrypt media and upload to the server
- send encrypted url to recipient and the encryption key in a protobuf message
I'm looking forward to understand more about encrypted protocol in yowsup, to actually do something about send encrypted media protocol, I will be glad to any help given.
@etinin , i follow you to change "media" to "encr_media", got the upload URL, but then got this post & response:
POST:
https://mmg.whatsapp.net/u/f/FIcI1bQcJGbRXaGee0_cSllrJNoABVRrIxaEqA/AkObQlFqUS5DA21KPJHyYOnL47WKzVMSGN8Jf0SaiBE8
Content-Type: multipart/form-data; boundary=zzXXzzYYzzXXzzQQ
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.16.11 S40Version/14.26 Device/Nokia-302
Content-Length: 4880
HEADER & FOOTER:
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="from"
[email protected]
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="file"; filename="d6d02600f4f65c6733303c90a821800e.jpg"
Content-Type: image/jpeg
RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Sat, 15 Jul 2017 17:10:05 GMT
Connection: close
Content-Length: 0
It seems enc image is send in the protobuf message, like when extracted image from receiving image.
I think @jlguardi , can help give us some more clues.
I'm currently short of the required time, but if someone could take a look at jiguardi's fork, this might be solved. As I understand it, his fork has the decryption method properly implemented.
https://github.com/jlguardi/yowsup/tree/master/yowsup
In a parallel note, maybe we could try uploading a pre-encrypted image file? As I understand, the server should probably accept it, since it doesn't really have the key. But, again, I haven't studied the proper code.
It seems you just have to send yourself an encrypted image and check the specifics of the AES encryption being employed.
I've tried intercepting the whatsapp app requests to solve this issue but it's harder than I believed. The APP both on iPhone and Android seems to ignore proxy settings entirely when it can connect straight to the internet. And even some requests that get through the proxy are closed by Whatsapp when the app sees the selfsigned SSL certificate (even though the cert is properly added to the system.
Anyone has knowledge any reliable procedure for intercepting requests? Med school is keeping me way too busy to keep working blindly.
I made some modifications, to send back received image with enc,
But recipient only got this message in WA instead of the image:
_Waiting for this message. This may take a while. Learn More_
This my debug log:
[message to="[email protected]" type="media" id="1500356450-2"]
[enc type="msg" mediatype="image" v="2"]
3! �ƕ�u����[ -�J�,��q���z�/�6wE"�� �MQ�H�x�Y�6��� .....BLABLA
HEX:330a2105845ae2d89594e ...BLABLA
[/enc]
[/message]
2017-07-18 12:40:51,414 [MainThread ] [DEBUG] rx:
[ack t="1500356451" from="[email protected]" class="message" id="1500356450-2"]
[/ack]
2017-07-18 12:40:52,778 [MainThread ] [DEBUG] rx:
[receipt type="retry" from="[email protected]" id="1500356450-2" t="1500356452"]
[retry count="1" t="1500356451" id="1500356450-2" v="1"]
[/retry]
[registration]
('+ê
HEX:28272bea
[/registration]
[/receipt]
2017-07-18 12:40:52,779 [MainThread ] [DEBUG] tx:
[ack to="[email protected]" type="retry" id="1500356450-2" class="receipt"]
[/ack]
@bahtiarp, you've got to properly encrypt the image and send the encryption key.
How did you get to this point?
Are you uploading the image or just resending something you received?
Could you please send the patch?
@etinin
This is how to encrypt:
def encryptImg(img, refkey):
img = pad(img)
derivative = HKDFv3().deriveSecrets(binascii.unhexlify(refkey),
binascii.unhexlify("576861747341707020496d616765204b657973"), 112)
parts = ByteUtil.split(derivative, 16, 32)
iv = parts[0]
cipherKey = parts[1]
cipher = AES.new(key=cipherKey, mode=AES.MODE_CBC, IV=iv)
imgEnc=cipher.encrypt(img)
return imgEnc[:-6]
refkey = binascii.hexlify(os.urandom(112))
Where should this be? In mediauploader.py after "stream = f.read()" ? I got this error: global name pad is not defined. Should I also change the media-tag to encr_media ?
@dietzi try this
def pad(self, s):
return s + ((16-len(s) % 16) * '{')
Here is my diff: https://pastebin.com/mWvjhSUX
Now I get "json data not found" at mediauploader.py line 160
try this:
after ssl_sock.write(bytearray(fBAOS.encode()))
dataux = ssl_sock.recv()
lines = dataux.decode().splitlines()
@dietzi
If you see the log, you got this when you upload the data:
RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Sun, 16 Jul 2017 13:24:23 GMT
Connection: close
Content-Length: 0
(so you dont get the json data, as expected by the next processed).
I've checked from wa web version (chrome).
I see the header when uploading encr image is diffrent from yowsup mediauploader done.
yowsup mediauploader.py version for Header POST:
POST https://mmg.whatsapp.net/u/f/Gqp_7Z4ZN1PsLrg8b3xHGllraQYABVRvM1QKAg/AkObQlFqUS5DA21KPJHyYOnL47WKzVMSGN8Jf0SaiBE8
Content-Type: multipart/form-data; boundary=zzXXzzYYzzXXzzQQ
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.16.11 S40Version/14.26 Device/Nokia-302
Content-Length: 4892
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="to"
[email protected]
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="from"
[email protected]
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="file"; filename="AkObQlFqUS5DA21KPJHyYOnL47WKzVMSGN8Jf0SaiBE8.enc"
Content-Type: image/jpeg
Response from Whatsapp:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Sun, 16 Jul 2017 13:24:23 GMT
Connection: close
Content-Length: 0
Whatsapp WEB (chrome) version for Header POST:
------WebKitFormBoundary83mOQO9W0A1qhgX7
Content-Disposition: form-data; name="hash"
xxfuy7CpXoeRjSI321m74C8sXG/u3Bls8niwzzdGxuE=
------WebKitFormBoundary83mOQO9W0A1qhgX7
Content-Disposition: form-data; name="refs"
UL9-EipnOTCQuDjlaN-C5_pwW5k=
p64bypqos9A0WxZrNLYkUOg2oZ4=
------WebKitFormBoundary83mOQO9W0A1qhgX7--
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream
Whatsapp WEB (chrome) RESPONSE:
{"type":"encrypted","mimetype":"application/octet-stream","size":"7034","filehash":"xxfuy7CpXoeRjSI321m74C8sXG/u3Bls8niwzzdGxuE=","url":"https://mmg-fna.whatsapp.net/d/f/AsL21rfdOsW-bDtnaMAHOcSsmWgt2gjQAtCfwiELT_Mj.enc"}
i've checked that this: xxfuy7CpXoeRjSI321m74C8sXG/u3Bls8niwzzdGxuE= is the b64Hash of image file.
While this two (Content-Disposition: form-data; name="refs"):
UL9-EipnOTCQuDjlaN-C5_pwW5k=
p64bypqos9A0WxZrNLYkUOg2oZ4=
I still dont know how to genereate.
But although we got the correct response from whatsapp when uploaded, we have totally have to change the next process in yowsup. because it's diffrent from old responses that yowsup processed.
@bahtiarp The refs is generated using the send number and recipient number with encripty:
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/sha256.min.js
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-utf8.min.js
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-base64.min.js
https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/lib-typedarrays.min.js
e = "55628226****@c.us"
for (var t = e.length, n = [], r = 0; t > r; r++)
n[r >>> 2] |= (255 & e.charCodeAt(r)) << 24 - r % 4 * 8;
a = new Uint8Array();
b = CryptoJS.lib.WordArray.create(a)
var t = CryptoJS.HmacSHA256(CryptoJS.enc.Utf8.parse(e), b);
t.sigBytes = 20
t.clamp()
var e = t.toString(CryptoJS.enc.Base64)
alert(e)
console.log(e)

If I add "hash" to the header with a random key then I get "unsupported media type". I think if we could get the hash-code then we will be able to send media. Does anybody know about to generate the hash?
@pabloruan0710
using your js script i still cannot get the correct refs;
from: 62851xxxxxx
to: 62895330xxxxx
refs should be:
UL9-EipnOTCQuDjlaN-C5_pwW5k=
qohsee679xXFE8N_aXqB40PLX1U=
can you try to get the same result with your js script?
@bahtiarp This numbers ref is random Cripty, not is same number, check post with sniffer in Whatsapp web.
I can Send, and received this response:
Content-Type: multipart/form-data; boundary=zzXXzzYYzzXXzzQQ
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.16.12 S40Version/14.26 Device/Nokia-302
Content-Length: 41905
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 08 Aug 2017 19:19:51 GMT
Connection: close
Content-Length: 221
{"type":"encrypted","mimetype":"application/octet-stream","size":"41517","filehash":"Ll9P92iz1ERZHgM1pSflrGT0UU6RUEzU4fTAE95JkA8=","url":"https://mmg-fna.whatsapp.net/d/f/AoEGRkSJG36LMUwEjvkGtUyjcNLUq8ftLcqu2Xf9EMZt.enc"}
However didn't received image in recipient number
@pabloruan0710 Have you sent ProtocolMedia message to the recipient? Or you have just uploaded the file.
@pabloruan0710 What did you do with refs? Did you encrypt sender and recipient respectively?
@pabloruan0710 great you've succeed to upload the image and get the response. (i still figuring out how to get the "refs" correct. unless you show the code :) )
The next step is like @jlguardi said, you have todo some modification in protocol media (toProtocolTreeNode), so the message will send in the following protobuf format:
[message to="[email protected]" type="media" id="1500356450-2"]
[enc type="msg" mediatype="image" v="2"]
3! �ƕ�u����[ -�J�,��q���z�/�6wE"�� �MQ�H�x�Y�6��� ..... --> DATA
[/enc]
[/message]
where DATA consist (encrypted) of:
random mediaKey,
url (we got when uploaded)
sorry for my bad english.
@bahtiarp i can send the media message (without encrypt img) and response similar like @pabloruan0710 , the recipient never received the message. But if i send the encrypted image, always return 400 bad request.
To generate the refs, i made some modifications of hBAOS :
digTo = hmac.new("".encode("utf-8"), self.jid.replace("@s.whatsapp.net","@c.us").encode("utf-8"), hashlib.sha256).digest()[:20]
refTo = base64.b64encode(digTo).decode()
digFrom = hmac.new("".encode("utf-8"), self.accountJid.replace("@s.whatsapp.net","@c.us").encode("utf-8"), hashlib.sha256).digest()[:20]
refFrom = base64.b64encode(digFrom).decode()
hBAOS = "--" + boundary + "\r\n"
hBAOS += "Content-Disposition: form-data; name=\"hash\"\r\n\r\n"
hBAOS += self.__class__.getFileHashForUpload(sourcePath) + "\r\n"
hBAOS += "--" + boundary + "\r\n"
hBAOS += "Content-Disposition: form-data; name=\"refs\"\r\n\r\n"
hBAOS += refFrom + "\r\n"
hBAOS += refTo + "\r\n"
hBAOS += "--" + boundary + "\r\n"
hBAOS += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "blob" + "\"\r\n"
hBAOS += "Content-Type: " + "application/octet-stream" + "\r\n\r\n"
How to encrypt image properly?
Any help would be appreciated.
@whyasta I think you're getting "400 bad request" because the length of encrypted file isn't the same from the raw file, so your "filesize" needs to be equal "len(stream)".
@whyasta
It's seems that that your Content-Length is based on file before encrypted.
This is how i fixed it:
try:
filename = os.path.basename(sourcePath)
filetype = MimeTools.getMIME(filename)
f = open(sourcePath, 'rb')
stream = f.read()
f.close()
refkey = binascii.hexlify(os.urandom(112))
stream=self.encryptImg(stream,refkey)
fenc = open(filename+".enc", 'wb')
fenc.write(stream)
fenc.seek(0, 2)
filesize=fenc.tell()
fenc.close()
sha1 = hashlib.sha256()
sha1.update(stream)
b64Hash = base64.b64encode(sha1.digest())
Now we can continue to fixing the next process.
@bahtiarp did you get to successfully upload the file? I'm stopped on an error saying "415 Unsupported Media Type"
@duzzifelipe
Yes, i got this:
POST https://mmg.whatsapp.net/u/f/ctq7Cm2nDwGv6rv1jqGWdlmMe7gABVZn2tCVcQ/AmJ99kyxGcMaIS1BkYC8vyFDFmPPbXQ779hJKmhWMCZL
Content-Type: multipart/form-data; boundary=zzXXzzYYzzXXzzQQ
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.16.11 S40Version/14.26 Device/Nokia-302
Content-Length: 7422
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="hash"
NCzF2z0pL8F+zAN41s/MFiJPOrL4yi0cNMmCsWSHc6w=
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="refs"
bsD9smTr55H5ifQkU3xd+F1Webo=
KuU/zMxPnXiAqbatZ0tN3aKXjqA=
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 10 Aug 2017 15:28:56 GMT
Connection: close
Content-Length: 220
{"type":"encrypted","mimetype":"application/octet-stream","size":"7034","filehash":"NCzF2z0pL8F+zAN41s/MFiJPOrL4yi0cNMmCsWSHc6w=","url":"https://mmg-fna.whatsapp.net/d/f/AtOdjxzg-CAUEi-2LL_uepNfYNquO9rIItlkp-uKRngh.enc"}
As you can see:
Content-Length: 7422 --> size of the encrypted file + headers length
"size":"7034" --> original size of the encrypted file return by whatsapp.
@bahtiarp woow! I got it using your code to generate b64Hash. Thank you!
Now I'll try to see how this message is sent by whatsapp, maybe using this plugin: https://github.com/jlguardi/wireshark-whatsapp
Can you help us, the Loqui team, to get this working under our messenger LoquiIM? It's based on yowsup, but uses javascript as language. You can join our telegram group. Thank you, that we can see some work on yowsup again!
Does anybody know what to do for sending the image to the receipent? The file is uploading correctly but not sent to the other number. There is no error or something else. What message must be send to push the image to the receipent? Here is my diff: https://pastebin.com/LhtH7GyX
See my diff: https://pastebin.com/ADJX5EnQ
Now I'm getting an ack-message from the receipent but there is no message. It seems the message is sent but it never comes to the phone... See my log: https://pastebin.com/ettx3t0p
@dietzi
btw why is it twice to send same request for upload: (see line 3 and 9 on your log)
and also you get 2 same rx for those request: line 15 and line 39.
I don't know. The log says the message is send but it never retrieves on the phone..... I think the error is at line 32
if you see my post 26 days ago, and follow the same format your message will arrive in dest phone.
the encrypted message consist of :
I'm still looking for my idle time to learn and modify in axolot layer for sending encrypted image message, or waiting for others solved this first.
What did you changed in the code? Can you show a diff?
i made some modifications but i forgat all, but mainly i modify
https://github.com/tgalal/yowsup/blob/master/yowsup/layers/axolotl/layer_send.py
line 46, so that the message will send in that format.
Just go to console in your yowsup-folder and type "git diff"
@bahtiarp
You wrote in your post (https://github.com/tgalal/yowsup/issues/2149#issuecomment-322039950) "encrypted message consist of...". Have the message to be encrypted? Yowsup sends this message after upload (I changed the code so mediaKey (got from refkey) is included):
ID: 1502735729-2
To: 49176**@s.whatsapp.net
Type: media
Timestamp: 1502735729
Media Type: image
Has Preview: True
MimeType: image
File Hash:
3736a38324a39507852765042775a37514a76564c6a57432f564761626156576e7544582b5074695457593d
URL: https://mmg.whatsapp.net/d/f/ApbBa3ek7yXDgkMaPr3gyYZYAcKNDIWTq3zvSRTmQ1D4.enc
IP: None
File Size: 5136
File name: i.png
Encoding: raw
Width: 192
Height: 192
mediaKey: 99c1863d363939796dcf66b6161cc0ed56d12bc2a282a0c132c8c5178d46b3865e34cec0f8aa92e8e5afc233f32df93bfd80a0b010e165f6f2796c5033eab2a7c12236709b12647d2733dee9f294f03c411c89a7db9f25ab45445883ccc23554dda99c970bbc2a3d55e9819cdfb6c3aa
`
But on my phone I only get the message "Waiting for this message......". Yowsup shows "\
Base on @jlguardi hint:
We need the inverse procedure when receiving image:
this is my log when receiving encrypted message with url to encrypted image:
image-received-log
this is my log when sent data:
where [DATA] in body of mediaNode is encrypted of protobuf imageMesage.
this is how i compose imageMesage in protobuf before it encrypted and sent.
def toProtobufMessage(self):
mediaKey=binascii.unhexlify(mediaKey) --> mediaKey we genereted when uploading enc image
fileHash= filehash --> filehash we got as in responsed when uploading enc image
url=self.url..encode('latin-1') -> url we got in responsed when uploading enc image
image_message = ImageMessage()
image_message.url = url
image_message.width = self.width
image_message.height = self.height
image_message.mime_type = self.mimeType
image_message.file_sha256 = self.fileHash
image_message.file_length = self.size
image_message.caption = "judul"
image_message.jpeg_thumbnail = self.preview
image_message.media_key = mediaKey
return image_message
i still doubt in filehash (because when i observed when receiving image in binary format, but i sent still in plain hash).
So if i put [DATA] as random string, the message will reached the destination phone, but we no image only text:
_Waiting for this message. This may take a while. Learn More_
But if i put [DATA] with the encrypted ImageMessage. the message is sent ang i got ACK but the message didn't reached the destination phone.
Currently i still didn't have idle time for further analyzing. May be if somebody can sniff from whatsapp web how is the propper node structure to send image message, will help to speedup solving this case.
i tried to send image from yowsup A to yowsup B, in B logs i found that the message arrived but, yowsup cannot parsed the enc message.
File "/home/dev/WA/py/yowsup-master/yowsup/layers/axolotl/layer_receive.py", line 137, in handleWhisperMessage
whisperMessage = WhisperMessage(serialized=enc.getData())
File "/usr/lib/python2.7/site-packages/axolotl/protocol/whispermessage.py", line 38, in __init__
whisperMessage.ParseFromString(message)
google.protobuf.message.DecodeError: Error parsing message.
@bahtiarp maybe the way you send is leaving the "enc" node child empty and decoder cannot understand.
And did you get to send an image message? I'm almost there. The closest I got was this:

I know I forgot something, but I didn't find it yet.
if i fill "enc" child node empty, the message reached the dest, but no image warning message only.
if i fill with encrypted imageMessage protobuf, then i got ack but the image didn't rendered on dest.
(i know that the message is reached the dest, but still not proper so the dest cannot render).
btw, can you show your send log when the data shown as in your screen captured. i'm affraid that the enc attribute not attribute for image type.
my new progress, i can send image from yowsup A to yowsup B. and message and image decrypted properly, and i can view the image correctly.
but if i send from yowsup to whatsapp phone the image still not rendered although , my yowsup get
The prev image now come but cannot renderd the full image.
when click error message: Download failed
"The download was unable to complete. Please try again later."

Maybe the problem now is with correctly upload encrypted media, because the preview is generated based on the file path (at least on my repo) and does not depends on the media upload.
This week I had no time to do it right and I even lost 2 numbers. But I'll try this weekend, at least get at the same step as you.
@bahtiarp how did you got to this point? Can you send a diff please? So we can work together to get the problem solved. I'm sniffing the packets by using a proxy on my home-server, so I can decrypt the SSL-messages.
I tried with sniffing but WhatsApp (on Android) expects a special certificate for SSL-connection. So my fakecert wont't work.....
@dietzi , this is the diff: diff
with that i now can:
now 2.10 am morning, need for sleep now 😴
Your link don't work. Good night ;)
You sent the link from my diff. That's working? Or was this a typo?
should we try this on the master?
On 17 August 2017 at 22:10, dietzi notifications@github.com wrote:
You sent the link from my diff. That's working? Or was this a typo?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/tgalal/yowsup/issues/2149#issuecomment-323248114, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AR0Z7uYzMX1Etj4UcPW6sE0qrbCZXhyuks5sZQC5gaJpZM4OWLf4
.
sorry i miss the link, this the link:
https://pastebin.com/jxk0hrgU
@dietzi , have you found what's wrong ?
it's seem that that whatsapp dest, cannot decrypt the image or i missed something?
I had no time to test your code. Maybe today I'll find time to test.
Im not sure if this help.
I try dump the thumb_image data and deserialize it.
Another image field value:-
media_url: https://mmg.whatsapp.net/d/f/AtYmOccQV4pO5TfQyeTDN0KZqVb9O6FfI4jL3VR7OJsP.enc
media_enc_hash: Tgzo7Ycn/5mITjxvNHG2eBPeZ4M1orKP/9iJPXh/Uw0=
I think the problem is the encryption. If I click download it starts with downloading and after that the error appears. So the hash or the mediakey transmitted are wrong. We should test with some combinations of hash and encryption-key. Maybe Whatsapp expects the end-to-end-keys for encryption. Today in the evening I'll make some tests
@dietzi , i agree it something wrong when whatsapp decrypt the enc image. but strangely, yowsup can decrypt the image properly the same as if we sent from whatsapp. btw, i checked that there is 1 variables that exist in imageMessage protobuf when whatsapp that did'nt handle in current imageMessage struct, it's seems like hash file, but i don't know what is for/from.
for hash of the image it self, i ovserved it' should be valid , because it's give same value when i received.
and one more i found another hash in in protobuf imageMessage, may be it should filled with the hash of the encrypted image that we uploaded?
in wa.proto (see: hash_like)
message ImageMessage {
required bytes url = 1;
required string mime_type = 2;
required string caption = 3;
required bytes file_sha256 = 4;
required uint64 file_length = 5;
required uint32 height = 6;
required uint32 width = 7;
required bytes media_key = 8;
optional bytes hash_like = 9;
required bytes jpeg_thumbnail = 16;
}
I've analysed your changes and I think the problem is at:
message_media_downloadable.py: DownloadableMediaMessageProtocolEntity.fromBuilder(builder)
---> filehash = WATools.getFileHashForUpload2(builder.getFilepath())
I think the routine "getFileHashForUpload2" returns a wrong value. But how to figure it out?
hmm, but i got the same value with getFileHashForUpload2 hashfile if i send image from whatsapp and from yowsup, so i'm sure that getFileHashForUpload2 is right.
If I send a image I get this "error" in yowsup: Axolotl layer does not have the message, bubbling it upwards
So I think there is a Problem with the structre of the parameters or something else. I'm trying on. What I found in message_media_downloadable.py: the filepath for filesize doesn't include .enc - maybe this is the problem.
If I add "mediaNode.setAttribute("caption", "test")" in media_message_downloadable_image toProtocolTreeNode this works. Whatsapp download's the image but can not show it. So the filehash or the encryption may be wrong....
Hi guys,
maybe we need to send both, the encrypted file-hash AND the unencrypted file-hash.
I think it could be something like that:
message ImageMessage {
required bytes url = 1;
required string mime_type = 2;
required string caption = 3;
required bytes file_sha256 = 4;
required uint64 file_length = 5;
required uint32 height = 6;
required uint32 width = 7;
required bytes media_key = 8;
required bytes file_enc_sha256 = 9;
required bytes jpeg_thumbnail = 16;
}
Unfortunately, I don't know how to implement it, but maybe it helps...
@Nicos-git i've already done that also, but no diffrent in result.
My suspicions now on : The refs for from and to number is wrong.
because i observed that the refs always result the same hash for the same image.
so it it function of : number and imagesize or imagehash
@bahtiarp
Could you please post your changes in a proper formating?
@ventrixcode
https://pastebin.com/pVxryQ12
this is cmd to compile protobuf to python:
protoc -I=. --python_out=. wa.proto
I'm testing your changes @ventrixcode and they look fine (at least they compile). I had couple of errors, some of them I could workaround, but not the last one.
A workaround: I'm in P3 and unicode() does not exist.
So in wa_pb2.py I've added this at the beginning, below imports:
`
if sys.version_info >= (3,):
def unicode(value,encoding):
if isinstance(value, str):
return value
else:
return value.decode(encoding)
`
Now, here is the fatal error while using /image send as usual. It fails because another process is being using a file (I suppose is the temporary image file). Here is the short error trace:
DEBUG:yowsup.layers.logger.layer:tx:
b'33650d846c7ff15a4703ff85eb7102bc3bebd9172448e1bf76188d16f159ad4e'
filesize:21258
21258
file_enc_sha256:ae9456c753fbd8967f2cfb79c36bac38700ff80713436cfa6f3ca30d70b9ef5d
{'size': '21258', 'filehash': 'rpRWx1P72JZ/LPt5w2usOHAP+AcTQ2z6bzyjDXC5710=', 'u
rl': 'https://mmg.whatsapp.net/d/f/Ap_lt4XwJVOOFPI4wf67IefIthSCJ9-Z2cjICEI-8m9h.
enc', 'name': None, 'type': 'encrypted', 'error': None, 'width': None, 'height':
None, 'mimetype': 'application/octet-stream'}
ERROR:yowsup.common.optionalmodules:PIL import failed
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer [WinError 32] The process has no access to file because it is being used by another process: 'c:\users\--user-is-hidden--\appdata\local\temp\tmphxdp2p'
Here is the ful trace:
Traceback (most recent call last):
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\layers\protocol_media\mediauploader.py", line 221, in run
self.successCallback(sourcePath, self.jid, result)
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\demos\cli\layer.py", line 561, in
successFn = lambda filePath, jid, url: self.doSendMedia(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\demos\cli\layer.py", line 543, in doSendMedia
entity = ImageDownloadableMediaMessageProtocolEntity.fromFilePath(filePath, url, ip, to, caption = caption)
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\layers\protocol_media\protocolentities\message_media_downloadable_image.py", line 129, in fromFilePath
return ImageDownloadableMediaMessageProtocolEntity.fromBuilder(builder)
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\layers\protocol_media\protocolentities\message_media_downloadable_image.py", line 109, in fromBuilder
builder.getOrSet("preview", lambda: ImageTools.generatePreviewFromImage(builder.getOriginalFilepath()))
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\layers\protocol_media\protocolentities\builder_message_media_downloadable.py", line 54, in getOrSet\te
self.set(key, func())app.net
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\layers\protocol_media\protocolentities\message_media_downloadable_image.py", line 109, in
builder.getOrSet("preview", lambda: ImageTools.generatePreviewFromImage(builder.getOriginalFilepath()))="w:p">
File "K:\aaa_git\home\xxx\git\yowsup\yowsup\yowsup\common\tools.py", line 162, in generatePreviewFromImage
os.remove(path).logger.layer:rx:
PermissionError: [WinError 32] The process has no access to file because it is being used by another process: 'c:\users\--user-is-hidden--\appdata\local\temp\tmphxdp2p'
ERROR:yowsup.demos.cli.layer:Upload file mediatest01.jpg to https://mmg.wh
atsapp.net/u/f/3LTzkEotHb4SuIvIkeCc1FmkMngABVfRsyHuzQ/AiHJb7-OMAmEiCgrPe2Kv-X2oH
MwDNaziol64AWvWLBy for [email protected] failed!
Any idea of what's going on?
Are we realy doing something in parallel on such file, or maybe we forgot to close it?
Thanks.
Regards.
hgc.
I've found some wrong things according to Whatsapp Web code (I haven't tested it yet, will do it tomorrow).
* I think there's something to do about cryptoKey, like receiving it from the iqRequest response. But as I didn't test it, I don't know yet.
def getMediaLabel(self):
if self.media_type == "image":
m_type = "Image"
elif self.media_type == "video":
m_type = "Video"
elif self.media_type == "audio":
m_type = "Audio"
elif self.media_type == "document":
m_type = "Document"
return "WhatsApp %s Keys" % m_type
def generateCrypto(self):
cryptoKey = binascii.hexlify(self.b64Hash) # don't know if it's right, maybe another key
derivative = HKDFv3().deriveSecrets(binascii.unhexlify(cryptoKey), self.getMediaLabel(), 112)
iv = derivative[:16]
cipherKey = derivative[16: 16 + 32] # length is 32
macKey = derivative[48: 48 + 32]
refKey = derivative[80: 80 + 32]
# instance variables (returned on success)
self.refKey = refKey
# return a function to encode image
return AES.new(key=cipherKey, mode=AES.MODE_CBC, IV=iv)
def encryptPhone(self, jid):
# generate hashs for header request "refs"
sha1 = hashlib.sha256(self.refKey)
parsed_jid = Jid.normalize(jid).replace("@c.us", "@s.whatsapp.net").encode("utf-8")
sha1.update(parsed_jid)
return base64.b64encode(sha1.digest()[:20])
I'll be waiting your tests. Thanks!
i think cryptoKey should be: "576861747341707020496d616765204b657973" based on decrypt method.
@bahtiarp no, this key you've sent is just an encoded string, like in getMediaLabel. Look:

I still do not have a phone number, I lost another one while registering (don't know why); I will try again later.
I've send a image and could get this from whatsapp-web:
Assertion Failed! decryption-error (false not truthy): msg:processEncryptedMedia MediaEncryptionError: hmac fail computed: DI97Dct8dKIyPA== given: jM9RL+ZJtDYMiQ==
Can we compute the right key back?
This is the function from whatsapp-javascript:
function d(e, t, n, a, o, i) { return f["default"].resolve().then(function() { if (!(10 <= o.length && o.length <= 32)) throw new v["default"].MediaEncryptionError("Given bad expected hmac"); var i = m["default"].build(t, n).readByteArray(); return new r(a).sign(i).then(function(t) { for (var n = new Uint8Array(t, 0, o.length), a = !1, r = 0; r < n.length; r++) n[r] !== o[r] && (a = !0); if (a) throw new v["default"].MediaEncryptionError("hmac fail computed: " + h["default"].encode(n) + " given: " + h["default"].encode(o)); return c(e, i) }) }).then(function(e) { var t = "string" == typeof i ? i : i(new Uint8Array(e)); return w["default"].createFromData(e, t) }) }
If I change the refTo and refFrom the computed value in WhatsApp changes. So we should search the problem there
Update: the keys change on every send.
Some tests later I can't solve the problem. I can't find the given hmac in yowsup. Where should this key be in yowsup? The WhatsApp-log say "MediaEncryptionError". So the function "encryptImg" seem's to be false. For now it's enough today. I'll go to bed now. Good night at all.
@dietzi , interesting progress. can you tell me how to get that js log in chrome. it'll will help for dubuging.
so far i didn't see error log appeared in console when inspected in chrome.
I'm using firefox. There I press ctrl+shift+k and then on analyse network. WhatsApp tries to load the image and on error I see a POST-request with the log as response. Sometimes I have to refresh the page. I'll post here a image

@dietzi , thanks. i'll try to do some experiment tonight.
I think we missing hmacKey encryption in yowsup.
Please refer my comment above.
Found article about hmackey
https://codedump.io/share/hGCbxQ8vsuoT/1/decrypting-aes-and-hmac-with-pycrypto
Great example and code on decrypting! Thanks!
But I don't know if I'll be able to apply it. Let me see.
Not sure how useful this is but the whatsapp-plugin for the multi-messenger Disa can send Media without problems.
It's closed source but fortunately written in c# which can be decompiled basically perfectly (if anyone wants to do further digging the weird dpk can be unpacked using bindump -e file.dpkbinwalk -e file.dpk and the dlls can be decompiled using dnSpy (or probably any other c# decompiler).
This is the decompiled UploadFile method from the plugin:
c#
// Disa.Framework.WhatsApp.WhatsApp
// Token: 0x06000518 RID: 1304 RVA: 0x0001AAC4 File Offset: 0x00018CC4
private ProtocolTreeNode UploadFile(string to, string fileType, string fileHash, byte[] fileBytes, string filePath, byte[] thumbnail, string mimeType, Action<int> progressUpdate, bool recording = false, int seconds = 0, bool encrypted = false, Dictionary<string, string> extraUploadStrings = null)
{
Func<string> func = delegate
{
string mimeType2 = mimeType;
uint num = <PrivateImplementationDetails>.ComputeStringHash(mimeType2);
if (num <= 3109025507u)
{
if (num <= 2471643833u)
{
if (num != 1639502448u)
{
if (num != 1826612852u)
{
if (num == 2471643833u)
{
if (mimeType2 == "audio/mp4")
{
return ".mp4";
}
}
}
else if (mimeType2 == "audio/wav")
{
return ".wav";
}
}
else if (mimeType2 == "video/mp4")
{
return ".mp4";
}
}
else if (num != 2799670939u)
{
if (num != 2970156561u)
{
if (num == 3109025507u)
{
if (mimeType2 == "audio/mpeg")
{
return ".mp3";
}
}
}
else if (mimeType2 == "audio/aac")
{
return ".aac";
}
}
else if (mimeType2 == "audio/ogg; codecs=opus")
{
return ".opus";
}
}
else if (num <= 3404529107u)
{
if (num != 3355350250u)
{
if (num != 3373101051u)
{
if (num == 3404529107u)
{
if (mimeType2 == "video/3gpp")
{
return ".3gp";
}
}
}
else if (mimeType2 == "audio/webm")
{
return ".webm";
}
}
else if (mimeType2 == "audio/amr")
{
return ".amr";
}
}
else if (num != 3485255564u)
{
if (num != 3901389917u)
{
if (num == 4015067401u)
{
if (mimeType2 == "video/avi")
{
return ".avi";
}
}
}
else if (mimeType2 == "image/jpeg")
{
return ".jpg";
}
}
else if (mimeType2 == "audio/3gpp")
{
return ".3gp";
}
throw new Exception("Unsupported MimeType to determine file extension");
};
List<KeyValue> list = Enumerable.ToList<KeyValue>(new KeyValue[]
{
new KeyValue("hash", fileHash),
new KeyValue("type", fileType)
});
if (!encrypted)
{
list.Add(new KeyValue("size", ((filePath == null) ? ((long)fileBytes.Length) : new FileInfo(filePath).Length).ToString(CultureInfo.InvariantCulture)));
}
ProtocolTreeNode children = new ProtocolTreeNode((!encrypted) ? "media" : "encr_media", list.ToArray());
string text = this.MakeIqId("request_media_upload_");
ProtocolTreeNode node = new ProtocolTreeNode("iq", new KeyValue[]
{
new KeyValue("id", text),
new KeyValue("type", "set"),
new KeyValue("to", "s.whatsapp.net"),
new KeyValue("xmlns", "w:m")
}, children);
WhatsApp.WaitTask3<bool, ProtocolTreeNode> waitTask = new WhatsApp.WaitTask3<bool, ProtocolTreeNode>(30000, text);
this._uploadResponses.Add(waitTask);
try
{
this.SendProtocolTreeNode(node, false);
}
catch
{
base.DebugPrint("Failed to ask for an upload.");
this._uploadResponses.Remove(waitTask);
throw;
}
if (!waitTask.WaitOne())
{
this._uploadResponses.Remove(waitTask);
throw new TimeoutException("Eish. Waited too long for a upload request.");
}
ProtocolTreeNode additional = waitTask.Additional;
Utils.DebugPrint(additional.NodeString(""));
if (additional.GetChild("duplicate") != null)
{
ProtocolTreeNode child = additional.GetChild("duplicate");
string attribute = child.GetAttribute("url");
string attribute2 = child.GetAttribute("size");
return WhatsApp.GenerateMediaSendNode(child.GetAttribute("type"), attribute, Enumerable.Last<string>(attribute.Split(new char[]
{
'/'
})), attribute2, thumbnail, recording, seconds);
}
if (additional.GetChild((!encrypted) ? "media" : "encr_media") == null || string.IsNullOrWhiteSpace(additional.GetChild((!encrypted) ? "media" : "encr_media").GetAttribute("url")))
{
throw new ServiceBubbleSendFailedException("Could not get a url from the node.");
}
string attribute3 = additional.GetChild((!encrypted) ? "media" : "encr_media").GetAttribute("url");
string name = this.GenerateMediaFilename(func.Invoke());
Dictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("to", to);
dictionary.Add("from", this.GetMyAccountWaAddress());
Dictionary<string, object> dictionary2 = dictionary;
if (filePath == null)
{
dictionary2.Add("file", new OkHttpClient.FormFile
{
Name = name,
ContentType = mimeType,
Bytes = fileBytes
});
}
else
{
dictionary2.Add("file", new OkHttpClient.FormFile
{
Name = name,
ContentType = mimeType,
FilePath = filePath
});
}
if (extraUploadStrings != null)
{
foreach (KeyValuePair<string, string> keyValuePair in extraUploadStrings)
{
dictionary2.Add(keyValuePair.Key, keyValuePair.Value);
}
}
using (OkHttpClient okHttpClient = new OkHttpClient())
{
if (mimeType.StartsWith("image"))
{
okHttpClient.Timeout = 30000;
okHttpClient.ReadWriteTimeout = 30000;
}
else
{
okHttpClient.Timeout = 60000;
okHttpClient.ReadWriteTimeout = 60000;
}
okHttpClient.UserAgent = WhatsConstants.UserAgent;
try
{
string text2 = okHttpClient.PostMultiPart(attribute3, dictionary2, delegate(double progress)
{
progressUpdate.Invoke((int)progress);
});
Utils.DebugPrint(text2);
string[] array = text2.Split(new string[]
{
"\n"
}, 1);
int i = 0;
while (i < array.Length)
{
string text3 = array[i];
if (text3.StartsWith("{"))
{
JObject jobject = JObject.Parse(text3.TrimEnd(new char[1]));
if (string.IsNullOrWhiteSpace((string)jobject["filehash"]))
{
throw new Exception("File hash is null!");
}
string text4 = (string)jobject["name"];
string text5 = (string)jobject["url"];
if (string.IsNullOrWhiteSpace(text4))
{
text4 = Enumerable.Last<string>(text5.Split(new char[]
{
'/'
}));
Utils.DebugPrint("No filename. Generated: " + text4);
}
return WhatsApp.GenerateMediaSendNode((string)jobject["type"], text5, text4, (string)jobject["size"], thumbnail, recording, seconds);
}
else
{
i++;
}
}
}
catch (OkHttpClient.UploadMultiPartException ex)
{
if (ex.Status == 415)
{
throw new ServiceBubbleSendFailedException("Unsupported media type.");
}
throw;
}
}
throw new ServiceBubbleSendFailedException("Could not upload file (end of method).");
}
@jakibaki , can you find / decompile function: GenerateMediaSendNode.
(And functions related to encrypt an image/media)
and how to install bindump.
@jakibaki , can you find / decompile function: GenerateMediaSendNode.
Here's a zip with all the code decompiled and the original dlls.
and how to install bindump.
Woops I meant binwalk, it's in the package repos of most linux-distros and for macOS in homebrew. There is no windows-support afaik.
So this is the GenerateMediaSendNode Method:
// Token: 0x06000514 RID: 1300 RVA: 0x0001A910 File Offset: 0x00018B10
private static ProtocolTreeNode GenerateMediaSendNode(string type, string url, string name, string size, byte[] thumbnail, bool recording = false, int seconds = 0)
{
List<KeyValue> list = new List<KeyValue>();
list.Add(new KeyValue("type", type));
list.Add(new KeyValue("url", url));
list.Add(new KeyValue("file", name));
list.Add(new KeyValue("size", size));
List<KeyValue> list2 = list;
if (thumbnail != null)
{
list2.Add(new KeyValue("encoding", "raw"));
}
if (recording)
{
list2.Add(new KeyValue("origin", "live"));
}
if (seconds > 0)
{
list2.Add(new KeyValue("seconds", seconds.ToString(CultureInfo.InvariantCulture)));
}
return new ProtocolTreeNode("media", list2, null, thumbnail);
}
@jakibaki, thanks. finally i've to installed vs2017 and learn c#, only for patching 3 lines of my last code. but it's working now to send an image via yowsup. i'll show the diff soon.
Thank you so much!
Please Tell us how to apply your changes!
I still didn't have time to tidy up the code, but this is the change i've made:
def pad(self,s):
return s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
def encryptImg(self,img, refkey):
derivative = HKDFv3().deriveSecrets(binascii.unhexlify(refkey),
binascii.unhexlify("576861747341707020496d616765204b657973"), 112)
parts = ByteUtil.split(derivative, 16, 32)
iv = parts[0]
cipherKey = parts[1]
macKey=derivative[48:80]
mac = hmac.new(macKey,digestmod=hashlib.sha256)
mac.update(iv)
cipher = AES.new(key=cipherKey, mode=AES.MODE_CBC, IV=iv)
imgEnc = cipher.encrypt(self.pad(img))
mac.update(imgEnc)
hash = mac.digest()
hashKey = ByteUtil.trim(mac.digest(), 10)
finalEnc = imgEnc + hashKey
return finalEnc
@bahtiarp What is this string "576861747341707020496d616765204b657973" you are using in line 6?
And how can I send the encrypted file (finalEnc)?

like in c#
string text = null;
if (bubble is ImageBubble)
{
text = "WhatsApp Image Keys";
}
if (bubble is VideoBubble)
{
text = "WhatsApp Video Keys";
}
if (bubble is AudioBubble)
{
text = "WhatsApp Audio Keys";
}
if (bubble is FileBubble)
{
text = "WhatsApp Document Keys";
}
@bahtiarp Okay thanks but still don't get how I can now send an image. I created now my encrypted image but which method in yowsup I have to use to send the image to a Jid?
Great. It work's. Now we have to copy this for video, audio and documents. I need to send audio. Maybe tomorrow I will try to copy this lines for audio.
@bahtiarp Is that from above the final diff or is it following? I ask because some people said it works.
Im too dumb to get this working if anyone could post all the changes in all files?
They currently seem to tidy up the code so we don't need to implement unnecessary stuff. This was a long term work thread :)
Please make an new pull request later then or better make an own fork with patched stuff @bahtiarp
Thank you ;)
Yes, just change method encryptimg from my last diff.
On Sep 9, 2017 5:21 AM, "Bjarne Roß" notifications@github.com wrote:
@bahtiarp https://github.com/bahtiarp Is that from above the final diff
or is it following? I ask because some people said it works.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tgalal/yowsup/issues/2149#issuecomment-328227257, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADQLdBnUWbA2NIlGUf1CwdYfwqyQqlUHks5sgb3UgaJpZM4OWLf4
.
I try to do in php.. do anyone know why every time upload encoding image file get "invalid_path" url..
this encr_media url return from s.whatsapp.net.. https://mmg.whatsapp.net/u/f/TPQO_r_quLO0Kt2aKlIPuFmz5RAABVjBOflBgw/ApG0Yjm0bgnEoEWWtGC8NPhpwQ5ab8iukiPqQsA3z2Df
upload non-encoding, whatsapp return success..
@bahtiarp Can you put the diff of your files? And another questions What is a refkey in the encrpyting method??
i cant get it work please post a full diff!
Very thanks @bahtiarp
The patches to follow:
https://pastebin.com/baqG5kU3
/yowsup/common/tools.py
https://pastebin.com/vQbWVjL9
/yowsup/layers/axolotl/layer_send.py
https://pastebin.com/u3d0LDhb
/yowsup/layers/protocol_media/mediauploader.py
https://pastebin.com/2vji8sr0
/yowsup/layers/protocol_media/protocolentities/iq_requestupload.py
https://pastebin.com/sgdKQh1Z
/yowsup/layers/protocol_media/protocolentities/iq_requestupload_result.py
https://pastebin.com/bef8MMpV
/yowsup/layers/protocol_media/protocolentities/message_media.py
https://pastebin.com/HVgJL9A6
/yowsup/layers/protocol_media/protocolentities/message_media_downloadable.py
https://pastebin.com/Q9BZSrjq
/yowsup/layers/protocol_media/protocolentities/message_media_downloadable_image.py
https://pastebin.com/TfzaSE88
/yowsup/layers/protocol_messages/proto/wa_pb2.py
The patch attached:
#Download HERE full patch for send image#
@bahtiarp
With your edits, sending pictures works, but there is a problem with sending longitude and latitude
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/protocol_media/protocolentities/message_media_location.py", line 58, in toProtocolTreeNode
mediaNode.setAttribute("latitude", self.latitude)
AttributeError: 'NoneType' object has no attribute 'setAttribute'
`
my layer.py
latitude="43.8808631897"
longitude="11.0972576141"
locationName="Piazza del duomo, 11"
locationURL="http://www.github.com"
locationEncoding="raw"
outLocation = (LocationMediaMessageProtocolEntity(latitude, longitude, locationName, locationURL, locationEncoding, to = recipient ))
self.toLower(outLocation)`
Patch is not working for Python3
Sending a image to a single contact works now, but sending a image to a group doesn't.
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer bytearray index out of range
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/protocol_media/mediauploader.py", line 202, in run
self.successCallback(sourcePath, self.jid, result)
File "/usr/local/lib/python2.7/dist-packages/yowsup/demos/cli/layer.py", line 558, in <lambda>
successFn = lambda filePath, jid, url: self.doSendMedia(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
File "/usr/local/lib/python2.7/dist-packages/yowsup/demos/cli/layer.py", line 545, in doSendMedia
self.toLower(entity)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 136, in send
send(entity)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/protocol_media/layer.py", line 35, in sendMessageEntity
self.entityToLower(entity)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 140, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer_send.py", line 87, in send
self.handleEncNode(node)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer_send.py", line 54, in handleEncNode
ciphertext = sessionCipher.encrypt(messageData)
File "/usr/local/lib/python2.7/dist-packages/axolotl/sessioncipher.py", line 49, in encrypt
senderEphemeral = sessionState.getSenderRatchetKey()
File "/usr/local/lib/python2.7/dist-packages/axolotl/state/sessionstate.py", line 67, in getSenderRatchetKey
return Curve.decodePoint(bytearray(self.sessionStructure.senderChain.senderRatchetKey), 0)
File "/usr/local/lib/python2.7/dist-packages/axolotl/ecc/curve.py", line 35, in decodePoint
type = _bytes[0] # byte appears to be automatically converted to an integer??
IndexError: bytearray index out of range
self.sessionStructure.senderChain.senderRatchetKey is empty. Any Ideas?
Have applied the patch but when I send the image, the recipient is not getting anything
my screen output is as follows
filesize:42010
42010
b64Hash:mwXun4J65HlNigdco+sWWkxLxgrleb59rV40ljIyjFQ=
file_enc_sha256:9b05ee9f827ae4794d8a075ca3eb165a4c4bc60ae579be7dad5e349632328c54
_media_sender.py_ [INFO][2017-09-10 13:45:54,990] [Upload progress]0fef0b77b0eac1f2c0a9bd99a255e34b.gif => [email protected], 100%
{'mimetype': u'application/octet-stream', 'name': None, 'filehash': u'mwXun4J65HlNigdco+sWWkxLxgrleb59rV40ljIyjFQ=', 'url': u'https://mmg.whatsapp.net/d/f/Aml25cbveniWycTZzhi_RXTzK1qAf87HH-wH3bYHz8jT.enc', 'height': None, 'width': None, 'error': None, 'type': u'encrypted', 'size': u'42010'}
mediakey:1f28794282a07f969fb00ff33cf5416163a842b3d115e0b05c1e38a79d60aeb9
mimetype:image/gif
filehash:abf526cd0c5184cb51a81e6c57ee03e7a1d760a1bf909fdab443e16454629037
file_enc_sha256:9b05ee9f827ae4794d8a075ca3eb165a4c4bc60ae579be7dad5e349632328c54
MIME:image/gif
Masuk enc
mimeType: image/gif
masuk ENC
Here is the whole working Repo (image only): https://github.com/dietzi/yowsup
Now I'm trying to send audio. I get no error but the message never receives....
Command for sending image:
./yowsup-cli demos -y -c /path/to/config
/L
/image send 49170xxxxxxxx image.jpg
why we should use your repo?
even the tgalal repo (patch) now sends the pictures
Sending images now working but still got issues with image/gif. The message is not being delivered, no errors.
Meaning we still have 3 issues
Caption works lol!

@ventrixcode do you have diff that works the caption?
Okay so I made all changes in your diff, but It isn't working at Python 3 at all.
First I had to replace unicode(...) by bytes(...) that I can run yowsupcli
But now I can't send any text message nor recive anything.
Program is always crashing.
(Example Crash: TypeError: ord() expected string of length 1, but int found)
Image send also fails (return s + (16 - len(s) % 16) * chr(16 - len(s) % 16) TypeError: can't concat bytes to str)
@AragurDEV
Replace your pad with:
def pad(self,s):
y = (16 - len(s) % 16) * chr(16 - len(s) % 16)
a = s + y.encode()
return a
Greetings from Germany
@pabloruan0710
I will try to send diff tommorow ;)
_Edit: I cant figure out what i had changed... Will try my best _
@ventrixcode
Thank you but now I'm faling at this step:
AttributeError: 'Message' object has no attribute 'image_message'
Greetings from Germany too ;)
Use this wa_pb2.py in yowsup/layers/protocol_messages/proto
@ventrixcode Thanks your wa_pb2.py is working fine for me. But sending an image to a group is not working.
(Added you on Discord)
The caption is working. If you are using yowsup-cli to test yowsup-cli you are not passing the caption parameter to the function.
yowsup / demos / cli / layer.py
current function
@clicmd ("Send an image with optional caption")
    def image_send (self, number, path, caption = None):
        self.media_send (number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_IMAGE)
new function
@clicmd ("Send an image with optional caption")
    def image_send (self, number, path, caption = None):
        self.media_send (number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_IMAGE, caption)
@leogaletti It's not working neither
Works for me! Thanks
Em 12 de set de 2017, Ã (s) 12:36, AragurDEV <[email protected]notifications@github.com> escreveu:
@leogalettihttps://github.com/leogaletti It's not working neither
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/tgalal/yowsup/issues/2149#issuecomment-328884352, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH-wDK3JSWLg9P8ZZHcLHsK_FOLy2RVkks5shqN3gaJpZM4OWLf4.
can send imange but cannot receive image
AttributeError: 'ImageDownloadableMediaMessageProtocolEntity' object has no attribute 'getMediaContent'
I think we cant send Images to Group because the storageprotos_pb2.py in axolotl is outdated.
@ventrixcode so you mean this file? https://github.com/tgalal/python-axolotl/blob/master/axolotl/state/storageprotos_pb2.py
@leogaletti Thanks its working
I made changes in library as specified in https://pastebin.com/pVxryQ12 by @bahtiarp. I managed to send image to some numbers. Thanks for the diff helped alot :)
But it gives the following error many times:
Error occured at transfer bytearray index out of range
Please help!!
@AragurDEV Yes this!
@drashtived Maybe the "chat" is a group?
@ventrixcode No I am sending to a single user. I see this on console
Error occured at transfer bytearray index out of range
Upload file failed!image.jpg [email protected] https://mmg.whatsapp.net/u/f/gcmCG7cVKzsWt5mDCWaDglm5I3kABVkRPYmPnQ/AhP8NZqLXz_rpIdcrmH-Am1kmCly-JL0HwGg4UMY3bUq
Working fine now in Python 3.6.2.
I have been forked Yowsup and pushed my code version, feel free to clone:
https://github.com/alancpazetto/yowsup
Thanks for all.
@alancpazetto Nope send Image to Group is still broken!
@ventrixcode Sorry about that, I didn't test to groups, only for contacts.
I got sending to group working.
Just download my fork: https://github.com/AragurDEV/yowsup
Or look at my commit: https://github.com/AragurDEV/yowsup/commit/40dd8680bd3d0242da9691584c16e96a03dde9e0
layer_send.py starting line 51
If you need any assistance jump on our support discord: https://discord.gg/Wa7QSxZ
Now I can send audio-files. But only those are generated by WhatsApp-App. If i try to send a mp3 or something else it doesn't download the message. I had send a "voice-file" from my WhatsApp via e-mail and sent this file back to the phone via yowsup.
/audio send 4917*** voice.opus
See my Repo for changes (https://github.com/dietzi/yowsup)
Changes have to be done here for sending mp3: https://github.com/dietzi/yowsup/blob/master/yowsup/layers/protocol_media/protocolentities/message_media_downloadable_audio.py#L109
Got it. The error was on generating the encryption-key. See here: https://github.com/dietzi/yowsup/blob/master/yowsup/layers/protocol_media/mediauploader.py#L55
Now sending audio work's
Only we have to implement a function to get the duration of the audio-file
Please make an new Issue then, wrong Issue
@dietzi add me on Discord VentrixCode#6897
@tgalal you can Close this Issue i think!
@AragurDEV Hi, i fork your code, i got error "hex() argument can't be converted to hex", what i missing?
/yowsup-master/yowsup/structs/protocoltreenode.py", line 56, in toString
val = ''.join(['%' + hex(b)[2:] for b in val])
TypeError: hex() argument can't be converted to hex
@AragurDEV @mhuzqu
@AragurDEV Hi, i fork your code, i got error "hex() argument can't be converted to hex", what i missing?
I have the same error when trying to run the script. Could you share with us the only part that you chaged to get the groups working
@mhuzqu @drmaposa
which Python version are you using?
And also can i please get the complete dump?
And also detailed information in what you are doing?
@drmaposa
I dindn't change anything else. I tested it with Python 3.4 and it works fine.
Hi @AragurDEV i use Python 2.7, then i jump to use python3 version 3.6.1 dan install pip3, send message work fine (when used 2.7 are fail), then i try send image using "/image send path/file.jpg" still error:
[connected]:/image send xxnumberxx /opt/img.jpg
ERROR:yowsup.common.optionalmodules:PIL import failed100%
ERROR:yowsup.common.optionalmodules:PIL import failed
the error caused pillow module is not installed, so i run the "pip3 install pillow", then try send image. viola, send images work perfectly.... awesome @AragurDEV thankyou...
@drmaposa try to install python3, install pip3, install pillow via pip3, should work.....
@mhuzqu As you can see in the README.md:
Required python packages for yowsup-cli: argparse, readline (or pyreadline for windows), pillow (for sending images)
So my fork only works with Python 3 not Python 2.7? Maybe I should investegate that.
@AragurDEV yups, your code doesn't work on python 2.7.
In my case, on python2 pillow already installed, when i install the python3, i forgot to install pillow.
when we run yowsup using this command below:
python3 yowsup-cli demos -c yowsup-cli_1.config -s xxnumberxxx "sending message"
would you please tell me which class and method in Yowsup will be execute?
@mhuzqu
What do you mean by that?
would you please tell me which class and method in Yowsup will be execute?
Also I would be pleased if you can send me the full crash on python 2.7 (I'm currently at work and can't test it)
@AragurDEV i mean, i tried to figure out when we use command ' _phyton yowsup-cli demos -c config.config -s xxnumberxx "message"_ ', is that command execute the method onSendAndExit located in /yowsup/demos/cli/layer.py or another method in another class ??
here is the trace log:
Traceback (most recent call last):
File "yowsup-cli", line 368, in
if not parser.process():
File "yowsup-cli", line 272, in process
self.startSendClient()
File "yowsup-cli", line 324, in startSendClient
stack.start()
File "/yowsup/demos/sendclient/stack.py", line 31, in start
self.stack.loop()
File "/yowsup/stacks/yowstack.py", line 196, in loop
asyncore.loop(args, *kwargs)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 216, in loop
poll_fun(timeout, map)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 162, in poll
write(obj)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 95, in write
obj.handle_error()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 91, in write
obj.handle_write_event()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 467, in handle_write_event
self.handle_connect_event()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 455, in handle_connect_event
self.handle_connect()
File "/yowsup/layers/network/layer.py", line 82, in handle_connect
self.emitEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECTED))
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 94, in emitEvent
self.__upper.emitEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 88, in emitEvent
if self.__upper and not self.__upper.onEvent(yowLayerEvent):
File "/yowsup/layers/__init__.py", line 212, in onEvent
stopEvent = stopEvent or s.onEvent(yowLayerEvent)
File "/yowsup/layers/__init__.py", line 109, in onEvent
return self.event_callbackseventName
File "/yowsup/layers/auth/layer_authentication.py", line 57, in onConnected
self.login()
File "/yowsup/layers/auth/layer_authentication.py", line 63, in login
self._sendAuth()
File "/yowsup/layers/auth/layer_authentication.py", line 110, in _sendAuth
self.entityToLower(AuthProtocolEntity(self.credentials[0], passive=passive, nonce=authBlob))
File "/yowsup/layers/__init__.py", line 140, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/yowsup/layers/axolotl/layer_send.py", line 115, in send
self.toLower(node)
File "/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/yowsup/layers/axolotl/layer_control.py", line 34, in send
self.toLower(node)
File "/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/yowsup/layers/logger/layer.py", line 8, in send
logger.debug("tx:\n%s" % ldata)
File "/yowsup/structs/protocoltreenode.py", line 90, in __str__
return self.toString()
File "/yowsup/structs/protocoltreenode.py", line 56, in toString
val = ''.join(['%' + hex(b)[2:] for b in val])
TypeError: hex() argument can't be converted to hex
@mhuzqu Thank you for your trace log - I will investegate this.
Here you can find the callbacks called when enter a command in the yowsup cli: https://github.com/AragurDEV/yowsup/blob/master/yowsup/demos/cli/layer.py
@drmaposa
I dindn't change anything else. I tested it with Python 3.4 and it works fine.
I have Python 2.7 and can we work out a solution for both Python 2 and 3
@drmaposa
Could you please add print repr(b) ahead of line 56 in "/yowsup/structs/protocoltreenode.py", recompile, install yowsup and send me the output? (before the crash happens)
hiii @drmaposa
File "/tested/yowsup/layers/logger/layer.py", line 8, in send
logger.debug("tx:\n%s" % ldata)
File "/tested/yowsup/structs/protocoltreenode.py", line 91, in __str__
return self.toString()
File "/tested/yowsup/structs/protocoltreenode.py", line 56, in toString
print repr(b)
UnboundLocalError: local variable 'b' referenced before assignment
okay sry I made a mistake
instead print repr(b)
paste this:
for b in val:
print repr(b)
here the output:
't'
'r'
'u'
'e'
Traceback (most recent call last):
@mhuzqu
Seems wired...
Can you please compare it with the output from python3?
@AragurDEV i tried your code and on python 3.6 am getting the error after uploading the file;
assert dimensions, "Could not determine image dimensions"
AssertionError: Could not determine image dimensions
ERROR:yowsup.demos.cli.layer:Upload file sky_colors-wide copy.png to https://mmg.whatsapp.net/u/f/D0ySWW2HTXKeDFSgxfvPclm6eoIABVklr9YIKA/Auv38AmaNpCW38LsgI3h5RwLcn-uFBKMNC-NWuvE5S2f for [email protected] failed!
can you please help fix it ..
shekar
Ok now it worked after installing pillow
sudo pip install -I pillow
suggestion from https://github.com/tgalal/yowsup/issues/577
Thanks a lot for the great work guys ...
Now just need to see how to send image from run.py and layer.py
@AragurDEV yeah its wired..... with python3 the error is :
/yowsup-master/yowsup/structs/protocoltreenode.py", line 57
print repr(b)
^
SyntaxError: invalid syntax
hmmmmm
@mhuzqu Yes because Python 3 replaces print with a function, so print(repr(b)) is needed.
Hi
Can anybody help on how to add the SendImage function in the layer.py for implementing the send image on requesting in an interactive mode ..
for eg., user sends a message saying getimage and is should be in a position to call send_image function with file path and destination number/group
Would be really great if someone can help me on this..
Shekar
@AragurDEV there's nothing in console after i put the print(repr(b)) but send message success. so, is the python2 have a bug.... or what?? i think, just used the python3 then close the issue.
hii @shekar3110a
you should find the method onMessage in demos/cli/layer.py, then try to call image_send method, you have to hardcoded the parameter required image_send method for testing purpose.
with above scenario, i have success to interactive with, then you should able to explore based on you need.
Hi Mhuzqu
I managed to copy some function and try .. but it came through message sending and am getting error message sending failed here is my appended code;
def image_send(self, number, path, caption = None):
self.media_send(number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_IMAGE)
def media_send(self, number, path, mediaType, caption = None):
jid = number
entity = RequestUploadIqProtocolEntity(mediaType, filePath=path)
successFn = lambda successEntity, originalEntity: self.onRequestUploadResult(jid, mediaType, path, successEntity, originalEntity, caption)
errorFn = lambda errorEntity, originalEntity: self.onRequestUploadError(jid, path, errorEntity, originalEntity)
self._sendIq(entity, successFn, errorFn)
def onRequestUploadResult(self, jid, mediaType, filePath, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity, caption = None):
if resultRequestUploadIqProtocolEntity.isDuplicate():
self.doSendMedia(mediaType, filePath, resultRequestUploadIqProtocolEntity.getUrl(), jid,
resultRequestUploadIqProtocolEntity.getIp(), caption)
else:
successFn = lambda filePath, jid, url: self.doSendMedia(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
mediaUploader = MediaUploader(jid, self.getOwnJid(), filePath,
resultRequestUploadIqProtocolEntity.getUrl(),
resultRequestUploadIqProtocolEntity.getResumeOffset(),
successFn, self.onUploadError, self.onUploadProgress, async=False)
mediaUploader.start()
def onRequestUploadError(self, jid, path, errorRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
print ("Request upload for file %s for %s failed" % (path, jid))
def onUploadError(self, filePath, jid, url):
print ("Upload file %s to %s for %s failed!" % (filePath, url, jid))
def onUploadProgress(self, filePath, jid, url, progress):
sys.stdout.write("%s => %s, %d%% \r" % (os.path.basename(filePath), jid, progress))
sys.stdout.flush()
and am calling the function in the below way to send the image;
if message == 'hi':
answer = "Hi "+namemitt+" "
self.toLower(textmsg(answer, to = recipient ))
print ( datetime.datetime.now())
print (answer)
number = recipient
path = "/Users/chandrashekar/Downloads/yowsup-master/ussdn.png"
caption = "Testing"
self.image_send( number, path, caption)
not sure what am i missing ..help would be appreciated
@shekar3110a i just added the code below:
def onMessage(self, message):
.....
self.output("Sent delivered receipt"+" and Read" if self.sendRead else "", tag = "Message %s" % message.getId())
#send testing image_send
self.image_send("xxnumberxx", "/opt/img.jpg", "test")
should work....
@mhuzqu
am getting error
File "/Users/chandrashekar/Downloads/yowsup-master/layer.py", line 136, in onTextMessage
self.output("Sent delivered receipt"+" and Read" if self.sendRead else "", tag = "Message %s" % message.getId())
AttributeError: 'EchoLayer' object has no attribute 'output'
Exception ignored in:
AttributeError: 'Logger' object has no attribute 'flush'
@shekar3110a you miss something, try to get all source code from @AragurDEV here : https://github.com/AragurDEV/yowsup/blob/master/yowsup
use python3, install pillow, compile yowsup, then run your yowsup
hello, i have used this repository: https://github.com/dietzi/yowsup, i can send images to any contact, but on receiving i download the picture but i can not see it is as if it was corrupt.
This is the patch to send geolocation after the changes for sending images (enc)
@AragurDEV you can add this edit to your fork
@mhuzqu
I have done all those and successfully sent the picture message for both single and group using yawsup-cli
now am trying to integrate with independent application where i can reply with image for certain string when user sends me the message.
Shekar
@shekar3110a look here
https://github.com/tgalal/yowsup/issues/1648#issuecomment-226345506
Dear @langioletto , @mhuzqu and all the guys who made this happen to send the image .. finally got my script working ...
the problem was on the Upload progress
Changed from :
def onUploadProgress(self, filePath, jid, url, progress):
sys.stdout.write("%s => %s, %d%% \r" % (os.path.basename(filePath), jid, progress))
sys.stdout.flush()
To:
def onUploadProgress(self, filePath, jid, url, progress):
print("%s => %s, %d%% \r" % (os.path.basename(filePath), jid, progress))
#sys.stdout.flush()
it worked like a charm .. will try and fine tune the complete and upload it later ..
Thanks once again guys ..
Shekar
@langioletto
Thanks for your diff, I will look into it and add it to my fork asap.
@mhuzqu
Yes Python2 is acting wired. Maybe we should only support Python3 in the future, why bother with an old version?
@shekar3110a
I'm glad you got your script working. But maybe next time try to make an own issue or join my (newly created) discord channel for Yowsup support https://discord.gg/Wa7QSxZ
@AragurDEV
Sure, However, am not a core developer, just an amateur guy who likes some excited things and try and put different codes from great developer and try and build something they way I need..
Just started with Python only after downloading yowsup.. but happy to help where possible and share what i have learnt in the process
shekar
I am using fork from @dietzi and tested sending image is working but how do I deal with receive photo and save it to a folder?
@jcchua look here
https://github.com/tgalal/yowsup/issues/1648#issuecomment-226345506
You guys did a really good job here. Thanks
Hi All,
First of all i would like to Than @tgalal and @AragurDEV ++ all those members who were involved in making this Yowsup happen.
Secondly, i would like to thank all those guys whose scripts i had taken from various sources in the net to put to gather a server application where i could build the bot kind of stuff along with HTTP server for sending the alerts and stuff.
please find the scripts in the https://pastebin.com/wY5ehF8j
Please feel free to take the script and customise it to your needs
@shekar3110a great then, try to modify Yowsup as you need.
i am newbie in python too, my primary programming language is Java.
you link is useful..... great
@AragurDEV yes, that what i mean, someone should update the readme.md and put the PYTHON3 as requirement.
@mhuzqu Make a pull request on my repo
@AragurDEV great...
Hi everyone, meanwhile we thought that we could solve the issue of sending broadcast?
/message broadcast 40xxxxxxxxx,40xxxxxxxxx"Ciao"
[connected]:Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 368, in
if not parser.process():
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 268, in process
self.startCmdline()
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 297, in startCmdline
stack.start()
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/demos/cli/stack.py", line 26, in start
self.stack.loop(timeout = 0.5, discrete = 0.5)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/stacks/yowstack.py", line 188, 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.5.2-py2.7.egg/yowsup/layers/network/layer.py", line 102, in handle_read
self.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/network/layer.py", line 110, in receive
self.toUpper(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
self.processReceived()
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
self.toUpper(oneMessageData)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive
self.toUpper(payload)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-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.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-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.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive
self.toUpper(protocolTreeNode)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_send.py", line 118, in receive
if not self.processIqRegistry(protocolTreeNode):
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 163, in processIqRegistry
errorClbk(protocolTreeNode, originalIq)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_base.py", line 81, in onError
errorClbk(errorNode, getKeysEntity)
TypeError:() takes no arguments (2 given)
@langioletto try to use python3, not python2
>
File "/usr/local/bin/yowsup-cli", line 4, in
__import__('pkg_resources').run_script('yowsup2==2.5.2', 'yowsup-cli')
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 534, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1438, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 59, in execfile
exec(compile(open(fn).read(), fn, 'exec'), globs, locs)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/EGG-INFO/scripts/yowsup-cli", line 368, in
if not parser.process():
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/EGG-INFO/scripts/yowsup-cli", line 268, in process
self.startCmdline()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/EGG-INFO/scripts/yowsup-cli", line 297, in startCmdline
stack.start()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/demos/cli/stack.py", line 26, in start
self.stack.loop(timeout = 0.5, discrete = 0.5)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/stacks/yowstack.py", line 188, in loop
asyncore.loop(args, *kwargs)
File "/usr/lib/python3.4/asyncore.py", line 208, in loop
poll_fun(timeout, map)
File "/usr/lib/python3.4/asyncore.py", line 153, in poll
read(obj)
File "/usr/lib/python3.4/asyncore.py", line 87, in read
obj.handle_error()
File "/usr/lib/python3.4/asyncore.py", line 83, in read
obj.handle_read_event()
File "/usr/lib/python3.4/asyncore.py", line 442, in handle_read_event
self.handle_read()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/network/layer.py", line 102, in handle_read
self.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/network/layer.py", line 110, in receive
self.toUpper(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
self.processReceived()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
self.toUpper(oneMessageData)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive
self.toUpper(payload)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/coder/layer.py", line 35, in receive
self.toUpper(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/logger/layer.py", line 14, in receive
self.toUpper(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive
self.toUpper(protocolTreeNode)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_send.py", line 118, in receive
if not self.processIqRegistry(protocolTreeNode):
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 163, in processIqRegistry
errorClbk(protocolTreeNode, originalIq)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_base.py", line 81, in onError
errorClbk(errorNode, getKeysEntity)
TypeError:
@langioletto try changes in yowsup/layers/axolotl/layer_base.py", line 81:
remove this:
errorClbk(errorNode, getKeysEntity)
for this:
errorClbk()
Now no error, but the recipient receives nothing
[connected]:
/message broadcast 39xxxxxxxxxx,39xxxxxxxxxx Ciao
[connected]:Iq:
ID: 14
Type: result
from: [email protected]
Send it via boot
destinations=["39xxxxxxxxx", "39xxxxxxxxx"]
self.toLower(textmsg(answer, to = destinations ))
+ python3 /root/.yowsup/run.py
root@raspberrypi:~# Traceback (most recent call last):
File "/root/.yowsup/run.py", line 30, in <module>
stack.loop( timeout = 0.5, discrete = 0.5 ) #this is the program mainloop
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/stacks/yowstack.py", line 188, in loop
asyncore.loop(*args, **kwargs)
File "/usr/lib/python3.4/asyncore.py", line 208, in loop
poll_fun(timeout, map)
File "/usr/lib/python3.4/asyncore.py", line 153, in poll
read(obj)
File "/usr/lib/python3.4/asyncore.py", line 87, in read
obj.handle_error()
File "/usr/lib/python3.4/asyncore.py", line 83, in read
obj.handle_read_event()
File "/usr/lib/python3.4/asyncore.py", line 442, in handle_read_event
self.handle_read()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/network/layer.py", line 102, in handle_read
self.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/network/layer.py", line 110, in receive
self.toUpper(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
self.processReceived()
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
self.toUpper(oneMessageData)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive
self.toUpper(payload)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/coder/layer.py", line 35, in receive
self.toUpper(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/logger/layer.py", line 14, in receive
self.toUpper(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive
self.toUpper(protocolTreeNode)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 41, in receive
self.onMessage(protocolTreeNode)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 74, in onMessage
self.handleEncMessage(protocolTreeNode)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 88, in handleEncMessage
self.handleWhisperMessage(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 151, in handleWhisperMessage
self.parseAndHandleMessageProto(encMessageProtocolEntity, plaintext[:-padding])
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 195, in parseAndHandleMessageProto
self.handleConversationMessage(node, m.conversation)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_receive.py", line 224, in handleConversationMessage
self.toUpper(messageNode)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 194, in receive
s.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 130, in receive
recv(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/protocol_messages/layer.py", line 21, in recvMessageStanza
self.toUpper(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 79, in toUpper
self.__upper.receive(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/interface/interface.py", line 80, in receive
self.entity_callbacks[entityType](entity)
File "/root/.yowsup/layer.py", line 80, in onMessage
self.onTextMessage(messageProtocolEntity) #Send the answer
File "/root/.yowsup/layer.py", line 196, in onTextMessage
self.toLower(textmsg(answer, to = destinations ))
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 136, in send
send(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/protocol_messages/layer.py", line 15, in sendMessageEntity
self.entityToLower(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 140, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_send.py", line 100, in send
self.processPlaintextNodeAndSend(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_send.py", line 141, in processPlaintextNodeAndSend
recipient_id = node["to"].split('@')[0]
AttributeError: 'list' object has no attribute 'split'
@pabloruan0710 You are only "fixing" the error handling.
Broadcast messages are still failing.
WhatsApp retunrs following iq:
<iq type="error" id="2" from="s.whatsapp.net">
<error code="406" text="not-acceptable">
</error>
</iq>
@shekar3110a
ERROR:yowsup.demos.cli.layer:Request upload for file cat.jpg for [email protected] failed
DEBUG:yowsup.layers.logger.layer:rx:
< iq from="s.whatsapp.net" id="3" type="error" >
< error text="feature-not-implemented" code="501" >
< /error >
< /iq >
Any help?
Hi guys, Can we send videos with these changes? As i am trying to send a video .mp4 format i am getting the following error
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer 'NoneType' object has no attribute 'setAttribute'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/protocol_media/mediauploader.py", line 198, in run
self.successCallback(sourcePath, self.jid, result)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/demos/cli/layer.py", line 762, in <lambda>
successFn = lambda filePath, jid, url: self.doSendMedia(mediaType, filePath, url, jid, resultRequestUploadIqProtocolEntity.getIp(), caption)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/demos/cli/layer.py", line 749, in doSendMedia
self.toLower(entity)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 84, in toLower
self.__lower.send(data)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 198, in send
s.send(data)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 136, in send
send(entity)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/protocol_media/layer.py", line 35, in sendMessageEntity
self.entityToLower(entity)
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 140, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/usr/local/lib/python2.7/site-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/protocol_media/protocolentities/message_media_downloadable_video.py", line 84, in toProtocolTreeNode
mediaNode.setAttribute("encoding", self.encoding)
AttributeError: 'NoneType' object has no attribute 'setAttribute'
However I also tried installing ffvideo on my mac. However no luck. Can anyone help me in this regard?
Hi all,
I am using Aragur's fork. However, I recieve the following error with trying to send an image
Error occured at transfer bytearray index out of range
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/protocol_media/mediauploader.py", line 200, in run
self.successCallback(sourcePath, self.jid, result)
File "/home/parag/WhatsappClient/src/ImageLayer.py", line 37, in onUploadSuccess
self.toLower(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init.py", line 84, in toLower
self.lower.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init.py", line 198, in send
s.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init__.py", line 136, in send
send(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/protocol_media/layer.py", line 35, in sendMessageEntity
self.entityToLower(entity)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init.py", line 140, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init.py", line 84, in toLower
self.lower.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/init.py", line 198, in send
s.send(data)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_send.py", line 113, in send
self.handleEncNode(node)
File "/usr/local/lib/python3.4/dist-packages/yowsup2-2.5.2-py3.4.egg/yowsup/layers/axolotl/layer_send.py", line 73, in handleEncNode
ciphertext = sessionCipher.encrypt(messageData)
File "/usr/local/lib/python3.4/dist-packages/python_axolotl-0.1.39-py3.4.egg/axolotl/sessioncipher.py", line 49, in encrypt
senderEphemeral = sessionState.getSenderRatchetKey()
File "/usr/local/lib/python3.4/dist-packages/python_axolotl-0.1.39-py3.4.egg/axolotl/state/sessionstate.py", line 66, in getSenderRatchetKey
return Curve.decodePoint(bytearray(self.sessionStructure.senderChain.senderRatchetKey), 0)
File "/usr/local/lib/python3.4/dist-packages/python_axolotl-0.1.39-py3.4.egg/axolotl/ecc/curve.py", line 34, in decodePoint
type = _bytes[0] # byte appears to be automatically converted to an integer??
IndexError: bytearray index out of range
Upload file failed!/home/parag/WhatsappClient/src/image.jpg 919975172622 https://mmg.whatsapp.net/u/f/eXWecrAdfqeNVLH6lS06XFnBC1sABVmJ35AGLQ/AibQjuvZED-MhwvRGDJrhADq2rm6O9ZgRWDLADa0So
I tried switching to Python 3 as well. Anyone who faced and solved the same please help!
Use fork @AragurDEV
I am using his fork. Still getting this error
@AragurDEV can you help me in sending the video?
that fork does not have the patch
Yes it doesn't have it. But together we can achieve it.
together we can fix the broadcast
@drashtived
To fixe this error
> type = _bytes[0] # byte appears to be automatically converted to an integer??
> IndexError: bytearray index out of range
> Upload file failed!/home/parag/WhatsappClient/src/image.jpg 919975172622
You need to add this in handleEncNode method inside yowsup/layers/axolotl/layer_send.py file on line 70
if not self.store.containsSession(recipient_id,1):
self.getKeysFor([node["to"]], lambda successJids, b: self.sendToContact(node) if len(successJids) == 1 else self.toLower(node), la
mbda: self.toLower(node))
It is just an key exchange problem.
PS: I'm using AragurDEV (https://github.com/AragurDEV/yowsup/) rep.
Hi
can anybody help me with this error ??
serialized_pb=_b('\n\x08wa.proto\x12\x12\x63om.whatsapp.proto\"\x95\x04\n\x07Message\x12\x14\n\x0c\x63onversation\x18\x01 \x01(\t\x12Y\n\x1fsender_key_distribution_message\x18\x02 \x01(\x0b\x32\x30.com.whatsapp.proto.SenderKeyDistributionMessage\x12\x37\n\rimage_message\x18\x03 \x01(\x0b\x32 .com.whatsapp.proto.ImageMessage\x12;\n\x0f\x63ontact_message\x18\x04 \x01(\x0b\x32\".com.whatsapp.proto.ContactMessage\x12=\n\x10location_message\x18\x05 \x01(\x0b\x32#.com.whatsapp.proto.LocationMessage\x12=\n\x10\x64ocument_message\x18\x07 \x01(\x0b\x32#.com.whatsapp.proto.DocumentMessage\x12\x33\n\x0burl_message\x18\x06 \x01(\x0b\x32\x1e.com.whatsapp.proto.UrlMessage\x12\x37\n\raudio_message\x18\x08 \x01(\x0b\x32 .com.whatsapp.proto.AudioMessage\x12\x37\n\rvideo_message\x18\t \x01(\x0b\x32 .com.whatsapp.proto.VideoMessage\"`\n\x1cSenderKeyDistributionMessage\x12\x0f\n\x07groupId\x18\x01 \x02(\t\x12/\n\'axolotl_sender_key_distribution_message\x18\x02 \x02(\x0c\"\xb3\x01\n\x0cImageMessage\x12\x0b\n\x03url\x18\x01 \x02(\x0c\x12\x11\n\tmime_type\x18\x02 \x02(\t\x12\x0f\n\x07\x63\x61ption\x18\x03 \x02(\t\x12\x13\n\x0b\x66ile_sha256\x18\x04 \x02(\x0c\x12\x13\n\x0b\x66ile_length\x18\x05 \x02(\x04\x12\x0e\n\x06height\x18\x06 \x02(\r\x12\r\n\x05width\x18\x07 \x02(\r\x12\x11\n\tmedia_key\x18\x08 \x02(\x0c\x12\x13\n\x0b\x66ile_enc_sha256\x18\x09 \x02(\x0c\x12\x16\n\x0ejpeg_thumbnail\x18\x10 \x02(\x0c\"\xa6\x01\n\x0cVideoMessage\x12\x0b\n\x03url\x18\x01 \x02(\x0c\x12\x11\n\tmime_type\x18\x02 \x02(\t\x12\x13\n\x0b\x66ile_sha256\x18\x03 \x02(\x0c\x12\x13\n\x0b\x66ile_length\x18\x04 \x02(\x04\x12\x10\n\x08\x64uration\x18\x05 \x02(\x04\x12\x11\n\tmedia_key\x18\x06 \x02(\x0c\x12\x0f\n\x07\x63\x61ption\x18\x07 \x02(\t\x12\x16\n\x0ejpeg_thumbnail\x18\x10 \x02(\x0c\"\x8a\x01\n\x0c\x41udioMessage\x12\x0b\n\x03url\x18\x01 \x02(\x0c\x12\x11\n\tmime_type\x18\x02 \x02(\t\x12\x13\n\x0b\x66ile_sha256\x18\x03 \x02(\x0c\x12\x13\n\x0b\x66ile_length\x18\x04 \x02(\x04\x12\x10\n\x08\x64uration\x18\x05 \x02(\x04\x12\x0b\n\x03unk\x18\x06 \x02(\r\x12\x11\n\tmedia_key\x18\x07 \x02(\x0c\"\x8a\x01\n\x0fLocationMessage\x12\x18\n\x10\x64\x65grees_latitude\x18\x01 \x02(\x01\x12\x19\n\x11\x64\x65grees_longitude\x18\x02 \x02(\x01\x12\x0c\n\x04name\x18\x03 \x02(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x04 \x02(\t\x12\x0b\n\x03url\x18\x05 \x02(\t\x12\x16\n\x0ejpeg_thumbnail\x18\x10 \x02(\x0c\"\xa9\x01\n\x0f\x44ocumentMessage\x12\x0b\n\x03url\x18\x01 \x02(\t\x12\x11\n\tmime_type\x18\x02 \x02(\t\x12\r\n\x05title\x18\x03 \x02(\t\x12\x13\n\x0b\x66ile_sha256\x18\x04 \x02(\x0c\x12\x13\n\x0b\x66ile_length\x18\x05 \x02(\x04\x12\x12\n\npage_count\x18\x06 \x02(\r\x12\x11\n\tmedia_key\x18\x07 \x02(\x0c\x12\x16\n\x0ejpeg_thumbnail\x18\x10 \x02(\x0c\"\x83\x01\n\nUrlMessage\x12\x0c\n\x04text\x18\x01 \x02(\t\x12\x14\n\x0cmatched_text\x18\x02 \x02(\t\x12\x15\n\rcanonical_url\x18\x04 \x02(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x02(\t\x12\r\n\x05title\x18\x06 \x02(\t\x12\x16\n\x0ejpeg_thumbnail\x18\x10 \x02(\x0c\"5\n\x0e\x43ontactMessage\x12\x14\n\x0c\x64isplay_name\x18\x01 \x02(\t\x12\r\n\x05vcard\x18\x10 \x02(\x0c')
File "/home/maria/Documentos/whatstelegram/venv/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 829, in __new__
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't parse file content!
I was able to send video by doing some changes however it says "Download Failed" the download was unable to complete please try again later. Any help?
This is caused by a encryption key mismatch
@AragurDEV @fmachadodev thanks a ton!! I am now able to send image .
It still throws error but the image goes through
Can you please paste your error on Pastebin?
Hi All,
Is any fork send audio or video? I am using Aragur's fork and I can send image ok, but audio and video doesn't working for me.
Has anyone been able to send audio and video?
Using different pieces of code from different forks, i have been able to send images, video messages.If anyone is still interested, https://github.com/fenilgandhi/Websup you can use the yowsup folder from this repo.
Also i had to add a new layer which can be found in Clientapp/yowsup_integration
@fenilgandhi, can you send audio and video on your fork?
thanks
@fmachadodev I have been sending images for the last month. As for the video only few selected videos can be sent but i'm still facing some issues as sometimes they are not received. 6/10 times whatsapp disconnects me as i start the upload for the video but i had success a few times. I will push an update as soon i get a stable solution for video.
Note: While testing for video integration, i got my 3 numbers banned in last 7 days.
@AragurDEV and @fenilgandhi I made all step to send video as enc v2 message. The upload of video message is working, i'm receiving ack from whatsapp and receiving "receipt" ack from whatsapp too, but I did not receive the video on my phone.
If you could help me, I will appreciate
my proto object is
video_message {
url: "https://mmg-fna.whatsapp.net/d/f/AmoYTrb1SHuZSsLNv3-Hc-wgtL3KayKUwKda3ZvCvfSc.enc"
mime_type: "video/mp4"
caption: ""
file_sha256: "\210\305\324\3334;\273\345q\371\266\'\306\316\301\036dsn\257s)\034;\377_\376\004U:4\265"
file_length: 379987
height: 304
width: 400
duration: 29977000
vbitrate: 101407
abitrate: 165
vcodec: "h264"
acodec: "aac"
media_key: "\245HL\005\377z\303x\017\\)\020\235\004\'\246\021t,U\220\201\t336\"G\264%365327\"
file_enc_sha256: "\006\005>314y\207?y\031\007d315316\273]375\277331W347\243322x\200374\254>374302\230314\t"
jpeg_thumbnail:....`
the xml created is
<message type="media" to="[email protected]" id="1508298888-2">
<enc mediatype="video" v="2" type="msg">
....
</enc>
</message>
I received yowsup ack
DEBUG:yowsup.layers.logger.layer:rx:
<receipt from="[email protected]" t="1508298900" id="1508298857-2">
</receipt>
and I receive 'receipt confirmation'
DEBUG:yowsup.layers.logger.layer:tx:
<ack class="receipt" to="[email protected]" id="1508298857-2">
</ack>
let me know if you need more information
@fmachadodev, I'm pretty sure you don't need to send "vbitrate", "abitrate", "vcodec" and "acodec"
@Nicos-git, thanks for replying, you are right. I'm already able to send video messages, but, only for android users. The iphone users can't download the video when I send using yowsup.
I will try to fix this problem with Iphone Users and I will make a pull request to @AragurDEV repo.
@Nicos-git @fenilgandhi @AragurDEV @gitanderson
I fixed the video sending functionality and already made a pull request to @AragurDEV repo. But you can clone my repository if you need the send videos.
If someone has managed to send audio? If so, share the code please
Hello, I managed to send audio file, I still need to fix duration attribute to got 100%.
I managed to implement others things too, like: receive image, video, location, vcard.
For document I receive but it don't open (I don't know if is decrypt problem or mimetype probleam), about send document, I am able to send pdf file for now, but I need to do more tests yet.
Soon I will share the code.
Ps. Maybe the code is not the best because I'm new to Python.
btw, i got my numbers cannot login (not-authorized) today, but not blocked. never happend before. is it only me?
Had the same problem resolved after updating the latest repository
On Nov 9, 2017 11:00 AM, "bahtiarp" notifications@github.com wrote:
btw, i got my numbers cannot login (not-authorized) today, but not
blocked. never happend before. is it only me?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tgalal/yowsup/issues/2149#issuecomment-343051552, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AeeqrV1HUToUTmKhdg5BStwz0x-GSQ6gks5s0o3wgaJpZM4OWLf4
.
Hi, when I send an image to yowsup I get this error
File "/usr/local/lib/python3.5/dist-packages/yowsup2-2.5.2-py3.5.egg/yowsup/layers/interface/interface.py", line 80, in receive
self.entity_callbacks[entityType](entity)
File "/root/.yowsup/layer.py", line 74, in onMessage
self.onTextMessage(messageProtocolEntity) #Send the answer
File "/root/.yowsup/layer.py", line 387, in onTextMessage
self.getMediaMessage(messageProtocolEntity)
File "/root/.yowsup/layer.py", line 128, in getMediaMessage
return self.getDownloadableMediaMessageBody(messageProtocolEntity)
File "/root/.yowsup/layer.py", line 138, in getDownloadableMediaMessageBody
f.write(self.getMediaContent(self.url))
File "/root/.yowsup/layer.py", line 166, in getMediaContent
data = urlopen(self.url).read()
File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.5/urllib/request.py", line 457, in open
req.timeout = timeout
AttributeError: 'bytes' object has no attribute 'timeout'
With py2.7 the image is instead received saved
@aarcwb
what changes you've made to receive images, videos, etc and so on?
Thank you
Try change data = urlopen(self.url).read()
for
urlopen(self.url.decode('ASCII')).read()
Ok, work!!!
Very thanks!!
I managed to implement others things too, like: receive image, video, location, vcard.
For document I receive but it don't open (I don't know if is decrypt problem or mimetype probleam), about send document, I am able to send pdf file for now, but I need to do more tests yet.
@aarcwb When do you see your code? :)
@shekar3110a What repository are you using? I'm getting the AuthError: not-authorized for a registered number for the last 2 days. Thank you.
try to delete
axolotl.db
ex: /root/.yowsup/44xxxxxxxxxx
Deleted the axolotl.db file, but to no avail. It just keeps getting re-created and the _'yowsup.layers.auth.autherror.AuthError: not-authorized'_ keeps getting thrown again. The phone number I'm using is definitely registered properly. I suspect the env configuration or the keys changed or blocked by WhatsApp...
No, because I'm working
Try using the number on a phone
Suggestion here solved my problem (#2319):
This seems to sort it out.. _VERSION = "2.16.12" _OS_NAME= "S40" _OS_VERSION = "14.26" _DEVICE_NAME = "302" _MANUFACTURER = "Nokia" _TOKEN_STRING = "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1494451854337{phone}" _AXOLOTL = True
Hi @langioletto
with which repository did it work?
https://github.com/tgalal/yowsup/issues/2149#issuecomment-343722402
Regards
AragurDEV
@aarcwb do you can send pdf?
@pabloruan0710 Yes, I managed to implement all yowsup features.
Now I have been working in chat api (php), I managed to login, send message, I amplemented upload enc file and the next step, I will try to send image.
today i got an error when sending and image.
File "/home/dev/WA/py/yowsup-master/yowsup/layers/protocol_media/mediauploader.py", line 204, in run
raise Exception("json data not found")
Exception: json data not found
is this only me?
@bahtiarp I'm having this issue too
I have this error @bahtiarp
Got this when upluad:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Thu, 16 Nov 2017 09:44:16 GMT
X-FB-Use-Regional: 0
Connection: close
Content-Length: 0
seems this: "X-FB-Use-Regional", new header, any clue what is this?
is there anyone still can "send media"?
@bahtiarp @danielcardeenas @pabloruan0710
what repository are you using? because I still can send media files
i try my own repo and also try @AragurDEV repo, the result is the same. What repo did you use?
@AragurDEV repo.
@fmachadodev and work today with @AragurDEV repo?
@pabloruan0710 @bahtiarp . Sorry, it really not sending media messages.
I get same error of @bahtiarp
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer json data not found
Traceback (most recent call last):
File "yowsup/yowsup/layers/protocol_media/mediauploader.py", line 204, in run
raise Exception("json data not found")
Exception: json data not found
I am getting the same error as @bahtiarp , is anyone able to sent media with no errors?
my numbers are blocked after the first shipment, please help me
I'm using @AragurDEV repo
Same issue
----------------------------------Request------------------------------------
POST https://mmg.whatsapp.net/u/f/91V0Jb-eB8QWv7dE7wbv2VoWssMABV6k2Tu7cw/AhBhglftWZi7k2M65u2A_spaH46o8RTpMJNBE9Abv1qC?f=j
Content-Type: multipart/form-data; boundary=-------6ece948418700ed0b17e55af4329e3f6
Host: mmg.whatsapp.net
User-Agent: WhatsApp/2.16.12 S40Version/14.26 Device/Nokia-302
Content-Length: 166490
-----------------------------Response--------------------------------------------
b'HTTP/1.1 400 Bad Request\r\nContent-Type: application/json\r\nDate: Thu, 23 Nov 2017 11:36:36 GMT\r\nX-FB-Use-Regional: 1\r\nConnection: close\r\nContent-Length: 0\r\n\r\n'
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer json data not found
Traceback (most recent call last):
File "/home/rahil/Documents/whatsapp/developBranch/yowsup/layers/protocol_media/mediauploader.py", line 189, in run
raise Exception("json data not found")
Exception: json data not found
ERROR:yowsup.demos.cli.layer:Upload file /home/rahil/Pictures/IMG_72348.png to https://mmg.whatsapp.net/u/f/91V0Jb-eB8QWv7dE7wbv2VoWssMABV6k2Tu7cw/AhBhglftWZi7k2M65u2A_spaH46o8RTpMJNBE9Abv1qC?f=j for [email protected] failed!
Same problem
Upload file /root/.yowsup/fanculo.jpg to https://mmg.whatsapp.net/u/f/yJ4hYCsBDsw3H0QyjPiNVloXOfwABV6s6IrL8A/AuTb21zxuS_O70Jg7HKYhP9gFOkdcpk0KDy-bVj4q9SV for [email protected] failed!
PY3.5 o PY2.7 do not send image
Position works
yesterday new disa version
https://github.com/seaneliasson/seaneliasson.github.io
Disa.Framework.WhatsApp.Mobile-1124.dpk
@bahtiarp
you can kindly check what they have changed in Disa.Framework.WhatsApp.Mobile-1124.dpk for sending pictures to Whatsapp?
Very thanks!!
If someone can decompile it and provide the source code that would be awesome
You can unzip the *.dpk file and decompile the *.dll with dotPeek
I made some modifications in mediauploader.py and I am able to send media.
@danielcardeenas
It's been done here already
https://github.com/tgalal/yowsup/issues/2149#issuecomment-327080038
@aarcwb
Can you kindly give your diff?
Judging from the web version, looks like there are some missing headers during the POST call.
In my solution I lost upload progress (1%...10%) because now I send hBAOS + encFile + fBAOS in just one request (requests.post(...)), bellow the code:
Needed to remove commented lines.
def run(self):
sourcePath = self.sourcePath
uploadUrl = self.uploadUrl
#_host = uploadUrl.replace("https://","")
#self.url = _host[:_host.index('/')]
#print("URL UPLOAD")
#print(uploadUrl)
try:
filename = os.path.basename(sourcePath)
filetype = MimeTools.getMIME(filename)
f = open(sourcePath, 'rb')
stream = f.read()
f.close()
refkey = binascii.hexlify(os.urandom(32))
stream=self.encryptMedia(stream,refkey,filetype)
fenc = open(sourcePath+".enc", 'wb') # bahtiar
fenc.write(stream)
fenc.seek(0, 2)
filesize=fenc.tell()
fenc.close()
print(sourcePath+".enc")
#os.remove(sourcePath+".enc")
filesize2=len(stream)
sha1 = hashlib.sha256()
sha1.update(stream)
b64Hash = base64.b64encode(sha1.digest())
file_enc_sha256 = hashlib.sha256(stream).hexdigest()
#self.sock.connect((self.url, self.port))
#ssl_sock = ssl.wrap_socket(self.sock)
m = hashlib.md5()
m.update(filename.encode())
crypto = m.hexdigest() + os.path.splitext(filename)[1]
#boundary = "zzXXzzYYzzXXzzQQ"#"-------" + m.hexdigest() #"zzXXzzYYzzXXzzQQ"
#contentLength = 0
digTo = hmac.new("".encode("utf-8"), self.jid.replace("@s.whatsapp.net", "@c.us").encode("utf-8"),
hashlib.sha256).digest()[:20]
refTo = base64.b64encode(digTo).decode()
digFrom = hmac.new("".encode("utf-8"), self.accountJid.replace("@s.whatsapp.net", "@c.us").encode("utf-8"),
hashlib.sha256).digest()[:20]
refFrom = base64.b64encode(digFrom).decode()
#hBAOS = "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"hash\"\r\n\r\n"
#hBAOS += b64Hash.decode() + "\r\n"
#hBAOS += "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"refs\"\r\n\r\n"
#hBAOS += refFrom + "\r\n"
#hBAOS += refTo + "\r\n"
#hBAOS += "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "blob" + "\"\r\n"
#hBAOS += "Content-Type: " + "application/octet-stream" + "\r\n\r\n"
#fBAOS = "\r\n------" + boundary + "--"
#contentLength += len(hBAOS)
#contentLength += len(fBAOS)
#contentLength += filesize
#POST = "POST %s\r\n" % uploadUrl
#POST += "Content-Type: multipart/form-data; boundary=------" + boundary + "\r\n"
#POST += "Host: %s\r\n" % self.url
#POST += "User-Agent: %s\r\n" % self.getUserAgent()
#POST += "Content-Length: " + str(contentLength) + "\r\n\r\n"
#print(POST)
#print(hBAOS)
#ssl_sock.write(bytearray(POST.encode()))
#ssl_sock.write(bytearray(hBAOS.encode()))
#totalsent = 0
#buf = 1024
#status = 0
#lastEmit = 0
#while totalsent < int(filesize):
# ssl_sock.write(stream[:buf])
# status = totalsent * 100 / filesize
# if lastEmit!=status and status!=100 and filesize>12288:
# if self.progressCallback:
# self.progressCallback(self.sourcePath, self.jid, uploadUrl, int(status))
# lastEmit = status
# stream = stream[buf:]
# totalsent = totalsent + buf
#ssl_sock.write(bytearray(fBAOS.encode()))
#sleep(1)
#data = ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#if self.progressCallback:
# self.progressCallback(self.sourcePath, self.jid, uploadUrl, 100)
hBAOS = "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"hash\"\r\n\r\n"
hBAOS += b64Hash.decode() + "\r\n"
hBAOS += "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"refs\"\r\n\r\n"
hBAOS += refTo + "\r\n"
hBAOS += refFrom + "\r\n"
hBAOS += "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "blob" + "\"\r\n"
hBAOS += "Content-Type: " + "application/octet-stream" + "\r\n\r\n"
fBAOS = "\r\n------zzXXzzYYzzXXzzQQ--"
contentLength = len(hBAOS) + len(fBAOS) + len(stream)
headers = {
"content-length": contentLength,
"user-agent": self.getUserAgent(),
"content-type": "multipart/form-data; boundary=----zzXXzzYYzzXXzzQQ"}
data = bytearray(hBAOS, 'utf-8') + stream + bytearray(fBAOS, 'utf-8')
response = requests.post(uploadUrl, data=data, headers=headers)
#lines = data.decode().splitlines()
result = None
#for l in lines:
# if l.startswith("{"):
# result = self.parser.parse(l, self.pvars)
# break
if response.text.startswith("{"):
result = self.parser.parse(response.text, self.pvars)
if not result:
raise Exception("json data not found")
if result["url"] is not None:
if self.successCallback:
# self.successCallback(sourcePath, self.jid, result["url"])
result["mediaKey"]=refkey
result["file_enc_sha256"]=file_enc_sha256
self.successCallback(sourcePath, self.jid, result)
else:
logger.exception("uploadUrl: %s, result of uploading media has no url" % uploadUrl)
if self.errorCallback:
self.errorCallback(sourcePath, self.jid, uploadUrl)
except:
logger.exception("Error occured at transfer %s"%sys.exc_info()[1])
if self.errorCallback:
self.errorCallback(sourcePath, self.jid, uploadUrl)
@aarcwb works for me, but have change headers contentLength for string
headers = {
"content-length": str(contentLength),
"user-agent": self.getUserAgent(),
"content-type": "multipart/form-data; boundary=----zzXXzzYYzzXXzzQQ"}
you can post the file mediauploader.py full?
with the changes the definition
def encryptImg (self, img, refkey):
is not correct
Thanks!!
@langioletto follow code.
from yowsup.common.http.warequest import WARequest
from yowsup.common.http.waresponseparser import JSONResponseParser
import socket, ssl, os, hashlib, sys
from time import sleep
import threading
import logging
import requests
from yowsup.common.tools import MimeTools
import base64
import hmac
from Crypto.Cipher import AES
import binascii
from axolotl.kdf.hkdfv3 import HKDFv3
from axolotl.sessioncipher import pad
from axolotl.util.byteutil import ByteUtil
from .protocolentities.message_media_downloadable import DownloadableMediaMessageProtocolEntity
logger = logging.getLogger(__name__)
class MediaUploader(WARequest, threading.Thread):
def __init__(self, jid, accountJid, sourcePath, uploadUrl, resumeOffset = 0, successClbk = None, errorClbk = None, progressCallback = None, async = True):
WARequest.__init__(self)
self.async = async
self.jid = jid
self.accountJid = accountJid
self.sourcePath = sourcePath
self.uploadUrl = uploadUrl
self.resumeOffset = resumeOffset
self.successCallback = successClbk
self.errorCallback = errorClbk
self.progressCallback = progressCallback
self.pvars = ["name", "type", "size", "url", "error", "mimetype", "filehash", "width", "height"]
self.setParser(JSONResponseParser())
self.sock = socket.socket()
def start(self):
if self.async:
threading.Thread.__init__(self)
super(MediaUploader, self).start()
else:
self.run()
def pad(self,s):
# return s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
y = (16 - len(s) % 16) * chr(16 - len(s) % 16)
a = s + y.encode()
return a
def getKey(self, filetype):
print("FILE TYPE")
print(filetype)
if "video" in filetype:
return DownloadableMediaMessageProtocolEntity.VIDEO_KEY
elif "image" in filetype:
return DownloadableMediaMessageProtocolEntity.IMAGE_KEY
elif "audio" in filetype:
return DownloadableMediaMessageProtocolEntity.AUDIO_KEY
elif "application" in filetype:
return DownloadableMediaMessageProtocolEntity.DOCUMENT_KEY
elif "text" in filetype:
return DownloadableMediaMessageProtocolEntity.DOCUMENT_KEY
raise Exception ("FILE TYPE NOT SUPPORTED")
def encryptMedia(self,img, refkey,filetype):
key = self.getKey(filetype)
derivative = HKDFv3().deriveSecrets(binascii.unhexlify(refkey),
binascii.unhexlify(key), 112)
parts = ByteUtil.split(derivative, 16, 32)
iv = parts[0]
cipherKey = parts[1]
macKey=derivative[48:80]
mac = hmac.new(macKey,digestmod=hashlib.sha256)
mac.update(iv)
cipher = AES.new(key=cipherKey, mode=AES.MODE_CBC, IV=iv)
imgEnc = cipher.encrypt(self.pad(img))
mac.update(imgEnc)
hash = mac.digest()
hashKey = ByteUtil.trim(mac.digest(), 10)
finalEnc = imgEnc + hashKey
return finalEnc
def run(self):
sourcePath = self.sourcePath
uploadUrl = self.uploadUrl
#_host = uploadUrl.replace("https://","")
#self.url = _host[:_host.index('/')]
#print("URL UPLOAD")
#print(uploadUrl)
try:
filename = os.path.basename(sourcePath)
filetype = MimeTools.getMIME(filename)
f = open(sourcePath, 'rb')
stream = f.read()
f.close()
refkey = binascii.hexlify(os.urandom(32))
stream=self.encryptMedia(stream,refkey,filetype)
fenc = open(sourcePath+".enc", 'wb') # bahtiar
fenc.write(stream)
fenc.seek(0, 2)
filesize=fenc.tell()
fenc.close()
print(sourcePath+".enc")
os.remove(sourcePath+".enc")
filesize2=len(stream)
sha1 = hashlib.sha256()
sha1.update(stream)
b64Hash = base64.b64encode(sha1.digest())
file_enc_sha256 = hashlib.sha256(stream).hexdigest()
#self.sock.connect((self.url, self.port))
#ssl_sock = ssl.wrap_socket(self.sock)
m = hashlib.md5()
m.update(filename.encode())
crypto = m.hexdigest() + os.path.splitext(filename)[1]
#boundary = "zzXXzzYYzzXXzzQQ"#"-------" + m.hexdigest() #"zzXXzzYYzzXXzzQQ"
#contentLength = 0
digTo = hmac.new("".encode("utf-8"), self.jid.replace("@s.whatsapp.net", "@c.us").encode("utf-8"),
hashlib.sha256).digest()[:20]
refTo = base64.b64encode(digTo).decode()
digFrom = hmac.new("".encode("utf-8"), self.accountJid.replace("@s.whatsapp.net", "@c.us").encode("utf-8"),
hashlib.sha256).digest()[:20]
refFrom = base64.b64encode(digFrom).decode()
#hBAOS = "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"hash\"\r\n\r\n"
#hBAOS += b64Hash.decode() + "\r\n"
#hBAOS += "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"refs\"\r\n\r\n"
#hBAOS += refFrom + "\r\n"
#hBAOS += refTo + "\r\n"
#hBAOS += "------" + boundary + "\r\n"
#hBAOS += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "blob" + "\"\r\n"
#hBAOS += "Content-Type: " + "application/octet-stream" + "\r\n\r\n"
#fBAOS = "\r\n------" + boundary + "--"
#contentLength += len(hBAOS)
#contentLength += len(fBAOS)
#contentLength += filesize
#POST = "POST %s\r\n" % uploadUrl
#POST += "Content-Type: multipart/form-data; boundary=------" + boundary + "\r\n"
#POST += "Host: %s\r\n" % self.url
#POST += "User-Agent: %s\r\n" % self.getUserAgent()
#POST += "Content-Length: " + str(contentLength) + "\r\n\r\n"
#print(POST)
#print(hBAOS)
#ssl_sock.write(bytearray(POST.encode()))
#ssl_sock.write(bytearray(hBAOS.encode()))
#totalsent = 0
#buf = 1024
#status = 0
#lastEmit = 0
#while totalsent < int(filesize):
# ssl_sock.write(stream[:buf])
# status = totalsent * 100 / filesize
# if lastEmit!=status and status!=100 and filesize>12288:
# if self.progressCallback:
# self.progressCallback(self.sourcePath, self.jid, uploadUrl, int(status))
# lastEmit = status
# stream = stream[buf:]
# totalsent = totalsent + buf
#ssl_sock.write(bytearray(fBAOS.encode()))
#sleep(1)
#data = ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#data += ssl_sock.recv(8192)
#if self.progressCallback:
# self.progressCallback(self.sourcePath, self.jid, uploadUrl, 100)
hBAOS = "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"hash\"\r\n\r\n"
hBAOS += b64Hash.decode() + "\r\n"
hBAOS += "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"refs\"\r\n\r\n"
hBAOS += refTo + "\r\n"
hBAOS += refFrom + "\r\n"
hBAOS += "------zzXXzzYYzzXXzzQQ\r\n"
hBAOS += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "blob" + "\"\r\n"
hBAOS += "Content-Type: " + "application/octet-stream" + "\r\n\r\n"
fBAOS = "\r\n------zzXXzzYYzzXXzzQQ--"
contentLength = len(hBAOS) + len(fBAOS) + len(stream)
headers = {
"content-length": str(contentLength),
"user-agent": self.getUserAgent(),
"content-type": "multipart/form-data; boundary=----zzXXzzYYzzXXzzQQ"}
data = bytearray(hBAOS, 'utf-8') + stream + bytearray(fBAOS, 'utf-8')
response = requests.post(uploadUrl, data=data, headers=headers)
#lines = data.decode().splitlines()
result = None
#for l in lines:
# if l.startswith("{"):
# result = self.parser.parse(l, self.pvars)
# break
if response.text.startswith("{"):
result = self.parser.parse(response.text, self.pvars)
if not result:
raise Exception("json data not found")
if result["url"] is not None:
if self.successCallback:
# self.successCallback(sourcePath, self.jid, result["url"])
result["mediaKey"]=refkey
result["file_enc_sha256"]=file_enc_sha256
self.successCallback(sourcePath, self.jid, result)
else:
logger.exception("uploadUrl: %s, result of uploading media has no url" % uploadUrl)
if self.errorCallback:
self.errorCallback(sourcePath, self.jid, uploadUrl)
except:
logger.exception("Error occured at transfer %s"%sys.exc_info()[1])
if self.errorCallback:
self.errorCallback(sourcePath, self.jid, uploadUrl)
Very thanks, work
diff with fork tagal
https://pastebin.com/zVUfRmtT
diff with fork AragurDEV
https://pastebin.com/m95pZ2SA
Can you publish a functioning repository please? I still get an error.
@carlos-angulo https://github.com/AragurDEV/yowsup/
@AragurDEV thanks , someone has managed to send audios?
@AragurDEV I try to use ur repo, but I'm getting this error below, can you help me?
`ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer object of type 'int' has no len()
Traceback (most recent call last):
File "/usr/lib/python3.6/http/client.py", line 986, in send
self.sock.sendall(data)
File "/usr/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 313, in sendall
sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
File "/usr/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 301, in _send_until_done
return self.connection.send(data)
File "/usr/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1535, in send
raise TypeError("data must be a memoryview, buffer or byte string")
TypeError: data must be a memoryview, buffer or byte string
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "yowsup/yowsup/layers/protocol_media/mediauploader.py", line 150, in run
response = requests.post(uploadUrl, data=data, headers=headers)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, *kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, *kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, *send_kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, *kwargs)
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1065, in _send_output
self.send(chunk)
File "/usr/lib/python3.6/http/client.py", line 990, in send
self.sock.sendall(d)
File "/usr/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 312, in sendall
while total_sent < len(data):
TypeError: object of type 'int' has no len()`
@fmachadodev
Maybe reinstall OpenSSL
for further support jump on our Discord: https://discord.gg/Wa7QSxZ
@fmachadodev Try modifying the headers like this:
headers = {
"content-length": str(contentLength),
"user-agent": self.getUserAgent(),
"content-type": "multipart/form-data; boundary=----zzXXzzYYzzXXzzQQ" }
around line 216 in mediauploader.py in @aarcwb version, or here:
@carlos-angulo see my repo: https://github.com/aarcwb/yowsup
Need to install:
pip3 install audioread
pip3 install preview-generator
SEND:
audio ok
vcard ok
location ok
image Thanks @araguDEV
video Thanks @fmachadodev
document (after new method for uploading file, the documet arrive on mobile but do not open, today I will try to fix)
RECEIVE:
image ok
audio ok
video ok
document ok
vcard ok
location ok
Added in yowsup-cli
/document send
/location
/vcard
bugs:
location (if not pass name, street, url properties the thumbnail arrive with None for this fields, I am not able to turn this properties optional
PS. I tested just in Android phone, if someone could test in iphone, I will appreciate.
@carlos-angulo , I had this problem with video sending to, try to change the DOCUMENT_KEY const to "576861747341707020446f63756d656e74204b657973"
@fmachadodev works with that key. Thanks!
@aarcwb would you mind creating a pull request to my repo to have one central fork?
@AragurDEV sorry I am new in git, How can I do that?
@aarcwb
First you have to fork my repo https://github.com/AragurDEV/yowsup
Than clone your fork.
Make your changes, commit them.
Create a Pull Request on my Repo, than I will look over it and merge it.
For more details see: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
whatsapp blocks my numbers is there any solution for this?
Do not send messages to contacts that havent been sync
@AragurDEV I think that I made the pull request correctly, please let me know if I forget to do something.
@aarcwb yes i saw it. Just read what i wrote there
Is there a limit to different numbers to which a message can be sent?
I need to notify 35 different numbers every 4 days,
but whatsapp blocks me before I get to number 20
@AragurDEV and @aarcwb ,
i just implement you'r repo to my yowsup.
first, i found issue about pyopen (then i fixed reinstall OpenSSH). #https://github.com/tgalal/yowsup/issues/2149#issuecomment-347233081
But still can't receive image from service.
and from service no error.
how can i fixed that ?
i use python 3.6.2
@Mantauwhite I need more details about your code, but at least for me, the simple code below I am able to receive image:
def onMediaMessage(self, messageProtocolEntity):
if messageProtocolEntity.getMediaType() == "image":
print("Echoing image %s to %s" % (messageProtocolEntity.url, messageProtocolEntity.getFrom(False)))
data = messageProtocolEntity.getMediaContent()
f = open("/tmp/image.jpg", "wb")
f.write(data)
f.close()
aragurdev/yowsup is working fine for sending text and images. I've just used it.
https://github.com/AragurDEV/yowsup
@aarcwb hello,I can send and receive image now,thanks so much, and how to get the image from file.enc?
@ykguCoder see the getMediaContent method code, there the image/video/audio are decrypted from file.enc url.
@aarcwb Thank you so much,work fine.
why my phone number blocked when I receiving messages?
import os
from Crypto.Cipher import AES
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from axolotl.kdf.hkdfv3 import HKDFv3
from axolotl.util.byteutil import ByteUtil
import binascii
import base64
from urlparse import urlparse
import magic
def decrypt(encimg, refKey, encKey):
derivative = HKDFv3().deriveSecrets(refKey, binascii.unhexlify(encKey), 112)
parts = ByteUtil.split(derivative, 16, 32)
iv = parts[0]
cipherKey = parts[1]
e_img = encimg[:-10]
AES.key_size=128
cr_obj = AES.new(key=cipherKey, mode=AES.MODE_CBC, IV=iv)
return cr_obj.decrypt(e_img)
def decMedia(url, key, mediaType):
data = urlopen(url.decode('ASCII')).read()
decData = decrypt(data, base64.b64decode(key), getKey(mediaType))
if(magic.from_buffer(decData) != "data"):
print "Done"
else:
print "Failed"
def getKey(mediaType):
if mediaType == 1: #image
return "576861747341707020496d616765204b657973"
if mediaType == 3: #video
return "576861747341707020566964656f204b657973"
return None
def getExt(mediaType):
if mediaType == 1:
return ".jpeg"
if mediaType == "audio" or mediaType == "ptt":
return ".wma"
if mediaType == 3:
return ".mp4"
if type == "document":
if filename is not None:
return "." + filename.split(".")[-1]
return None
decMedia(media_url, media_enc_hash, media_wa_type)
media_url contains url from column media_url, media_enc_hash contains base-64 string from media_enc_hash and also media_wa_type contains int from media_wa_type.
Why i cnt decode any image or video?
Still no images, not even an errormessage.
`14:50:17 3: WhatsApp: sending /image send xxxxxxxxxxx /tmp/strassenglaette-orange.gif
2018.01.17 14:50:17 4: WhatsApp: parse: [connected]:
2018.01.17 14:50:18 4: WhatsApp: parse:
Sent: 1516197018-40
documents could be send
installed from https://github.com/AragurDEV/yowsup
cache deleted
python 3.5.3
please help

Hi, I still can not send an image, there is no error and the image is never received on the cell phone.
Help me . thanks
@ahlermi we are working on it.
Please add aditional details here: https://github.com/AragurDEV/yowsup/issues/47
Can someone please help me with this:
AttributeError: 'AxolotlReceivelayer' object has no attribute 'adjustId'
... or tell me if there's a working fork to send at least images?
Hi,
Since last week , if i register new number, I always get :
status: fail
retry_after: 300
reason: temporarily_unavailable
Is there any body now get the same messages when registering new number? Is there any solutions for this ?
Thanks.
Anyone have this working yet?
Yes it is working, Just keep your environment clean. I mean server and libraries especially python -axolotol.
https://github.com/AragurDEV/yowsup/. Use this it will work.
@naushrambo just cloned this repo and installed, same issue as above request error
me too
is anyone able to send audio, video, document with the AragurDEV fork?
I'm able to send image, but nothing else.
is anyone able to receive media files? I see the message, but the media file is still encrypted. I saw posts that people are able to receive media, but can't get it work.
All of my numbers is blocked today, is this because the end of whatsapp support for S40?
is there anyone have the same problem?
I get "Login Failed, reason: not-authorized" :-(
Most helpful comment
I got sending to group working.
Just download my fork: https://github.com/AragurDEV/yowsup
Or look at my commit: https://github.com/AragurDEV/yowsup/commit/40dd8680bd3d0242da9691584c16e96a03dde9e0
layer_send.py starting line 51
If you need any assistance jump on our support discord: https://discord.gg/Wa7QSxZ