diff --git a/your_daily_dose_malware/backends/malshare.py b/your_daily_dose_malware/backends/malshare.py index 591fa3b..54517d4 100644 --- a/your_daily_dose_malware/backends/malshare.py +++ b/your_daily_dose_malware/backends/malshare.py @@ -1,28 +1,30 @@ -import requests import os -from dotenv import load_dotenv +import requests +from dotenv import load_dotenv load_dotenv() + def scrap_malshare(): api_key = os.getenv("MALSHARE_API_KEY") print(api_key) try: response = requests.post( f"https://malshare.com//api.php?api_key={api_key}&action=getlist", - verify=True - + verify=True, ) response.raise_for_status() hashes = response.json() except Exception as err: raise err - try : + try: sha256_ids = [hashe["sha256"] for hashe in hashes] for sha256_id in sha256_ids: with requests.post( - f"https://malshare.com//api.php?api_key={api_key}&action=getfile&hash={sha256_id}",stream=True,verify=True + f"https://malshare.com//api.php?api_key={api_key}&action=getfile&hash={sha256_id}", + stream=True, + verify=True, ) as response: response.raise_for_status() with open(f"malware_{sha256_id[:4]}.zip", "wb") as f: @@ -31,11 +33,5 @@ def scrap_malshare(): except Exception as err: raise err -scrap_malshare() - - - - - - +scrap_malshare() diff --git a/your_daily_dose_malware/main.py b/your_daily_dose_malware/main.py index 5b16609..80049a2 100644 --- a/your_daily_dose_malware/main.py +++ b/your_daily_dose_malware/main.py @@ -1,14 +1,14 @@ import argparse -from rich.console import Console -from your_daily_dose_malware.constants import (MALWARE_BANNER, - MALWARE_DESCRIPTION) -from your_daily_dose_malware.backends.malware_bazaar import scrap_malware_bazaar from dotenv import load_dotenv +from rich.console import Console +from your_daily_dose_malware.backends.malware_bazaar import scrap_malware_bazaar +from your_daily_dose_malware.constants import MALWARE_BANNER, MALWARE_DESCRIPTION load_dotenv() + def run_scrapper(args): scrap_malware_bazaar(args.hundred_recent) @@ -16,15 +16,23 @@ def run_scrapper(args): def main(): parser = argparse.ArgumentParser( description="Download recent samples from multiple OSINT provider backends" - "MalwareBazaar: all the recent recent malware's uploaded within" - "the last 48 hours sha256 hash" - "MalwareBazaar: By using api from 'https://mb-api.abuse.ch/api/v1/'" + "MalwareBazaar: all the recent recent malware's uploaded within" + "the last 48 hours sha256 hash" + "MalwareBazaar: By using api from 'https://mb-api.abuse.ch/api/v1/'" + ) + parser.add_argument( + "-MwBz_48H", + "--last-48H", + action="store_true", + help="get the most recent sha256 hashes", + default=True, + ) + parser.add_argument( + "-MwBz_100", + "--hundred-recent", + action="store_true", + help="get the most recent hundred recent malware's uploaded within the last 60 min", ) - parser.add_argument('-MwBz_48H', '--last-48H', action='store_true', - help="get the most recent sha256 hashes", default=True) - parser.add_argument('-MwBz_100', '--hundred-recent', - action='store_true', - help="get the most recent hundred recent malware's uploaded within the last 60 min") args = parser.parse_args() console = Console()