masscan

package module
v0.0.0-...-6b7297e Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 5 Imported by: 1

README

go-masscan

go-masscan is a golang library to run masscan scans, parse scan results.

Installation

go get github.com/dean2021/go-masscan

to install the package

import "github.com/dean2021/go-masscan"

Example

package main

import (
	"github.com/dean2021/go-masscan"
	"fmt"
)

func main() {

	m := masscan.New()

	// masscan可执行文件路径,默认不需要设置
	//m.SetSystemPath("/usr/local/masscan/bin/masscan")

	// 扫描端口范围
	m.SetPorts("0-65535")

	// 扫描IP范围
	m.SetRanges("0.0.0.0/8")

	// 扫描速率
	m.SetRate("2000")

	// 隔离扫描名单
	m.SetExclude("127.0.0.1")

	// 开始扫描
	err := m.Run()
	if err != nil {
		fmt.Println("scanner failed:", err)
		return
	}

	// 解析扫描结果
	results, err := m.Parse()
	if err != nil {
		fmt.Println("Parse scanner result:", err)
		return
	}

	for _, result := range results {
		fmt.Println(result)
	}

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	Ip string `json:"ip"`
}

type Masscan

type Masscan struct {
	SystemPath string
	Args       []string
	Ports      string
	Ranges     string
	Rate       string
	Exclude    string
	Result     []byte
}

func New

func New() *Masscan

func (*Masscan) Parse

func (m *Masscan) Parse() ([]Host, error)

Parse scans result.

func (*Masscan) Pause

func (m *Masscan) Pause()

func (*Masscan) Run

func (m *Masscan) Run() error

Start scanning

func (*Masscan) SetArgs

func (m *Masscan) SetArgs(arg ...string)

func (*Masscan) SetExclude

func (m *Masscan) SetExclude(exclude string)

func (*Masscan) SetPorts

func (m *Masscan) SetPorts(ports string)

func (*Masscan) SetRanges

func (m *Masscan) SetRanges(ranges string)

func (*Masscan) SetRate

func (m *Masscan) SetRate(rate string)

func (*Masscan) SetSystemPath

func (m *Masscan) SetSystemPath(systemPath string)

Jump to

Keyboard shortcuts

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