TheHive and Cortex
Two Cortex analyzers bring urlquery into TheHive cases: run them on an observable, and the case gets urlquery's verdict, alerts and report link, with the server's IP as a new observable. They are tested with Cortex 4.2.
| Analyzer | Observables | What it does |
|---|---|---|
Urlquery_Analyze | url | Reuses urlquery's newest report of the URL from the last 7 days, or analyzes the URL as a restricted report and waits for it. |
Urlquery_Lookup | url, domain, fqdn | Finds urlquery's newest report from the last 30 days. It never analyzes anything, so it can run on observables you don't want to send for analysis. |
Install
The analyzer is one folder, Urlquery, with a program and two definitions:
-
Put the
Urlqueryfolder in a directory of custom analyzers, such as/opt/cortex-analyzers/Urlquery/, and makeurlquery_analyzer.pyexecutable. -
Add the directory to Cortex's
application.conf, beside the analyzers you already use:analyzer.urls = ["https://catalogs.download.strangebee.com/latest/json/analyzers.json""/opt/cortex-analyzers"]With the Cortex Docker image, pass both instead:
--analyzer-url https://catalogs.download.strangebee.com/latest/json/analyzers.json --analyzer-url /opt/cortex-analyzers. A given--analyzer-urlreplaces the default catalog. -
The analyzer runs as a process on the Cortex host, so install its packages where Cortex runs it:
pip install -r requirements.txt. With Cortex in Docker, build an image with them:FROM thehiveproject/cortex:4.2.0RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip \&& rm -rf /var/lib/apt/lists/* \&& pip3 install --break-system-packages --no-cache-dir cortexutils==2.2.1 urlquery-api -
Restart Cortex. In the organization's Analyzers, refresh the list, then enable
Urlquery_Analyze,Urlquery_Lookupor both, with your urlquery API key.
| Setting | Analyzer | Default | Meaning |
|---|---|---|---|
key | both | Your urlquery API key; see Authentication. | |
access | Analyze | restricted | Visibility of new reports: restricted, private or public. |
max_age | both | 7 (Analyze), 30 (Lookup) | Days a report is reused. |
wait_timeout | Analyze | 300 | Seconds to wait for a new analysis. |
Looking up or analyzing an observable sends it to urlquery. Use Cortex's own Max TLP and Max PAP settings on each analyzer to keep sensitive observables in: TLP:AMBER and PAP:AMBER are a sensible limit.
In TheHive
With Cortex connected to TheHive, select an observable and run the analyzer. The report has:
- Taxonomies, shown on the observable:
urlquery:Verdict(malicious,suspicious,benignas safe, orunknownas info) and, when the report has urlquery alerts,urlquery:Alertswith their number, in red when one is a phishing or malware alert. A lookup that finds no report showsurlquery:Report="none". - The full report: the report ID and link, the analysis time, the submitted and final URL, the page title, the server's IP and network, urlquery's tags, and each alert with its severity and the host it fired on.
- New observables: the server's IP, and the final URL when the page redirected, tagged
urlquery. Import them into the case from the analyzer's report.
unknown means urlquery has no recent evidence about the URL, not that it is safe. A lookup without a report is not an error; run Urlquery_Analyze when you want the URL analyzed.
When a new analysis takes longer than wait_timeout, the job fails with a message that names the report. The analysis goes on: run the analyzer again later, and it finds the finished report instead of submitting the URL again.
Adapt it
- More evidence. The analyzer reads the report overview. The full report, with
client.report(report_id), adds every HTTP transaction, script and artifact; see the phishing guide for what to take from it. - TheHive templates. Cortex reports show as JSON in TheHive. A short and long report template for the
Urlqueryanalyzers makes them easier to read. - Responders. To add a case's indicators to a urlquery watchlist, a Cortex responder can call
create_watchlistwith the Python library, as the MISP page shows.