GitXplorerGitXplorer
N

go-ps

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
c817b40645b604f62ba6720459165e737ff2eb81

Create FUNDING.yml

NNovusEdge committed 3 years ago
Unverified
08516e5c6c0312742a9eec9769cdc4ab756d54f6

Corrected package name in colors.go

NNovusEdge committed 3 years ago
Unverified
5d9bd7fc622f431156558c5a8628c7198485bffc

Added colors

NNovusEdge committed 3 years ago
Unverified
f5dcdd32382999b323dff8c0b78ce476cd04ac83

Fixing Scans()

NNovusEdge committed 3 years ago
Unverified
fde0567aac4aa02efa3cdbb565f0a64b5609787b

Updating Scans() to return []int instead of chan int

NNovusEdge committed 3 years ago
Unverified
f190e6b62bc52bd895a45c4b6c9d05146ad61bd1

Made corrections in go.mod

NNovusEdge committed 3 years ago

README

The README file for this repository.

go-ps

go-ps is a simple implementation of a port-scanner in golang.

Usage

To obtain the module, simply execute in shell:

$ go get github.com/NovusEdge/go-ps

Example use-case:

  • Importing the module:
import gops "github.com/NovusEdge/go-ps"


  • Declaring an a variable of type PortScanner:
// Decalring a PortScanner object.

/*
struct definition:
type PortScanner struct {
	Domain   string
	Protocol string
}
*/

ps := gops.PortScanner{
	Domain: "scanme.nmap.org",
	Protocol: "tcp",
}


  • Scan() iterates over all ports in range [startPort, endPort] and reports which ports are open by printing to stdout.
/* Scan() parameters:
	startPort [int] Port from which to start scanning (inclusive)
	endPort   [int] Port on which to stop the scanning. (inclusive)
	timeout   [time.Duration] timeout for each port being scanned.
*/
ps.Scan(1, 1024, 500*time.Millisecond)

Output:

[*] Port 80 open
...
...


  • Scans() iterates over all ports in range [startPort, endPort] and returns a list of open ports.
/* Scans() parameters:
	startPort [int] Port from which to start scanning (inclusive)
	endPort   [int] Port on which to stop the scanning. (inclusive)
	timeout   [time.Duration] timeout for each port being scanned.

Returns: []int
*/

ports := ps.Scans(1, 1024, 500*time.Millisecond)

fmt.Println("Open Ports: ", ports)

Output:

Open Ports: [ 80 448 ... ]

Sample program:

package main

import (
    "fmt"
    "time"

    gops "github.com/NovusEdge/go-ps"
)

func main() {
    ps := gops.PortScanner{
	Domain: "scanme.nmap.org",
	Protocol: "tcp",
    }
    
    // Scan and report open ports in stdout:
    ps.Scan(1, 1024, 500*time.Millisecond)

    // Scan ports and get a list of open ports:
    openPorts := ps.Scans(1, 1024, 500*time.Millisecond)

    // Use in whatever way you like :)
    // For this sample, we'll just print it to stdout:

    fmt.Println(openPorts)
}