pcap

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertIP

func ConvertIP(bytes []byte) string

ConvertIP 将bytes格式的IP,转为字符串

func PrintStruct

func PrintStruct(i interface{})

PrintStruct 打印结构体

func Struct2Json

func Struct2Json(i interface{}) string

Struct2Json Struct转Json

Types

type DNS

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

DNS 协议结构

func (*DNS) FromBytes

func (d *DNS) FromBytes(data []byte) error

FromBytes 解析DNS应答数据

type DNSAnswer

type DNSAnswer struct {
	Name string `json:"name"`
	Addr string `json:"addr"`
}

DNSAnswer DNS应答内容

type DNSInfo

type DNSInfo struct {
	Domain  string      `json:"domain"`
	Answers []DNSAnswer `json:"answers"`
}

DNSInfo DNS信息

func NewDNSInfo

func NewDNSInfo(domain string) DNSInfo

NewDNSInfo new dns info

func (*DNSInfo) AddDNSAnswer

func (d *DNSInfo) AddDNSAnswer(name string, addr string)

AddDNSAnswer add dns answer

type HTTPRequest

type HTTPRequest struct {
	URL         string `json:"URL,omitempty"`         // url,不包含 ://
	Method      string `json:"Method,omitempty"`      // GET POST 等请求方法
	RequestData string `json:"RequestData,omitempty"` // 请求数据,包含请求方法、头部、请求体
	ResponeData string `json:"ResponeData,omitempty"` // 响应数据
}

HTTPRequest 存放一次HTTP请求,及其数据。

func NewHTTPRequest

func NewHTTPRequest() HTTPRequest

NewHTTPRequest init

func (*HTTPRequest) GetMethod

func (r *HTTPRequest) GetMethod() string

GetMethod get

func (*HTTPRequest) GetRequestData

func (r *HTTPRequest) GetRequestData() string

GetRequestData get

func (*HTTPRequest) GetResponeData

func (r *HTTPRequest) GetResponeData() string

GetResponeData get

func (*HTTPRequest) GetURL

func (r *HTTPRequest) GetURL() string

GetURL get

func (*HTTPRequest) SetMethod

func (r *HTTPRequest) SetMethod(mtd string)

SetMethod set

func (*HTTPRequest) SetRequestData

func (r *HTTPRequest) SetRequestData(rd string)

SetResponeData set

func (*HTTPRequest) SetResponeData

func (r *HTTPRequest) SetResponeData(rd string)

SetResponeContentType set

func (*HTTPRequest) SetURL

func (r *HTTPRequest) SetURL(url string)

SetURL set

type MailAccount

type MailAccount struct {
	User string `json:"user,omitempty"`
	Pwd  string `json:"pwd,omitempty"`
}

MailAccount 邮箱账号

type MailContent

type MailContent struct {
	From    string `json:"from,omitempty"`
	To      string `json:"to,omitempty"`
	Subject string `json:"subject,omitempty"`
	Content string `json:"content,omitempty"`
}

MailContent 邮件内容

type MailInfos

type MailInfos struct {
	Accounts []MailAccount `json:"accounts,omitempty"`
	Contents []MailContent `json:"contents,omitempty"`
}

MailInfos 邮箱信息

type Parser

type Parser struct {
	HTTPRequests []HTTPRequest
	DNSInfos     []DNSInfo
	MailInfos    MailInfos
	TDatas       []TransmissionData //存放每次交互传输的数据,不包括已解析的数据,如HTTP、DNS、SMTP。

	IPs []string // 存放pcap中,出现的所有IP。
	// contains filtered or unexported fields
}

Parser Pcap解析器

func NewParser

func NewParser() *Parser

NewParser 初始化

func (*Parser) AddDNSInfo

func (p *Parser) AddDNSInfo(d DNSInfo)

AddDNSInfo add dns info

func (*Parser) AddIP

func (p *Parser) AddIP(ip string)

AddIP add ip

func (*Parser) Parse

func (p *Parser) Parse(path string) error

Parse 解析目标pcap文件

func (*Parser) ParseBytes

func (p *Parser) ParseBytes(bs []byte) error

ParseBytes 解析目标pcap bytes 格式

func (*Parser) ParseReader

func (p *Parser) ParseReader(src io.Reader) error

ParseReader 解析目标pcap reader

type TransmissionData

type TransmissionData struct {
	Source          string // 来源的IP/域名/URL
	SourcePort      uint16 // 来源的IP/域名/URL
	Destination     string // 目的地的IP/域名/URL
	DestinationPort uint16 // 端口
	Data            []byte //传输的数据

}

TransmissionData 存放传输的数据,TCP/UDP等,未解析的数据

Jump to

Keyboard shortcuts

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