August 30, 2026 · Offensive Cyber Operations with AI

n8nOSINTPhishingNmapSerpAPIHunter.ioLLM Router

AI Red Teaming Lab 4: AI-Powered OSINT, Phishing Operations & Network Recon — a technical write-up

Lab 4 builds AI-augmented offensive automation in n8n: four chat-driven workflows that combine LLM calls (Groq) with OSINT APIs (SerpAPI, Hunter.io) and remote Nmap scanning over SSH. No native n8n AI-agent nodes are used — every "agent" is a raw HTTP request to Groq's OpenAI-compatible endpoint with a carefully engineered system prompt. The prompt engineering is the lab content.

Key result: a single chat interface that routes between Nmap scanning, multi-source OSINT fusion, and GitHub recon — driven entirely by a one-word LLM classification.

Attack path (how the steps chain)

  1. Start from a name — the OSINT workflow turns "Jane Doe from Acme" into LinkedIn/social profiles, org email addresses, and the company's email pattern (SerpAPI + Hunter.io).
  2. Weaponize the OSINT — the phishing workflow feeds the same collected data to a "seasoned social engineer" persona, producing a copy-paste-ready spear-phish personalized with the target's role and colleagues.
  3. Map the infrastructure in parallel — the Nmap-over-SSH workflow scans the target and the LLM turns raw ports into a vulnerability assessment with an explicit attack-path analysis and risk scoring.
  4. Fuse everything behind one chat — the capstone router classifies intent (SCAN / OSINT / GITHUB) in a single word and dispatches the right chain, including commit-email harvesting from GitHub metadata.
  5. The real-world chain this mirrors: recon (OSINT + scan) → weaponization (phish) → delivery → initial access — the front half of every intrusion, automated end-to-end.

1. Setup (common to all exercises)

docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
# open http://localhost:5678, create owner account
# Workflows → Import from File → each exercise JSON

Keys needed: Groq (console.groq.com), SerpAPI, Hunter.io. The shipped JSONs contain hardcoded lab keys inline in HTTP node URLs/headers — replace them with your own (worth fixing properly: use n8n Credentials, rotate exposed keys). For Ex 3/4 create an SSH Password credential for a host with nmap (a Kali VM is ideal) and select it on the Nmap nodes — the shipped credential IDs are placeholders. Finally, toggle each workflow to Active so the chat webhook responds.

2. Exercise 1 — AI OSINT pipeline

Flow: Chat Trigger → Parse Target Input (JS: strips command verbs, extracts name + company via "X from Y" regex, guesses company.com domain) → three parallel collectors → aggregate → Groq report.

Input: osint on Sundar Pichai from Google · Output: a formatted report with profile URLs, org email list + pattern, and social-engineering attack vectors.

3. Exercise 2 — OSINT → targeted phishing

Same collection half, but the LLM is prompted as a "seasoned social engineer": write ONE highly targeted phishing email with a compelling subject, using psychological triggers (urgency, authority, curiosity), no introductory text. A Merge node (mergeByPosition) joins the three sources, and the output is wrapped in a "Targeted Phishing Payload Generated" block with an authorized-use watermark. Expected: a copy-paste-ready spear-phish personalized with the target's role, company context, and colleagues discovered via OSINT.

4. Exercise 3 — AI-analyzed Nmap scan

Linear pipeline: Chat → Parse Target (IPv4 regex → domain → last token) → SSH node running nmap -Pn -sV -T4 <target> on the remote host → Prepare AI Body → Groq (llama-3.1-8b-instant, temp 0.2) with an elite-pentester system prompt demanding an exact skeleton: Executive Summary, Open Ports table, per-port Vulnerability Assessment (Risk / Attack Surface / MITRE ATT&CK / CVEs / Remediation), Attack Path Analysis, Risk Score Matrix (X/10), Top-5 Actions.

Input: scan scanme.nmap.org · Output: a structured pentest-style report. Lab quirk: the parsed scanType ("verbose") is never used downstream — a workflow limitation, not your error.

5. Exercise 4 — All-in-One agentic router (~30 nodes)

The capstone: an LLM acts as an intent router. A cheap classification call (llama-3.3-70b-versatile) answers exactly one word — SCAN, OSINT, or GITHUB — and a Switch node dispatches:

Inputs: aggressive scan example.com · research Jane Doe from Acme · analyze github torvalds.

6. Key insights

7. Troubleshooting

References