This folder contains the docker-compose.yml
file needed to start ThePhish and all the required services with Docker Compose. It uses the following images:
- cassandra:3.11
- thehiveproject/thehive4:4.1.9-1
- docker.elastic.co/elasticsearch/elasticsearch:7.11.1
- thehiveproject/cortex:3.1.1-1
- redis:6.2.5
- mysql:8.0.26
- coolacid/misp-docker:core-v2.4.148a
- emalderson/thephish:latest
These images are used with a minimal configuration. You can change the default parameters that are provided in the docker-compose.yml
file. Moreover, it is possible to use additional settings by following the configuration guides available for those images.
This folder also contains three subfolders that contain the configuration files used by TheHive, Cortex and ThePhish and that will be mounted as volumes in the respective containers.
In order to use this installation method, it is required to have a Linux-based OS with Docker 19.03.0+ and Docker Compose 1.25.5+ installed. The guide to install Docker can be found here, while the guide to install Docker Compose can be found here.
This guide will not only show you how to run the containers but also how to configure them so that you'll be able to analyze your first email.
-
Clone the repository
$ git clone https://github.com/emalderson/ThePhish.git
-
Run the multi-container application.
$ cd ThePhish/docker $ docker-compose up
-
If the logs start showing many errors, this is because you need to change the ownership of some folders. Indeed, a new folder called
vol
will be created that will be used by the various containers to store data. You need to change the owner of some of its subfolders to match the user that has run thedocker-compose up
command so that the containers will be able to access their content. In order to do that, you need to stop the application, apply the change of ownership and then restart the application.$ docker-compose stop $ sudo chown -R 1000:1000 vol/index vol/data vol/elastic* $ docker-compose up
This must be done once all the files in those folders have been created. If you face the same errors after having followed this procedure, try waiting some time (minutes) and re-execute the command to change the ownership of those folders recursively.
It is advisable that the email address from which ThePhish fetches the emails to analyze be a Gmail address since it is the one with which ThePhish has been tested the most. It is preferable that the account is a newly created one, with the sole purpose of being used by ThePhish. Here is explained the procedure to activate the app password that is required by ThePhish to connect to the mailbox and fetch the emails.
Let's suppose that a Gmail address will be used. Once the email address is ready to use, edit the imap part of the filethephish_conf_files/configuration.json
so that it looks like this:
"imap" : {
"host" : "imap.gmail.com",
"port" : "993",
"user" : "<YourEmailAddress>",
"password" : "<YourEmailAddressAppPassword>",
"folder" : "inbox"
}
- Go to
https://localhost
and log in with the default credentials:- Username:
admin@admin.test
- Password:
admin
- Username:
- Create a new organization
- Administration -> Add Organization
- Name:
<YourOrganizationName>
- Click on "Generate UUID"
- Click on "Submit"
- Change settings
- Administration -> Server Settings and Maintenance -> MISP Settings
- Change the field
MISP.live
toTrue
- Change the field
MISP.baseurl
tohttps://localhost
- Change the field
MISP.external_base_url
tohttps://localhost
- Change the field
MISP.org
to<YourOrganizationName>
- Change the field
MISP.host_org_id
to<YourOrganizationName>
- Create a new user that is used for the integration with TheHive and Cortex
- Administration -> Add User
- email:
sync_user@<YourOrganizationDomain>
- organization:
<YourOrganizationName>
- role:
Sync User
- Uncheck all the checkboxes
- click on "Create user"
- Obtain the Authentication key of the
Sync User
- Administration -> List Users
- Click on the "Eye" on the right for the just created user (View)
- Click on "Auth Keys"
- Delete the already created auth key
- Administration -> List Users (again)
- Click on the "Eye" on the right for the just created user (again)
- Click on "Auth Keys" (again)
- Click on "Add authentication key"
- Click on "Submit" and save it for later
- Enable MISP feeds
- Sync Actions -> List Feeds -> Load default feed metadata -> All feeds
- Select the feeds to enable
- Click on "Enable selected"
- Go to
http://localhost:9001
and click on "Update database" - Create a new admin user
- Login:
admin@<YourOrganizationName>
- Name:
admin
- Password:
<Password>
- Login:
- Create a new organization
- Organizations -> Add Organization
- Name:
<YourOrganizationName>
- Description:
<YourOrganizationDescription>
- Create a new orgadmin user in that organization
- Click on the newly created organization
<YourOrganizationName>
- Click on "Add user"
- Login:
thephish@<YourOrganizationName>
- Full name:
ThePhish
- Roles:
read, analyze, orgadmin
- Click on "New password" for the newly created user and set a password for that user
- Click on the newly created organization
- Create another user in that organization that is used for the integration with TheHive and to use the API
- Click on the newly created organization
<YourOrganizationName>
- Click on "Add user"
- Login:
integration_account@<YourOrganizationName>
- Full name:
integration_account
- Roles:
read, analyze
- Click on "Create API key" and then on "Reveal" for the newly created user and save it for later
- Click on the newly created organization
- Log out the admin user and log in the orgadmin user (ThePhish)
On Cortex, while logged in with the orgadmin user, do the following:
- Organization -> Responders
- Enable the Mailer responder
- Configure the Mailer responder
- from:
<YourGmailEmailAddress>
- smtp_host :
smtp.gmail.com
- smtp_port:
587
- smtp_user:
<YourGmailEmailAddress>
- smtp_pwd:
<YourGmailEmailAddressAppPassword>
- from:
In order to run the Cortex neurons (analyzers and responders), it is possible to clone the repository containing the neurons and execute them locally in the Cortex container, but the recommended way is to use dockerized neurons (which is used in this case). This means that their images are pulled from Docker Hub once and then every time a neuron is executed, a container is created based on that image and is destroyed at the end of the execution. Those containers are started on the host system by the Docker client inside the Cortex container, which has access to the Docker daemon on the host system thanks to the UNIX socket docker.sock on which the Docker daemon is listening and that is mounted as a volume in the Cortex container.
Since the default bridge network created by Docker is the one to which the neuron containers are attached during their execution, the container that runs the MISP_2_1 analyzer will not be able to reach the MISP instance in the MISP container unless that container is also connected to the default bridge network. Moreover, using the IP address of the interface that connects the MISP container to the default bridge network is the only way that the MISP_2_1 analyzer container can use to reach the MISP instance since the embedded DNS server is not available in the default networks.
To connect the MISP container to the default bridge network execute the following commands:
$ docker network connect bridge misp
$ docker network inspect bridge
You should see the IP address that has been assigned in the default bridge network to the MISP container. It will be used to configure the MISP_2_1 analyzer on Cortex.
Now, on Cortex, while logged in with the orgadmin user, do the following:
- Organization -> Analyzers
- Enable the MISP_2_1 analyzer
- Configure the MISP_2_1 analyzer
- url:
https://<IPAddressOfTheMISPInstanceInTheDefaultBridgeNetwork>
- key:
<AutheticationKeyOfTheSyncUserCreatedOnMISP>
- cert_check:
False
- url:
On Cortex, while logged in with the orgadmin user, do the following:
- Organization -> Analyzers
- Enable the desired analyzers and configure them (following this guide)
Edit the cortex part of the file thehive/application.conf
to replace the XXXXXXXXXXXXXXx
with the API key of the integration_account
created in Cortex.
play.modules.enabled += org.thp.thehive.connector.cortex.CortexModule
cortex {
servers = [
{
name = local
url = "http://cortex:9001"
auth {
type = "bearer"
key = "XXXXXXXXXXXXXXx"
}
# HTTP client configuration (SSL and proxy)
# wsConfig {}
# List TheHive organisation which can use this Cortex server. All ("*") by default
# includedTheHiveOrganisations = ["*"]
# List TheHive organisation which cannot use this Cortex server. None by default
# excludedTheHiveOrganisations = []
}
]
# Check job update time intervalcortex
refreshDelay = 5 seconds
# Maximum number of successive errors before give up
maxRetryOnError = 3
# Check remote Cortex status time interval
statusCheckInterval = 1 minute
}
Edit the misp part of the file thehive/application.conf
to replace the XXXXXXXXXXXXXXx
with the Authentication key of the sync_user
created in MISP.
# MISP configuration
play.modules.enabled += org.thp.thehive.connector.misp.MispModule
misp {
interval: 5 min
servers: [
{
name = "MISP THP" # MISP name
url = "https://misp/" # URL or MISP
auth {
type = key
key = "XXXXXXXXXXXXXXx" # MISP API key
}
wsConfig { ssl { loose { acceptAnyCertificate: true } } }
}
]
}
- Go to
http://localhost:9000
and log in with the default credentials:- Username:
admin@thehive.local
- Password:
secret
- Username:
- Create a new organization
- Click on "New organization"
- Name:
<YourOrganizationName>
- Description:
<YourOrganizationDescription>
- Create a new orgadmin user in that organization
- Click on the newly created organization
<YourOrganizationName>
- Click on "Create new user"
- Login:
thephish@<YourOrganizationName>
- Full name:
ThePhish
- Profile:
org-admin
- Click on "New password" for the newly created user and set a password for that user
- Click on "Create API key" and then on "Reveal" for the newly created user and save it for later
- Click on the newly created organization
- Log out the admin user and log in the orgadmin user (ThePhish)
Edit the thehive and the cortex parts of the filethephish_conf_files/configuration.json
to set the API key of the orgadmin
user created on TheHive and the API key of the integration account
created on Cortex.
{
"thehive" : {
"url" : "http://thehive:9000",
"apikey" : ""
},
"cortex" : {
"url" : "http://cortex:9001",
"apikey" : "",
"id" : "local"
}
}
First of all, you need to restart the multi-container application for the changes to be applied.
$ docker-compose stop
$ docker-compose up -d
Now the application should be reachable at http://localhost:8080
.
- Open Firefox and type
about:config
in the address bar (accept the risk) - Find the
network.http.network-changed.timeout
setting and raise its value from 5 to an higher value (e.g. 60) [stackoverflow] - Find the
network.websocket.extensions.permessage-deflate
setting and change it tofalse
[stackoverflow]
This is because after some troubleshooting, it emerged that the Firefox browser closed the AJAX connection before receiving the response and also the messages sent on the WebSocket connection got corrupted.
You're all set now! When a user sends an email to the email address that you created, it will appear in the list of emails to analyze and you can select it for the analysis.
However, in order to make ThePhish work better, you should also configure the whitelist and the analyzer levels that best suit your needs by using the files thephish_conf_files/analyzers_level_conf.json
and thephish_conf_files/whitelist.json
. In order to learn how to do that, please refer to these two sections in the main installation guide: