gomap

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 10 Imported by: 3

README

gomap

GitHub Go Reference Go Report Card Codacy Badge

What is gomap?

Gomap is a fully self-contained nmap like module for Golang. Unlike other projects which provide nmap C bindings or rely on other local dependencies, gomap is a fully implemented in pure Go. Gomap imports zero non-core modules making it ideal for applications that have zero control on the clients operating system. Since this is a small library, it only focuses on providing a few core features. For the most part its API is stable with changes being applied to its unexposed internal scanning functions.

Features

  • Parallel port scanning using go routines
  • Automated CIDR range scanning
  • Service prediction by port number
  • SYN (Silent) Scanning Mode
  • UDP Scanning (Non-Stealth)
  • Fast and detailed scanning for common ports
  • Pure Go with zero dependencies
  • Easily integrated into other projects

Upcoming Features

  • CIDR range size detection

Example Usage - 1

Performs a fastscan for the most common ports on every IP on a local range

Create Files
  1. Create quickscan.go
package main

import (
	"fmt"

	"github.com/JustinTimperio/gomap"
)

func main() {
	var (
		proto    = "tcp"
		fastscan = true
		syn      = false
	)

	scan, err := gomap.ScanRange(proto, fastscan, syn)
	if err != nil {
		// handle error
	}
	fmt.Printf(scan.String())
}
  1. go mod init quickscan
  2. go mod tidy
  3. go run quickscan.go
Example Output
Host: computer-name (192.168.1.132)
        |     Port      Service
        |     ----      -------
        |---- 22        ssh
 
Host: server-nginx (192.168.1.143)
        |     Port      Service
        |     ----      -------
        |---- 443       https
        |---- 80        http
        |---- 22        ssh
 
Host: server-minio (192.168.1.112)
        |     Port      Service
        |     ----      -------
        |---- 22        ssh

Host: some-phone (192.168.1.155)
        |- No Open Ports

Example Usage - 2

Performs a detailed stealth scan on a single IP

Create Files
  1. Create stealthmap.go
package main

import (
	"fmt"

	"github.com/JustinTimperio/gomap"
)

func main() {
	// Stealth scans MUST be run as root/admin
	var (
		fastscan = false
		syn      = true
		proto    = "tcp"
		ip       = "192.168.1.120"
	)

	scan, err := gomap.ScanIP(ip, proto, fastscan, syn)
	if err != nil {
		// handle error
	}
	fmt.Printf(scan.String())
}
  1. go mod init stealthmap
  2. go mod tidy
  3. sudo go run stealthmap.go
Example Output
Host: 192.168.1.120 | Ports Scanned 3236/3236
Host: Voyager (192.168.1.120)
        |     Port      Service
        |     ----      -------
        |---- 22        SSH Remote Login Protocol
        |---- 80        World Wide Web HTTP
        |---- 443       HTTP protocol over TLS/SSL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPScanResult

type IPScanResult struct {
	Hostname string
	IP       []net.IP
	Results  []portResult
}

IPScanResult contains the results of a scan on a single ip

func ScanIP

func ScanIP(hostname string, proto string, fastscan bool, stealth bool) (*IPScanResult, error)

ScanIP scans a single IP for open ports

func (*IPScanResult) Json

func (results *IPScanResult) Json() (string, error)

Contains a marshaled struct containing the results for a ip scan

func (*IPScanResult) String

func (results *IPScanResult) String() string

String with the results of a single scanned IP

type JsonIP

type JsonIP struct {
	IP       string
	Hostname string
	Active   bool
	Ports    []string
}

JsonIP contains the results for a single JSON entry

type JsonRange

type JsonRange struct {
	// contains filtered or unexported fields
}

JsonRange contains a slice of of JsonIP results

type RangeScanResult

type RangeScanResult []*IPScanResult

RangeScanResult contains multiple IPScanResults

func ScanRange

func ScanRange(proto string, fastscan bool, stealth bool) (RangeScanResult, error)

ScanRange scans every address on a CIDR for open ports

func (RangeScanResult) Json

func (results RangeScanResult) Json() (string, error)

Contains a marshaled struct containing the results for a range scan

func (RangeScanResult) String

func (results RangeScanResult) String() string

String with the results of multiple scanned IP's

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL