config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2022 CFC4N <[email protected]>. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright © 2022 Hengqi Chen

Index

Constants

View Source
const (
	LdLoadPath       = "/etc/ld.so.conf"
	ElfArchIsandroid = false
)
View Source
const (
	GoTlsReadFunc         = "crypto/tls.(*Conn).Read"
	GoTlsWriteFunc        = "crypto/tls.(*Conn).writeRecordLocked"
	GoTlsMasterSecretFunc = "crypto/tls.(*Config).writeKeyLog"
)
View Source
const (
	ElfTypeBin uint8 = 1
	ElfTypeSo  uint8 = 2
)
View Source
const (
	TlsCaptureModelText   = "text"
	TlsCaptureModelPcap   = "pcap"
	TlsCaptureModelPcapng = "pcapng"
	TlsCaptureModelKey    = "key"
	TlsCaptureModelKeylog = "keylog"
)
View Source
const (
	BTFModeAutoDetect = 0
	BTFModeCore       = 1
	BTFModeNonCore    = 2
)
View Source
const (
	DefaultIfname = "eth0"
)
View Source
const DefaultNsprNssPath = "/usr/lib/firefox/libnspr4.so"

Variables

View Source
var (
	ErrorGoBINNotFound            = errors.New("The executable program (compiled by Golang) was not found")
	ErrorSymbolEmpty              = errors.New("symbol is empty")
	ErrorSymbolNotFound           = errors.New("symbol not found")
	ErrorSymbolNotFoundFromTable  = errors.New("symbol not found from table")
	ErrorNoRetFound               = errors.New("no RET instructions found")
	ErrorNoFuncFoundFromSymTabFun = errors.New("no function found from golang symbol table with Func Name")
)
View Source
var (

	// default: 4MB
	DefaultMapSizePerCpu = os.Getpagesize() * 1024
)

1, the RPATH binary header (set at build-time) of the library causing the lookup (if any) 2, the RPATH binary header (set at build-time) of the executable 3, the LD_LIBRARY_PATH environment variable (set at run-time) 4, the RUNPATH binary header (set at build-time) of the executable 5, /etc/ld.so.cache 6, base library directories (/lib and /usr/lib) ref: http://blog.tremily.us/posts/rpath/

Functions

func GetDynLibDirs

func GetDynLibDirs() []string

func GlobMany

func GlobMany(targets []string, onErr func(string, error)) []string

func ParseDynLibConf

func ParseDynLibConf(pattern string) (dirs []string, err error)

ParseDynLibConf reads/parses DL config files defined as a pattern and returns a list of directories found in there (or an error).

Types

type BashConfig

type BashConfig struct {
	Bashpath string `json:"bashpath"` //bash的文件路径
	Readline string `json:"readline"`
	ErrNo    int
	ElfType  uint8 //
	// contains filtered or unexported fields
}

Bashpath 与 readline 两个参数,使用时二选一

func NewBashConfig

func NewBashConfig() *BashConfig

func (*BashConfig) Check

func (bc *BashConfig) Check() error

func (*BashConfig) EnableGlobalVar

func (c *BashConfig) EnableGlobalVar() bool

func (*BashConfig) GetBTF

func (c *BashConfig) GetBTF() uint8

func (*BashConfig) GetDebug

func (c *BashConfig) GetDebug() bool

func (*BashConfig) GetHex

func (c *BashConfig) GetHex() bool

func (*BashConfig) GetPerCpuMapSize

func (c *BashConfig) GetPerCpuMapSize() int

func (*BashConfig) GetPid

func (c *BashConfig) GetPid() uint64

func (*BashConfig) GetUid

func (c *BashConfig) GetUid() uint64

func (*BashConfig) SetBTF

func (c *BashConfig) SetBTF(BtfMode uint8)

func (*BashConfig) SetDebug

func (c *BashConfig) SetDebug(b bool)

func (*BashConfig) SetHex

func (c *BashConfig) SetHex(isHex bool)

func (*BashConfig) SetPerCpuMapSize

func (c *BashConfig) SetPerCpuMapSize(size int)

func (*BashConfig) SetPid

func (c *BashConfig) SetPid(pid uint64)

func (*BashConfig) SetUid

func (c *BashConfig) SetUid(uid uint64)

type FuncOffsets

type FuncOffsets struct {
	Start   uint64
	Returns []uint64
}

type GnutlsConfig

type GnutlsConfig struct {

	//Curlpath string `json:"curlpath"` //curl的文件路径
	Gnutls  string `json:"gnutls"`
	ElfType uint8  //
	// contains filtered or unexported fields
}

最终使用openssl参数

func NewGnutlsConfig

func NewGnutlsConfig() *GnutlsConfig

func (*GnutlsConfig) Check

func (gc *GnutlsConfig) Check() error

func (*GnutlsConfig) EnableGlobalVar

func (c *GnutlsConfig) EnableGlobalVar() bool

func (*GnutlsConfig) GetBTF

func (c *GnutlsConfig) GetBTF() uint8

func (*GnutlsConfig) GetDebug

func (c *GnutlsConfig) GetDebug() bool

func (*GnutlsConfig) GetHex

func (c *GnutlsConfig) GetHex() bool

func (*GnutlsConfig) GetPerCpuMapSize

func (c *GnutlsConfig) GetPerCpuMapSize() int

func (*GnutlsConfig) GetPid

func (c *GnutlsConfig) GetPid() uint64

func (*GnutlsConfig) GetUid

func (c *GnutlsConfig) GetUid() uint64

func (*GnutlsConfig) SetBTF

func (c *GnutlsConfig) SetBTF(BtfMode uint8)

func (*GnutlsConfig) SetDebug

func (c *GnutlsConfig) SetDebug(b bool)

func (*GnutlsConfig) SetHex

func (c *GnutlsConfig) SetHex(isHex bool)

func (*GnutlsConfig) SetPerCpuMapSize

func (c *GnutlsConfig) SetPerCpuMapSize(size int)

func (*GnutlsConfig) SetPid

func (c *GnutlsConfig) SetPid(pid uint64)

func (*GnutlsConfig) SetUid

func (c *GnutlsConfig) SetUid(uid uint64)

type GoTLSConfig

type GoTLSConfig struct {
	Path       string `json:"path"`       // golang application path to binary built with Go toolchain.
	PcapFile   string `json:"pcapFile"`   // pcapFile  the  raw  packets  to file rather than parsing and printing them out.
	KeylogFile string `json:"keylogFile"` // keylogFile  The file stores SSL/TLS keys, and eCapture captures these keys during encrypted traffic communication and saves them to the file.
	Model      string `json:"model"`      // model  such as : text, pcapng/pcap, key/keylog.
	Ifname     string `json:"ifName"`     // (TC Classifier) Interface name on which the probe will be attached.
	PcapFilter string `json:"pcapFilter"` // pcap filter

	Buildinfo             *buildinfo.BuildInfo
	ReadTlsAddrs          []int
	GoTlsWriteAddr        uint64
	GoTlsMasterSecretAddr uint64
	IsPieBuildMode        bool
	// contains filtered or unexported fields
}

GoTLSConfig represents configuration for Go SSL probe

func NewGoTLSConfig

func NewGoTLSConfig() *GoTLSConfig

NewGoTLSConfig creates a new config for Go SSL

func (*GoTLSConfig) Check

func (gc *GoTLSConfig) Check() error

func (*GoTLSConfig) EnableGlobalVar

func (c *GoTLSConfig) EnableGlobalVar() bool

func (*GoTLSConfig) GetBTF

func (c *GoTLSConfig) GetBTF() uint8

func (*GoTLSConfig) GetDebug

func (c *GoTLSConfig) GetDebug() bool

func (*GoTLSConfig) GetHex

func (c *GoTLSConfig) GetHex() bool

func (*GoTLSConfig) GetPerCpuMapSize

func (c *GoTLSConfig) GetPerCpuMapSize() int

func (*GoTLSConfig) GetPid

func (c *GoTLSConfig) GetPid() uint64

func (*GoTLSConfig) GetUid

func (c *GoTLSConfig) GetUid() uint64

func (*GoTLSConfig) ReadTable

func (gc *GoTLSConfig) ReadTable() (*gosym.Table, error)

func (*GoTLSConfig) SetBTF

func (c *GoTLSConfig) SetBTF(BtfMode uint8)

func (*GoTLSConfig) SetDebug

func (c *GoTLSConfig) SetDebug(b bool)

func (*GoTLSConfig) SetHex

func (c *GoTLSConfig) SetHex(isHex bool)

func (*GoTLSConfig) SetPerCpuMapSize

func (c *GoTLSConfig) SetPerCpuMapSize(size int)

func (*GoTLSConfig) SetPid

func (c *GoTLSConfig) SetPid(pid uint64)

func (*GoTLSConfig) SetUid

func (c *GoTLSConfig) SetUid(uid uint64)

type IConfig

type IConfig interface {
	Check() error //检测配置合法性
	GetPid() uint64
	GetUid() uint64
	GetHex() bool
	GetBTF() uint8
	GetDebug() bool
	SetPid(uint64)
	SetUid(uint64)
	SetHex(bool)
	SetBTF(uint8)
	SetDebug(bool)
	GetPerCpuMapSize() int
	SetPerCpuMapSize(int)
	EnableGlobalVar() bool //
}

type MysqldConfig

type MysqldConfig struct {
	Mysqldpath  string     `json:"mysqldPath"` //curl的文件路径
	FuncName    string     `json:"funcName"`
	Offset      uint64     `json:"offset"`
	ElfType     uint8      //
	Version     MysqldType //
	VersionInfo string     // info
	// contains filtered or unexported fields
}

最终使用mysqld参数

func NewMysqldConfig

func NewMysqldConfig() *MysqldConfig

func (*MysqldConfig) Check

func (mc *MysqldConfig) Check() error

func (*MysqldConfig) EnableGlobalVar

func (c *MysqldConfig) EnableGlobalVar() bool

func (*MysqldConfig) GetBTF

func (c *MysqldConfig) GetBTF() uint8

func (*MysqldConfig) GetDebug

func (c *MysqldConfig) GetDebug() bool

func (*MysqldConfig) GetHex

func (c *MysqldConfig) GetHex() bool

func (*MysqldConfig) GetPerCpuMapSize

func (c *MysqldConfig) GetPerCpuMapSize() int

func (*MysqldConfig) GetPid

func (c *MysqldConfig) GetPid() uint64

func (*MysqldConfig) GetUid

func (c *MysqldConfig) GetUid() uint64

func (*MysqldConfig) SetBTF

func (c *MysqldConfig) SetBTF(BtfMode uint8)

func (*MysqldConfig) SetDebug

func (c *MysqldConfig) SetDebug(b bool)

func (*MysqldConfig) SetHex

func (c *MysqldConfig) SetHex(isHex bool)

func (*MysqldConfig) SetPerCpuMapSize

func (c *MysqldConfig) SetPerCpuMapSize(size int)

func (*MysqldConfig) SetPid

func (c *MysqldConfig) SetPid(pid uint64)

func (*MysqldConfig) SetUid

func (c *MysqldConfig) SetUid(uid uint64)

type MysqldType

type MysqldType uint8
const (
	MysqldTypeUnknow MysqldType = iota
	MysqldType56
	MysqldType57
	MysqldType80
)

type NsprConfig

type NsprConfig struct {

	//Firefoxpath string `json:"firefoxpath"` //curl的文件路径
	Nsprpath string `json:"nsprpath"`
	ElfType  uint8  //
	// contains filtered or unexported fields
}

最终使用openssl参数

func NewNsprConfig

func NewNsprConfig() *NsprConfig

func (*NsprConfig) Check

func (nc *NsprConfig) Check() error

func (*NsprConfig) EnableGlobalVar

func (c *NsprConfig) EnableGlobalVar() bool

func (*NsprConfig) GetBTF

func (c *NsprConfig) GetBTF() uint8

func (*NsprConfig) GetDebug

func (c *NsprConfig) GetDebug() bool

func (*NsprConfig) GetHex

func (c *NsprConfig) GetHex() bool

func (*NsprConfig) GetPerCpuMapSize

func (c *NsprConfig) GetPerCpuMapSize() int

func (*NsprConfig) GetPid

func (c *NsprConfig) GetPid() uint64

func (*NsprConfig) GetUid

func (c *NsprConfig) GetUid() uint64

func (*NsprConfig) SetBTF

func (c *NsprConfig) SetBTF(BtfMode uint8)

func (*NsprConfig) SetDebug

func (c *NsprConfig) SetDebug(b bool)

func (*NsprConfig) SetHex

func (c *NsprConfig) SetHex(isHex bool)

func (*NsprConfig) SetPerCpuMapSize

func (c *NsprConfig) SetPerCpuMapSize(size int)

func (*NsprConfig) SetPid

func (c *NsprConfig) SetPid(pid uint64)

func (*NsprConfig) SetUid

func (c *NsprConfig) SetUid(uid uint64)

type OpensslConfig

