venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.14k forks source link

Whatsapi working again with help from yowsup and googlevoice. #238

Open jonnywilliamson opened 11 years ago

jonnywilliamson commented 11 years ago

Ok firstly there's going to be a bit of a rant at the start before I give you my results.

It just seems incredible to me how many people take the time to find this repository, find the issues section and then without even taking 2 secs to look at the other threads in here - create a brand new issue and ask the same question as 400 other people immediate below them. I'm tired of getting dozens of emails that are all CRAP.

Come on people SMARTEN UP. You are not ALL stupid.

Also can we just clear up some issues once and for all.

1) If you're using v1 of the authentication proceedure (ie everything up until the changes a few weeks ago) and things are still working for you, you are living on borrowed time. Sooner or later you will find that you cannot connect. You will know this by the error message "incorrect password". Do not come here and tell us about it, we know.

2) It seems fairly clear now. WHATSAPP NOW ASSIGN A PASSWORD to each user account, THERE IS NO WAY TO GENERATE IT ANYMORE. You must discover what your new password is, there's no more generating it from your phones IMEI or MAC address.

3) To those people who have been sending more than 10,000 messages a day and complained about being blocked - I call shenanigans. You are spammers. I HATE spammers, I'm delighted your accounts have been blocked.

So as we continue what am I showing you?

I have finally found away to (easily) get the password for a particular whatsapp account, and I have modified the code in whatsapi to use this password to allow me to send messages again. This solution will NOT help everyone.

A lot of you will want to use the SAME account as your phone (in my case iphone), THIS IS NOT POSSIBLE USING MY SOLUTION AT THE MOMENT.

I have been unable to find a way to extract the password from my phone, therefore I used yowsup and my googlevoice number to create a new account and capture the password from there before using it in WHATSAPI.

HOWEVER when someone finds a way to read the password file stored on the iphone etc we will be able to use the rest of my solution below.

Here's what I did.

a) Download YOWSUP from https://github.com/tgalal/yowsup . This is a python implementation of whatsapp and will allow us to register and capture our new account password. You will need a server that has python installed to be able to use this. Move all the YOWSUP files to your server.

b) Edit the config.example file in the yowsup directory. Place your googlevoice number in the config file. It should look like this:

phone=12225556666
d=
password=

c) run the yowsup-cli file with the following parameters:

 python ./yowsup-cli -c config.example -d --requestcode voice

You will see the connection being made to whatsapp and after a few secs whatsapp will make a voicecall to your googlevoice number with the confirmation code.

In my case I let googlevoicemail pick up the call and record the message. I was then able to play the message back and hear my confirmation code. I didn't check to see if googlevoice would receive a sms message from whatsapp. If you would like to try this method, then run this command:

 python ./yowsup-cli -c config.example -d --requestcode sms

d) Now we need to finish the registration by sending the confirmation code back. Run this command:

 python ./yowsup-cli -c config.example -d -R 123456

Where 123456 is your 6 digit confirmation code. If success full you will see something like this:

status: ok kind: free pw: YOURPASSWORDISHERE price: $0.99 price_expiration: 1359720290 currency: USD cost: 0.99 expiration: 1388155832 login: type: new

e) Now take/copy your password, if you like you are now finished with yowsup.

f) The password you have is a base64 encoded string containing your password. We have to now add a way for WHATSAPI to be able to use it. There's 2 code changes we have to make to the current code to get this to work.

open whatsprot.class.php find

    protected $_whatsAppVer = "2.8.4";

change to

    protected $_whatsAppVer = "2.8.7";

find

    public function encryptPassword()
    {
        if(stripos($this->_imei, ":") !== false){
            $this->_imei = strtoupper($this->_imei);
            return md5($this->_imei.$this->_imei);
        }
        else {
            return md5(strrev($this->_imei));
        }
    }

and replace with

    public function encryptPassword()
    {
        return base64_decode($this->_imei);
    }

Now you are good to go! To use a very quick proof, create this php file and enter your details, then run the file, you should receive a message after a second.

