Skip to main content

OpenCTI

urlquery_opencti.py is an internal-enrichment connector for OpenCTI. It enriches Url, Domain-Name and Hostname observables with urlquery reports. It is tested with OpenCTI 7.261109.

What it does​

  • A Url is analyzed as a restricted report, unless it was analyzed in the last 7 days; then its newest report is used.
  • A Domain-Name or Hostname gets its newest report from the last 7 days (url.domain or url.fqdn), if there is one. It is not analyzed, because a domain alone doesn't say which page to visit.

From the report, the connector adds:

ToWhat
The observableA score of 90 for a malicious verdict and 50 for suspicious (other verdicts leave the score alone); the label urlquery:<verdict> and urlquery's tags as labels; an external reference to the report; and the screenshot as a file.
A note on the observableThe verdict, final URL, title, alerts, the kit's rare scripts and its Telegram bots, with a link to the report.
Related observablesThe IP address that served the page, and the final URL when the page redirected, each related-to the observable.

The connector's author is the urlquery organization. It creates no indicators: urlquery's verdict comes from one visit, so promoting an observable to an indicator stays your decision.

Run it​

Create a user for the connector in OpenCTI, in the Connectors group, and use its token. Then run the connector next to your platform, where it can reach OpenCTI and its RabbitMQ. Put the script and this Dockerfile in a connector-urlquery folder beside OpenCTI's docker-compose.yml:

docker-compose.yml
connector-urlquery/
Dockerfile
urlquery_opencti.py
FROM python:3.12-slim
# pycti must match your OpenCTI version.
RUN pip install --no-cache-dir "pycti==7.261109.0" urlquery-api
COPY urlquery_opencti.py /app/
USER nobody
CMD ["python", "/app/urlquery_opencti.py"]
# Added to OpenCTI's docker-compose.yml
connector-urlquery:
build: ./connector-urlquery
environment:
- OPENCTI_URL=http://opencti:8080
- OPENCTI_TOKEN=${CONNECTOR_URLQUERY_TOKEN}
- CONNECTOR_ID=${CONNECTOR_URLQUERY_ID} # a UUID of your own, kept across restarts
- URLQUERY_APIKEY=${URLQUERY_APIKEY}
- CONNECTOR_AUTO=false
restart: always

The connector sets its own type (INTERNAL_ENRICHMENT), name (urlquery) and scope (Url,Domain-Name,Hostname), so CONNECTOR_TYPE, CONNECTOR_NAME and CONNECTOR_SCOPE aren't needed; set them only to change them, for example CONNECTOR_SCOPE=Url to enrich Urls only. The connector appears in Data > Ingestion > Connectors. To enrich an observable, use Enrich on its page and choose urlquery.

SettingDefaultMeaning
CONNECTOR_AUTOfalsetrue enriches every new Url, Domain-Name and Hostname automatically. Each new Url can be an analysis on your account, so set it only when your quota allows.
URLQUERY_MAX_TLPTLP:AMBERThe highest TLP sent to urlquery; the level itself is sent. With the default, observables marked TLP:CLEAR, TLP:GREEN or TLP:AMBER are sent, and TLP:AMBER+STRICT or TLP:RED are not. An observable with several TLP markings is sent only when all of them are within the limit. Looking up or analyzing a URL shares it with urlquery.
URLQUERY_ACCESSrestrictedVisibility of new reports: restricted, private or public.
URLQUERY_MAX_AGE7Days a report is reused before a Url is analyzed again.
CONNECTOR_LOG_LEVELerrorinfo logs each enrichment.

When an analysis is still running​

The connector waits up to five minutes for a new analysis. If it isn't done by then, the enrichment ends with an error that names the report. The analysis goes on: enrich the observable again later, and the connector finds the finished report instead of submitting the URL again.

Adapt it​

  • Indicators. To create an indicator for a malicious verdict, add a stix2.Indicator with the pattern [url:value = '…'] and a based-on relationship to the observable. Consider a valid_until a few weeks out: phishing URLs are short-lived.
  • More observables. The report's rare script hashes, its Telegram bots and the hosts it contacted can become observables of their own, related to the URL. Read them from the full report, as the note does.
  • Playbooks. In an OpenCTI playbook, use the connector as an enrichment step, for example on Urls from a phishing-report feed.