Beispiel #1
0
 /**
  * Authenticate with the WhatsApp Server.
  *
  * @return string Returns binary string
  */
 protected function authenticate()
 {
     $keys = KeyStream::GenerateKeys(base64_decode($this->password), $this->parent->getChallengeData());
     $this->inputKey = new KeyStream($keys[2], $keys[3]);
     $this->outputKey = new KeyStream($keys[0], $keys[1]);
     $return = CustGetHex($keys[0]);
     echo "{$return} \n";
     $return = CustGetHex($keys[1]);
     echo "{$return} \n";
     $return = CustGetHex($keys[2]);
     echo "{$return} \n";
     $return = CustGetHex($keys[3]);
     echo "{$return} \n";
     $ttt = time();
     file_put_contents(__DIR__ . '/log.txt', $ttt . "\n", FILE_APPEND);
     $chd = $this->parent->getChallengeData();
     $return = CustGetHex($chd);
     file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
     $array = "" . $this->phoneNumber . $this->parent->getChallengeData() . '' . time() . '000' . hex2bin('00') . '000' . hex2bin('00') . Constants::OS_VERSION . hex2bin('00') . Constants::MANUFACTURER . hex2bin('00') . Constants::DEVICE . hex2bin('00') . Constants::BUILD_VERSION;
     $return = CustGetHex($array);
     file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
     $response = $this->outputKey->EncodeMessage($array, 0, 4, strlen($array) - 4);
     $this->parent->setOutputKey($this->outputKey);
     $return = CustGetHex($response);
     file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
     return $response;
 }
Beispiel #2
0
    //	file_put_contents(__DIR__.'/log.txt', $return."\n", FILE_APPEND);
}
$inputKey = new KeyStream($keys[2], $keys[3]);
$outputKey = new KeyStream($keys[0], $keys[1]);
/*      $array = "\0\0\0\0".$this->phoneNumber.$this->parent->getChallengeData().''.time().'000'
.hex2bin('00').'000'.hex2bin('00')
       .Constants::OS_VERSION.hex2bin('00').Constants::MANUFACTURER.hex2bin('00').Constants::DEVICE.hex2bin('00').Constants::BUILD_VERSION;
*/
$buffer = "" . "79250069542";
/*	for($i = 0; $i < count($ChallengeData); $i++) {
       $buffer .=sprintf('%02.x', $ChallengeData[$i]);
  	}  */
$buffer .= $ChallengeData;
//uffer .= ''."1460340975"; // time
$buffer .= '' . "1460432318";
// time
$buffer .= "000";
$buffer .= hex2bin('00') . '000' . hex2bin('00') . Constants::OS_VERSION . hex2bin('00') . Constants::MANUFACTURER . hex2bin('00') . Constants::DEVICE . hex2bin('00') . Constants::BUILD_VERSION;
$return = CustGetHex($buffer);
file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
$out = $outputKey->EncodeMessage($buffer, 0, 4, strlen($buffer) - 4);
//echo "$out  \n";
$return = CustGetHex($out);
file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
echo $return;
$node = new ProtocolNode('response', null, null, $out);
$writer = new BinTreeNodeWriter();
$encdata = $writer->write($node, true);
$return = CustGetHex($encdata);
file_put_contents(__DIR__ . '/log.txt', $return . "\n", FILE_APPEND);
echo $return;