-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocal_Malware_Bazaar_API.py
More file actions
64 lines (58 loc) · 1.93 KB
/
Copy pathLocal_Malware_Bazaar_API.py
File metadata and controls
64 lines (58 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
def download_List():
import requests
name = r"D:\Malware List\testfile.zip"
folder = r"D:\Malware List"
file = requests.get("https://bazaar.abuse.ch/export/txt/sha256/full/")
with open(name, "wb") as f:
f.write(file.content)
from zipfile import ZipFile
with ZipFile(name, "r") as zip:
zip.extractall(folder)
for item in os.listdir(folder):
if item.endswith(".txt"):
file = open(folder + "\\" + item).readlines()
new_File = []
for i, line in enumerate(file):
if i < 9 or "entries" in line.replace(":", "").split(" "):
continue
new_File.append(line)
with open(folder + "\\" + item, "w") as f:
for item in new_File:
f.write(str(item))
os.remove(name)
def check_List(hashed_item):
#
# hashed_item is ALWAYS Sha256
#
files = []
pfad = r"D:\Malware List"
for file in os.listdir(pfad):
if not file.endswith(".txt"):
continue
if os.path.isdir(pfad + "\\" + file):
continue
f = open(pfad + "\\" + file)
if len(files) == 0:
files = f
else:
files.extend(f)
files = list(set(files))
for entries in files:
if hashed_item == entries:
return True
else:
continue
return False
def Test_check():
import hashlib
path = r"D:\Malware List"
for file in os.listdir(path):
if os.path.isdir(path + "\\" + file):
continue
with open(path + "\\" + file, "rb") as f:
hash = hashlib.sha256(f.read()).hexdigest()
Malware = check_List(hash)
print(str(file) + " --> " + str(Malware))
if Malware:
print("ITS MALWARE!!!!!!!!!!!!!!!!!!!!!!!\n\n\n\n\n Its Malware!!!")