def do_GET(self): lookup = TemplateLookup(directories=["cuckoo/web/"], output_encoding='utf-8', encoding_errors='replace') template = lookup.get_template("web.html") try: parts = os.path.split(self.path) if parts[0] == "/": self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() db = CuckooDatabase() tasks = db.completed_tasks(30) html = template.render(section_title="Recent Analysis", tasks=tasks) self.wfile.write(html) return elif parts[0] == "/analysis": analysis_id = parts[1].strip() if not analysis_id.isdigit(): self.send_error(404) return analysis_path = "analysis/%s/reports/report.html" % analysis_id if os.path.exists(analysis_path): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(open(analysis_path, "rb").read()) return else: self.send_error(404) return elif parts[0] == "/search": md5 = parts[1].strip() if not md5.isalnum() or len(md5) != 32: self.send_error(404) return self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() db = CuckooDatabase() tasks = db.search_tasks(md5) html = template.render(section_title="Search results for: %s" % md5, tasks=tasks) self.wfile.write(html) return else: self.send_error(404) return except Exception, why: print why self.send_error(404) return
if not target: return False # Check if the target file actually exists, otherwise terminate script. if not os.path.exists(target): print(bold(red("ERROR")) + ": The target file \"%s\" does not exist." % target) return False try: md5 = hashlib.md5(open(target, "rb").read()).hexdigest() except Exception, why: md5 = None # Add task to the database. try: db = CuckooDatabase() task_id = db.add_task(target, md5, options.timeout, options.package, options.priority, options.custom, options.machine) if not task_id: print(bold(red("ERROR")) + ": Unable to add task to database.") return False else: print(bold(cyan("DONE")) + ": Task successfully added with ID %d." % task_id) except Exception, why: print(bold(red("ERROR")) + ": Unable to add new task: %s" % why)
# Check if the target file actually exists, otherwise terminate script. if not os.path.exists(target): print( bold(red("ERROR")) + ": The target file \"%s\" does not exist." % target) return False try: md5 = hashlib.md5(open(target, "rb").read()).hexdigest() except Exception, why: md5 = None # Add task to the database. try: db = CuckooDatabase() task_id = db.add_task(target, md5, options.timeout, options.package, options.priority, options.custom, options.machine) if not task_id: print(bold(red("ERROR")) + ": Unable to add task to database.") return False else: print( bold(cyan("DONE")) + ": Task successfully added with ID %d." % task_id) except Exception, why: print(bold(red("ERROR")) + ": Unable to add new task: %s" % why) return False return True