Skip to content

gab-dev-7/port-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Simple TCP Port Scanner

A minimal, single-threaded TCP port scanner written in C. Designed for educational purposes to demonstrate the fundamentals of TCP connect-based scanning.

Overview

The scanner tests a range of TCP ports on a target IP by attempting a full TCP connection (connect()).

Key characteristics:

  • Sequential: Scans ports one by one (simple, but slow for large ranges).
  • Non-blocking I/O: Uses non-blocking sockets with select() to avoid hanging.
  • Timeout-based: Waits up to 1 second per port before reporting a timeout.

Build & Run

Compile:

gcc -o scanner scanner.c

Run:

./scanner <IP> <Start Port> <End Port>

Example:

./scanner 127.0.0.1 80 100

Output Meaning

  • [OPEN] — TCP connection succeeded (service listening)
  • [TIMEOUT] — No response within timeout (likely filtered)
  • [ERROR] — System or socket error
  • (No output) — Port closed (connection refused immediately)

Example Use Cases

  • Verify local services

    ./scanner 127.0.0.1 8080 8080
  • Check common service ports

    ./scanner 127.0.0.1 22 3306
  • Detect filtered or non-responsive hosts

    ./scanner 192.0.2.1 80 85

Notes & Limitations

  • Scanning large ranges (e.g. 1–65535) is slow due to sequential execution.
  • Uses a full TCP handshake (not stealthy).
  • No service, version, or OS detection.
  • Intended for learning, not production use.

Disclaimer: Scan only systems you own or have explicit authorization to test. Unauthorized port scanning may be illegal.

About

Simple TCP Port Scanner

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages