From 7bb74ac06b7bfb1134a76d7a7836c68292bae5f0 Mon Sep 17 00:00:00 2001 From: Didier Barzin Date: Mon, 13 Jun 2022 22:01:47 +0200 Subject: [PATCH 1/4] Update INSTALL.md --- INSTALL.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index aed7023..c4fbf90 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,10 +36,7 @@ tqdm Asii Art -------- - -https://patorjk.com/software/taag/#p=display&f=Bloody&t=Pandora-Box - - +_Bloody Style_ ██▓███ ▄▄▄ ███▄ █ ▓█████▄ ▒█████ ██▀███ ▄▄▄ ▄▄▄▄ ▒█████ ▒██ ██▒ ▓██░ ██▒▒████▄ ██ ▀█ █ ▒██▀ ██▌▒██▒ ██▒▓██ ▒ ██▒▒████▄ ▓█████▄ ▒██▒ ██▒▒▒ █ █ ▒░ @@ -51,9 +48,33 @@ https://patorjk.com/software/taag/#p=display&f=Bloody&t=Pandora-Box ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ +https://patorjk.com/software/taag/#p=display&f=Bloody&t=Pandora-Box +_Flower Power_ +.-------. ____ ,---. .--. ______ ,-----. .-------. ____ _______ ,-----. _____ __ +\ _(`)_ \ .' __ `. | \ | || _ `''. .' .-, '. | _ _ \ .' __ `. \ ____ \ .' .-, '. \ _\ / / +| (_ o._)|/ ' \ \| , \ | || _ | ) _ \ / ,-.| \ _ \ | ( ' ) | / ' \ \| | \ | / ,-.| \ _ \ .-./ ). / ' +| (_,_) /|___| / || |\_ \| ||( ''_' ) |; \ '_ / | :|(_ o _) / |___| / || |____/ / ; \ '_ / | : \ '_ .') .' +| '-.-' _.-` || _( )_\ || . (_) `. || _`,/ \ _/ || (_,_).' __ _.-` || _ _ '. | _`,/ \ _/ |(_ (_) _) ' +| | .' _ || (_ o _) ||(_ ._) ': ( '\_/ \ ;| |\ \ | |.' _ || ( ' ) \: ( '\_/ \ ; / \ \ +| | | _( )_ || (_,_)\ || (_.\.' / \ `"/ \ ) / | | \ `' /| _( )_ || (_{;}_) | \ `"/ \ ) / `-'`-' \ +/ ) \ (_ o _) /| | | || .' '. \_/``".' | | \ / \ (_ o _) /| (_,_) / '. \_/``".' / / \ \ +`---' '.(_,_).' '--' '--''-----'` '-----' ''-' `'-' '.(_,_).' /_______.' '-----' '--' '----' + +https://patorjk.com/software/taag/#p=display&f=Flower%20Power&t=PandoraBox +Little Devils +_ (`-') (`-') _ <-. (`-')_ _(`-') (`-') (`-') _ <-.(`-') (`-') + \-.(OO ) (OO ).-/ \( OO) )( (OO ).-> .-> <-.(OO ) (OO ).-/ __( OO) .-> (OO )_.-> + _.' \ / ,---. ,--./ ,--/ \ .'_ (`-')----. ,------,) / ,---. '-'---.\ (`-')----. (_| \_)--. +(_...--'' | \ /`.\ | \ | | '`'-..__)( OO).-. '| /`. ' | \ /`.\ | .-. (/ ( OO).-. '\ `.' / +| |_.' | '-'|_.' || . '| |) | | ' |( _) | | || |_.' | '-'|_.' | | '-' `.)( _) | | | \ .') +| .___.'(| .-. || |\ | | | / : \| |)| || . .'(| .-. | | /`'. | \| |)| | .' \ +| | | | | || | \ | | '-' / ' '-' '| |\ \ | | | | | '--' / ' '-' '/ .'. \ +`--' `--' `--'`--' `--' `------' `-----' `--' '--' `--' `--' `------' `-----'`--' '--' + +https://patorjk.com/software/taag/#p=display&f=Lil%20Devil&t=Pandora%20Box Screensaver ----------- From 1052b54dc74f665fafd04f3fae1b4e7ad04e7bfc Mon Sep 17 00:00:00 2001 From: Didier Barzin Date: Mon, 13 Jun 2022 22:10:20 +0200 Subject: [PATCH 2/4] Update INSTALL.md --- INSTALL.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index c4fbf90..0cbd017 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -81,6 +81,16 @@ Screensaver tty-clock -srt +Start +----- +Start ClamAV + + sudo service clamav-daemon start + +Start Pandora + + cd pandora + poetry run start From 145ebb41a09585f3da0917e5e36fb0d6c548917c Mon Sep 17 00:00:00 2001 From: Didier Date: Mon, 13 Jun 2022 20:10:33 +0000 Subject: [PATCH 3/4] work in progress --- pandorabox.py | 103 +++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/pandorabox.py b/pandorabox.py index 04203f9..ded77bc 100755 --- a/pandorabox.py +++ b/pandorabox.py @@ -18,9 +18,9 @@ import time # ----------------------------------------------------------- NO_SCAN = True -USB_AUTO_MOUNT = True +USB_AUTO_MOUNT = False PANDORA_ROOT_URL = "http://127.0.0.1:6100" -FAKE_SCAN = True +FAKE_SCAN = False # ---------------------------------------------------------- @@ -223,12 +223,19 @@ def mount_device(device): else: return "" else: - res = os.system("pmount " + device.device_node + " box") - if res == 1: - return "/media/box" - else: - return "" + res = os.system("pmount " + device.device_node + " /media/box") + found = False + loop = 0 + while (not found) and (loop < 10): + time.sleep(1) + try: + statvfs=os.statvfs(mount_point) + except Exception as e : + loop +=1 + continue + break; log("Device mounted at /media/box") + return "/media/box" """Unmount USB device""" @@ -261,7 +268,8 @@ def device_loop(): try: statvfs=os.statvfs(mount_point) except Exception as e : - logging.error("Unexpected error: ", e) + log("Unexpected error1: %s" % e) + logging.exception("An exception was thrown!") continue print_size(human_readable_size(statvfs.f_frsize * statvfs.f_blocks)) print_used(human_readable_size(statvfs.f_frsize * (statvfs.f_blocks - statvfs.f_bfree))) @@ -294,7 +302,8 @@ def device_loop(): umount_device() update_bar(0) except Exception as e: - log("Unexpected error: %s" % e ) + log("Unexpected error2: %s" % e ) + logging.exception("An exception was thrown!") finally: log("Done.") @@ -325,47 +334,46 @@ def log_device_info(dev): """Scan a mount point with Pandora""" def scan(mount_point, used): global infected_filed - infected_files = array() + infected_files = [] scanned = 0 file_count = 0 scan_start_time = time.time() - if FAKE_SCAN: - for root, dirs, files in os.walk(mount_point): - for file in files: - try : - full_path = os.path.join(root,file) - file_size = os.path.getsize(full_path) - log("Check %-s [%s]" % (file, human_readable_size(file_size))) - file_scan_start_time = time.time() + if not FAKE_SCAN: + pandora = pypandora.PyPandora(root_url=PANDORA_ROOT_URL) + for root, dirs, files in os.walk(mount_point): + for file in files: + try : + full_path = os.path.join(root,file) + file_size = os.path.getsize(full_path) + log("Check %s [%s]" % (file, human_readable_size(file_size))) + file_scan_start_time = time.time() + if FAKE_SCAN : time.sleep(0.1) - file_scan_end_time = time.time() - log("Check %s (%ds) -> %-s" % (file,(file_scan_end_time - file_scan_start_time),"SKIPPED")) - scanned += os.path.getsize(full_path) - file_count += 1 - update_bar(scanned * 100 // used) - except Exception as e : - log("Unexpected error: %s" % e) - return False - update_bar(100) - log("Scan done in %ds" % (time.time() - scan_start_time)) - log("%d files scanned" % file_count) - else: - pp = pypandora.PyPandora(root_url=PANDORA_ROOT_URL) - for arg in sys.argv[1:]: - log("Scan %-80s" % arg) - - res = pp.submit_from_disk(arg) - - while True: - time.sleep(1) - - res = pp.task_status(res["taskId"]) - - if res["status"] != "WAITING": - break - break; - - log("Scan %s -> %s" % (arg,res["status"])) + status = "SKIPPED" + else: + if file_size > (1024*1024*1024): + status = "TOO BIG" + else: + res = pandora.submit_from_disk(full_path) + time.sleep(0.1) + while True: + res = pandora.task_status(res["taskId"]) + status = res["status"] + if status != "WAITING": + break + time.sleep(0.5) + file_scan_end_time = time.time() + log("Check %s (%ds) -> %-s" % (file,(file_scan_end_time - file_scan_start_time),status)) + scanned += os.path.getsize(full_path) + file_count += 1 + update_bar(scanned * 100 // used) + except Exception as e : + log("Unexpected error3: %s" % e) + logging.exception("An exception was thrown!") + return False + update_bar(100) + log("Scan done in %ds" % (time.time() - scan_start_time)) + log("%d files scanned" % file_count) return True @@ -381,7 +389,8 @@ def main(stdscr): while True: device_loop() except Exception as e : - logging.error("Unexpected error: ", e) + log("Unexpected error4: %s" % e) + logging.exception("An exception was thrown!") # logging.error(traceback.format_exc()) finally: end_curses() From 857c97fba34f332da857b8456363e915e013574d Mon Sep 17 00:00:00 2001 From: Didier Date: Mon, 13 Jun 2022 21:00:07 +0000 Subject: [PATCH 4/4] work --- INSTALL.md | 5 ++++- pandorabox.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0cbd017..7a6e522 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -93,6 +93,9 @@ Start Pandora poetry run start - +Homepage +-------- + +sudo fbi -T 2 -d /dev/fb1 -noverbose -a demo.png diff --git a/pandorabox.py b/pandorabox.py index ded77bc..b2417c4 100755 --- a/pandorabox.py +++ b/pandorabox.py @@ -345,7 +345,7 @@ def scan(mount_point, used): try : full_path = os.path.join(root,file) file_size = os.path.getsize(full_path) - log("Check %s [%s]" % (file, human_readable_size(file_size))) + # log("Check %s [%s]" % (file, human_readable_size(file_size))) file_scan_start_time = time.time() if FAKE_SCAN : time.sleep(0.1) @@ -363,7 +363,11 @@ def scan(mount_point, used): break time.sleep(0.5) file_scan_end_time = time.time() - log("Check %s (%ds) -> %-s" % (file,(file_scan_end_time - file_scan_start_time),status)) + log("Scan %s [%s] -> %s (%ds)" % ( + file, + human_readable_size(file_size), + status, + (file_scan_end_time - file_scan_start_time))) scanned += os.path.getsize(full_path) file_count += 1 update_bar(scanned * 100 // used)