Replace a binary file within another binary file The 2019 Stack Overflow Developer Survey Results Are InHow to find all binary executables recursively within a directory?how to find offset of one binary file inside another?dowload find binary , accidentally deleted /usr/bin/find binary fileFind & replace image URLs in one file from another fileReplace or append a line with string within a fileExtract data between two matched patterns in a binary fileHow to view a binary file?Editing binary streams containing 'x00' bytesHow are binary files “binary”?Replace a binary block within a large file
How can I fix this gap between bookcases I made?
Limit to 0 ambiguity
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
How to create dashed lines/arrows in Illustrator
What is the steepest angle that a canal can be traversable without locks?
Springs with some finite mass
JSON.serialize: is it possible to suppress null values of a map?
Why do UK politicians seemingly ignore opinion polls on Brexit?
Why did Howard Stark use all the Vibranium they had on a prototype shield?
Geography at the pixel level
What is the meaning of Triage in Cybersec world?
Which Sci-Fi work first showed weapon of galactic-scale mass destruction?
Idiomatic way to prevent slicing?
The difference between dialogue marks
A poker game description that does not feel gimmicky
How to reverse every other sublist of a list?
Realistic Alternatives to Dust: What Else Could Feed a Plankton Bloom?
Output the Arecibo Message
How to manage monthly salary
Does it makes sense to buy a new cycle to learn riding?
Is this food a bread or a loaf?
"To split hairs" vs "To be pedantic"
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Understanding the implication of what "well-defined" means for the operation in quotient group
Replace a binary file within another binary file
The 2019 Stack Overflow Developer Survey Results Are InHow to find all binary executables recursively within a directory?how to find offset of one binary file inside another?dowload find binary , accidentally deleted /usr/bin/find binary fileFind & replace image URLs in one file from another fileReplace or append a line with string within a fileExtract data between two matched patterns in a binary fileHow to view a binary file?Editing binary streams containing 'x00' bytesHow are binary files “binary”?Replace a binary block within a large file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is it possible replace in place a binary file located inside another binary file?
For example, compressed firmware.bin file contains:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
392 0x188 uImage header, header size: 64 bytes, header CRC: 0x15075729, created: 1969-12-31 23:59:59, image size: 1572736 bytes, Data Address: 0x20008000, Entry Point: 0x20008000, data CRC: 0x1DCD72E0, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: "abcd_rom_bin"
13596 0x351C gzip compressed data, maximum compression, from Unix, last modified: 2017-08-02 06:04:47
1573192 0x180148 uImage header, header size: 64 bytes, header CRC: 0x6FFB9B98, created: 1969-12-31 23:59:59, image size: 8376320 bytes, Data Address: 0x0, Entry Point: 0x0, data CRC: 0xC95886CF, OS: Linux, CPU: ARM, image type: Filesystem Image, compression type: none, image name: "abcd_rom_bin"
1573256 0x180188 Squashfs filesystem, little endian, non-standard signature, version 3.1, size: 8372772 bytes, 1028 inodes, blocksize: 131072 bytes, created: 2017-08-02 06:39:51
One of these binaries contains also busybox binary, is there way to replace it without the full decompression?
sed data-recovery gzip binary
add a comment |
Is it possible replace in place a binary file located inside another binary file?
For example, compressed firmware.bin file contains:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
392 0x188 uImage header, header size: 64 bytes, header CRC: 0x15075729, created: 1969-12-31 23:59:59, image size: 1572736 bytes, Data Address: 0x20008000, Entry Point: 0x20008000, data CRC: 0x1DCD72E0, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: "abcd_rom_bin"
13596 0x351C gzip compressed data, maximum compression, from Unix, last modified: 2017-08-02 06:04:47
1573192 0x180148 uImage header, header size: 64 bytes, header CRC: 0x6FFB9B98, created: 1969-12-31 23:59:59, image size: 8376320 bytes, Data Address: 0x0, Entry Point: 0x0, data CRC: 0xC95886CF, OS: Linux, CPU: ARM, image type: Filesystem Image, compression type: none, image name: "abcd_rom_bin"
1573256 0x180188 Squashfs filesystem, little endian, non-standard signature, version 3.1, size: 8372772 bytes, 1028 inodes, blocksize: 131072 bytes, created: 2017-08-02 06:39:51
One of these binaries contains also busybox binary, is there way to replace it without the full decompression?
sed data-recovery gzip binary
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48
add a comment |
Is it possible replace in place a binary file located inside another binary file?
For example, compressed firmware.bin file contains:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
392 0x188 uImage header, header size: 64 bytes, header CRC: 0x15075729, created: 1969-12-31 23:59:59, image size: 1572736 bytes, Data Address: 0x20008000, Entry Point: 0x20008000, data CRC: 0x1DCD72E0, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: "abcd_rom_bin"
13596 0x351C gzip compressed data, maximum compression, from Unix, last modified: 2017-08-02 06:04:47
1573192 0x180148 uImage header, header size: 64 bytes, header CRC: 0x6FFB9B98, created: 1969-12-31 23:59:59, image size: 8376320 bytes, Data Address: 0x0, Entry Point: 0x0, data CRC: 0xC95886CF, OS: Linux, CPU: ARM, image type: Filesystem Image, compression type: none, image name: "abcd_rom_bin"
1573256 0x180188 Squashfs filesystem, little endian, non-standard signature, version 3.1, size: 8372772 bytes, 1028 inodes, blocksize: 131072 bytes, created: 2017-08-02 06:39:51
One of these binaries contains also busybox binary, is there way to replace it without the full decompression?
sed data-recovery gzip binary
Is it possible replace in place a binary file located inside another binary file?
For example, compressed firmware.bin file contains:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
392 0x188 uImage header, header size: 64 bytes, header CRC: 0x15075729, created: 1969-12-31 23:59:59, image size: 1572736 bytes, Data Address: 0x20008000, Entry Point: 0x20008000, data CRC: 0x1DCD72E0, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: "abcd_rom_bin"
13596 0x351C gzip compressed data, maximum compression, from Unix, last modified: 2017-08-02 06:04:47
1573192 0x180148 uImage header, header size: 64 bytes, header CRC: 0x6FFB9B98, created: 1969-12-31 23:59:59, image size: 8376320 bytes, Data Address: 0x0, Entry Point: 0x0, data CRC: 0xC95886CF, OS: Linux, CPU: ARM, image type: Filesystem Image, compression type: none, image name: "abcd_rom_bin"
1573256 0x180188 Squashfs filesystem, little endian, non-standard signature, version 3.1, size: 8372772 bytes, 1028 inodes, blocksize: 131072 bytes, created: 2017-08-02 06:39:51
One of these binaries contains also busybox binary, is there way to replace it without the full decompression?
sed data-recovery gzip binary
sed data-recovery gzip binary
edited 2 days ago
minto
asked Apr 6 at 13:54
mintominto
169312
169312
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48
add a comment |
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48
add a comment |
1 Answer
1
active
oldest
votes
If you want to write the contents of file.gz
at offset 13596 within firmware.bin
(overwriting what's already there), you'd do:
zsh
:
zmodload zsh/system
sysseek -u1 13596 && cat; < file.gz 1<> firmware.bin
ksh93
:
cat < file.gz 1<> firmware.bin >#((13596))
dd
, any shell, but reading and writing one byte at a time
dd conv=notrunc bs=1 seek=13596 if=file.gz of=firmware.bin
GNU dd
, any shell, more efficient
dd bs=64k conv=notrunc oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Or to pad with zeros to the length of 1573192 - 13596 (POSIX sh syntax for the arithmetic expansion):
dd bs=64k conv=notrunc,sync bs="$((1573192 - 13596))" count=1
oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Now you'll need file.gz
to be at most as large as the gzip
ped file that was already in there. And if those headers contain checksums of the different parts, then you'll also need to compute and update the checksums.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510904%2freplace-a-binary-file-within-another-binary-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to write the contents of file.gz
at offset 13596 within firmware.bin
(overwriting what's already there), you'd do:
zsh
:
zmodload zsh/system
sysseek -u1 13596 && cat; < file.gz 1<> firmware.bin
ksh93
:
cat < file.gz 1<> firmware.bin >#((13596))
dd
, any shell, but reading and writing one byte at a time
dd conv=notrunc bs=1 seek=13596 if=file.gz of=firmware.bin
GNU dd
, any shell, more efficient
dd bs=64k conv=notrunc oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Or to pad with zeros to the length of 1573192 - 13596 (POSIX sh syntax for the arithmetic expansion):
dd bs=64k conv=notrunc,sync bs="$((1573192 - 13596))" count=1
oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Now you'll need file.gz
to be at most as large as the gzip
ped file that was already in there. And if those headers contain checksums of the different parts, then you'll also need to compute and update the checksums.
add a comment |
If you want to write the contents of file.gz
at offset 13596 within firmware.bin
(overwriting what's already there), you'd do:
zsh
:
zmodload zsh/system
sysseek -u1 13596 && cat; < file.gz 1<> firmware.bin
ksh93
:
cat < file.gz 1<> firmware.bin >#((13596))
dd
, any shell, but reading and writing one byte at a time
dd conv=notrunc bs=1 seek=13596 if=file.gz of=firmware.bin
GNU dd
, any shell, more efficient
dd bs=64k conv=notrunc oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Or to pad with zeros to the length of 1573192 - 13596 (POSIX sh syntax for the arithmetic expansion):
dd bs=64k conv=notrunc,sync bs="$((1573192 - 13596))" count=1
oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Now you'll need file.gz
to be at most as large as the gzip
ped file that was already in there. And if those headers contain checksums of the different parts, then you'll also need to compute and update the checksums.
add a comment |
If you want to write the contents of file.gz
at offset 13596 within firmware.bin
(overwriting what's already there), you'd do:
zsh
:
zmodload zsh/system
sysseek -u1 13596 && cat; < file.gz 1<> firmware.bin
ksh93
:
cat < file.gz 1<> firmware.bin >#((13596))
dd
, any shell, but reading and writing one byte at a time
dd conv=notrunc bs=1 seek=13596 if=file.gz of=firmware.bin
GNU dd
, any shell, more efficient
dd bs=64k conv=notrunc oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Or to pad with zeros to the length of 1573192 - 13596 (POSIX sh syntax for the arithmetic expansion):
dd bs=64k conv=notrunc,sync bs="$((1573192 - 13596))" count=1
oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Now you'll need file.gz
to be at most as large as the gzip
ped file that was already in there. And if those headers contain checksums of the different parts, then you'll also need to compute and update the checksums.
If you want to write the contents of file.gz
at offset 13596 within firmware.bin
(overwriting what's already there), you'd do:
zsh
:
zmodload zsh/system
sysseek -u1 13596 && cat; < file.gz 1<> firmware.bin
ksh93
:
cat < file.gz 1<> firmware.bin >#((13596))
dd
, any shell, but reading and writing one byte at a time
dd conv=notrunc bs=1 seek=13596 if=file.gz of=firmware.bin
GNU dd
, any shell, more efficient
dd bs=64k conv=notrunc oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Or to pad with zeros to the length of 1573192 - 13596 (POSIX sh syntax for the arithmetic expansion):
dd bs=64k conv=notrunc,sync bs="$((1573192 - 13596))" count=1
oflag=seek_bytes seek=13596 if=file.gz of=firmware.bin
Now you'll need file.gz
to be at most as large as the gzip
ped file that was already in there. And if those headers contain checksums of the different parts, then you'll also need to compute and update the checksums.
edited Apr 6 at 14:20
answered Apr 6 at 14:08
Stéphane ChazelasStéphane Chazelas
313k57593950
313k57593950
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510904%2freplace-a-binary-file-within-another-binary-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you make your question clearer.
– ctrl-alt-delor
Apr 6 at 21:46
It will depend on the file format.
– ctrl-alt-delor
Apr 6 at 21:48