1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
{
buildGoModule,
fetchFromGitHub,
bpftools,
lib,
nspr,
libpcap,
clang,
fd,
go-bindata,
glibc,
gnutls,
bashInteractive,
postgresql,
mariadb,
openssl,
bash,
zsh,
nix-update-script,
llvmPackages,
withNonBTF ? false,
kernel ? null,
}:
buildGoModule rec {
pname = "ecapture";
version = "1.3.1";
src = fetchFromGitHub {
owner = "gojue";
repo = "ecapture";
tag = "v${version}";
hash = "sha256-SY7Q8WlxE473An6/MntjPaIT3mFE/u9JJS6nb8BWiuQ=";
fetchSubmodules = true;
};
nativeBuildInputs = [
llvmPackages.libllvm
clang
fd
bpftools
go-bindata
];
newlibpcap = libpcap.overrideAttrs (previousAttrs: {
configureFlags = previousAttrs.configureFlags ++ [ "--without-libnl" ];
});
buildInputs = [
newlibpcap
glibc.static
glibc
];
CGO_LDFLAGS = "-lpcap -lpthread -static";
ldflags = [
"-extldflags '-static'"
"-linkmode=external"
];
hardeningDisable = [
"zerocallusedregs"
];
postPatch = ''
substituteInPlace user/config/config_gnutls_linux.go \
--replace-fail 'return errors.New("cant found Gnutls so load path")' 'gc.Gnutls = "${lib.getLib gnutls}/lib/libgnutls.so.30"' \
--replace-fail '"errors"' ' '
substituteInPlace user/module/probe_bash.go \
--replace-fail '/bin/bash' '${lib.getExe bashInteractive}'
substituteInPlace user/config/config_bash.go \
--replace-fail '/bin/bash' '${lib.getExe bashInteractive}'
substituteInPlace user/config/config_nspr_linux.go \
--replace-fail '/usr/lib/firefox/libnspr4.so' '${lib.getLib nspr}/lib/libnspr4.so'
substituteInPlace user/config/config_zsh.go \
--replace-fail '/bin/zsh' '${lib.getExe zsh}'
substituteInPlace user/module/probe_zsh.go \
--replace-fail '/bin/zsh' '${lib.getExe zsh}'
substituteInPlace cli/cmd/postgres.go \
--replace-fail '/usr/bin/postgres' '${postgresql}/bin/postgres'
substituteInPlace cli/cmd/mysqld.go \
--replace-fail '/usr/sbin/mariadbd' '${mariadb}/bin/mariadbd'
substituteInPlace user/module/probe_mysqld.go \
--replace-fail '/usr/sbin/mariadbd' '${mariadb}/bin/mariadbd'
substituteInPlace user/config/config_openssl_linux.go \
--replace-fail 'return errors.New("cant found openssl so load path")' 'oc.Openssl = "${lib.getLib openssl}/lib/libssl.so.3"' \
--replace-fail '"errors"' ' '
'';
postConfigure = ''
sed -i '/git/d' Makefile
sed -i '/git/d' variables.mk
substituteInPlace Makefile \
--replace-fail '/bin/bash' '${lib.getExe bash}'
''
+ lib.optionalString withNonBTF ''
substituteInPlace variables.mk \
--replace-fail "-emit-llvm" "-emit-llvm -I${kernel.dev}/lib/modules/${kernel.modDirVersion}/build/include -Wno-error=implicit-function-declaration"
KERN_BUILD_PATH=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build KERN_SRC_PATH=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source make ebpf_noncore
''
+ ''
make ebpf
go-bindata -pkg assets -o "assets/ebpf_probe.go" $(find user/bytecode -name "*.o" -printf "./%p ")
'';
checkFlags =
let
skippedTests = [
"TestCheckLatest"
];
in
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
vendorHash = "sha256-B2Jq6v1PibZ1P9OylFsVp/ULZa/ne5T+vCsBWWrjW/4=";
passthru.updateScript = nix-update-script { };
meta = {
description = "Capture SSL/TLS text content without CA certificate Using eBPF";
changelog = "https://github.com/gojue/ecapture/releases/tag/v${version}";
homepage = "https://ecapture.cc";
platforms = [
"x86_64-linux"
"aarch64-linux"
];
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ bot-wxt1221 ];
mainProgram = "ecapture";
};
}
|