Code Monkey home page Code Monkey logo

wa-decrypt-nodejs's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar smashah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wa-decrypt-nodejs's Issues

Audio OGG Encryption/Decryption Loss of trailing bytes

Describe the bug
Audio OGG decryption is losing some bytes. In every test, there is between 4 to 12 bytes trimmed off / lost. Resulting OGG from wa-decrypt is always a multiple of 16. (This is likely issue of block-mode decrypt, skipping any trailing bytes below block size (16/32 ?) .I Believe this may be the cause of the issue of losing a second from OGG sending.

Steps to Reproduce
Uploaded files for testing below:

  1. Test File (Original OGG: 11204 bytes): www.indizaonline.co.za/file.ogg
  2. Encoded File (WhatsApp Encoded - from ClientUrl): www.indizaonline.co.za/file.enc
  3. Decoded File (Output from WA-Decrypt - 11200 bytes - 4 bytes trimmed from end): www.indizaonline.co.za/wadecrypt.oga
  4. all three files above zipped: www.indizaonline.co.za/ogg_test.zip
  5. File/Key info:
    mediaKey: 'WYzZPAw9wN+2MIEu9owTxCv8DfWN3pghj5ZPBCrn5Uk='
    filehash: 'eDo3djnfwGUxmViq8PH8kzb/wYDryu7KA4byvdWFM/Y='
    uploadhash: 'kxTTUN3TxCSQSThjNF1heKvnzfreSxFuRbQqZnTYyJA='
    size: 11204,

create() code
This is the code you use to create the client. e.g

...

Expected behavior
Full OGG decrypted, without loss of bytes

DEBUG INFO
This is the info printed to the console when you start your app. It should look like this

Debug Info {
  Current Release / Default settings
}

Screenshots
If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots

Host (please complete the following information):

  • OS: Ubuntu 18

Additional context
using php for testing (requires openssl extension / use phpfiddle.org):

$salt = base64_decode('e+nLIMCM2QRQX/Z/kT9iYkc6vQoSIHT+ZMOffiG2PlM=');
$iv = base64_decode('jOVmsDgmWsQ/gSQK/YMWcg==');
$data = substr($encoded_data, 0, -10);
$decrypted = (openssl_decrypt($data, 'aes-256-cbc', $salt, 0, $iv));
$resultOk = hash('sha256',$decrypted) == '783a377639dfc065319958aaf0f1fc9336ffc180ebcaeeca0386f2bdd58533f6';
echo $resultOk ? "ok":"failed";

New Update WhatsappWeb paramter

message.clientUrl change to message.deprecatedMms3Url

if (!message.clientUrl ) throw new Error('message is missing critical data needed to download the file.');
to
if (!message.deprecatedMms3Url) throw new Error('message is missing critical data needed to download the file.');

Error: Request failed with status code 404

id='true_41********[email protected]_3EB0201B6B3EA660A0B8';
decryptMedia = require('@open-wa/wa-decrypt').decryptMedia;
client.getMessageById(id).then(message => decryptMedia(message).then(console.log));

Promise { <pending> }
> (node:37462) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
    at createError (/private/tmp/kk/node_modules/@open-wa/wa-decrypt/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/private/tmp/kk/node_modules/@open-wa/wa-decrypt/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/private/tmp/kk/node_modules/@open-wa/wa-decrypt/node_modules/axios/lib/adapters/http.js:236:11)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:506:15)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:37462) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 34)

However, it works if I use this other message id:
id='true_4********[email protected]_3EB0BDAAE8FDF920D479';

Both ids are correct, with message.mimetype = "image/jpeg", and both images are available on the android phone.

What can be the problem?

decryptMedia not working

I speak in spanish, sorry if my english is'n correct

In the decrypt.ts file

Captura de pantalla de 2020-01-23 12-20-49

in this part:
Captura de pantalla de 2020-01-23 12-21-39

I never get a response with statusCode 200

My code is this:
Captura de pantalla de 2020-01-23 12-22-23

webp extension is blank

Hi!
I'm getting a blank image file when I receive a sticker. The extension is .webp, the another extensions are fine.

image

Missing headers (possibly a small change by WA)

'Upgrade-Insecure-Requests':1

I believe WA has changed something on their backend, it might be some proxy/caching artefact. Apparently it has become mandatory to include

'origin': 'https://web.whatsapp.com/',
'referer': 'https://web.whatsapp.com/'

as headers as well, otherwise the promise could be rejected with status 400 - Bad Request. Without this change the test won't pass as well (same kind of error). With the change the test saves the balls image. Afterwards it stops mattering if the headers are there or not - the request is accepted just fine.

trouble qr code

Hi everyone!
the trouble is when access for second time to the app.
this example is with simple message (like the example webpage)
if i remove session folder and ask me to qr code scan works...
but when the session exist and no qr code needed there is the trouble :
so first time works, en second time no works.
thanks!
image

decrypt image

I am a beginner in nodejs and I am not able to decrypt image ....

could you please show me a basic example?

because when I run the example available I have the following error

root@167:/var/www/adm/services# node ../../admin/teste.js
/var/www/admin/teste.js:1
import { decryptMedia } from '@open-wa/wa-decrypt';
^

SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
root@167:/var/www/adm/services#

this and the script I'm using...

import { decryptMedia } from '@open-wa/wa-decrypt';
const mime = require('mime-types');
const fs = require('fs');

const processMessage = async message => {
if (message.mimetype) {
const filename = ${message.t}.${mime.extension(message.mimetype)};
const mediaData = await decryptMedia(message);
const imageBase64 = data:${message.mimetype};base64,${mediaData.toString( 'base64' )};
fs.writeFile(filename, mediaData, function(err) {
if (err) {
return console.log(err);
}
console.log('The file was saved!');
});
}
}

I would just like to save the received images ...

please help me

Problem with decrypt .xlsx files

I've been using the library for over 1 year and in the meantime only 1 time we've had a problem with audio files having a few seconds cut off,
however this was fixed with a fix and so far we have never had any problems with any type of media, except excel files in .xlsx format, which when going through the decrypt function it becomes corrupted.

What I could analyze and I don't know if this is the reason for the problem is that, between the original file and the file that returns from the decrypt (this comparing the base64) there is a difference at the end of the file, everything is identical except the last 15 to 25 characters.

I will attach 2 links here:

  • This is the original file uploaded directly:
    original_file

  • This is the same however after going through the decrypt.
    after_decrypt

I will also attach the 2 base64 files from the same files I used to analyze.
example image
txt original Base64
txt afterdecrypt base64

Once again I reinforce that I already use the same lib for all the rest of the files and none of them generates this type of error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.