09.SOAR N8N Workflow
Objective
This workflow will automatically:
Extract destination IP addresses from the Fluent Bit index in Elasticsearch.
Send each IP to VirusTotal for reputation analysis.
Filter malicious or suspicious IPs based on VirusTotal results.
Send an email alert containing only those IPs to the analyst (in this case, my own email address) with the required subject format:
bash GROUP#_Abdelwahab_Shandy
๐งฑ Pre-requisites
Before building the workflow, we configured the following:
1๏ธโฃ VirusTotal API Key
-
Logged in to VirusTotal.
-
Navigated to User Profile โ API Key.
-
Copied the key and stored it securely.
-
Used it later inside n8nโs HTTP Request (VirusTotal) node to authenticate API requests.
2๏ธโฃ Elasticsearch API Credential
-
Created a new Credential in n8n:
-
Type:
Elasticsearch API -
Auth Method:
Elasticsearch Account -
Username:
elastic -
Password: (The one obtained during ELK setup)
-
Host URL:
https://192.168.1.16:9200
This allows n8n to securely fetch logs directly from our ELK SIEM index.
3๏ธโฃ Email App Password
-
Since Gmail no longer allows direct login with username & password, we:
-
Enabled 2-Step Verification on the Gmail account.
-
Generated an App Password via:\
Google Account โ Security โ App Passwords โ Select App: Mail โ Select Device: Other (Custom name: n8n)| link -
Copied the 16-character password generated by Google.
-
Added it in n8nโs Email Credential settings (type: โGmail SMTPโ).
-
Host : smtp.gmail.com
-
Port : 465
-
Enable SSL/TLS
-
Client Host Name :
localhost
This allows the workflow to send automated reports securely via Gmail.
โก Workflow Breakdown
Step 1 โ Trigger the Workflow
- Node: Manual Trigger\ The workflow starts manually from the n8n UI.
Step 2 โ Retrieve Logs from Elasticsearch
-
Node: HTTP Request โ Elasticsearch API
-
Method:
POST -
Endpoint:
bash https://192.168.1.16:9200/lab-abdelwahabshandy-fluentbit/_search -
Body:
bash { "_source": ["DestinationIP"], "query": { "exists": { "field": "DestinationIP" } } } -
Credential Used: Elasticsearch Account\ โ Purpose: Fetch all logs containing a Destination IP field.
Step 3 โ Extract IPs
-
Node: Function
-
Extracts
DestinationIPvalues from the logs. -
Creates a clean list of IPs for further analysis.
Step 4 โ Check IP Reputation
-
Node: HTTP Request โ VirusTotal API
-
Method:
GET -
URL:
bash https://www.virustotal.com/api/v3/ip_addresses/{{ $json["DestinationIP"] }} -
Header:
bash x-apikey: <your_virustotal_api_key> -
Credential Used: None (direct API key header).\ โ Purpose: Query VirusTotal to check if the IP is malicious.
Step 5 โ Filter Malicious IPs
-
Node: IF / Filter
-
Condition:
bash {{$json["data"]["attributes"]["last_analysis_stats"]["malicious"]}}
โ Keeps only IPs flagged as malicious by VirusTotal.
Step 6 โ Aggregate Malicious IPs
-
Node: Merge or Function Node
-
Collects all filtered malicious IPs into a single list.
-
Prepares them for reporting.
Step 7 โ Send Email Report
-
Node: Email Send (Gmail)
-
From: (Your Gmail account configured with App Password)
-
To: (Your email or team address)
-
Subject:
bash GROUP1_ABDELWAHAB_SHANDY -
Body Example:
```plaintext Malicious IPs Detected
The following suspicious IP addresses have been flagged: {{ $json.allMalicious.map(ip => "- " + ip.data.id).join("\n") }}
I hope I will do well in the exam. Abdelwahab Ahmed Abdelwahab Shandy ```
โ Final Result
By the end of this workflow:
-
Logs are automatically retrieved from Elasticsearch.
-
IPs are analyzed in real-time via VirusTotal.
-
Malicious IPs are filtered and reported automatically to your inbox.
This completes the SOAR Integration, turning your SIEM into a proactive detection and response system.