Skip to content

Commit

Permalink
lint:make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
poneoneo committed Jun 12, 2024
1 parent 5cd689f commit 5323420
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
22 changes: 9 additions & 13 deletions your_daily_dose_malware/backends/malshare.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -31,11 +33,5 @@ def scrap_malshare():
except Exception as err:
raise err

scrap_malshare()







scrap_malshare()
32 changes: 20 additions & 12 deletions your_daily_dose_malware/main.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
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)


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()
Expand Down

0 comments on commit 5323420

Please sign in to comment.