From 22238dea9827eb2245256419a5df0082e5ce4556 Mon Sep 17 00:00:00 2001 From: Rohan Gupta Date: Sat, 24 Sep 2022 19:51:55 +0530 Subject: [PATCH] Update address to hex in syscalls --- qltool | 2 +- qltui.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qltool b/qltool index f6ffade3..5f358dab 100755 --- a/qltool +++ b/qltool @@ -265,7 +265,7 @@ if __name__ == '__main__': if options.json: report = report.generate_report(ql) - report["syscalls"] = ql.os.stats.syscalls + report["syscalls"] = qltui.transform_syscalls(ql.os.stats.syscalls) if options.subcommand == 'qltui': qltui.show_report(ql, report, hook_dictionary) else: diff --git a/qltui.py b/qltui.py index f4d605f8..04a3e6c9 100644 --- a/qltui.py +++ b/qltui.py @@ -483,7 +483,7 @@ def show_report(ql, report, hook_dictionary): elif command == 'interactive report': Controller().run(DataSourceType.VARIABLE, report) elif command == 'report to pdf': - time = datetime.now().strftime("%d_%m_%Y_%H_%M_%S") + time = datetime.now().strftime("%Y_%m_%d_%H-%M-%S") report_name = f"report_{ql.targetname.replace('.', '_')}_{os_name}_{arch_name}_{time}.pdf" pdfc = PdfConverter() with open(report_name, "wb") as pdf_fl: @@ -665,3 +665,22 @@ def hook(ql): getattr(ql, hook_type)(getattr(Callback_Functions, operation), *args, user_data=user_data) return hook_dictionary + + +def transform_syscalls(syscalls, keys=["address"], func=lambda x: hex(x)): + for i in syscalls: + try: + if type(i) == type({}): + transform_syscalls(i, keys, func) + if isinstance(i, list): + transform_syscalls(i, keys, func) + elif isinstance(syscalls[i], list): + transform_syscalls(syscalls[i], keys, func) + elif type(syscalls[i]) == type({}): + transform_syscalls(syscalls[i], keys, func) + if i in keys and isinstance(syscalls[i], int): + syscalls[i] = func(syscalls[i]) + except: + pass + + return syscalls