Module Assign NameStore Str Import alias Import alias Import alias Import alias Import alias ClassDef bases NameLoad body FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list decorator_list ClassDef bases body FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr Dict Str Dict Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr If CompareEq Call NameLoad NameLoad Num body Return TryExcept body AugAssignAdd SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Num Index Str Num handlers ExceptHandler type NameLoad body TryExcept body Assign SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Num Index Str Num handlers ExceptHandler type NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Num Dict Str Num Assign NameStore Str For NameStore Call NameLoad Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad TryExcept body AugAssignAdd SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Index NameLoad Num handlers ExceptHandler type NameLoad body TryExcept body Assign SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Index NameLoad Num handlers ExceptHandler type NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad Dict NameLoad Num Assign NameStore NameLoad For NameStore NameLoad body If CompareNotIn NameLoad AttributeLoad NameLoad attr body Raise decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Str Assign NameStore ListLoad While NameLoad body Assign NameStore SubscriptLoad SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr keyword Call AttributeLoad NameLoad attr Num Index Num Index Num If CompareEq NameLoad Str body Break Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Return Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListLoad If CompareLt Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr Num body Assign NameStore NameLoad Assign NameStore Num While NameLoad body TryExcept body Assign NameStore ListLoad NameLoad Assign NameStore NameLoad While NameLoad body Assign NameStore Num For NameStore NameLoad body AugAssignAdd NameStore Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr If CompareLt NameLoad Num body Assign NameStore SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Num attr keyword Call AttributeLoad NameLoad attr Num Slice Num Assign NameStore IfExp CompareLt NameLoad BinOpSub Call NameLoad NameLoad Num NameLoad BinOpSub Call NameLoad NameLoad Num If CompareEq NameLoad Num body Assign NameStore Num orelse Assign NameStore Call AttributeLoad NameLoad attr Num NameLoad AugAssignSub NameStore NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num orelse Assign NameStore SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Num attr keyword Call AttributeLoad NameLoad attr Num Slice Num If CompareLt Call NameLoad NameLoad BinOpAdd NameLoad Num body Raise Call NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore NameLoad Break handlers ExceptHandler type NameLoad body Assign NameStore NameLoad AugAssignAdd NameStore Num If CompareGt NameLoad Num body Raise Call NameLoad orelse Expr Call AttributeLoad NameLoad attr SubscriptLoad SubscriptLoad SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr keyword Call AttributeLoad NameLoad attr Num Slice Num Index NameLoad Index Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareEq NameLoad Num body Return ListLoad Num Return BinOpAdd Call AttributeLoad NameLoad attr BinOpDiv NameLoad NameLoad NameLoad ListLoad BinOpMod NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore BinOpAdd BinOpMult ListLoad Num BinOpSub Call NameLoad Call AttributeLoad NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr Num NameLoad Num Call NameLoad NameLoad NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign NameStore BinOpAdd Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num NameLoad Num If CompareNotEq BinOpMod Call NameLoad NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr Str Assign NameStore ListLoad For NameStore Call NameLoad BinOpDiv Call NameLoad NameLoad NameLoad body Assign NameStore Num For NameStore Call NameLoad NameLoad body Assign NameStore BinOpAdd BinOpMult NameLoad NameLoad BinOpSub BinOpSub NameLoad Num NameLoad AugAssignAdd NameStore BinOpMult SubscriptLoad NameLoad Index NameLoad BinOpPow NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad Assign NameStore ListLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Assign NameStore NameLoad While NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Num Num Assign NameStore SubscriptLoad NameLoad Index Num For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad For NameStore NameLoad body If CompareNotEq NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr Str Assign NameStore NameLoad handlers ExceptHandler type NameLoad body Continue Break Return Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Str Assign NameStore SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr keyword Call AttributeLoad NameLoad attr Num Slice Num Assign NameStore ListLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad While CompareNotEq Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Num If CompareEq NameLoad Str body Assign NameStore Str If CompareEq NameLoad Str body Continue Assign NameStore SubscriptLoad Call NameLoad Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr keyword Call AttributeLoad NameLoad attr Num Slice Num Assign NameStore NameLoad For NameStore Call NameLoad Call NameLoad NameLoad body If CompareEq SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num NameLoad body Assign NameStore NameLoad Break If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad If CompareGtE Call NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore NameLoad Assign NameStore NameLoad orelse If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad Assign NameStore NameLoad orelse If CompareLt Call NameLoad NameLoad Num body Assign NameStore ListLoad NameLoad Assign NameStore ListLoad Call NameLoad NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Assign NameStore NameLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Return Call AttributeLoad Str attr Call NameLoad NameLoad NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign NameStore Str Assign NameStore Str Assign NameStore Call NameLoad With Call NameLoad NameLoad Str NameStore body Assign NameStore Call AttributeLoad NameLoad attr Expr Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad Str attr ListComp Call NameLoad Call AttributeLoad NameLoad attr Num Num comprehension NameStore Call NameLoad Num If CompareNotEq NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad body Print Str Assign NameStore Str Print Call AttributeLoad Str attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Print Call AttributeLoad Str attr NameLoad Assign NameStore Call NameLoad Expr Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Print Call AttributeLoad Str attr Call AttributeLoad NameLoad attr NameLoad
N/A N/A __author__ bwall N/A re N/A operator N/A random N/A logging N/A math AlgorithmFailException N/A Exception N/A __init__ N/A N/A self N/A N/A N/A N/A N/A Exception __init__ self N/A N/A MarkovKeyState N/A N/A __init__ N/A N/A self N/A N/A N/A 
        It is a constructor that takes no arguments, why do you care about what it does???
        :return:
         N/A N/A self words N/A set N/A N/A self raw_scores N/A --terminate-- N/A N/A N/A self new_base 16 N/A learn_sentence N/A N/A self sentence N/A N/A N/A 
        Learn based on the input sentence.

        :param sentence: Space separated sentence to apply to Markov model
        :return: No relevant return data
         N/A parts N/A N/A re findall \w[\w']* N/A N/A sentence lower N/A N/A N/A len parts 0 N/A N/A N/A N/A N/A N/A N/A N/A self raw_scores N/A N/A parts N/A -1 N/A --terminate-- 1 N/A N/A N/A KeyError N/A N/A N/A N/A N/A N/A N/A self raw_scores N/A N/A parts N/A -1 N/A --terminate-- 1 N/A N/A N/A KeyError N/A N/A N/A N/A self raw_scores N/A N/A parts N/A -1 N/A --terminate-- 1 N/A last --terminate-- N/A x N/A xrange N/A len parts N/A N/A current N/A parts N/A x N/A N/A N/A N/A N/A N/A self raw_scores N/A last N/A current 1 N/A N/A N/A KeyError N/A N/A N/A N/A N/A N/A N/A self raw_scores N/A last N/A current 1 N/A N/A N/A KeyError N/A N/A N/A N/A self raw_scores N/A last N/A current 1 N/A last current N/A part parts N/A N/A N/A part N/A self raw_scores N/A N/A N/A print_most_likely_sentence N/A N/A self N/A N/A N/A 
        This function is mostly for testing/fun.  It generates the most likely sentence from the Markov model
        :return: The sentence
         N/A last --terminate-- N/A parts N/A N/A True N/A N/A current N/A N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A last items key N/A N/A operator itemgetter 1 N/A -1 N/A 0 N/A N/A current --terminate-- N/A N/A N/A N/A N/A parts append current N/A last current N/A N/A N/A join parts N/A create_byte N/A N/A self last byte_value N/A N/A N/A 
        Internal function to generate an obfuscated byte, which can be represented by multiple words/sentences

        :param last: The last word in the current obfuscated sentence
        :param byte_value: The byte value to append
        :return: A string of words to append
         N/A words N/A N/A N/A N/A len N/A N/A N/A N/A self raw_scores N/A last items 256 N/A N/A try_again True N/A attempts 0 N/A try_again N/A N/A N/A N/A words_to_use N/A last N/A remaining_value byte_value N/A True N/A N/A count 0 N/A word words_to_use N/A N/A count N/A len N/A N/A N/A N/A self raw_scores N/A word items N/A N/A count 256 N/A N/A current_list N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A N/A words_to_use N/A -1 items key N/A N/A operator itemgetter 1 N/A -1 N/A upper_bound N/A N/A remaining_value N/A N/A len current_list 1 remaining_value N/A N/A len current_list 1 N/A N/A upper_bound 0 N/A N/A index 0 N/A N/A index N/A N/A random randint 0 upper_bound N/A remaining_value index N/A N/A N/A words_to_use append N/A N/A current_list N/A index N/A 0 N/A N/A current_list N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A N/A words_to_use N/A -1 items key N/A N/A operator itemgetter 1 N/A -1 N/A N/A N/A len current_list N/A remaining_value 1 N/A N/A N/A AlgorithmFailException N/A N/A N/A words_to_use append N/A N/A current_list N/A remaining_value N/A 0 N/A words N/A words_to_use N/A 1 N/A try_again False N/A N/A N/A N/A AlgorithmFailException N/A N/A try_again True N/A attempts 1 N/A N/A attempts 1024 N/A N/A N/A AlgorithmFailException N/A N/A N/A N/A words append N/A N/A N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A last items key N/A N/A operator itemgetter 1 N/A -1 N/A byte_value N/A 0 N/A words N/A _char_to_base N/A N/A chr_int target_base N/A N/A N/A N/A chr_int 0 N/A N/A N/A 0 N/A N/A N/A N/A MarkovKeyState _char_to_base N/A chr_int target_base target_base N/A N/A chr_int target_base N/A staticmethod char_to_base N/A N/A chr_int target_base N/A N/A N/A r N/A N/A MarkovKeyState _char_to_base chr_int target_base N/A r N/A N/A N/A 0 N/A N/A int N/A N/A math ceil N/A N/A N/A math log 256 target_base 1 N/A len r r N/A r N/A staticmethod base_to_chars N/A N/A chr_ints original_base N/A N/A N/A numbers_per_char N/A N/A int N/A N/A math ceil N/A N/A math log 256 original_base 1 N/A N/A N/A N/A len chr_ints numbers_per_char 0 N/A N/A N/A N/A logging debug Base conversion is borked... N/A results N/A N/A index N/A xrange N/A N/A len chr_ints numbers_per_char N/A N/A number 0 N/A position N/A xrange numbers_per_char N/A N/A x N/A N/A index numbers_per_char N/A N/A numbers_per_char 1 position N/A number N/A N/A chr_ints N/A x N/A original_base position N/A N/A N/A results append number N/A results N/A staticmethod obfuscate_string N/A N/A self s N/A N/A N/A 
        Obfuscate the input binary string with the Markov model

        :param s: Input string, can be binary string, we immediately convert to ints anyways
        :return: The obfuscated string
         N/A parts N/A map ord N/A list s N/A temp_parts N/A N/A p parts N/A N/A N/A N/A temp_parts extend N/A N/A MarkovKeyState char_to_base p N/A self new_base N/A parts temp_parts N/A True N/A N/A N/A N/A result N/A N/A self create_byte --terminate-- N/A N/A random randint 0 256 N/A last N/A result N/A -1 N/A x parts N/A N/A to_append N/A N/A self create_byte last x N/A current to_append N/A N/A N/A current --terminate-- N/A N/A N/A N/A result append current N/A N/A N/A N/A result append .  N/A last current N/A N/A N/A AlgorithmFailException N/A N/A N/A N/A N/A N/A join result N/A deobfuscate_string N/A N/A self s N/A N/A N/A 
        Well...now we need to be able to deobfuscate a string, right?

        :param s: The string to deobfuscate
        :return: The deobfuscated string
         N/A parts N/A N/A s split N/A last --terminate-- N/A last_list N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A last items key N/A N/A operator itemgetter 1 N/A -1 N/A result N/A N/A running_values None N/A running_list_lengths None N/A running_value None N/A N/A N/A len parts 0 N/A N/A current_word N/A N/A parts pop 0 N/A N/A current_word . N/A N/A current_word --terminate-- N/A N/A current_word N/A N/A N/A current_list N/A N/A sorted N/A N/A N/A N/A self raw_scores N/A current_word items key N/A N/A operator itemgetter 1 N/A -1 N/A current_value None N/A x N/A xrange N/A len last_list N/A N/A N/A N/A N/A last_list N/A x N/A 0 current_word N/A N/A current_value x N/A N/A N/A running_values None N/A N/A N/A N/A running_list_lengths append N/A len last_list N/A N/A N/A running_values append current_value N/A N/A N/A sum running_list_lengths 256 N/A N/A N/A N/A result append N/A sum running_values N/A running_list_lengths None N/A running_values None N/A N/A N/A running_value None N/A N/A N/A N/A result append N/A current_value running_value N/A running_value None N/A N/A N/A N/A len last_list 256 N/A N/A running_values N/A current_value N/A running_list_lengths N/A N/A len last_list N/A N/A N/A N/A result append current_value N/A last current_word N/A last_list current_list N/A N/A running_value None N/A N/A N/A N/A result append running_value N/A N/A running_values None N/A N/A N/A N/A result append N/A sum running_values N/A result N/A result N/A 1 N/A result N/A N/A MarkovKeyState base_to_chars result N/A self new_base N/A N/A N/A join N/A map chr result N/A N/A N/A N/A __name__ __main__ N/A N/A N/A N/A logging basicConfig level N/A logging DEBUG N/A split_regex \n N/A training_file ../datasets/98.txt N/A m N/A MarkovKeyState N/A N/A open training_file r f N/A N/A text N/A N/A f read N/A N/A map N/A m learn_sentence N/A N/A re split split_regex text N/A i N/A xrange 3 N/A N/A rand_string N/A N/A join N/A N/A chr N/A N/A random randint 0 255 N/A k N/A xrange 64 N/A N/A rand_string N/A N/A m deobfuscate_string N/A N/A m obfuscate_string rand_string N/A N/A Failed integrity test N/A test_string This is a test message to prove the concept. N/A N/A N/A Original string: {0} format test_string N/A s N/A N/A m obfuscate_string test_string N/A N/A N/A Obfuscated string: {0} format s N/A m2 N/A MarkovKeyState N/A N/A map N/A m2 learn_sentence N/A N/A re split split_regex text N/A N/A N/A Deobfuscated string: {0} format N/A N/A m2 deobfuscate_string s