def testSetTimeout(self): doc = w3c.parseString(TEST_SETTIMEOUT) win = Window(TEST_URL, doc) win.fireOnloadEvents() tag = doc.getElementById('hello') self.assertEquals(1, int(tag.firstChild.data))
def handle_frame(self, frame, redirect_type = 'frame'): log.warning(frame) src = frame.get('src', None) if not src: return try: response, content = self.window._navigator.fetch(src, redirect_type = redirect_type) except: return if response.status == 404: return if 'content-type' in response: handler = log.MIMEHandler.get_handler(response['content-type']) if handler and handler(content): return _src = self.window._navigator._normalize_url(src) if _src: src = _src doc = w3c.parseString(content) window = Window.Window(src, doc, personality = log.ThugOpts.useragent) #window.open(src) dft = DFT(window) dft.run()
def testSetInterval(self): doc = w3c.parseString(TEST_SETINTERVAL) win = Window(TEST_URL, doc) win.fireOnloadEvents() tag = doc.getElementById('hello') self.assertEquals(4, int(tag.firstChild.data))
def handle_frame(self, frame, redirect_type = 'frame'): log.warning(frame) src = frame.get('src', None) if not src: return try: response, content = self.window._navigator.fetch(src, redirect_type) except: return if response.status == 404: return if 'content-type' in response: handler = log.MIMEHandler.get_handler(response['content-type']) if handler and handler(content): return doc = w3c.parseString(content) window = Window.Window(src, doc, personality = log.ThugOpts.useragent) #window.open(src) dft = DFT(window) dft.run()
def follow_href(self, href): doc = w3c.parseString('') window = Window.Window(self.window.url, doc, personality = log.ThugOpts.useragent) window = window.open(href) if window: dft = DFT(window) dft.run()
def handle_meta(self, meta): log.warning(meta) name = meta.get('name', None) if name and name.lower() in ('generator', ): content = meta.get('content', None) if content: log.ThugLogging.add_behavior_warn("[Meta] Generator: %s" % (content, )) http_equiv = meta.get('http-equiv', None) if not http_equiv or http_equiv.lower() != 'refresh': return content = meta.get('content', None) if not content or not 'url' in content.lower(): return timeout = 0 url = None for s in content.split(';'): s = s.strip() if s.lower().startswith('url='): url = s[4:] try: timeout = int(s) except: pass if not url: return if url in self.meta and self.meta[url] >= 3: return try: response, content = self.window._navigator.fetch(url) except: return if response.status == 404: return if url in self.meta: self.meta[url] += 1 else: self.meta[url] = 1 self.window.doc = w3c.parseString(content) self.window.doc.DFT = self self.window.open(url) self.run()
def handle_meta(self, meta): log.info(meta) http_equiv = meta.get('http-equiv', None) if not http_equiv or http_equiv.lower() != 'refresh': return content = meta.get('content', None) if not content or not 'url' in content.lower(): return timeout = 0 url = None for s in content.split(';'): s = s.strip() if s.lower().startswith('url='): url = s[4:] try: timeout = int(s) except: pass if not url: return if url in self.meta and self.meta[url] >= 3: return try: response, content = self.window._navigator.fetch(url) except: return if response.status == 404: return if url in self.meta: self.meta[url] += 1 else: self.meta[url] = 1 self.window.doc = w3c.parseString(content) self.window.doc.DFT = self self.window.open(url) self.run()
def handle_frame(self, frame, redirect_type = 'frame'): log.warning(frame) src = frame.get('src', None) if not src: return try: response, content = self.window._navigator.fetch(src, redirect_type) except: return if response.status == 404: return if 'content-type' in response and response['content-type'] in ('application/pdf', ): return doc = w3c.parseString(content) window = Window.Window(src, doc) window.open(src) dft = DFT(window) dft.run()
def setUp(self): self.doc = w3c.parseString(TEST_HTML) self.win = Window(TEST_URL, self.doc)