<?php
    require "whatsprot.class.php";

    $fromMobNumber = "12225556666"; //ENTER YOUR GOOGLEVOICENUMBER HERE
    $toMobNumber = "09876543210"; //ENTER YOUR OWN NUMBER HERE
    $id = "<YOUR NEW PASSWORD>";  //ENTER THE PASSWORD YOU COPIED EARLIER HERE
    $nick = "YourNick";

    $w = new WhatsProt($fromMobNumber, $id, $nick);
    $w->Connect();
    $w->Login();
    $w->sendNickname($nick);
    $w->Message($toMobNumber , "Testing123");
    sleep (2);

?>
brittson commented 11 years ago

@jonnywilliamson great. thanks man

kingk110 commented 11 years ago

@jonnywilliamson @adasmalakar did u check that it is working ? because I am trying to do the same in the .net api but getting wrong password

brittson commented 11 years ago

@kingk110 yes its working on php

jonnywilliamson commented 11 years ago

Oh course I checked it was working @kingk110 - do you think I'd type all that out just to pass an hour in the afternoon?

guidomgs commented 11 years ago

Nice!!! thanks that is really good!

I added one more line on the code to get a confirmation message:

!/usr/bin/php

<?php require "../src/php/whatsprot.class.php";

$fromMobNumber = "YOWSUPNUMBER"; //ENTER YOUR GOOGLEVOICENUMBER HERE
$toMobNumber = "DEST"; //ENTER YOUR OWN NUMBER HERE
$id = "YOWSUPPASS";  //ENTER THE PASSWORD YOU COPIED EARLIER HERE
$nick = "nickname";

$w = new WhatsProt($fromMobNumber, $id, $nick);
$w->Connect();
$w->Login();
$w->sendNickname($nick);
$w->Message($toMobNumber , "hello");  //<----This is the message line :)
sleep (1);
exit(0);

?>

jonnywilliamson commented 11 years ago

@guidomgs Thanks. I missed that when copying and pasting. Added to original post.

cluber22 commented 11 years ago

Am I right in saying that with this method, when you go back onto your phone you need to re-register and verify on your phone.

guidomgs commented 11 years ago

Is not google voice exclusive, I registered with yowsup a spear sim card, also you can register with yowsup a land line phone.

jonnywilliamson commented 11 years ago

@cluber22 As per my post:

A lot of you will want to use the SAME account as your phone (in my case iphone), THIS IS NOT POSSIBLE USING MY SOLUTION AT THE MOMENT.

cluber22 commented 11 years ago

@jonnywilliamson I did read that but was looking for some clarification regarding the reverifying. Thanks.

g0g0l commented 11 years ago

@kingk110 you need to do something like this in .net public static string base64Decode(string imei) { byte[] binary_hash = Convert.FromBaseString(imei); return Encoding.Default.GetString(binary_hash); } It is done in php using base64_decode() function. The method given here is really helpful, thanks @jonnywilliamson

kingk110 commented 11 years ago

I tried too much but always getting wrong answer @g0g0l what about the md5 encryption if u debug the .net you will notice that there is an md5 encryption while calling the function ExistsAndDelete! is there an md5 encryption of the decoded string in the php before using it as a token?

horaceho commented 11 years ago

@jonnywilliamson Thanks for the great information and detail instructions. It works like a charm.

g0g0l commented 11 years ago

The md5(reversed imei) was the password in older protocol, I don't think md5 encryption is required any longer, at least it is not required in php

g0g0l commented 11 years ago

@cluber22 the phone,hash combination gets deactivated when you try to use same number in phone, because the rule of WhatsApp is: "You can only register one number in only one device". When you register a number using yowsup, WhatsApp considers it as a device and same number cannot be used in phone or tablet.

kingk110 commented 11 years ago

there is also rc4 encryption while using the login function do you have any idea about it @g0g0l ? I tired to skip the ExistsAndDelete and debug but my mind was lost while calling too many functions to encrypt data !!! I don't know why there is so many encryption while using a request ??

If you know .net and can help to solve it I'll thank you a lot because nobody is giving it any important in the .net repository

jonnywilliamson commented 11 years ago

