Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
opts.remove('base64')
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.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()
if log.ThugOpts.features_logging:
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()
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 = ('
log.DFT._handle_data_uri(url)
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()
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 = ('
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()
try:
soup.body.unwrap()
except AttributeError:
pass
code = soup.script.get_text(types = (NavigableString, CData, Script))
html = tostring(E.HTML(E.HEAD(), E.BODY(E.SCRIPT(code))))
else:
html = content
if log.ThugOpts.features_logging:
log.ThugLogging.Features.add_characters_count(len(html))
log.ThugLogging.Features.add_whitespaces_count(len([a for a in html if isinstance(a, six.string_types) and a.isspace()]))
doc = w3c.parseString(html)
window = Window('about:blank', doc, personality = log.ThugOpts.useragent)
window.open()
self.__run(window)