Beispiel #1
0
    def evalScript(self, script, tag=None):
        result = 0

        if tag:
            self.doc.current = tag
        else:
            try:
                body = self.doc.body
            except:
                # This code is for when you are desperate :)
                body = self.doc.getElementsByTagName('body')[0]

            if body:
                self.doc.current = body.tag.contents[-1]
            else:
                self.doc.current = self.doc.doc.contents[-1]

        with self.context as ctxt:
            try:
                ast = AST(script)
            except:
                log.debug(traceback.format_exc())
                return result

            if log.ThugOpts.Personality.isIE():
                script = script.replace('@cc_on!@', '*/!/*')

            shellcode = Shellcode.Shellcode(self, ctxt, ast, script)
            result = shellcode.run()

        return result
Beispiel #2
0
    def evalScript(self, script, tag=None):
        dom_logging(log, 'eval script', script)
        result = 0

        try:
            log.JSClassifier.classify(
                '[Local analysis]' if log.ThugOpts.local else self.url, script)
        except:
            pass

        if tag:
            self.doc.current = tag
        else:
            try:
                body = self.doc.body
            except:
                # This code is for when you are desperate :)
                body = self.doc.getElementsByTagName('body')[0]

            if body and body.tag.contents:
                self.doc.current = body.tag.contents[-1]
            else:
                self.doc.current = self.doc.doc.contents[-1]

        with self.context as ctxt:
            try:
                ast = AST(self, script)
            except:
                log.debug(traceback.format_exc())
                return result

            if log.ThugOpts.Personality.isIE():
                cc = CCInterpreter()
                script = cc.run(script)

            shellcode = Shellcode.Shellcode(self, ctxt, ast, script)
            result = shellcode.run()

        return result