Example #1
0
    def do_GET(self):

        print('get', self.path)

        page = dispatchUrl(self.server.proj, self.path)
        if page:

            self.ok_html()
            self.wfile.write(
                "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" /></head><body>"
            )

            if page.has_name_form:
                self.wfile.write(
                    name_form(page.addr, self.server.proj.database))

            renderer = HtmlRenderer(self.server.proj.database)

            page.load()
            page.render(renderer)

            self.wfile.write(renderer.getContents())

            self.wfile.write("</body></html>")

        elif self.path == '/style.css':
            self.send_response(200)
            self.send_header('Content-type', 'text/css')
            self.end_headers()
            with open('style.css', 'r') as f:
                self.wfile.write(f.read())

        elif self.path == '/favicon.ico':
            self.send_response(200)
            self.send_header('Content-type', 'image/x-icon')
            self.end_headers()
            with open('favicon.ico', 'r') as f:
                self.wfile.write(f.read())

        elif self.path.startswith('/set-name?'):
            q = urlparse(self.path).query
            p = parse_qs(q)
            print(p, q)
            addr = address.fromConventional(p['addr'][0])
            name = p['name'][0]
            self.server.proj.database.setNameForAddress(addr, name)
            self.redirect(self.headers['Referer'])

        elif self.path == '/quit/':
            self.server.request_stop = True
            self.send_response(200)
            self.end_headers()

        else:
            self.send_response(404)
            self.end_headers()
Example #2
0
    def do_GET(self):

        print('get', self.path)


        page = dispatchUrl(self.server.proj, self.path)
        if page:

            self.ok_html()
            self.wfile.write("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" /></head><body>")

            if page.has_name_form:
                self.wfile.write(name_form(page.addr, self.server.proj.database))

            renderer = HtmlRenderer(self.server.proj.database)

            page.load()
            page.render(renderer)

            self.wfile.write(renderer.getContents())

            self.wfile.write("</body></html>")

        elif self.path == '/style.css':
            self.send_response(200)
            self.send_header('Content-type', 'text/css')
            self.end_headers()
            with open('style.css', 'r') as f:
                self.wfile.write(f.read())

        elif self.path == '/favicon.ico':
            self.send_response(200)
            self.send_header('Content-type', 'image/x-icon')
            self.end_headers()
            with open('favicon.ico', 'r') as f:
                self.wfile.write(f.read())

        elif self.path.startswith('/set-name?'):
            q = urlparse(self.path).query
            p = parse_qs(q)
            print(p, q)
            addr = address.fromConventional(p['addr'][0])
            name = p['name'][0]
            self.server.proj.database.setNameForAddress(addr, name)
            self.redirect(self.headers['Referer'])

        elif self.path == '/quit/':
            self.server.request_stop = True
            self.send_response(200)
            self.end_headers()

        else:
            self.send_response(404)
            self.end_headers()
Example #3
0
    def work(self):
        def strip_tags(text):
            return re.sub(r'<[^><\(\)]*?>', '', text)
        proj = self.base_proj.openCopy()
        database = proj.database

        if self.scope == 'all':
            procs = sorted(database.getAll())
        elif self.scope == 'bank':
            procs = sorted(database.getAllInBank(self.bank))
        elif self.scope == 'proc':
            procs = [address.fromConventional(self.address)]
        else:
            raise AttributeError

        num_procs = len(procs)
        i = 0
        with open(self.filename, "wb") as f:

            for addr in procs:
                if self.requestCancel:
                    self.report(i, num_procs, "Cancelled")
                    return
                self.report(i, num_procs, "Analyzing proc: " + str(addr))

                renderer = HtmlRenderer(database)

                if self.mode == 'symbols':
                    if database.hasNameForAddress(addr):
                        renderer.add(str(addr) + ' ' + database.nameForAddress(addr))
                    else:
                        renderer.add(str(addr))
                elif self.mode == 'basic':
                    procedure.loadProcedureRange(proj, addr).render(renderer)
                elif self.mode == 'flow':
                    proj.flow.uncached(addr).render(renderer)
                else:
                    raise AttributeError

                print >>f, strip_tags(renderer.getContents())

                i += 1

        proj.close()
        self.report(i, num_procs, "Done!")