@kingk110 I'm sorry but you are obviously completely out of your depth. You are mistaking what we are doing here, using WHATSAPI with a new password, with the actual code needed in behind the scenes to make a signed/encrypted request with the whatsapp servers. Not only that but your problems are related to code in another language to what is being discussed here!

I appreciate you just want help, but you're in the wrong place.

Please start a new topic with your issues and stop using this one.

olpo commented 11 years ago

stop telling this spammer how to do it . everyone who is not dumb as fuck already figured it out.

kingk110 commented 11 years ago

thanks for you guys

ruriimasu commented 11 years ago

Did any of you guys ever get an error Old_version when input SMS code? But no problem if I re-register the phone number with latest whatsapp client.

The said phone number was used in an old version of Whatsapp and I'm trying to re-register in the new password format.

Currito commented 11 years ago

@jonnywilliamson Great work!

stoyicker commented 11 years ago

Thank you very much. This was not valid for me, since I live in Spain where Google Voice isn't supported. However the method has anyway worked. I've used the sms verification and, for the phone, just my country code and my mobile phone number, e. g., 34123456789, where 123456789 is my phone number, registered in Spain (country code 34). I've received the SMS within seconds.

Thank you very much again @jonnywilliamson

lahmacuns commented 11 years ago

What is this Problem ?

python ./yowsup-cli -c config.example -d --requestcode voice File "./yowsup-cli", line 191 password = identity or password if args["v1"] else base64.b64decode(password) ^ SyntaxError: invalid syntax

shirioko commented 11 years ago

That is line 222, not 191 https://github.com/tgalal/yowsup/blob/master/src/yowsup-cli perhaps you have accidentally deleted some lines? Try downloading it again.

jandrito80 commented 11 years ago

Is it possible to migrate yowsup from python to php? I use php to send and receive messages, and would like to register a new number from php. I can't understand python code. Is there any way to register a new number with php code? Thank you

shirioko commented 11 years ago

You can call python from php and then parse the output. Just use both.

jandrito80 commented 11 years ago

The script works fine on my computer (I have python 2.7.2), but the server does not work online. I've tried a basic script:

test.py

print "Hello World"

and php exec ("python test.py", $ output); This works correctly. but exec ("python yowsup/yowsup-cli -c config.example -d --requestcode voice", $ output); not work. Do I have to do some extra configuration? Do I have to open a special port?

shirioko commented 11 years ago

Go to yowsup's repository and verify that you have all the dependencies installed (python version, libraries etc.). It's in the readme file.

gotoalberto-zz commented 11 years ago

@Stoyicker try fonyou.com for get a virtual number, it's free.

gotoalberto-zz commented 11 years ago

Hi, i'm trying:

<?php
    require "whatsprot.class.php";

    $fromMobNumber = "34668******"; //ENTER YOUR GOOGLEVOICENUMBER HERE
    $toMobNumber = "34622******"; //ENTER YOUR OWN NUMBER HERE
    $id = "RG+AtFm0LwD1pdX8LT**********";  //ENTER THE PASSWORD YOU COPIED EARLIER HERE
    $nick = "YourNick";

    $w = new WhatsProt($fromMobNumber, $id, $nick);
    $w->Connect();
    $w->Login();
    $w->sendNickname($nick);
    $w->Message($toMobNumber , "Hello!");

?>

But it's not working. Anyone could say me what's wrong here? Thanks in advance.

willyue commented 11 years ago

hi @jonnywilliamson , I have tried your methods and it works in my localhost but somehow I cant make it work in my hosting server.

This error produced:- Warning: socket_connect() [function.socket-connect]: unable to connect [110]: Connection timed out in whatsprot.class.php on line 233

Warning: socket_send() [function.socket-send]: unable to write to socket [32]: Broken pipe in whatsprot.class.php on line 106

Warning: socket_send() [function.socket-send]: unable to write to socket [32]: Broken pipe in whatsprot.class.php on line 106

Warning: socket_send() [function.socket-send]: unable to write to socket [32]: Broken pipe in whatsprot.class.php on line 106

Warning: socket_read() [function.socket-read]: unable to read from socket [107]: Transport endpoint is not connected in whatsprot.class.php on line 118

