From 27f5d249a760c819692cba55b0268a3051fc8da9 Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Fri, 23 Aug 2019 17:19:03 +0500 Subject: [PATCH] add a workaround against the clients who send zero as their itimestamp --- mtprotoproxy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mtprotoproxy.py b/mtprotoproxy.py index 45cd925..8563f0f 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -939,7 +939,8 @@ async def handle_fake_tls_handshake(handshake, reader, writer, peer): continue timestamp = int.from_bytes(xored_digest[-4:], "little") - if not is_time_skewed and not TIME_SKEW_MIN < time.time() - timestamp < TIME_SKEW_MAX: + client_time_is_ok = TIME_SKEW_MIN < time.time() - timestamp < TIME_SKEW_MAX + if not client_time_is_ok and not is_time_skewed and timestamp != 0: print_err("Client with time skew detected from %s, can be a replay-attack" % peer[0]) print_err("The clocks were %d minutes behind" % ((time.time() - timestamp) // 60)) continue