Add supporting infrastructure for nginx HTTP capture using kretprobe on __x64_sys_recvfrom to replace the blocked tracepoint sys_exit_recvfrom. Changes: - bpf/bpf_types.h: Add nginx_pid_map for filtering recvfrom by PID - cmd/ja4ebpf/main.go: Add Uprobes configuration section - Makefile: Add test targets for recvfrom validation - internal/loader: Generate nginx HTTP event structures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
250 lines
5.9 KiB
Go
250 lines
5.9 KiB
Go
// Code generated by bpf2go; DO NOT EDIT.
|
|
//go:build 386 || amd64
|
|
|
|
package loader
|
|
|
|
import (
|
|
"bytes"
|
|
_ "embed"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/cilium/ebpf"
|
|
)
|
|
|
|
type Ja4TcAcceptEvent struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
type Ja4TcAcceptKey struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
}
|
|
|
|
type Ja4TcHttpPlainEvent struct {
|
|
Payload [4096]uint8
|
|
SrcIp uint32
|
|
DstIp uint32
|
|
SrcPort uint16
|
|
DstPort uint16
|
|
PayloadLen uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
type Ja4TcNginxHttpEvent struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
TimestampNs uint64
|
|
HttpMethod [16]uint8
|
|
Uri [256]uint8
|
|
Query [128]uint8
|
|
Data [3640]uint8
|
|
MethodLen uint32
|
|
UriLen uint32
|
|
QueryLen uint32
|
|
BodyLen uint32
|
|
DataLen uint32
|
|
}
|
|
|
|
type Ja4TcNginxReadArgs struct {
|
|
Fd int32
|
|
BufPtr uint64
|
|
Count uint64
|
|
}
|
|
|
|
type Ja4TcSslConnInfo struct {
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
}
|
|
|
|
type Ja4TcSslDataEvent struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
Data [4096]uint8
|
|
DataLen uint32
|
|
TimestampNs uint64
|
|
Direction uint8
|
|
}
|
|
|
|
type Ja4TcSslReadArgs struct {
|
|
SslPtr uint64
|
|
BufPtr uint64
|
|
Num uint32
|
|
}
|
|
|
|
type Ja4TcTlsHelloEvent struct {
|
|
Payload [2048]uint8
|
|
SrcIp uint32
|
|
DstIp uint32
|
|
SrcPort uint16
|
|
DstPort uint16
|
|
PayloadLen uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
// LoadJa4Tc returns the embedded CollectionSpec for Ja4Tc.
|
|
func LoadJa4Tc() (*ebpf.CollectionSpec, error) {
|
|
reader := bytes.NewReader(_Ja4TcBytes)
|
|
spec, err := ebpf.LoadCollectionSpecFromReader(reader)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("can't load Ja4Tc: %w", err)
|
|
}
|
|
|
|
return spec, err
|
|
}
|
|
|
|
// LoadJa4TcObjects loads Ja4Tc and converts it into a struct.
|
|
//
|
|
// The following types are suitable as obj argument:
|
|
//
|
|
// *Ja4TcObjects
|
|
// *Ja4TcPrograms
|
|
// *Ja4TcMaps
|
|
//
|
|
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
|
|
func LoadJa4TcObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
|
|
spec, err := LoadJa4Tc()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return spec.LoadAndAssign(obj, opts)
|
|
}
|
|
|
|
// Ja4TcSpecs contains maps and programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcSpecs struct {
|
|
Ja4TcProgramSpecs
|
|
Ja4TcMapSpecs
|
|
}
|
|
|
|
// Ja4TcSpecs contains programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcProgramSpecs struct {
|
|
CaptureTc *ebpf.ProgramSpec `ebpf:"capture_tc"`
|
|
}
|
|
|
|
// Ja4TcMapSpecs contains maps before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcMapSpecs struct {
|
|
HttpBuf *ebpf.MapSpec `ebpf:"__http_buf"`
|
|
NginxBuf *ebpf.MapSpec `ebpf:"__nginx_buf"`
|
|
SslBuf *ebpf.MapSpec `ebpf:"__ssl_buf"`
|
|
TlsBuf *ebpf.MapSpec `ebpf:"__tls_buf"`
|
|
AcceptMap *ebpf.MapSpec `ebpf:"accept_map"`
|
|
AllowedPorts *ebpf.MapSpec `ebpf:"allowed_ports"`
|
|
FdConnMap *ebpf.MapSpec `ebpf:"fd_conn_map"`
|
|
IgnoredSrc *ebpf.MapSpec `ebpf:"ignored_src"`
|
|
NginxReadArgsMap *ebpf.MapSpec `ebpf:"nginx_read_args_map"`
|
|
PbAccept *ebpf.MapSpec `ebpf:"pb_accept"`
|
|
PbGinxHttp *ebpf.MapSpec `ebpf:"pb_ginx_http"`
|
|
PbHttpPlain *ebpf.MapSpec `ebpf:"pb_http_plain"`
|
|
PbSslData *ebpf.MapSpec `ebpf:"pb_ssl_data"`
|
|
PbTcpSyn *ebpf.MapSpec `ebpf:"pb_tcp_syn"`
|
|
PbTlsHello *ebpf.MapSpec `ebpf:"pb_tls_hello"`
|
|
SslArgsMap *ebpf.MapSpec `ebpf:"ssl_args_map"`
|
|
SslConnMap *ebpf.MapSpec `ebpf:"ssl_conn_map"`
|
|
TcStats *ebpf.MapSpec `ebpf:"tc_stats"`
|
|
}
|
|
|
|
// Ja4TcObjects contains all objects after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcObjects struct {
|
|
Ja4TcPrograms
|
|
Ja4TcMaps
|
|
}
|
|
|
|
func (o *Ja4TcObjects) Close() error {
|
|
return _Ja4TcClose(
|
|
&o.Ja4TcPrograms,
|
|
&o.Ja4TcMaps,
|
|
)
|
|
}
|
|
|
|
// Ja4TcMaps contains all maps after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcMaps struct {
|
|
HttpBuf *ebpf.Map `ebpf:"__http_buf"`
|
|
NginxBuf *ebpf.Map `ebpf:"__nginx_buf"`
|
|
SslBuf *ebpf.Map `ebpf:"__ssl_buf"`
|
|
TlsBuf *ebpf.Map `ebpf:"__tls_buf"`
|
|
AcceptMap *ebpf.Map `ebpf:"accept_map"`
|
|
AllowedPorts *ebpf.Map `ebpf:"allowed_ports"`
|
|
FdConnMap *ebpf.Map `ebpf:"fd_conn_map"`
|
|
IgnoredSrc *ebpf.Map `ebpf:"ignored_src"`
|
|
NginxReadArgsMap *ebpf.Map `ebpf:"nginx_read_args_map"`
|
|
PbAccept *ebpf.Map `ebpf:"pb_accept"`
|
|
PbGinxHttp *ebpf.Map `ebpf:"pb_ginx_http"`
|
|
PbHttpPlain *ebpf.Map `ebpf:"pb_http_plain"`
|
|
PbSslData *ebpf.Map `ebpf:"pb_ssl_data"`
|
|
PbTcpSyn *ebpf.Map `ebpf:"pb_tcp_syn"`
|
|
PbTlsHello *ebpf.Map `ebpf:"pb_tls_hello"`
|
|
SslArgsMap *ebpf.Map `ebpf:"ssl_args_map"`
|
|
SslConnMap *ebpf.Map `ebpf:"ssl_conn_map"`
|
|
TcStats *ebpf.Map `ebpf:"tc_stats"`
|
|
}
|
|
|
|
func (m *Ja4TcMaps) Close() error {
|
|
return _Ja4TcClose(
|
|
m.HttpBuf,
|
|
m.NginxBuf,
|
|
m.SslBuf,
|
|
m.TlsBuf,
|
|
m.AcceptMap,
|
|
m.AllowedPorts,
|
|
m.FdConnMap,
|
|
m.IgnoredSrc,
|
|
m.NginxReadArgsMap,
|
|
m.PbAccept,
|
|
m.PbGinxHttp,
|
|
m.PbHttpPlain,
|
|
m.PbSslData,
|
|
m.PbTcpSyn,
|
|
m.PbTlsHello,
|
|
m.SslArgsMap,
|
|
m.SslConnMap,
|
|
m.TcStats,
|
|
)
|
|
}
|
|
|
|
// Ja4TcPrograms contains all programs after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcPrograms struct {
|
|
CaptureTc *ebpf.Program `ebpf:"capture_tc"`
|
|
}
|
|
|
|
func (p *Ja4TcPrograms) Close() error {
|
|
return _Ja4TcClose(
|
|
p.CaptureTc,
|
|
)
|
|
}
|
|
|
|
func _Ja4TcClose(closers ...io.Closer) error {
|
|
for _, closer := range closers {
|
|
if err := closer.Close(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Do not access this directly.
|
|
//
|
|
//go:embed ja4tc_x86_bpfel.o
|
|
var _Ja4TcBytes []byte
|