{
  "id": "ZUiF05eiy3I0zdls",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "IP_Info_&_HttpPortScanner",
  "tags": [],
  "nodes": [
    {
      "id": "d48dee47-1fed-49fe-bf32-9b6b9982616e",
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -416,
        -16
      ],
      "parameters": {
        "event": "rowAdded",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit?usp=drivesdk",
          "cachedResultName": "IP-Info"
        }
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dc06f30b-8083-4e3b-8923-09f743ad7858",
      "name": "Update_IP_Info_row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        48,
        -16
      ],
      "parameters": {
        "columns": {
          "value": {
            "IP": "={{ $json.query }}",
            "ISP": "={{ $json.isp }}",
            "Lat": "={{ $json.lat }}",
            "Lon": "={{ $json.lon }}",
            "Org": "={{ $json.org }}",
            "City": "={{ $json.city }}",
            "Country": "={{ $json.country }}"
          },
          "schema": [
            {
              "id": "IP",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "IP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lat",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lat",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lon",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lon",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ISP",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ISP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Org",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Org",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "IP"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit?usp=drivesdk",
          "cachedResultName": "IP-Info"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5a0d22ee-2fb5-48e4-9000-e6799420bd8c",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        480,
        -16
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "ports",
        "fieldsToInclude": "IP"
      },
      "typeVersion": 1
    },
    {
      "id": "dcf55b8f-76b2-4f9f-96c8-93dec9258495",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        256,
        -16
      ],
      "parameters": {
        "include": "selected",
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "60aefa6f-50dd-484e-af28-a65e7cc695c8",
              "name": "ports",
              "type": "array",
              "value": "[80,443,8080,8000,3000]"
            }
          ]
        },
        "includeFields": "IP",
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "8504d3c2-186c-4534-b3c9-b23641e2a47a",
      "name": "Update_HTTP_Ports_State",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1152,
        -16
      ],
      "parameters": {
        "columns": {
          "value": {
            "IP": "={{ $('Split Out').first().json.IP }}",
            "Port_80": "={{ $json.result['80'] }}",
            "Port_443": "={{ $json.result['443'] }}",
            "PORT_3000": "={{ $json.result['3000'] }}",
            "Port_8000": "={{ $json.result['8000'] }}",
            "Port_8080": "={{ $json.result['8080'] }}"
          },
          "schema": [
            {
              "id": "IP",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "IP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lat",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Lat",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lon",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Lon",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ISP",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "ISP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Org",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Org",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Port_80",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Port_80",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Port_443",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Port_443",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Port_8000",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Port_8000",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Port_8080",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Port_8080",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PORT_3000",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "PORT_3000",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "IP"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit?usp=drivesdk",
          "cachedResultName": "IP-Info"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "fe67923f-d24f-404b-a16f-6d860a8531ac",
      "name": "CheckHttpPort",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        704,
        -16
      ],
      "parameters": {
        "url": "=http://{{ $json.IP }}:{{$json.ports}}/",
        "options": {
          "timeout": 10000,
          "allowUnauthorizedCerts": true
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0b9969ad-6e89-4432-931d-311ea510fbb5",
      "name": "PutAll_in_OneItem",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        -16
      ],
      "parameters": {
        "jsCode": "function startsWithHttpCode(error) {\n  return /^\\s*\\d{3}\\b/.test(error);\n}\n\n// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nconst result = {};\nlet index = 0;\nfor (const item of $input.all()) {\n  const portItem = $(\"Split Out\").itemMatching(index).json;\n    \n  if(item.json.error)\n    result[portItem.ports] = startsWithHttpCode(item.json.error.message);\n  else\n    result[portItem.ports] = true;\n  index++;\n}\n\nreturn {result};"
      },
      "typeVersion": 2
    },
    {
      "id": "757ec413-fe8a-44c8-ac9c-49fc5694f59a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -384
      ],
      "parameters": {
        "width": 704,
        "height": 224,
        "content": "## Automate IP geolocation and HTTP port scanning with Google Sheets trigger\nThis n8n template automatically enriches IP addresses with geolocation data and performs HTTP port scanning when new IPs are added to a Google Sheets document. Perfect for network monitoring, security research, or maintaining an IP intelligence database.\n\n**Sample Sheet** [Link](https://docs.google.com/spreadsheets/d/19MSjNyjzs1FeRI5_QLiVk8Hi9JNt5HD1bNulfpB6SzI/edit?usp=sharing)"
      },
      "typeVersion": 1
    },
    {
      "id": "d442a1dc-be9c-4768-8350-584c8b291aa5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -96
      ],
      "parameters": {
        "color": 6,
        "height": 240,
        "content": "triggers whenever a new row containing an IP address is added to your Google Sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "7cfbe7d3-cf98-441b-a8a8-910c778deaed",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 208,
        "height": 240,
        "content": "\n**Get IP Geolocation Data**"
      },
      "typeVersion": 1
    },
    {
      "id": "652acfc7-f734-4de4-a598-ec527d2ab20d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 432,
        "height": 240,
        "content": "**Define HTTP ports list for scan**\nConvert the array to items list in order to execute http request for each port"
      },
      "typeVersion": 1
    },
    {
      "id": "773abbaa-5b51-4914-aeb9-317f1ee55a92",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 224,
        "height": 240,
        "content": "\n**Test HTTP Port Connectivity**"
      },
      "typeVersion": 1
    },
    {
      "id": "541c08d8-ff68-4110-8759-a9d95ee4415f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 224,
        "height": 240,
        "content": "**Aggregate Port Scan Results**\nCheck is the port open for each port"
      },
      "typeVersion": 1
    },
    {
      "id": "312c9a35-3cf4-4b38-be02-64482435589c",
      "name": "GetIP_Info",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -176,
        -16
      ],
      "parameters": {
        "url": "=http://ip-api.com/json/{{ $json.IP }}",
        "options": {}
      },
      "typeVersion": 4.2
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ee0b130b-725e-4809-bbfc-0bdfb962f936",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "CheckHttpPort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetIP_Info": {
      "main": [
        [
          {
            "node": "Update_IP_Info_row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckHttpPort": {
      "main": [
        [
          {
            "node": "PutAll_in_OneItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PutAll_in_OneItem": {
      "main": [
        [
          {
            "node": "Update_HTTP_Ports_State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update_IP_Info_row": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "GetIP_Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}