def _discover_and_bruteforce( self ): ''' Discovery and bruteforce phases are related, so I have joined them here in this method. @return: A list with fuzzable requests that were found during discovery and bruteforce. ''' res = set() add = res.add #TODO: This is a horrible thing to do, we consume lots of memory # for just a loop. The issue is that we had some strange # "RuntimeError: Set changed size during iteration" and I had # no time to solve them. tmp_set = set(self._fuzzable_request_set) while True: discovered_fr_list = self._discover( tmp_set ) successfully_bruteforced = self._bruteforce( tmp_set.union(discovered_fr_list) ) chain = itertools.chain( discovered_fr_list, successfully_bruteforced, self._fuzzable_request_set) map(add, chain) if not successfully_bruteforced: # Haven't found new credentials break else: # So in the next "while True:" loop I can do a discovery # using the new URLs found during bruteforce tmp_set = successfully_bruteforced # Now I reconfigure the urllib to use the newly found credentials self._reconfigureUrllib() # Update the KB before returning update_URLs_in_KB( res ) return res
except KeyboardInterrupt: self._w3af_core._end() raise except (w3afMustStopOnUrlError, w3afException, w3afMustStopException), w3: om.out.error('The target URL: %s is unreachable.' % url) om.out.error('Error description: %s' % w3) except Exception, e: om.out.error('The target URL: %s is unreachable ' 'because of an unhandled exception.' % url) om.out.error('Error description: "%s". See debug ' 'output for more information.' % e) om.out.error('Traceback for this error: %s' % traceback.format_exc()) # Load the target URLs to the KB update_URLs_in_KB( self._fuzzable_request_set ) def _auth_login(self): ''' Make login to the web application when it is needed. ''' for plugin in self._w3af_core.plugins.plugins['auth']: try: try: if not plugin.is_logged(): plugin.login() finally: tm.join(plugin) except Exception, e: # Smart error handling, much better than just crashing.