Skip to content

Instantly share code, notes, and snippets.

@R0X4R
Created September 4, 2025 09:34
Show Gist options
  • Save R0X4R/3eb7cde8c9ba33c00aa6bfdf33c33529 to your computer and use it in GitHub Desktop.
Save R0X4R/3eb7cde8c9ba33c00aa6bfdf33c33529 to your computer and use it in GitHub Desktop.
A simple Python tool that extracts open ports from Nmap output and prints them in clean host:port format, perfect for recon workflows.

A lightweight Python tool that parses Nmap output and extracts open ports in clean host:port format.
Perfect for bug bounty and recon workflows.

Features

  • Reads directly from stdin
  • Extracts hostnames or IPs with their open ports
  • Minimal, fast, and easy to chain in pipelines

Usage

nmap -iL targets.txt -p 80,443,22 -sS -Pn -oN - | python filter.py
import sys
import re
def filter():
host = None
for line in sys.stdin:
line = line.strip()
if line.startswith("Nmap scan report"):
parts = line.split()
if len(parts) >= 5:
host = parts[4]
elif "open" in line:
match = re.match(r"(\d+)/tcp\s+open", line)
if match and host:
port = match.group(1)
print(f"{host}:{port}")
if __name__ == "__main__":
filter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment