Skip to content

Commit 3e324a1

Browse files
Merge branch 'release/1.5.1'
2 parents 3b40210 + 4d98839 commit 3e324a1

File tree

17 files changed

+286
-142
lines changed

17 files changed

+286
-142
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ SpamScope can be downloaded, used, and modified free of charge. It is available
5656
## Authors
5757

5858
### Main Author
59-
Fedele Mantuano (**Twitter**: [@fedelemantuano](https://twitter.com/fedelemantuano))
59+
Fedele Mantuano (**LinkedIn**: [Fedele Mantuano](https://www.linkedin.com/in/fmantuano/))
6060

6161

6262

docs/images/Docker02.png

-2.35 KB
Loading

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject spamscope "1.5.0-SNAPSHOT"
1+
(defproject spamscope "1.5.1-SNAPSHOT"
22
:resource-paths ["_resources"]
33
:target-path "_build"
44
:min-lein-version "2.0.0"

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PyYAML==3.12
22
backports.functools-lru-cache==1.3
33
chainmap==1.0.2
4-
elasticsearch==5.3.0
4+
elasticsearch==5.4.0
55
mail-parser==1.1.10
66
patool==1.12
77
pyparsing==2.2.0
@@ -11,6 +11,6 @@ shodan==1.6.5
1111
simplejson==3.10.0
1212
six==1.10.0
1313
ssdeep==3.2
14-
streamparse==3.4.0
14+
streamparse==3.5.0
1515
tika-app==1.1.0
1616
virustotal-api==1.1.2

src/bolts/attachments.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,15 @@ def process(self, tup):
6565
sha256_random = tup.values[0]
6666
with_attachments = tup.values[1]
6767

68-
try:
69-
# Remove all values
70-
self.attach.removeall()
68+
# Remove all values
69+
self.attach.removeall()
7170

72-
# Add the new values
73-
self.attach.extend(tup.values[2])
71+
# Add the new values
72+
self.attach.extend(tup.values[2])
7473

75-
# Run analysis
76-
# self.attach.run() == self.attach()
77-
self.attach.run()
74+
# Run analysis
75+
# self.attach.run() == self.attach()
76+
self.attach.run()
7877

79-
except Exception as e:
80-
self.log("Failed process attachments for mail: {}".format(
81-
sha256_random), "error")
82-
self.raise_exception(e, tup)
83-
84-
else:
85-
self.emit([sha256_random, with_attachments, list(self.attach)])
78+
# emit
79+
self.emit([sha256_random, with_attachments, list(self.attach)])

src/bolts/json_maker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def _compose_output(self, greedy_data):
5757
if attachments:
5858
mail["with_attachments"] = True
5959
mail["attachments"] = attachments
60+
else:
61+
mail["with_attachments"] = False
6062

6163
# Urls in attachments:
6264
# Add urls attachments because you can have more differents attachments

src/bolts/network.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,14 @@ def process(self, tup):
3131
ipaddress = tup.values[1]
3232
is_filtered = tup.values[2]
3333

34-
try:
35-
results = {}
36-
37-
if not is_filtered and ipaddress:
38-
for p in processors:
39-
try:
40-
p(self.conf[p.__name__], ipaddress, results)
41-
except KeyError:
42-
self.log("KeyError: {!r} doesn't exist in conf".format(
43-
p.__name__), "error")
44-
45-
except Exception as e:
46-
self.log("Failed process network for mail: {}".format(
47-
sha256_random), "error")
48-
self.raise_exception(e, tup)
49-
50-
else:
51-
self.emit([sha256_random, results])
34+
results = {}
35+
36+
if not is_filtered and ipaddress:
37+
for p in processors:
38+
try:
39+
p(self.conf[p.__name__], ipaddress, results)
40+
except KeyError:
41+
self.log("KeyError: {!r} doesn't exist in conf".format(
42+
p.__name__), "error")
43+
44+
self.emit([sha256_random, results, is_filtered])

src/modules/attachments/attachments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from collections import UserList
2626

2727
import copy
28+
import datetime
2829
import logging
2930
import os
3031
import shutil
@@ -232,6 +233,8 @@ def _addmetadata(self):
232233
file size, content type, if is a archive and archived files.
233234
"""
234235
for i in self:
236+
i["analisys_date"] = datetime.datetime.utcnow().isoformat()
237+
235238
if not i.get("is_filtered", False):
236239
payload, size, ext = Attachments._metadata(i)
237240
content_type = contenttype(payload)
@@ -265,6 +268,8 @@ def _addmetadata(self):
265268
content_type = contenttype(payload)
266269
filename = os.path.basename(j)
267270

271+
t["analisys_date"] = \
272+
datetime.datetime.utcnow().isoformat()
268273
t["filename"] = filename
269274
t["extension"] = extension(filename)
270275
t["size"] = len(payload)

src/modules/networks/post_processing.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
from __future__ import absolute_import, print_function, unicode_literals
2121
import logging
2222

23+
try:
24+
import simplejson as json
25+
except ImportError:
26+
import json
27+
2328
try:
2429
from modules import register
2530
except ImportError:
@@ -55,7 +60,8 @@ def processor(conf, ipaddress, results):
5560
"""
5661

5762

58-
@register(processors, active=True)
63+
@register(processors, active=False)
64+
# TODO: to solve issue https://github.com/Parsely/streamparse/issues/368
5965
def shodan(conf, ipaddress, results):
6066
"""This method updates the attachments results
6167
with the Tika reports.
@@ -75,8 +81,12 @@ def shodan(conf, ipaddress, results):
7581

7682
try:
7783
report = api.host(ipaddress)
84+
json.dumps(report, ensure_ascii=False)
7885
except shodan.APIError:
79-
log.exception("Shodan API error")
86+
return
87+
except TypeError:
88+
log.error("JSON TypeError in Shodan report for ip {!r}".format(
89+
ipaddress))
8090
else:
8191
if report:
8292
results["shodan"] = report
@@ -99,7 +109,17 @@ def virustotal(conf, ipaddress, results):
99109
if conf["enabled"]:
100110
from virus_total_apis import PublicApi as VirusTotalPublicApi
101111
vt = VirusTotalPublicApi(conf["api_key"])
102-
report = vt.get_ip_report(ipaddress)
103112

104-
if report:
105-
results["virustotal"] = report
113+
# Error: {u'virustotal': {'error': SSLError(SSLEOFError(8, u'EOF
114+
# occurred in violation of protocol (_ssl.c:590)'),)}}')
115+
# TypeError: SSLError(SSLEOFError(8, u'EOF occurred in violation of
116+
# protocol (_ssl.c:590)'),) is not JSON serializable')
117+
try:
118+
report = vt.get_ip_report(ipaddress)
119+
json.dumps(report, ensure_ascii=False)
120+
except TypeError:
121+
log.error("TypeError in VirusTotal report for ip {!r}".format(
122+
ipaddress))
123+
else:
124+
if report:
125+
results["virustotal"] = report

src/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from os.path import join
2121

22-
__version__ = "1.5.0"
22+
__version__ = "1.5.1"
2323
__configuration_path__ = "/etc/spamscope"
2424

2525
__defaults__ = {

0 commit comments

Comments
 (0)