---
# System prepended metadata

title: Bazaar每日爬蟲，串接Fame API惡意軟體分析

---

# Bazaar每日爬蟲，串接Fame API惡意軟體分析
```
from datetime import date, timedelta
import os
import zipfile
import webget
import requests
import json

Date = str(date.today() - timedelta(1))
url = "https://datalake.abuse.ch/malware-bazaar/daily/" + Date + ".zip"
response = wget.download(url, "malware.zip")

headers = {
    'Accept': "application/json",
    'X-API-KEY': 'fd1b0ffe84c0fa607be3123c4c82b87094e35289fe6ac270f6d071761d48988adcc17506e422be7f'
}

count = 0
with zipfile.ZipFile("/home/lab1/python/malware.zip", "r") as z:
    for member in z.namelist():
        if count == 0:
            count += 1
            continue
        else:
            extension = str(member).split(".")[-1]
            if str(extension) == "elf":
                path = os.path.join("/home/lab1/python", member)
    with open(path, 'rb') as f:
        params = {
            'modules': "Opcode_detector",
            'groups': 'cert'
        }
        files = {
            'file' : f
        }

        result = requests.post("https://demo.jskws.works/analyses/", files=files, data=params, headers=headers)
        json_object = json.loads(result.text)
os.remove("/home/lab1/python/malware.zip")
```
* 路徑改成自己的
* 利用linux 的crontab讓他可以每日執行