Skip to content

Commit df693dd

Browse files
tisftisf
tisf
authored and
tisf
committed
replacing dependencies
depending on 7z is not versatile enough. We have tried to depend on something easier to get. Plus changing some typos. Plus creating some typos to fix later.
1 parent d0c11ab commit df693dd

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Get the file you want to submit and just run `python prep_file.py file_tosubmit.
124124
- [ ] Fix and make 'light' version without malwares with _MalwareFetch function.
125125

126126
### Hopeful
127-
- [ ] A GUI interface.
127+
- [ ] A GUI.
128128
- [ ] Package releases.
129129

130130
If you have any suggestions or malware that you have indexed (in the manner laid out in the documentation) please send it to us to - thezoo-submissions [a-t] morirt [.d0t.] com - so we can add it for everyone's enjoyment.

prep_file.py

+39-15
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,45 @@
22

33
import os
44
import sys
5-
import zipfile
65
import hashlib
7-
import subprocess
6+
7+
try:
8+
import pyminizip
9+
except ImportError:
10+
sys.stderr.write("Could not import 'pyminizip'. Did you install requirements?\n")
11+
sys.stderr.write("You can always just get 'pyminizip' by 'pip install --user pyminizip'.\n")
12+
sys.exit(1)
813

914

1015
OUTPUT_FOLDER = "OUTPUT"
1116

1217

1318
def _help():
19+
"""
20+
hmmmm. nope.
21+
:return:
22+
"""
1423
print("Please run with '%s filename'." % sys.argv[0])
1524
return
1625

26+
1727
def _Do(file_path):
28+
"""
29+
Prep file from file path for submission. Take file name, encrypt in ZIP with password 'infected', create MD5
30+
and SHA1 sums and store all of that in a directory of it's own.
31+
:param file_path: str
32+
:return: Bool
33+
"""
1834
if not os.path.isfile(file_path):
1935
_help()
20-
print("Seems like '%s' is not a file." % file_path)
21-
sys.exit(1)
36+
sys.stderr.write("Seems like '%s' is not a file.\n" % file_path)
37+
return False
2238

2339
try:
2440
os.mkdir(OUTPUT_FOLDER)
2541
except OSError:
26-
print("Folder exists. Please remove it before continuing.")
27-
sys.exit(1)
42+
sys.stderr.write("Folder exists. Please remove it before continuing.\n")
43+
return False
2844

2945
if "\\" in file_path:
3046
filename = file_path.split("\\")[:-1]
@@ -34,14 +50,16 @@ def _Do(file_path):
3450
filename = file_path
3551

3652
# Create ZIP Archive:
53+
# We used 7z because 'zipfile' did not support adding a password. Apparently 'pyminizip' works just as well.
3754
try:
38-
rc = subprocess.call(['7z', 'a', '-pinfected', '-y', '%s/%s.zip' % (OUTPUT_FOLDER, filename)] + [file_path])
39-
except:
40-
print("Seems like you don't have 7z in your path. Please install or add with:\n\tbrew install 7zip #(OSX)\n\tsudo apt-get install p7zip-full #(Linux)")
41-
sys.exit(1)
55+
pyminizip.compress(file_path, OUTPUT_FOLDER, "%s.zip" % filename, "infected", 9)
56+
except Exception as e:
57+
sys.stderr.write("Unknown error occurred. Please report this to us so that we can fix this.\n")
58+
sys.stderr.write(str(e))
59+
return False
4260

4361
compressed_path = '%s/%s.zip' % (OUTPUT_FOLDER, filename)
44-
print("Created ZIP Archive.")
62+
sys.stdout.write("[+]\tCreated ZIP Archive.\n")
4563
md5sum = hashlib.md5(open(compressed_path, 'rb').read()).hexdigest()
4664
sha1sum = hashlib.sha1(open(compressed_path, 'rb').read()).hexdigest()
4765
open("%s/%s.md5" % (OUTPUT_FOLDER, filename), 'w').write(md5sum)
@@ -54,7 +72,13 @@ def _Do(file_path):
5472
if len(sys.argv) != 2:
5573
_help()
5674
sys.exit(1)
57-
_Do(sys.argv[1])
58-
print("Please don't forget to add details to 'conf/maldb.db'.")
59-
print("Thanks for helping us get this accessible to everyone.")
60-
print("")
75+
stt = _Do(sys.argv[1])
76+
if stt:
77+
sys.stdout.write("Please don't forget to add details to 'conf/maldb.db' "
78+
"and placing the folder in the appropriate directory.\n")
79+
sys.stdout.write("Thanks for helping us get this accessible to everyone.\n")
80+
sys.stdout.write("\n")
81+
sys.exit(0)
82+
else:
83+
sys.exit(1)
84+

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
urllib2
2+
pyminizip

0 commit comments

Comments
 (0)