Skip to content

mlesniak/port-scanner

Repository files navigation

Build Status Code of Conduct

Overview

Implementation of a simple port scanner in Go, mirroring the output of nmap.

Example

> port-scanner -hostname mlesniak.com -parallel 20 -port 75-85 -timeout 1
PORT      STATUS  SERVICE
75/tcp    closed  
76/tcp    closed  deos
77/tcp    closed  
78/tcp    closed  vettcp
79/tcp    closed  finger
80/tcp    open    www-http
81/tcp    closed  
82/tcp    closed  xfer
83/tcp    closed  mit-ml-dev
84/tcp    closed  ctf
85/tcp    closed  mit-ml-dev

Help

A list of available command line options can be obtained by executing

> port-scanner -help
A simple port scanner in go.
-hostname string
        hostname of the target system
-parallel int
        Maximum number of parallel connections (default 1)
-port string
        a single port (80) or a single range (80-1024)
-timeout float
        Timeout in seconds. Fractional values, e.g. 0.5 are allowed (default 1)

Building

To build and install port-scanner under $GOPATH you have to

git clone [email protected]:mlesniak/port-scanner.git
go install

We use go-bindata to embed files in data/, hence to build bindata.go, you have to

go-bindata data/

If you have not installed go-bindata, use

go get -u github.com/a-urth/go-bindata/...

beforehand.

To reduce the file size, use upx and

go build && strip port-scanner && upx -9 port-scanner

to create a 1MB single static file, e.g. for using it in docker containers.

Build with Docker

Building port-scanner with Docker is simple

git clone [email protected]:mlesniak/port-scanner.git
cd port-scanner
docker build -t port-scanner .
docker run --rm port-scanner -hostname mlesniak.com -parallel 20 -port 75-85 -timeout 1

To export the static binary simply run

docker run --rm --entrypoint="" port-scanner cat /usr/local/bin/port-scanner > port-scanner

Limitations

While this application is feature complete for my usages, the following limitations apply:

  • Scanning of TCP ports only.
  • Service list maps only single range ports, i.e. xwindow's definition from 6000-6003 is currently not correctly mapped

If these limitations annoy you, either fix this yourself and write a pull request :-) or open an issue.

Organization

A Trello Board can be found here.

License

The source code is licensed under the Apache license