Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Bash snippet - Extract part of a file (hex offsets allowed) and save in another.
SUBMITTED BY:
DanielK
DATE:
Aug. 13, 2016, 2:45 p.m.
FORMAT:
Bash
SIZE:
332 Bytes
Raw
Download
Tweet
HITS:
728
Go to comments
Report
function
hextract
()
{
if
[
$#
-gt
3
]
;
then
HEX2DEC_START
=
$((
16#
${
2
}
))
HEX2DEC_END
=
$((
16#
${
3
}
))
dd
if
=
"
${
1
}
"
of
=
"
${
4
}
"
bs
=
4096
count
=
$((
${
HEX2DEC_END
}
-
${
HEX2DEC_START
}
))
skip
=
${
HEX2DEC_START
}
iflag
=
count_bytes,skip_bytes
else
echo
"
${
FUNCNAME
}
<infile> <startoffset 0x> <endoffset 0x> <outfile>"
fi
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus