<s> from hashlib import sha256 <EOL> import time <EOL> from Crypto . Cipher import AES <EOL> def build_token ( server_token , timestamp , secret = "<STR_LIT>" , <EOL> pattern = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> sha = sha256 ( ) <EOL> sha . update ( secret + server_token ) <EOL> hash0 = sha . hexdigest ( ) <EOL> sha = sha256 ( ) <EOL> sha . update ( timestamp + secret ) <EOL> hash1 = sha . hexdigest ( ) <EOL> output = [ hash0 [ i ] if pattern [ i ] == '<STR_LIT:0>' else hash1 [ i ] for i in range ( len ( hash0 ) ) ] <EOL> return '<STR_LIT>' . join ( output ) <EOL> def build_evil ( original , timestamp , secret = "<STR_LIT>" , <EOL> pattern = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> sha = sha256 ( ) <EOL> sha . update ( timestamp + secret ) <EOL> hash1 = sha . hexdigest ( ) <EOL> output = [ original [ i ] if pattern [ i ] == '<STR_LIT:0>' else hash1 [ i ] for i in range ( len ( original ) ) ] <EOL> return '<STR_LIT>' . join ( output ) <EOL> def ecb_encrypt ( data , key ) : <EOL> length = <NUM_LIT:16> - ( len ( data ) % <NUM_LIT:16> ) <EOL> data += chr ( length ) * length <EOL> crypt = AES . new ( key , AES . MODE_ECB ) <EOL> return crypt . encrypt ( data ) <EOL> def ecb_decrypt ( data , key ) : <EOL> crypt = AES . new ( key , AES . MODE_ECB ) <EOL> result = bytes ( crypt . decrypt ( data ) ) <EOL> result = result [ : - ord ( result [ - <NUM_LIT:1> ] ) ] <EOL> return result <EOL> def timestamp ( ) : <EOL> """<STR_LIT>""" <EOL> return str ( int ( time . time ( ) * <NUM_LIT:100> ) ) </s>
