def get(self): try: filename = self.get_argument("obj", strip=False) fullPath = os.path.join('/tmp/', filename) data = RichHeaderRun(fullPath) self.write(data) except tornado.web.MissingArgumentError: raise tornado.web.HTTPError(400) except richlibrary.FileSizeError: self.write({'error': richlibrary.err2str(-2)}) except richlibrary.MZSignatureError: self.write({'error': richlibrary.err2str(-3)}) except richlibrary.MZPointerError: self.write({'error': richlibrary.err2str(-4)}) except richlibrary.PESignatureError: self.write({'error': richlibrary.err2str(-5)}) except richlibrary.RichSignatureError: self.write({'error': richlibrary.err2str(-6)}) except richlibrary.DanSSignatureError: self.write({'error': richlibrary.err2str(-7)}) except richlibrary.HeaderPaddingError: self.write({'error': richlibrary.err2str(-8)}) except richlibrary.RichLengthError: self.write({'error': richlibrary.err2str(-9)}) except Exception as e: self.write({"error": traceback.format_exc(e)})
def main(): if len(sys.argv) < 2: print("Usage: {} <pe-files>".format(sys.argv[0])) sys.exit(-1) for arg in sys.argv[1:]: error = 0 rich_parser = RichHeader(arg) try: rich = rich_parser.parse() except richlibrary.FileSizeError: error = -2 except richlibrary.MZSignatureError: error = -3 except richlibrary.MZPointerError: error = -4 except richlibrary.PESignatureError: error = -5 except richlibrary.RichSignatureError: error = -6 except richlibrary.DanSSignatureError: error = -7 except richlibrary.HeaderPaddingError: error = -8 except richlibrary.RichLengthError: error = -9 except Exception as e: print(traceback.format_exc(e)) if error < 0: print("\x1b[33m[-] " + richlibrary.err2str(rich['err']) + "\x1b[39m") sys.exit(rich['err']) else: rich_parser.pprint_header(rich)
def get(self): try: filename = self.get_argument("obj", strip=False) fullPath = os.path.join('/tmp/', filename) data = RichHeaderRun(fullPath) self.write(data) except tornado.web.MissingArgumentError: raise tornado.web.HTTPError(400) except richlibrary.MZSignatureError: self.write({'error': richlibrary.err2str(-2)}) except richlibrary.PESignatureError: self.write({'error': richlibrary.err2str(-3)}) except richlibrary.RichSignatureError: self.write({'error': richlibrary.err2str(-4)}) except richlibrary.DanSSignatureError: self.write({'error': richlibrary.err2str(-5)}) except richlibrary.PaddingError: self.write({'error': richlibrary.err2str(-6)}) except richlibrary.RichLengthError: self.write({'error': richlibrary.err2str(-7)}) except Exception as e: self.write({"error": traceback.format_exc(e)})