def end(self): """ This method is called when the plugin wont be used anymore. """ cookies = kb.kb.getData("collectCookies", "cookies") # Group correctly tmp = [] for c in cookies: tmp.append((c["cookie-string"], c.getURL())) # And don't print duplicates tmp = list(set(tmp)) resDict, itemIndex = groupbyMinKey(tmp) if itemIndex == 0: # Grouped by cookies msg = 'The cookie: "%s" was sent by these URLs:' else: # Grouped by URLs msg = 'The URL: "%s" sent these cookies:' for k in resDict: om.out.information(msg % k) for i in resDict[k]: om.out.information("- " + i)
def end(self): ''' This method is called when the plugin wont be used anymore. ''' headers = kb.kb.getData( 'strangeHeaders', 'strangeHeaders' ) # This is how I saved the data: #i['header_name'] = header_name #i['header_value'] = response.getHeaders()[header_name] # Group correctly tmp = [] for i in headers: tmp.append( (i['header_name'], i.getURL() ) ) # And don't print duplicates tmp = list(set(tmp)) resDict, itemIndex = groupbyMinKey( tmp ) if itemIndex == 0: # Grouped by header_name msg = 'The header: "%s" was sent by these URLs:' else: # Grouped by URL msg = 'The URL: "%s" sent these strange headers:' for k in resDict: om.out.information(msg % k) for i in resDict[k]: om.out.information('- ' + i )
def end( self ): ''' Print the results. ''' # First I get the data from the kb all_info_obj = kb.kb.getData( 'allowedMethods', 'methods' ) dav_info_obj = kb.kb.getData( 'allowedMethods', 'dav-methods' ) # Now I transform it to something I can use with groupbyMinKey allMethods = [] for i in all_info_obj: allMethods.append( (i.getURL() , i['methods']) ) davMethods = [] for i in dav_info_obj: davMethods.append( (i.getURL() , i['methods']) ) # Now I work the data... to_show, method_type = davMethods, ' DAV' if not self._report_dav_only: to_show, method_type = allMethods, '' # Make it hashable tmp = [] for url, methodList in to_show: tmp.append( (url, ', '.join( methodList ) ) ) result_dict, itemIndex = groupbyMinKey( tmp ) for k in result_dict: if itemIndex == 0: # Grouped by URLs msg = 'The URL: "%s" has the following' + method_type + ' methods enabled:' om.out.information(msg % k) else: # Grouped by Methods msg = 'The methods: ' + k + ' are enabled on the following URLs:' om.out.information(msg) for i in result_dict[k]: om.out.information('- ' + i )