Skip to content

Commit 66732e6

Browse files
Merge branch 'release/2.6.0'
2 parents 8bb98d0 + 620f8e4 commit 66732e6

26 files changed

+927
-116
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ python:
1010
- "2.7"
1111

1212
env:
13-
- TIKA_VER=1.16
14-
TIKA_APP_JAR=/tmp/tika-app-${TIKA_VER}.jar
13+
- TIKA_APP_JAR=/tmp/tika-app-${TIKA_VER}.jar
1514
FAUP_PATH=/tmp/faup
1615
ZEMANA_PATH=/tmp/zemana
1716
DOCKER_ELASTICSEARCH_PATH=/tmp/docker-elasticsearch

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ SpamScope has some topologies in [topologies folder](./topologies/), but you can
1616

1717
![Schema topology](docs/images/schema_topology.png?raw=true "Schema topology")
1818

19+
# What Does SpamScope do?
20+
SpamScope gets the raw emails (both RFC822 and Outlook formats) in input and returns an JSON object. Then it extracts urls and attachments (if they are zipped extracts the content files). All informations are saved in JSON objects. This is the first analysis. After that SpamScope runs a _phishing_ module, that gives a _phishing score_ to the emails.
21+
22+
Then you can enable/disable post processing modules, that connect SpamScope with third party tools. There are three main categories:
23+
- raw emails analysis
24+
- attachments analysis
25+
- sender emails analysis
26+
27+
It's possible to add new modules in these three categories, if you want connect SpamScope with others tools.
28+
29+
## Raw emails analysis
30+
These modules (see [here](./src/modules/mails)) analyze the raw emails:
31+
- SMTP dialect
32+
- SpamAssassin
33+
34+
## Attachments analysis
35+
These modules (see [here](./src/modules/attachments)) analyze the attachments of emails:
36+
- Apache Tika
37+
- Store sample on disk (as default SpamScope saves samples in JSON objects)
38+
- Thug
39+
- VirusTotal
40+
- Zemana
41+
42+
## Sender emails analysis
43+
SpamScope can detects the exact sender IP and then it can analyze it (see [here](./src/modules/networks)):
44+
- Shodan
45+
- VirusTotal
46+
1947
# Why should I use SpamScope
2048
- It's very fast: the job is splitted in functionalities that work in parallel.
2149
- It's flexible: you can choose what SpamScope has to do.
@@ -64,6 +92,7 @@ SpamScope can be downloaded, used, and modified free of charge. It is available
6492
- [The Honeynet Project](http://honeynet.org/node/1329)
6593
- [securityonline.info](http://securityonline.info/pcileech-direct-memory-access-dma-attack-software/)
6694
- [jekil/awesome-hacking](https://github.com/jekil/awesome-hacking)
95+
- [Linux Security Expert](https://linuxsecurity.expert/tools/spamscope/)
6796

6897
# Authors
6998

README.rst

Lines changed: 82 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
|PyPI version| |Build Status| |Coverage Status| |BCH compliance|
1+
`PyPI version <https://badge.fury.io/py/SpamScope>`__ `Build
2+
Status <https://travis-ci.org/SpamScope/spamscope>`__ `Coverage
3+
Status <https://coveralls.io/github/SpamScope/spamscope?branch=develop>`__
4+
`BCH compliance <https://bettercodehub.com/>`__
25

36
.. figure:: https://raw.githubusercontent.com/SpamScope/spamscope/develop/docs/logo/spamscope.png
47
:alt: SpamScope
@@ -26,20 +29,55 @@ folder <./topologies/>`__, but you can make others topologies.
2629

2730
Schema topology
2831

32+
What Does SpamScope do?
33+
=======================
34+
35+
SpamScope gets the raw emails (both RFC822 and Outlook formats) in input
36+
and returns an JSON object. Then it extracts urls and attachments (if
37+
they are zipped extracts the content files). All informations are saved
38+
in JSON objects. This is the first analysis. After that SpamScope runs a
39+
*phishing* module, that gives a *phishing score* to the emails.
40+
41+
Then you can enable/disable post processing modules, that connect
42+
SpamScope with third party tools. There are three main categories: - raw
43+
emails analysis - attachments analysis - sender emails analysis
44+
45+
It’s possible to add new modules in these three categories, if you want
46+
connect SpamScope with others tools.
47+
48+
Raw emails analysis
49+
-------------------
50+
51+
These modules (see `here <./src/modules/mails>`__) analyze the raw
52+
emails: - SMTP dialect - SpamAssassin
53+
54+
Attachments analysis
55+
--------------------
56+
57+
These modules (see `here <./src/modules/attachments>`__) analyze the
58+
attachments of emails: - Apache Tika - Store sample on disk (as default
59+
SpamScope saves samples in JSON objects) - Thug - VirusTotal - Zemana
60+
61+
Sender emails analysis
62+
----------------------
63+
64+
SpamScope can detects the exact sender IP and then it can analyze it
65+
(see `here <./src/modules/networks>`__): - Shodan - VirusTotal
66+
2967
Why should I use SpamScope
3068
==========================
3169

32-
- It's very fast: the job is splitted in functionalities that work in
70+
- Its very fast: the job is splitted in functionalities that work in
3371
parallel.
34-
- It's flexible: you can choose what SpamScope has to do.
35-
- It's distributed: SpamScope uses Apache Storm, free and open source
72+
- Its flexible: you can choose what SpamScope has to do.
73+
- Its distributed: SpamScope uses Apache Storm, free and open source
3674
distributed realtime computation system.
3775
- It makes JSON output that you can save where you want.
38-
- It's easy to setup: there are docker images and docker-compose ready
76+
- Its easy to setup: there are docker images and docker-compose ready
3977
for use.
40-
- It's integrated with Apache Tika, VirusTotal, Thug, Shodan and
78+
- Its integrated with Apache Tika, VirusTotal, Thug, Shodan and
4179
SpamAssassin (for now).
42-
- It's free and open source (for special functions you can contact me).
80+
- Its free and open source (for special functions you can contact me).
4381
- It can analyze Outlook msg.
4482

4583
Distributed
@@ -58,12 +96,12 @@ SpamScope comes with the following bolts: - **tokenizer** splits mail in
5896
token like headers, body, attachments and it can filter emails,
5997
attachments and ip addresses already seen - **phishing** looks for your
6098
keywords in email and connects email to targets (bank, your customers,
61-
etc.) - **raw\_mail** is for all third party tools that analyze raw
62-
mails like SpamAssassin - **attachments** analyzes all mail attachments
63-
and uses third party tools like VirusTotal - **network** analyzes all
64-
sender ip addresses with third party tools like Shodan - **urls**
65-
extracts all urls in email and attachments - **json\_maker** and
66-
**outputs** make the json report and save it
99+
etc.) - **raw_mail** is for all third party tools that analyze raw mails
100+
like SpamAssassin - **attachments** analyzes all mail attachments and
101+
uses third party tools like VirusTotal - **network** analyzes all sender
102+
ip addresses with third party tools like Shodan - **urls** extracts all
103+
urls in email and attachments - **json_maker** and **outputs** make the
104+
json report and save it
67105

68106
Store where you want
69107
--------------------
@@ -80,21 +118,21 @@ and/or remove spouts and bolts.
80118
API
81119
---
82120

83-
For now SpamScope doesn't have its own API, because it isn't tied to any
84-
tecnology. If you use ``Redis`` as spout (input), you'll use Redis API
85-
to put mails in topology. If you use ``Elasticsearch`` as output, you'll
121+
For now SpamScope doesnt have its own API, because it isnt tied to any
122+
tecnology. If you use ``Redis`` as spout (input), youll use Redis API
123+
to put mails in topology. If you use ``Elasticsearch`` as output, youll
86124
use Elasticsearch API to get results.
87125

88-
It's possible to develop a middleware API that it talks with input,
89-
output and changes the configuration, but now there isn't.
126+
Its possible to develop a middleware API that it talks with input,
127+
output and changes the configuration, but now there isnt.
90128

91129
Apache 2 Open Source License
92130
============================
93131

94132
SpamScope can be downloaded, used, and modified free of charge. It is
95133
available under the Apache 2 license.
96134

97-
|Donate|
135+
`Donate <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VEPXYP745KJF2>`__
98136

99137
SpamScope on Web
100138
================
@@ -104,6 +142,8 @@ SpamScope on Web
104142
- `The Honeynet Project <http://honeynet.org/node/1329>`__
105143
- `securityonline.info <http://securityonline.info/pcileech-direct-memory-access-dma-attack-software/>`__
106144
- `jekil/awesome-hacking <https://github.com/jekil/awesome-hacking>`__
145+
- `Linux Security
146+
Expert <https://linuxsecurity.expert/tools/spamscope/>`__
107147

108148
Authors
109149
=======
@@ -124,7 +164,7 @@ For Python requirements you can read: \* `mandatory
124164
requirements <./requirements.txt>`__ \* `optional
125165
requirements <./requirements_optional.txt>`__
126166

127-
*Thug* is another optional requirement, that it's not in requirements.
167+
*Thug* is another optional requirement, that its not in requirements.
128168
See `Thug section <#thug-optional>`__ for more details.
129169

130170
Apache Storm
@@ -197,32 +237,32 @@ errors in Apache Storm. To avoid any issue set
197237

198238
::
199239

200-
nr. user agents * timeout_thug < supervisor.worker.timeout.secs
240+
nr. user agents * timeout_thug < supervisor.worker.timeout.secs
201241

202242
The best value for ``threshold`` is 1.
203243

204244
VirusTotal (optional)
205245
---------------------
206246

207-
It's possible add to results (for mail attachments and sender ip
247+
Its possible add to results (for mail attachments and sender ip
208248
address) the VirusTotal report. You need a private API key.
209249

210250
Shodan (optional)
211251
-----------------
212252

213-
It's possible add to results the Shodan report for sender ip address.
253+
Its possible add to results the Shodan report for sender ip address.
214254
You need a private API key.
215255

216256
Elasticsearch (optional)
217257
------------------------
218258

219-
It's possible to store the results in Elasticsearch. In this case you
259+
Its possible to store the results in Elasticsearch. In this case you
220260
should install ``elasticsearch`` package.
221261

222262
Redis (optional)
223263
----------------
224264

225-
It's possible to store the results in Redis. In this case you should
265+
Its possible to store the results in Redis. In this case you should
226266
install ``redis`` package.
227267

228268
Configuration
@@ -231,12 +271,12 @@ Configuration
231271
Read the `example of main configuration
232272
file <./conf/spamscope.example.yml>`__. The default value where
233273
SpamScope will search the configuration file is
234-
``/etc/spamscope/spamscope.yml``, but it's possible to set the
274+
``/etc/spamscope/spamscope.yml``, but its possible to set the
235275
environment variable ``SPAMSCOPE_CONF_FILE``:
236276

237277
::
238278

239-
$ export SPAMSCOPE_CONF_FILE=/etc/spamscope/spamscope.yml
279+
$ export SPAMSCOPE_CONF_FILE=/etc/spamscope/spamscope.yml
240280

241281
When you change the configuration file, SpamScope automatically reloads
242282
the new changes.
@@ -252,21 +292,21 @@ Topologies
252292
==========
253293

254294
SpamScope comes with three topologies: -
255-
`spamscope\_debug <./topologies/spamscope_debug.py>`__: the output are
295+
`spamscope_debug <./topologies/spamscope_debug.py>`__: the output are
256296
JSON files on file system. -
257-
`spamscope\_elasticsearch <./topologies/spamscope_elasticsearch.py>`__:
297+
`spamscope_elasticsearch <./topologies/spamscope_elasticsearch.py>`__:
258298
the output are stored in Elasticsearch indexes. -
259-
`spamscope\_redis <./topologies/spamscope_redis.py>`__: the output are
299+
`spamscope_redis <./topologies/spamscope_redis.py>`__: the output are
260300
stored in Redis.
261301

262302
If you want submit SpamScope topology use ``spamscope-topology submit``
263303
tool. For more details `see SpamScope cli tools <src/cli/README.md>`__:
264304

265305
::
266306

267-
$ spamscope-topology submit --topology {spamscope_debug,spamscope_elasticsearch,spamscope_redis}
307+
$ spamscope-topology submit --topology {spamscope_debug,spamscope_elasticsearch,spamscope_redis}
268308

269-
It's possible to change the default settings for all Apache Storm
309+
Its possible to change the default settings for all Apache Storm
270310
options. I suggest to change these options:
271311

272312
- **topology.tick.tuple.freq.secs**: reload configuration of all bolts
@@ -297,16 +337,16 @@ variables:
297337

298338
::
299339

300-
$ export THUG_ENABLED=True
301-
$ export VIRUSTOTAL_ENABLED=True
302-
$ export VIRUSTOTAL_APIKEY="your key"
303-
$ export ZEMANA_ENABLED=True
304-
$ export ZEMANA_APIKEY="your key"
305-
$ export ZEMANA_PARTNERID="your partner id"
306-
$ export ZEMANA_USERID="your userid"
307-
$ export SHODAN_ENABLED=True
308-
$ export SHODAN_APIKEY="your key"
309-
$ export SPAMASSASSIN_ENABLED=True
340+
$ export THUG_ENABLED=True
341+
$ export VIRUSTOTAL_ENABLED=True
342+
$ export VIRUSTOTAL_APIKEY="your key"
343+
$ export ZEMANA_ENABLED=True
344+
$ export ZEMANA_APIKEY="your key"
345+
$ export ZEMANA_PARTNERID="your partner id"
346+
$ export ZEMANA_USERID="your userid"
347+
$ export SHODAN_ENABLED=True
348+
$ export SHODAN_APIKEY="your key"
349+
$ export SPAMASSASSIN_ENABLED=True
310350

311351
Output example
312352
==============
@@ -338,14 +378,3 @@ Screenshots
338378
:alt: SpamScope Map
339379

340380
SpamScope Map
341-
342-
.. |PyPI version| image:: https://badge.fury.io/py/SpamScope.svg
343-
:target: https://badge.fury.io/py/SpamScope
344-
.. |Build Status| image:: https://travis-ci.org/SpamScope/spamscope.svg?branch=master
345-
:target: https://travis-ci.org/SpamScope/spamscope
346-
.. |Coverage Status| image:: https://coveralls.io/repos/github/SpamScope/spamscope/badge.svg?branch=develop
347-
:target: https://coveralls.io/github/SpamScope/spamscope?branch=develop
348-
.. |BCH compliance| image:: https://bettercodehub.com/edge/badge/SpamScope/spamscope?branch=develop
349-
:target: https://bettercodehub.com/
350-
.. |Donate| image:: https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif
351-
:target: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VEPXYP745KJF2

conf/logstash/conf.d/postfix.conf

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
input {
2+
file {
3+
path => [ "/postfix_logs/maillog" ]
4+
tags => [ "postfix" ]
5+
}
6+
}
7+
8+
filter {
9+
if "postfix" in [tags] {
10+
grok {
11+
match => [ "message", "%{SYSLOGLINE}" ]
12+
overwrite => [ "message" ]
13+
}
14+
date {
15+
match => [ "timestamp8601", "ISO8601" ]
16+
remove_field => [ "timestamp8601" ]
17+
}
18+
if [message] =~ /message-id/ {
19+
grok {
20+
patterns_dir => [ "/usr/share/logstash/patterns" ]
21+
match => ["message", "%{POSTFIX_CODE}"]
22+
add_tag => ["message_id"]
23+
}
24+
} else if [message] =~ /client=/ {
25+
grok {
26+
patterns_dir => [ "/usr/share/logstash/patterns" ]
27+
match => ["message", "%{POSTFIX_CLIENT}"]
28+
add_tag => ["client", "code"]
29+
}
30+
} else if [message] =~ /^> / {
31+
grok {
32+
patterns_dir => [ "/usr/share/logstash/patterns" ]
33+
match => ["message", "%{POSTFIX_DIALECT}"]
34+
add_tag => ["client", "dialect"]
35+
add_field => { "actor" => "server" }
36+
}
37+
} else if [message] =~ /^< / {
38+
grok {
39+
patterns_dir => [ "/usr/share/logstash/patterns" ]
40+
match => ["message", "%{POSTFIX_DIALECT}"]
41+
add_tag => ["client", "dialect"]
42+
add_field => { "actor" => "client" }
43+
}
44+
} else if [message] =~ /^connect / {
45+
grok {
46+
patterns_dir => [ "/usr/share/logstash/patterns" ]
47+
match => ["message", "%{POSTFIX_CONNECT}"]
48+
add_tag => ["client", "connect"]
49+
}
50+
} else if [message] =~ /^disconnect / {
51+
grok {
52+
patterns_dir => [ "/usr/share/logstash/patterns" ]
53+
match => ["message", "%{POSTFIX_DISCONNECT}"]
54+
add_tag => ["client", "disconnect"]
55+
}
56+
}
57+
}
58+
}
59+
60+
output {
61+
if "postfix" in [tags] {
62+
elasticsearch {
63+
hosts => [ "elasticsearch" ]
64+
index => "postfix-%{+YYYY.MM.dd}"
65+
document_type => "_doc"
66+
}
67+
}
68+
}

conf/logstash/patterns/postfix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
POSTFIX_CODE %{NOTSPACE:code}:\s+message-id=%{NOTSPACE:message_id}
2+
POSTFIX_CLIENT %{NOTSPACE:code}:\s+client=%{NOTSPACE:client_name}\[%{NOTSPACE:client_ip}\]
3+
POSTFIX_DIALECT (>|<)\s+%{NOTSPACE:client_name}\[%{NOTSPACE:client_ip}\]:\s+%{GREEDYDATA:dialect}
4+
POSTFIX_CONNECT connect\sfrom\s%{NOTSPACE:client_name}\[%{NOTSPACE:client_ip}\]
5+
POSTFIX_DISCONNECT disconnect\sfrom\s%{NOTSPACE:client_name}\[%{NOTSPACE:client_ip}\]\s%{GREEDYDATA}

0 commit comments

Comments
 (0)