Update
This commit is contained in:
parent
edd5f81fec
commit
538c79940f
@ -187,6 +187,7 @@ class Session
|
|||||||
}
|
}
|
||||||
$x = $this->struct->unpack('<I', substr($packet, 0, 4));
|
$x = $this->struct->unpack('<I', substr($packet, 0, 4));
|
||||||
$auth_key_id = substr($packet, 4, 8);
|
$auth_key_id = substr($packet, 4, 8);
|
||||||
|
hex_dump($packet);
|
||||||
if ($auth_key_id == string2bin('\x00\x00\x00\x00\x00\x00\x00\x00')) {
|
if ($auth_key_id == string2bin('\x00\x00\x00\x00\x00\x00\x00\x00')) {
|
||||||
list($message_id, $message_length) = $this->struct->unpack('<8sI', substr($packet, 12, 12));
|
list($message_id, $message_length) = $this->struct->unpack('<8sI', substr($packet, 12, 12));
|
||||||
$data = substr($packet, 24, (24 + $message_length) - 24);
|
$data = substr($packet, 24, (24 + $message_length) - 24);
|
||||||
@ -210,6 +211,7 @@ class Session
|
|||||||
|
|
||||||
public function method_call($method, $kwargs)
|
public function method_call($method, $kwargs)
|
||||||
{
|
{
|
||||||
|
//var_dump($kwargs);
|
||||||
foreach (range(1, $this->MAX_RETRY) as $i) {
|
foreach (range(1, $this->MAX_RETRY) as $i) {
|
||||||
try {
|
try {
|
||||||
$this->send_message($this->tl->serialize_method($method, $kwargs));
|
$this->send_message($this->tl->serialize_method($method, $kwargs));
|
||||||
@ -230,6 +232,7 @@ class Session
|
|||||||
$ResPQ = $this->method_call('req_pq', ['nonce' => $nonce]);
|
$ResPQ = $this->method_call('req_pq', ['nonce' => $nonce]);
|
||||||
$server_nonce = $ResPQ['server_nonce'];
|
$server_nonce = $ResPQ['server_nonce'];
|
||||||
$public_key_fingerprint = $ResPQ['server_public_key_fingerprints'][0];
|
$public_key_fingerprint = $ResPQ['server_public_key_fingerprints'][0];
|
||||||
|
var_dump($public_key_fingerprint);
|
||||||
$pq_bytes = $ResPQ['pq'];
|
$pq_bytes = $ResPQ['pq'];
|
||||||
|
|
||||||
$pq = new \phpseclib\Math\BigInteger($pq_bytes, 256);
|
$pq = new \phpseclib\Math\BigInteger($pq_bytes, 256);
|
||||||
@ -273,7 +276,7 @@ class Session
|
|||||||
pyjslib_printnl(sprintf('Server-client time delta = %.1f s', $this->timedelta));
|
pyjslib_printnl(sprintf('Server-client time delta = %.1f s', $this->timedelta));
|
||||||
$dh_prime = $this->struct->unpack('>Q', $dh_prime_str);
|
$dh_prime = $this->struct->unpack('>Q', $dh_prime_str);
|
||||||
$g_a = $this->struct->unpack('>Q', $g_a_str);
|
$g_a = $this->struct->unpack('>Q', $g_a_str);
|
||||||
assert($this->PrimeModule->isPrime($dh_prime));
|
assert($this->PrimeModule->isprime($dh_prime));
|
||||||
$retry_id = 0;
|
$retry_id = 0;
|
||||||
$b_str = \phpseclib\Crypt\Random::string(256);
|
$b_str = \phpseclib\Crypt\Random::string(256);
|
||||||
$b = $this->struct->unpack('>Q', $b_str);
|
$b = $this->struct->unpack('>Q', $b_str);
|
||||||
|
@ -6,6 +6,7 @@ Created on Tue Sep 2 19:26:15 2014
|
|||||||
@author: Sammy Pfeiffer
|
@author: Sammy Pfeiffer
|
||||||
"""
|
"""
|
||||||
from binascii import crc32 as originalcrc32
|
from binascii import crc32 as originalcrc32
|
||||||
|
from binascii import hexlify
|
||||||
from time import time
|
from time import time
|
||||||
import io
|
import io
|
||||||
import os.path
|
import os.path
|
||||||
@ -125,6 +126,7 @@ class Session:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def method_call(self, method, **kwargs):
|
def method_call(self, method, **kwargs):
|
||||||
|
#print(kwargs)
|
||||||
for i in range(1, self.MAX_RETRY):
|
for i in range(1, self.MAX_RETRY):
|
||||||
try:
|
try:
|
||||||
self.send_message(TL.serialize_method(method, **kwargs))
|
self.send_message(TL.serialize_method(method, **kwargs))
|
||||||
@ -169,7 +171,6 @@ class Session:
|
|||||||
random_bytes = os.urandom(255-len(data)-len(sha_digest))
|
random_bytes = os.urandom(255-len(data)-len(sha_digest))
|
||||||
to_encrypt = sha_digest + data + random_bytes
|
to_encrypt = sha_digest + data + random_bytes
|
||||||
encrypted_data = key.encrypt(to_encrypt, 0)[0]
|
encrypted_data = key.encrypt(to_encrypt, 0)[0]
|
||||||
|
|
||||||
print("Starting Diffie Hellman key exchange")
|
print("Starting Diffie Hellman key exchange")
|
||||||
server_dh_params = self.method_call('req_DH_params',
|
server_dh_params = self.method_call('req_DH_params',
|
||||||
nonce=nonce,
|
nonce=nonce,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user