Beispiel #1
0
 def reload(self, browser):
     # close old
     browser.quit()
     # restart
     if self.browser == 'chrome':
         browser = chrome()
     else:
         browser = phantomjs()
     # add cookie, the scope is case_list[0].url's top-domain
     add_cookie(browser, self.url_list[0])
     return browser
Beispiel #2
0
 def run(self):
     blocked_urls = []
     if self.browser == 'chrome':
         browser = chrome()
     elif self.browser == 'chrome-headless':
         browser = chrome(headless=True)
     else:
         browser = phantomjs()
     # add cookie, the scope is case_list[0].url's top-domain
     add_cookie(browser, case_list[0].url)
     for case in self.case_list:
         if case.method == 'POST':
             continue
         vul = case.vul
         url = case.url
         args = case.args
         splited = url.split('/', 3)
         path = '/'.join(splited)
         # if not block
         if path not in blocked_urls:
             try:
                 browser.get(url)
             except TimeoutException, e:
                 LOGGER.warn(e)
                 # mark if browser get() exception
                 REQUEST_ERROR.append(('Openner get()', url, 'timeout'))
                 # browser blocked sometimes.
                 rtn = self.handle_block(browser)
                 if rtn is not None:
                     browser = rtn
                     splited = url.split('/', 3)
                     path = '/'.join(splited)
                     blocked_urls.append(path)
             except BadStatusLine, e:
                 LOGGER.warn(e)
                 REQUEST_ERROR.append(
                     ('Render get()', url, 'BadStatusLine'))
                 splited = url.split('/', 3)
                 path = '/'.join(splited)
                 blocked_urls.append(path)
Beispiel #3
0
 def run(self):
     blocked_urls = []
     if self.browser == 'chrome':
         browser = chrome()
     elif self.browser == 'chrome-headless':
         browser = chrome(headless=True)
     else:
         browser = phantomjs()
     # add cookie, the scope is url_list[0]'s top-domain
     add_cookie(browser, self.url_list[0])
     for url in self.url_list:
         splited = url.split('/', 3)
         path = '/'.join(splited)
         # if not block
         if path not in blocked_urls:
             try:
                 browser.get(url)
             except TimeoutException, e:
                 LOGGER.warn(e)
                 # save if browser get() exception
                 REQUEST_ERROR.append(('Render get()', url, 'timeout'))
                 # browser blocks sometimes.
                 rtn = self.handle_block(browser)
                 if rtn is not None:
                     browser = rtn
                     splited = url.split('/', 3)
                     path = '/'.join(splited)
                     blocked_urls.append(path)
             except BadStatusLine, e:
                 LOGGER.warn(e)
                 REQUEST_ERROR.append(
                     ('Render get()', url, 'BadStatusLine'))
                 splited = url.split('/', 3)
                 path = '/'.join(splited)
                 blocked_urls.append(path)
             except UnicodeDecodeError:
                 pass