Example #1
0
 public function eachCommonPrefix($key, $start, $fn)
 {
     $node = $this->base->get(0);
     $offset = 0;
     $in = new KeyStream($key, $start);
     for ($code = $in->read();; $code = $in->read(), $offset++) {
         $terminalIdx = $node;
         if ($this->chck->get($terminalIdx) === 0) {
             $fn->call($start, $offset, self::ID($this->base->get($terminalIdx)));
             if ($code === 0) {
                 return;
             }
         }
         $idx = $node + $code;
         $node = $this->base->get($idx);
         if ($this->chck->get($idx) === $code) {
             if ($node >= 0) {
                 continue;
             } else {
                 $this->call_if_keyIncluding($in, $node, $start, $offset, $fn);
             }
         }
         return;
     }
 }
Example #2
0
 /**
  * Authenticate with the Whatsapp Server.
  *
  * @return String
  *   Returns binary string
  */
 protected function authenticate()
 {
     $keys = KeyStream::GenerateKeys(base64_decode($this->password), $this->challengeData);
     $this->inputKey = new KeyStream($keys[2], $keys[3]);
     $this->outputKey = new KeyStream($keys[0], $keys[1]);
     $phone = $this->dissectPhone();
     $array = "" . $this->phoneNumber . $this->challengeData;
     // . time() . static::WHATSAPP_USER_AGENT . " MccMnc/" . str_pad($phone["mcc"], 3, "0", STR_PAD_LEFT) . "001";
     $response = $this->outputKey->EncodeMessage($array, 0, 4, strlen($array) - 4);
     return $response;
 }
Example #3
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]);
     $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;
     $response = $this->outputKey->EncodeMessage($array, 0, 4, strlen($array) - 4);
     $this->parent->setOutputKey($this->outputKey);
     return $response;
 }
Example #4
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;
 }
Example #5
0
<?php

require_once __DIR__ . '/../src/keystream.class.php';
$password = '******';
$enc = base64_decode($password);
PrintHex($enc);
echo "{$enc} \n";
//$challengeData = array(0xf7, 0xe2, 0x86, 0xd2, 0x1c, 0xda, 0x51, 0x2c, 0xef, 0x9b, 0x65, 0xb8, 0xd2, 0x69, 0x20, 0xf9, 0x3c, 0x5d, 0x64, 0x87);
$challengeData = array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
$challengeData = 'bbbbbbbb';
//file_put_contents(__DIR__.'/filename.txt', print_r(mb_list_encodings(), true));
$keys = KeyStream::GenerateKeys($enc, $challengeData);
PrintHex($keys[0]);
PrintHex($keys[1]);
PrintHex($keys[2]);
PrintHex($keys[3]);
function PrintHex($from)
{
    $return = "";
    for ($i = 0; $i < strlen($from); $i++) {
        $return .= ' ' . bin2hex(substr($from, $i, 1));
    }
    echo "{$return} \n";
}
Example #6
0
 /**
  * Authenticate with the WhatsApp Server.
  *
  * @return string Returns binary string
  */
 protected function authenticate()
 {
     $keys = KeyStream::GenerateKeys(base64_decode($this->password), $this->challenge_data);
     $this->input_key = new KeyStream($keys[2], $keys[3]);
     $this->output_key = new KeyStream($keys[0], $keys[1]);
     $array = "" . $this->phone_number . $this->challenge_data;
     $response = $this->output_key->EncodeMessage($array, 0, 4, strlen($array) - 4);
     return $response;
 }
Example #7
0
echo "{$ChallengeData} \n";
PrintHex($keys[0]);
PrintHex($keys[1]);
PrintHex($keys[2]);
PrintHex($keys[3]);
function PrintHex($from)
{
    $return = "";
    for ($i = 0; $i < strlen($from); $i++) {
        $return .= ' ' . bin2hex(substr($from, $i, 1));
    }
    echo "{$return} \n";
    //	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);
Example #8
0
 public function testEncodeMessage()
 {
     $ret = $this->object->encodeMessage('mystring', 8, 0, 8);
     $this->assertEquals(hex2bin('4f726d3f8a9b2d270e987920'), $ret);
 }