Skip to content

Setup

Once you have the ThreatHub Web App and Ingestor program installed, you can proceed with the setup.

  1. Create a MySQL user for ThreatHub and assign permissions, replacing PASSWORD with a strong password
CREATE USER 'threathub'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON threathub.* TO 'threathub'@'localhost';
FLUSH PRIVILEGES;
  1. Create another MySQL user for the report feature, replacing PASSWORD with a different strong password to the user you just created. Don’t grant any privileges just yet.
CREATE USER 'threathub_report_user'@'localhost' IDENTIFIED BY 'PASSWORD';
  1. Create a database
CREATE DATABASE threathub;
  1. Select the database
USE threathub;
  1. We need to run a script in the Web App. Essentially, run npm install in the directory and then run npm run run-migrations
  2. Now back to MySQL, run the following to grant specific permissions to the report user you created earlier. This is required to prevent malicious SQL being written into reports by users.
CREATE VIEW agents_safe AS
SELECT
id,
email,
display_name,
role,
created_at,
  updated_at,
  deleted_at
FROM agents
GRANT SELECT ON threathub.agents_safe TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.devices TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.vulnerabilities TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.vulnerability_exploit_types TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.vulnerability_references TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.vulnerability_tags TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.vulnerability_affected_software TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.customers TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.software TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.customer_vulnerability_software TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.customer_vulnerabilities TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.device_notes TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.device_vulnerabilities TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.device_vulnerabilities_history TO 'threathub_report_user'@'localhost';
GRANT SELECT ON threathub.remediation_tickets TO 'threathub_report_user'@'localhost';
FLUSH PRIVILEGES;
  1. Done! The database is set up
  1. Move into the WebApp directory and install dependencies
Terminal window
cd /home/threathub/webapp
npm install
  1. Create a .env file with contents like the following:
Terminal window
NEXTAUTH_SECRET=(RANDOM SECRET STRING)
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=threathub
MYSQL_PASSWORD=(MYSQL PASSWORD)
MYSQL_DATABASE=threathub
MYSQL_REPORT_USER=threathub_report_user
MYSQL_REPORT_PASSWORD=(MYSQL REPORT USER PASSWORD)
VariableDescription
NEXTAUTH_SECRETA random secret string used to hash tokens and sign/encrypt session cookies. It is essential this is set to long random string
MYSQL_HOSTThe address of the MySQL server. If running on the same machine it is likely localhost or 127.0.0.1
MYSQL_PORTThe port of the MySQL server. By default this is 3306 and it is unlikely you will need to change it
MYSQL_USERThe username you created inside MySQL during the Setup stage for ThreatHub to use. This was likely threathub, but if you chose something else, please change it here
MYSQL_PASSWORDThe password for the user you created inside MySQL during the Setup stage
MYSQL_DATABASEThe name of the MySQL database you crated during the Setup stage. You likely named this threathub but if not please change it here
MYSQL_REPORT_USERThe username you created inside MySQL for the report user. This is likely threathub_report_user but if you chose something else, please change it here
MYSQL_REPORT_PASSWORDThe password for the report user in MySQL
REDIS_HOSTThe address of the Redis server. If running on the same machine it is likely localhost or 127.0.0.1
REDIS_PORTThe port of the MySQL server. By default this is 6379 and it is unlikely you will need to change it
NEXTAUTH_URLThe URL that the Web App will be hosted on. For example, threathub.mycompany.com. This is used for authentication
  1. Build the project
Terminal window
npm run build
  1. That’s it for now, move on to the next section
  1. Move into the Ingestor directory
Terminal window
cd /home/threathub/ingestor
  1. Create a file named config.properties as shown below:
database.url=jdbc:mysql://localhost/threathub
database.username=(MYSQL USERNAME)
database.password=(MYSQL PASSWORD)
database.maxLifetime=600000
defender.baseApiUrl=https://api-eu3.securitycenter.microsoft.com
PropertyDescription
database.urlThe URL to the MySQL database. It is in the format jdbc:mysql://MYSQL_HOST/MYSQL_DATABASE
database.usernameThe username you created inside MySQL during the Setup stage for ThreatHub to use
database.passwordThe password for the user you created inside MySQL during the Setup stage
database.maxLifetimeThe maximum amount of time a connection in the pool is allowed to be open (in milliseconds). For advanced users
defender.baseApiUrlThe base API for the Microsoft Defender API. This is useful if you live in another part of the world outside of Europe as it gives you the ability to use a server closer to you. For advanced users

TODO

This is essentially creating an app registration in Entra ID with read permissions vulnerabilities, machines and software under WindowsDefenderATP, and setting up OAuth credentials on the same app registration (or separate if you prefer).