Please guide me. Thanks a lot :)

jonnywilliamson commented 11 years ago

Your remote host has a firewall blocking your outbound connections.

willyue commented 11 years ago

hmmm.. anyway to to bypass that firewall and connect outbound connections? been cracking head for few days. Thanks.

shirioko commented 11 years ago

Well yes you have to open that port. I believe it's 5222. On Jan 14, 2013 2:35 AM, "Will.C" notifications@github.com wrote:

hmmm.. anyway to to bypass that firewall and connect outbound connections? been cracking head for few days. Thanks.

— Reply to this email directly or view it on GitHub.

beldar commented 11 years ago

@jonnywilliamson Thank you for making my life easy.

codename12 commented 11 years ago

@jonnywilliamson I extracted my password, the same one my phone is using, of course its not the best way but, its a start... I downloaded charles proxy on my laptop, I set the iphone to use a proxy (which is my laptop) and spoofed the registration process of my whatsapp account..

The next step is to know how this password I got, get encrypteds to the pw.dat file saved in the iphone!

p.s: I havent tried yet to sign in using the password i got, I just had it..

rayxelloss commented 11 years ago

which version of python shall i use for this ?

shirioko commented 11 years ago

It's in yowsup's readme file. Go read it.

muslimsg commented 11 years ago

question 1) - how to change the profile pic with yowsup?

question 2) - I registered my number with yowsup. Now if I put the sim card into a mobile phone and login will the password change? If not can I set the profile pic via mobile phone?

shirioko commented 11 years ago

Answer 1 & 2: this is not yowsup. Done. No more. Only questions related to this project. On Jan 19, 2013 10:50 AM, "muslimsg" notifications@github.com wrote:

question 1) - how to change the profile pic with yowsup?

question 2) - I registered my number with yowsup. Now if I put the sim card into a mobile phone and login will the password change? If not can I set the profile pic via mobile phone?

— Reply to this email directly or view it on GitHubhttps://github.com/venomous0x/WhatsAPI/issues/238#issuecomment-12452750.

rayxelloss commented 11 years ago

thanks for the previous question. I installed all the Requirements in read me, when i tried to run the python by command (python ./yowsup-cli -c config.example -d --requestcode voice), i got "ImportError: No module named 'ConnectionIO' "

shirioko commented 11 years ago

And how is this related to WhatsAPI?

OrangeTux commented 11 years ago

Thanks for the code and for this tutorial.

guidomgs commented 11 years ago

Hi its me again! I was working fine with this method, but now its failing at login time. Some one else was having the same issue? on yowsup is working fine (but i dont like so much that one)

serweb commented 11 years ago

Existe algun pequeño instructivo para ejecutar el whatsapi en php? o py? una vez descubierto el password de una cuenta como se prosigue?

beldar commented 11 years ago

@serweb ves a mirar el archivo testprotocol.php ahí hay ejemplos, pero te recomiendo que cojas el codigo de mi fork de WhatsAPI, ya que la version de aqui no esta preparada para el nuevo sistema de passwords.

El dijous 7 de març de 2013, serweb ha escrit:

Existe algun pequeño instructivo para ejecutar el whatsapi en php? o py? una vez descubierto el password de una cuenta como se prosigue?

— Reply to this email directly or view it on GitHubhttps://github.com/venomous0x/WhatsAPI/issues/238#issuecomment-14543858 .

Martí

serweb commented 11 years ago

Perdon necesito un empujon, como arranco? donde pongo ese archivo y como lo ejecuto? o sea una breve explicacion desde cero y luego me la rebusco, pero necesito arrancar. Conozco un poco de shell scripts en linux pero php nunca lo utilice.

shirioko commented 11 years ago

No hablo espagnol.

Asking your questions in a different language won't make them less stupid. As said before, this is an issue tracker and not a tutorial. If you don't know the programming language you're screwed.

krish-kapadia commented 11 years ago

I tried getting the registration code via voice and sms but I got none of them. It said sent but I didn't get code via SMS or voice. Does it stop working???

shirioko commented 11 years ago

If only people would read...