<s> from argparse import ArgumentParser <EOL> from generate_from_subnets import get_socks_keys <EOL> def parse_args ( ) : <EOL> parser = ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT:input>' , required = True , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> return parser . parse_args ( ) <EOL> def generate_snort_rules ( blacklist , start_sid = <NUM_LIT> ) : <EOL> for word in blacklist : <EOL> start_sid += <NUM_LIT:1> <EOL> print "<STR_LIT>" % ( word . strip ( ) , start_sid ) <EOL> def decorate_socks_keys ( ) : <EOL> return map ( lambda x : '<STR_LIT:|>' + x + '<STR_LIT:|>' , <EOL> [ "<STR_LIT:U+0020>" . join ( s [ i : i + <NUM_LIT:2> ] for i in range ( <NUM_LIT:0> , len ( s ) , <NUM_LIT:2> ) ) <EOL> for s in get_socks_keys ( ) ] ) <EOL> def main ( ) : <EOL> args = parse_args ( ) <EOL> blacklist = open ( args . input , '<STR_LIT:r>' ) . readlines ( ) + decorate_socks_keys ( ) <EOL> start_sid = int ( args . sid or <NUM_LIT> ) <EOL> generate_snort_rules ( blacklist , start_sid ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
