From f9cdf2090fd38a5ba78aee366662552d639a11d2 Mon Sep 17 00:00:00 2001 From: breakwa11 Date: Sat, 26 Sep 2015 22:33:11 +0800 Subject: [PATCH] add crc verify --- shadowsocks/obfsplugin/http_simple.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shadowsocks/obfsplugin/http_simple.py b/shadowsocks/obfsplugin/http_simple.py index 0e3c211..367d7cc 100644 --- a/shadowsocks/obfsplugin/http_simple.py +++ b/shadowsocks/obfsplugin/http_simple.py @@ -238,12 +238,15 @@ class random_head(object): if self.has_sent_header: return buf self.has_sent_header = True - return os.urandom(common.ord(os.urandom(1)[0]) % 96 + 1) + return os.urandom(common.ord(os.urandom(1)[0]) % 96 + 4) def server_decode(self, buf): if self.has_recv_header: return (buf, True, False) + crc = binascii.crc32(buf) & 0xffffffff + if crc != 0xffffffff: + return (buf, True, False) self.has_recv_header = True # (buffer_to_recv, is_need_decrypt, is_need_to_encode_and_send_back) return (b'', False, True)