This commit is contained in:
danogentili 2016-09-24 17:58:17 +02:00
parent bedab1388d
commit b0a0e6d70c
5 changed files with 14 additions and 10 deletions

View File

@ -38,9 +38,13 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
-----END RSA PUBLIC KEY-----', -----END RSA PUBLIC KEY-----',
], ],
'connection' => [ 'connection' => [
'ip_address' => '149.154.167.50', 'dc_list' => [
'port' => '443', 2 => [
'protocol' => 'tcp_full', 'ip_address' => '149.154.167.50',
'port' => '443',
'protocol' => 'tcp_full',
],
],
], ],
'app_info' => [ 'app_info' => [
'api_id' => 25628, 'api_id' => 25628,

View File

@ -48,6 +48,7 @@ class CallHandler extends AuthKeyHandler
try { try {
$int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method)); $int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method));
$this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args]; $this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args];
var_dump($this->outgoing_messages);
$server_answer = $this->wait_for_response($int_message_id); $server_answer = $this->wait_for_response($int_message_id);
} catch (Exception $e) { } catch (Exception $e) {
$this->log->log('An error occurred while calling method '.$method.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().$e->getTraceAsString().'. Recreating connection and retrying to call method...'); $this->log->log('An error occurred while calling method '.$method.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().$e->getTraceAsString().'. Recreating connection and retrying to call method...');

View File

@ -31,7 +31,7 @@ class MessageHandler extends Crypt
} else { } else {
$seq_no = $this->generate_seq_no($content_related); $seq_no = $this->generate_seq_no($content_related);
var_dump($this->settings['authorization']['temp_auth_key']['server_salt']); var_dump($this->settings['authorization']['temp_auth_key']['server_salt']);
$encrypted_data = $this->struct->pack('<Q', $this->settings['authorization']['temp_auth_key']['server_salt']).$this->settings['authorization']['session_id'].$message_id.$this->struct->pack('<II', $seq_no, strlen($message_data)).$message_data; $encrypted_data = $this->struct->pack('<q', $this->settings['authorization']['temp_auth_key']['server_salt']).$this->settings['authorization']['session_id'].$message_id.$this->struct->pack('<II', $seq_no, strlen($message_data)).$message_data;
$message_key = substr(sha1($encrypted_data, true), -16); $message_key = substr(sha1($encrypted_data, true), -16);
$padding = \phpseclib\Crypt\Random::string(\danog\MadelineProto\Tools::posmod(-strlen($encrypted_data), 16)); $padding = \phpseclib\Crypt\Random::string(\danog\MadelineProto\Tools::posmod(-strlen($encrypted_data), 16));
list($aes_key, $aes_iv) = $this->aes_calculate($message_key); list($aes_key, $aes_iv) = $this->aes_calculate($message_key);
@ -63,7 +63,7 @@ class MessageHandler extends Crypt
list($aes_key, $aes_iv) = $this->aes_calculate($message_key, 'from server'); list($aes_key, $aes_iv) = $this->aes_calculate($message_key, 'from server');
$decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv); $decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv);
$server_salt = $this->struct->unpack('<Q', substr($decrypted_data, 0, 8))[0]; $server_salt = $this->struct->unpack('<q', substr($decrypted_data, 0, 8))[0];
if ($server_salt != $this->settings['authorization']['temp_auth_key']['server_salt']) { if ($server_salt != $this->settings['authorization']['temp_auth_key']['server_salt']) {
throw new Exception('Server salt mismatch (my server salt '.$this->settings['authorization']['temp_auth_key']['server_salt'].' is not equal to server server salt '.$server_salt.').'); throw new Exception('Server salt mismatch (my server salt '.$this->settings['authorization']['temp_auth_key']['server_salt'].' is not equal to server server salt '.$server_salt.').');
} }

View File

@ -48,7 +48,10 @@ class ResponseHandler extends MsgIdHandler
break; break;
case 'pong': case 'pong':
foreach ($this->outgoing_messages as $msg_id => &$omessage) {
var_dump($this->outgoing_messages);
foreach ($this->outgoing_messages as $msg_id => &$omessage) {
if (isset($omessage['content']['args']['ping_id']) && $omessage['content']['args']['ping_id'] == $response['ping_id']) { if (isset($omessage['content']['args']['ping_id']) && $omessage['content']['args']['ping_id'] == $response['ping_id']) {
$omessage['response'] = $response['msg_id']; $omessage['response'] = $response['msg_id'];
$this->incoming_messages[$response['msg_id']]['content'] = $response; $this->incoming_messages[$response['msg_id']]['content'] = $response;

View File

@ -8,8 +8,4 @@ if (!$config) {
exit(-1); exit(-1);
} }
function base64url_decode($data)
{
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
$MadelineProto = new \danog\MadelineProto\API($config); $MadelineProto = new \danog\MadelineProto\API($config);