コード例 #1
0
def parse_all_files  (config_file):
    renamer_options = { 'class_csv'       : None,
                        'field_csv'       : None,
                        'method_csv'      : None,
                        'server_rgs'      : None,
                        'client_rgs'      : None,
                        'server_rgs_out'  : None,
                        'client_rgs_out'  : None,
                        'server_src'      : None,
                        'client_src'      : None,
                        'package_name'    : None,
                        'unknown_name'    : None,
                        'known_name'      : None,
                        'md5_file_client' : None,
                        'md5_file_server' : None,
                        }

    config     = parsers.parse_config(config_file, renamer_options)
    
    class_csv  = parsers.parse_csv(config['class_csv'],  3, ',', ['full',      'trashbin', 'notch_c',  'trashbin',  'notch_s', 'description'])
    method_csv = parsers.parse_csv(config['method_csv'], 4, ',', ['trashbin',  'searge_c', 'trashbin', 'searge_s',  'full', 'description'])    
    field_csv  = parsers.parse_csv(config['field_csv'],  3, ',', ['trashbin',  'trashbin', 'searge_c', 'trashbin',  'trashbin', 'searge_s', 'full', 'description'])    
    
    client_rgs = parsers.parse_rgs(config['client_rgs']) #contains a list of notch_name to searge_name for the client
    server_rgs = parsers.parse_rgs(config['server_rgs']) #contains a list of notch_name to searge_name for the server

    #We want 3 dicts per soft. One for classes, methods and fields. Each dict is going to take the searge_name as the key, as it is the only
    #unique identifier we are sure of for now. Each dict will have at least 3 entries, notch_name, searge_name and full_name.
    #Classes will have an identical searge_name and full_name, as they are identical. Methods will also contain the notch_signature and maybe the searge_signature.
    #Packages can also be a value somewhere for the reobfuscation step.

    #Let's start with the class dictionary. For this one, we just need the rgs file.
    class_dict_c = create_dic_class(client_rgs)
    class_dict_s = create_dic_class(server_rgs)

    #Now the fields, as they are easy to process. Need both the csv and the rgs. Third argument is to get the right column
    field_dict_c = create_dic_member(client_rgs, field_csv, class_dict_c, 'c', 'field_map', config)
    field_dict_s = create_dic_member(server_rgs, field_csv, class_dict_s, 's', 'field_map', config)

    #And finally the methods. Same as before.
    method_dict_c = create_dic_member(client_rgs, method_csv, class_dict_c, 'c', 'method_map', config)
    method_dict_s = create_dic_member(server_rgs, method_csv, class_dict_s, 's', 'method_map', config)

    client_dic = {'class':class_dict_c, 'method':method_dict_c, 'field':field_dict_c}
    server_dic = {'class':class_dict_s, 'method':method_dict_s, 'field':field_dict_s}

    #solve_collisions(client_dic)
    #solve_collisions(server_dic)

    return client_dic, server_dic, config
コード例 #2
0
ファイル: ImportMCP.py プロジェクト: N3X15/MiddleCraft
def parse_all_files():
    class_csv  = parsers.parse_csv('data/mcp/classes.csv',  3, ',', ['full',      'trashbin', 'notch_c',  'trashbin',  'notch_s', 'description'])
    method_csv = parsers.parse_csv('data/mcp/methods.csv',  4, ',', ['trashbin',  'searge_c', 'trashbin', 'searge_s',  'full', 'description'])    
    field_csv  = parsers.parse_csv('data/mcp/fields.csv',   3, ',', ['trashbin',  'trashbin', 'searge_c', 'trashbin',  'trashbin', 'searge_s', 'full', 'description'])    
    
    #client_rgs = parsers.parse_rgs(config['client_rgs']) #contains a list of notch_name to searge_name for the client
    server_rgs = parsers.parse_rgs('data/mcp/minecraft_server.rgs') #contains a list of notch_name to searge_name for the server

    #We want 3 dicts per soft. One for classes, methods and fields. Each dict is going to take the searge_name as the key, as it is the only
    #unique identifier we are sure of for now. Each dict will have at least 3 entries, notch_name, searge_name and full_name.
    #Classes will have an identical searge_name and full_name, as they are identical. Methods will also contain the notch_signature and maybe the searge_signature.
    #Packages can also be a value somewhere for the reobfuscation step.

    #Let's start with the class dictionary. For this one, we just need the rgs file.
    #class_dict_c = create_dic_class(client_rgs)
    class_dict_s = create_dic_class(server_rgs)

    #Now the fields, as they are easy to process. Need both the csv and the rgs. Third argument is to get the right column
    #field_dict_c = create_dic_member(client_rgs, field_csv, class_dict_c, 'c', 'field_map', config)
    field_dict_s = create_dic_member(server_rgs, field_csv, class_dict_s, 's', 'field_map')

    #And finally the methods. Same as before.
    #method_dict_c = create_dic_member(client_rgs, method_csv, class_dict_c, 'c', 'method_map', config)
    method_dict_s = create_dic_member(server_rgs, method_csv, class_dict_s, 's', 'method_map')

    nmethods=0
    nfields=0
    nclasses=0
    ckeys=class_dict_s.keys()
    ckeys.sort()
    for ckey in ckeys:
        nclasses=nclasses+1
        #print '* Post-processing class %s...' % ckey
        for mkey in method_dict_s:
            method = method_dict_s[mkey]
            if method['class']==ckey:
                nmethods=nmethods+1
                nmkey = method['csv'] # Use CSV name to determine method key.
                if nmkey==None:
                    nmkey=method['searge']
                class_dict_s[ckey]['methods'][nmkey]=method
        for fkey in field_dict_s:
            field = field_dict_s[fkey]
            if field['class']==ckey:
                nfields=nfields+1
                nfkey = field['csv'] # Use CSV name to determine field key.
                if nfkey==None:
                    nfkey=field['searge']
                class_dict_s[ckey]['fields'][nfkey]=field
                
    print '*** POST-PROCESSING COMPLETE ***'
    print ' + %d classes' % nclasses
    print ' + %d methods' % nmethods
    print ' + %d fields' % nfields
    
    #solve_collisions(client_dic)
    #solve_collisions(server_dic)

    return class_dict_s