masscan

package module
v0.0.0-...-39d46ad Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 6 Imported by: 0

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 Address

type Address struct {
	Addr     string `xml:"addr,attr"`
	AddrType string `xml:"addrtype,attr"`
}

type Host

type Host struct {
	XMLName xml.Name `xml:"host"`
	Endtime string   `xml:"endtime,attr"`
	Address Address  `xml:"address"`
	Ports   Ports    `xml:"ports>port"`
}

type Masscan

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

func New

func New() *Masscan

func (*Masscan) Parse

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

Parse scans result.

func (*Masscan) Run

func (m *Masscan) Run() error

Start scanning

func (*Masscan) SetAdapter_port

func (m *Masscan) SetAdapter_port(port string)

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)

type Ports

type Ports []struct {
	Protocol string  `xml:"protocol,attr"`
	Portid   string  `xml:"portid,attr"`
	State    State   `xml:"state"`
	Service  Service `xml:"service"`
}

type Service

type Service struct {
	Name   string `xml:"name,attr"`
	Banner string `xml:"banner,attr"`
}

type State

type State struct {
	State     string `xml:"state,attr"`
	Reason    string `xml:"reason,attr"`
	ReasonTTL string `xml:"reason_ttl,attr"`
}

Jump to

Keyboard shortcuts

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