From f4490f5ff87911ee37eaa8b8705282031b5ea196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 1 Jul 2024 20:06:24 +0200 Subject: [PATCH] fix: Exception in phishtank module when there are no IPs file --- lookyloo/modules/phishtank.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lookyloo/modules/phishtank.py b/lookyloo/modules/phishtank.py index e2dce5a..3d7ba55 100644 --- a/lookyloo/modules/phishtank.py +++ b/lookyloo/modules/phishtank.py @@ -52,7 +52,10 @@ class Phishtank(AbstractModule): return json.load(f) def lookup_ips_capture(self, cache: CaptureCache) -> dict[str, list[dict[str, Any]]]: - with (cache.capture_dir / 'ips.json').open() as f: + ips_file = cache.capture_dir / 'ips.json' + if not ips_file.exists(): + return {} + with ips_file.open() as f: ips_dump = json.load(f) to_return: dict[str, list[dict[str, Any]]] = {} for ip in {ip for ips_list in ips_dump.values() for ip in ips_list}: @@ -96,7 +99,10 @@ class Phishtank(AbstractModule): self.url_lookup(cache.url) # Check all the IPs in the ips file of the capture - with (cache.capture_dir / 'ips.json').open() as f: + ips_file = cache.capture_dir / 'ips.json' + if not ips_file.exists(): + return {'error': 'No IP file found in the capture'} + with ips_file.open() as f: ips_dump = json.load(f) for ip in {ip for ips_list in ips_dump.values() for ip in ips_list}: self.ip_lookup(ip)