Automate Weekly Shodan IP and Port Monitoring with n8n

This n8n workflow automates the weekly monitoring of IP addresses and their open ports using Shodan, detecting unexpected open ports and generating alerts in TheHive for security teams.
httpRequest
theHive
scheduleTrigger
+7
Workflow Identifier: 1936
NODES in Use: Schedule Trigger, HTTP Request, Split In Batches, Item Lists, Filter, Set, HTML, Markdown, TheHive, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow runs every Monday to watch IP addresses and their open ports. It checks if any new, unexpected ports are open on those IPs using Shodan. When it finds extra ports, it makes alerts in TheHive so the security team can act fast.

The goal is to save time and avoid missing risks by doing this check automatically, not by hand.


Tools and Services Used

  • n8n automation platform: Runs the workflow, connects nodes.
  • Shodan API: Gets open port info for each IP.
  • Internal system API: Provides list of IPs and allowed ports to watch.
  • TheHive API: Receives alerts about unexpected open ports.

Inputs, Processing Steps, and Output

Inputs

  • List of monitored IP addresses and their allowed open ports from internal API.
  • Shodan API access to scan IP addresses.

Processing Steps

  1. Trigger runs every Monday at 5 AM.
  2. Retrieve IPs and allowed ports.
  3. Send each IP to Shodan to get current open services.
  4. Break the service list into separate items.
  5. Filter out ports that are allowed to find unexpected ones.
  6. Format unexpected open port info into an HTML table.
  7. Convert HTML table to Markdown for reports.
  8. Create an alert in TheHive with the Markdown data.

Output

An alert in TheHive for each IP with unexpected open ports, including a clear table of what was found.


Beginner step-by-step: How to use this workflow in n8n

Download and Import Workflow

  1. Click the Download button on this page to get the workflow file.
  2. Open the n8n editor (if self hosting, see self-host n8n setup).
  3. Use the Import from File option in n8n to bring in the workflow.

Configure Credentials and Settings

  1. Enter your Shodan API Key in the credentials section and link it to the Shodan HTTP Request node.
  2. Set up the URL and authentication for the internal system API in the Get watched IPs & Ports HTTP Request node.
  3. Enter your TheHive API credentials in the Create TheHive alert node.
  4. If needed, update any IDs, emails, channel names, or folders in TheHive node settings to match your environment.

Test and Activate

  1. Run the workflow manually once to check data outputs at each node.
  2. Fix any errors or credential issues shown.
  3. Activate the workflow to run every Monday at 5 AM automatically.

How the workflow works—Input → Process → Output

Input

  • The workflow receives a list of IPs and allowed ports from the internal API.
  • It uses the Shodan API Key to access port data.

Processing

  • The Split In Batches node sends IPs one-by-one to avoid overload.
  • The HTTP Request node queries Shodan for each IP’s open ports.
  • The Item Lists node splits the services array so each port can be checked.
  • The Filter node compares found ports to allowed ports to find unmatched ones.
  • The Set node collects IP details and port info.
  • The HTML node and Markdown node build a readable table.
  • The TheHive node sends an alert including this table.

Output

A clean alert in TheHive with all unexpected open ports listed for the security team.


Common Failures and Troubleshooting

API authentication failed in Shodan nodes

Cause: Wrong or missing API Key in credentials.

Fix: Check and update the Shodan API Key in n8n credentials.

Filter node not working right for port checks

Cause: Expression incorrectly written or node names changed.

Fix: Adjust to

= {{ $('For each IP').item.json.ports.includes($json.port) }}

and test with sample data.

TheHive alerts missing or not created

Cause: Credentials invalid or necessary fields not filled.

Fix: Confirm TheHive API token, and ensure alert fields like title and description are set.


Customization Ideas

  • Change Schedule Trigger node for daily or monthly scans.
  • Enhance filter to check service banner or name for suspicious signs.
  • Add Slack or email notifications after TheHive alert.
  • Include error handling nodes to log API errors or limits.
  • Pull IPs from multiple sources by expanding the Get watched IPs & Ports node.

Summary and Benefits of Using This Workflow

✓ Saves 3-4 hours weekly by automating IP open port monitoring.

✓ Detects unexpected services fast, improving risk response.

✓ Sends clear alerts with detailed data to TheHive.

✓ Reduces human error compared to manual checking.

→ Enables reliable, regular security checks without manual work.

Frequently Asked Questions

Check the Shodan API Key in n8n credentials and make sure it is correct and linked to the Shodan HTTP Request node.
The filter expression may be wrong or reference the wrong node. Use = {{ $(‘For each IP’).item.json.ports.includes($json.port) }} and test with sample data.
Verify TheHive API credentials and ensure alert fields like title and description are properly filled and mapped.
Yes. Modify the Schedule Trigger node to run daily or monthly as needed.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free