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
|
{
bzip2,
cabextract,
dmg2img,
dtc,
dumpifs,
enableUnfree ? false,
fetchFromGitHub,
fontconfig,
gnutar,
jefferson,
lib,
lzfse,
lzo,
lzop,
lz4,
openssl_3,
pkg-config,
python3,
rustPlatform,
sasquatch,
sleuthkit,
srec2bin,
stdenv,
ubi_reader,
ucl,
uefi-firmware-parser,
unrar,
unyaffs,
unzip,
versionCheckHook,
vmlinux-to-elf,
xz,
zlib,
zstd,
p7zip,
makeBinaryWrapper,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "binwalk";
version = "3.1.0";
src = fetchFromGitHub {
owner = "ReFirmLabs";
repo = "binwalk";
tag = "v${finalAttrs.version}";
hash = "sha256-em+jOnhCZH5EEJrhXTHmxiwpMcBr5oNU1+5IJ1H/oco=";
};
cargoHash = "sha256-cnJVeuvNNApEHqgZDcSgqkH3DKAr8+HkqXUH9defTCA=";
nativeBuildInputs = [
pkg-config
makeBinaryWrapper
];
# https://github.com/ReFirmLabs/binwalk/commits/master/dependencies
buildInputs = [
bzip2
dtc
fontconfig
lzo
openssl_3
python3.pkgs.python-lzo
ucl
unzip
xz
zlib
];
dontUseCargoParallelTests = true;
# skip broken tests
checkFlags = [
"--skip=binwalk::Binwalk"
"--skip=binwalk::Binwalk::scan"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"--skip=binwalk::Binwalk::analyze"
"--skip=binwalk::Binwalk::extract"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
"--skip=extractors::common::Chroot::append_to_file"
"--skip=extractors::common::Chroot::carve_file"
"--skip=extractors::common::Chroot::create_block_device"
"--skip=extractors::common::Chroot::create_character_device"
"--skip=extractors::common::Chroot::create_directory"
"--skip=extractors::common::Chroot::create_fifo"
"--skip=extractors::common::Chroot::create_file"
"--skip=extractors::common::Chroot::create_socket"
"--skip=extractors::common::Chroot::create_symlink"
"--skip=extractors::common::Chroot::make_executable"
];
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
versionCheckProgramArg = "-V";
postInstall = ''
wrapProgram $out/bin/binwalk --suffix PATH : ${
lib.makeBinPath (
[
p7zip
cabextract
dmg2img
jefferson
vmlinux-to-elf
lz4
lzfse
lzop
sasquatch
srec2bin
gnutar
sleuthkit
ubi_reader
uefi-firmware-parser
unyaffs
zstd
]
++ lib.optionals enableUnfree [
dumpifs
unrar
]
)
}
'';
meta = {
description = "Firmware Analysis Tool";
homepage = "https://github.com/ReFirmLabs/binwalk";
changelog = "https://github.com/ReFirmLabs/binwalk/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [
koral
felbinger
];
mainProgram = "binwalk";
};
})
|