From b2bd83892450f2950dbe9dcc47ef82542f9690b8 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Tue, 1 Mar 2022 21:42:26 +0200 Subject: [PATCH] Debug installing app, that didn't tested on VT --- modules/gui_manager.py | 65 +++++++++++++++++++++++------------------- modules/virustotal.py | 31 +++++++++++--------- 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/modules/gui_manager.py b/modules/gui_manager.py index 1ff4259..9973f1e 100644 --- a/modules/gui_manager.py +++ b/modules/gui_manager.py @@ -91,39 +91,46 @@ def install(package): "You can add it by entering horsy --vt [key] in terminal") download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) else: - download_ui.logs_box.append("If you want to disable scan, type horsy --vt disable in terminal") - download_ui.logs_box.append("Starting virustotal scan for program") - download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) - scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath)) - analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], - horsy_vars.horsypath)) - download_ui.logs_box.append(f"Scan finished for program \nYou can see report for program by opening: " - f"{analysis['link']} \n" - f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") - download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + try: + download_ui.logs_box.append("If you want to disable scan, type horsy --vt disable in terminal") + download_ui.logs_box.append("Starting virustotal scan for program") + download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath)) + analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], + horsy_vars.horsypath)) + download_ui.logs_box.append(f"Scan finished for program \nYou can see report for program by opening: " + f"{analysis['link']} \n" + f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") + download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + except: + pass if r['download']: - download_ui.logs_box.append("") - download_ui.logs_box.append("Starting virustotal scan for dependency") - download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) - scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath)) - download_ui.logs_box.append(f"Scan finished for dependency") - download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) - analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], - horsy_vars.horsypath)) - download_ui.logs_box.append(f"You can see report for dependency by opening: {analysis['link']}") - download_ui.logs_box.append(f"{analysis['detect']['malicious']} " - f"antivirus flagged this file as malicious") - download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) - if analysis['detect']['malicious'] > 0: - download_ui.logs_box.append("") - download_ui.logs_box.append(f"SECURITY WARNING, APP INSTALLATION STOPPED") - download_ui.logs_box.append(f"Dependency can be malicious. " - f"It may run now, if this added to installation config") - download_ui.logs_box.append(f"You can disable VT check with horsy --vt disable \n" - f"or use horsy CLI to force install") + try: download_ui.logs_box.append("") + download_ui.logs_box.append("Starting virustotal scan for dependency") download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], + horsy_vars.horsypath)) + download_ui.logs_box.append(f"Scan finished for dependency") + download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], + horsy_vars.horsypath)) + download_ui.logs_box.append(f"You can see report for dependency by opening: {analysis['link']}") + download_ui.logs_box.append(f"{analysis['detect']['malicious']} " + f"antivirus flagged this file as malicious") + download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + if analysis['detect']['malicious'] > 0: + download_ui.logs_box.append("") + download_ui.logs_box.append(f"SECURITY WARNING, APP INSTALLATION STOPPED") + download_ui.logs_box.append(f"Dependency can be malicious. " + f"It may run now, if this added to installation config") + download_ui.logs_box.append(f"You can disable VT check with horsy --vt disable \n" + f"or use horsy CLI to force install") + download_ui.logs_box.append("") + download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) + except: + pass if r['url'].split('.')[-1] == 'zip': os.remove('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath)) diff --git a/modules/virustotal.py b/modules/virustotal.py index 4f4250e..21fc0c3 100644 --- a/modules/virustotal.py +++ b/modules/virustotal.py @@ -63,18 +63,21 @@ def get_report(filename): def scan_to_cli(filename): - print(f"Starting virustotal scan") - if not get_key(): - print(f"[red]Virustotal api key not found[/]") - print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal") - else: - print(f"[green]Virustotal api key found[/]") - print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]" - f"[italic white] in terminal[/]") - scan_file(filename) - print(f"[green]Virustotal scan finished[/]") - analysis = get_report(filename) - print(f"[green]You can see report by opening: [white]{analysis['link']}[/]") - print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") + try: + print(f"Starting virustotal scan") + if not get_key(): + print(f"[red]Virustotal api key not found[/]") + print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal") + else: + print(f"[green]Virustotal api key found[/]") + print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]" + f"[italic white] in terminal[/]") + scan_file(filename) + print(f"[green]Virustotal scan finished[/]") + analysis = get_report(filename) + print(f"[green]You can see report by opening: [white]{analysis['link']}[/]") + print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") - return analysis + return analysis + except: + return None