(self, obj, config)
Being plugin processing
Being plugin processing
Being plugin processing
def run(self, obj, config):
        """
        Being plugin processing
        """
        #Load data from file as libchm will only accept a filename
        with self._write_to_file() as chm_file:
            try:
                self.chmparse.LoadCHM(chm_file)
            except Exception as e:
                raise e

        #Conduct analysis
        result = self.analyze()

        #Handle output of results
        if 'obj_items_summary' in result.keys():
            obj_items_summary = result.pop('obj_items_summary')

        #General CHM info
        for key, value in result.items():
            self._add_result('chm_overview', key, {'value': value})

        if config['chm_items']:
            #Data and details of each object/page in the CHM
            user = self.current_task.user
            if user.has_access_to(SampleACL.WRITE):
                for f in self.added_files:
                    handle_file(f[0], f[3], obj.source,
                                related_id=str(obj.id),
                                related_type=str(obj._meta['crits_type']),
                                campaign=obj.campaign,
                                source_method=self.name,
                                relationship=RelationshipTypes.CONTAINED_WITHIN,
                                user=self.current_task.user)
                    self._add_result("chm_items_added", f[0], {'size': f[1],'md5': f[2]})
            else:
                self._info("User does not have permission to add samples to CRITs.")
                self._add_result("chm_items_added","Items found but user does not have permission to add Samples to CRITs.")
        else:
            #Details of each object/page in the CHM
            for object_item in obj_items_summary:
                self._add_result('chm_items', object_item.get('name'),
                            {'size': object_item.get('size'),
                            'md5': object_item.get('md5')})

        #Detection results from CHM analysis
        for object_item in obj_items_summary:
            if object_item.get('detection'):
                for detection in object_item.get('detection'):
                    self._add_result('chm_detection', detection, {'chm_item': object_item.get('name')})

        #URLs and IPs found in CHM
        for object_item in obj_items_summary:
            if object_item.get('urls'):
                for url in object_item.get('urls'):
                    self._add_result('chm_urls', url, {'chm_item': object_item.get('name')})

        #Close file in memory
        self.chmparse.CloseCHM()
def run ( self , obj , config ) : #Load data from file as libchm will only accept a filename with self . _write_to_file ( ) as chm_file : try : self . chmparse . LoadCHM ( chm_file ) except Exception as e : raise e #Conduct analysis result = self . analyze ( ) #Handle output of results if 'obj_items_summary' in result . keys ( ) : obj_items_summary = result . pop ( 'obj_items_summary' ) #General CHM info for key , value in result . items ( ) : self . _add_result ( 'chm_overview' , key , { 'value' : value } ) if config [ 'chm_items' ] : #Data and details of each object/page in the CHM user = self . current_task . user if user . has_access_to ( SampleACL . WRITE ) : for f in self . added_files : handle_file ( f [ 0 ] , f [ 3 ] , obj . source , related_id = str ( obj . id ) , related_type = str ( obj . _meta [ 'crits_type' ] ) , campaign = obj . campaign , source_method = self . name , relationship = RelationshipTypes . CONTAINED_WITHIN , user = self . current_task . user ) self . _add_result ( "chm_items_added" , f [ 0 ] , { 'size' : f [ 1 ] , 'md5' : f [ 2 ] } ) else : self . _info ( "User does not have permission to add samples to CRITs." ) self . _add_result ( "chm_items_added" , "Items found but user does not have permission to add Samples to CRITs." ) else : #Details of each object/page in the CHM for object_item in obj_items_summary : self . _add_result ( 'chm_items' , object_item . get ( 'name' ) , { 'size' : object_item . get ( 'size' ) , 'md5' : object_item . get ( 'md5' ) } ) #Detection results from CHM analysis for object_item in obj_items_summary : if object_item . get ( 'detection' ) : for detection in object_item . get ( 'detection' ) : self . _add_result ( 'chm_detection' , detection , { 'chm_item' : object_item . get ( 'name' ) } ) #URLs and IPs found in CHM for object_item in obj_items_summary : if object_item . get ( 'urls' ) : for url in object_item . get ( 'urls' ) : self . _add_result ( 'chm_urls' , url , { 'chm_item' : object_item . get ( 'name' ) } ) #Close file in memory self . chmparse . CloseCHM ( )