type OpensslConfig struct {

	// Curlpath   string `json:"curlPath"` //curl的文件路径
	Openssl    string `json:"openssl"`
	Pthread    string `json:"pThread"`    // /lib/x86_64-linux-gnu/libpthread.so.0
	Model      string `json:"model"`      // eCapture Openssl capture model. text:pcap:keylog
	PcapFile   string `json:"pcapFile"`   // pcapFile  the  raw  packets  to file rather than parsing and printing them out.
	KeylogFile string `json:"keylog"`     // Keylog  The file stores SSL/TLS keys, and eCapture captures these keys during encrypted traffic communication and saves them to the file.
	Ifname     string `json:"ifName"`     // (TC Classifier) Interface name on which the probe will be attached.
	PcapFilter string `json:"pcapFilter"` // pcap filter
	SslVersion string `json:"sslVersion"` // openssl version like 1.1.1a/1.1.1f/boringssl_1.1.1
	CGroupPath string `json:"CGroupPath"` // cgroup path, used for filter process
	ElfType    uint8  //
	IsAndroid  bool   //	is Android OS ?
	AndroidVer string // Android OS version
	// contains filtered or unexported fields
}

最终使用openssl参数

func NewOpensslConfig

func NewOpensslConfig() *OpensslConfig

func (*OpensslConfig) Check

func (oc *OpensslConfig) Check() error

func (*OpensslConfig) EnableGlobalVar

func (c *OpensslConfig) EnableGlobalVar() bool

func (*OpensslConfig) GetBTF

func (c *OpensslConfig) GetBTF() uint8

func (*OpensslConfig) GetDebug

func (c *OpensslConfig) GetDebug() bool

func (*OpensslConfig) GetHex

func (c *OpensslConfig) GetHex() bool

func (*OpensslConfig) GetPerCpuMapSize

func (c *OpensslConfig) GetPerCpuMapSize() int

func (*OpensslConfig) GetPid

func (c *OpensslConfig) GetPid() uint64

func (*OpensslConfig) GetUid

func (c *OpensslConfig) GetUid() uint64

func (*OpensslConfig) SetBTF

func (c *OpensslConfig) SetBTF(BtfMode uint8)

func (*OpensslConfig) SetDebug

func (c *OpensslConfig) SetDebug(b bool)

func (*OpensslConfig) SetHex

func (c *OpensslConfig) SetHex(isHex bool)

func (*OpensslConfig) SetPerCpuMapSize

func (c *OpensslConfig) SetPerCpuMapSize(size int)

func (*OpensslConfig) SetPid

func (c *OpensslConfig) SetPid(pid uint64)

func (*OpensslConfig) SetUid

func (c *OpensslConfig) SetUid(uid uint64)

type PostgresConfig

type PostgresConfig struct {
	PostgresPath string `json:"postgresPath"`
	FuncName     string `json:"funcName"`
	// contains filtered or unexported fields
}

func NewPostgresConfig

func NewPostgresConfig() *PostgresConfig

func (*PostgresConfig) Check

func (pc *PostgresConfig) Check() error

func (*PostgresConfig) EnableGlobalVar

func (c *PostgresConfig) EnableGlobalVar() bool

func (*PostgresConfig) GetBTF

func (c *PostgresConfig) GetBTF() uint8

func (*PostgresConfig) GetDebug

func (c *PostgresConfig) GetDebug() bool

func (*PostgresConfig) GetHex

func (c *PostgresConfig) GetHex() bool

func (*PostgresConfig) GetPerCpuMapSize

func (c *PostgresConfig) GetPerCpuMapSize() int

func (*PostgresConfig) GetPid

func (c *PostgresConfig) GetPid() uint64

func (*PostgresConfig) GetUid

func (c *PostgresConfig) GetUid() uint64

func (*PostgresConfig) SetBTF

func (c *PostgresConfig) SetBTF(BtfMode uint8)

func (*PostgresConfig) SetDebug

func (c *PostgresConfig) SetDebug(b bool)

func (*PostgresConfig) SetHex

func (c *PostgresConfig) SetHex(isHex bool)

func (*PostgresConfig) SetPerCpuMapSize

func (c *PostgresConfig) SetPerCpuMapSize(size int)

func (*PostgresConfig) SetPid

func (c *PostgresConfig) SetPid(pid uint64)

func (*PostgresConfig) SetUid

func (c *PostgresConfig) SetUid(uid uint64)

Jump to

Keyboard shortcuts

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