Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not opts or not opts[0]:
opts = ["text/plain", "charset=US-ASCII"]
mimetype = opts[0]
handler = log.MIMEHandler.get_handler(mimetype)
if handler:
handler(self.window.url, data)
return None
if mimetype.startswith(('text/html', )):
from .Window import Window
doc = w3c.parseString(data)
window = Window(self.window.url, doc, personality = log.ThugOpts.useragent)
dft = DFT(window)
dft.run()
return data
log.ThugLogging.Features.increase_url_count()
try:
response = self.window._navigator.fetch(src, redirect_type = redirect_type)
except Exception as e:
log.info("[ERROR][handle_frame] %s", str(e))
return
if response is None or not response.ok: # pragma: no cover
return
if getattr(response, 'thug_mimehandler_hit', False): # pragma: no cover
return
doc = w3c.parseString(response.content)
window = Window(response.url, doc, personality = log.ThugOpts.useragent)
frame_id = frame.get('id', None)
if frame_id:
log.ThugLogging.windows[frame_id] = window
dft = DFT(window)
dft.run()
if self.mimeType:
contenttype = self.mimeType
else:
contenttype = self.responseHeaders.get('content-type', None)
if contenttype is None: # pragma: no cover
return 0
self.dispatchEvent("load")
self.dispatchEvent("readystatechange")
if 'javascript' in contenttype:
html = tostring(E.HTML(E.HEAD(), E.BODY(E.SCRIPT(response.text))))
doc = DOM.W3C.w3c.parseString(html)
window = DOM.Window.Window(self.bstrUrl, doc, personality = log.ThugOpts.useragent)
dft = DOM.DFT.DFT(window)
dft.run()
return 0
if 'text/html' in contenttype:
tags = ('
return
referer = self._window.url
if log.HTTPSession.check_equal_urls(url, referer):
log.warning("Skipping location redirection from %s to %s", referer, url)
return
for p in log.ThugOpts.Personality:
if log.ThugOpts.Personality[p]['userAgent'] == self._window._navigator.userAgent:
break
url = log.HTTPSession.normalize_url(self._window, url)
log.ThugLogging.log_href_redirect(referer, url)
doc = w3c.parseString('')
window = Window(referer, doc, personality = p) # pylint:disable=undefined-loop-variable
window = window.open(url)
if not window:
return
# self._window.url = url
dft = DFT(window)
dft.run()
def follow_href(self, href):
from .Window import Window
doc = w3c.parseString('')
window = Window(self.window.url, doc, personality = log.ThugOpts.useragent)
window = window.open(href)
if window:
dft = DFT(window)
dft.run()
log.info('[Shellcode Analysis] URL Detected: %s', url)
try:
response = self.window._navigator.fetch(url, redirect_type = "URL found")
log.ThugLogging.shellcode_urls.add(url)
except Exception:
return
if response is None:
return
if not response.ok:
return
doc = w3c.parseString(response.content)
window = Window(url, doc, personality = log.ThugOpts.useragent)
dft = DFT(window)
dft.run()
return prop[0]()
if log.ThugOpts.Personality.isIE() and key.lower() in ('wscript', 'wsh', ):
return self.WScript
if log.ThugOpts.Personality.isIE():
if key in self.WScript.__dict__ and callable(self.WScript.__dict__[key]):
return self.WScript.__dict__[key]
if log.ThugOpts.Personality.isIE():
xmlhttp = getattr(log, 'XMLHTTP', None)
if xmlhttp and key in xmlhttp:
return xmlhttp[key]
context = self.__class__.__dict__['context'].__get__(self, Window)
try:
self._symbols.add(key)
symbol = context.eval(key)
except Exception:
raise AttributeError(key)
finally:
self._symbols.discard(key)
if log.JSEngine.isJSFunction(symbol):
_method = None
if _method is None:
_method = six.create_bound_method(symbol, Window)
setattr(self, key, _method)
context.locals[key] = _method
try:
response = self.window._navigator.fetch(url, redirect_type = "meta")
except Exception as e:
log.info("[ERROR][handle_meta_refresh] %s", str(e))
return
if response is None or not response.ok:
return
if url not in log.ThugLogging.meta:
log.ThugLogging.meta[url] = 0
log.ThugLogging.meta[url] += 1
doc = w3c.parseString(response.content)
window = Window(self.window.url, doc, personality = log.ThugOpts.useragent)
dft = DFT(window)
dft.run()
if response is None or not response.ok:
return
ctype = response.headers.get('content-type', None)
if ctype is None: # pragma: no cover
return
handler = log.MIMEHandler.get_handler(ctype)
if handler:
handler(self.doc.window.url, response.content)
return
if ctype.startswith(('text/html', )):
doc = w3c.parseString(response.content)
window = Window(response.url, doc, personality = log.ThugOpts.useragent)
dft = DFT(window)
dft.run()