How to repack an img file extracted from a device firmware?












1















So I've got a DVR and obviously forgot its password. Tried to telnet it, got credentials from internet (I guess they are the same for many resellers since the manufacturer is probably the same), JTR'd password. But this has awaken my curiosity, and now I just want to mess with firmware for the fun of it. I've tried to put a custom logo since it's a really stupid one, and possibly change languages of menus so other people from my family can also operate it.



Firmware comes as a binary file. Unzipped it to 4 .img files.




  • custom-x.cramfs.img

  • logo-x.cramfs.img

  • romfs-x.cramfs.img

  • user-x.cramfs.img


I couldn't get to mount them since there was some header bytes added to those images by mkimage, as I was told by some blog posts.



file command output of one of these images (logo):



logo-x.cramfs.img: u-boot legacy uImage, linux, Linux/ARM, Standalone Program (gzip), 40960 bytes, Fri Jul  4 06:04:30 2014, Load Address: 0x00770000, Entry Point: 0x00780000, Header CRC: 0xBC5511F0, Data CRC: 0xC6BFF7D1


After stripping the 64 bytes of data with dd I can get to mount it, and access files. Stuck trying to add some garbage files just to generate a different image file. How would I proceed about repacking the mounted img after doing changes/adding files? And how should I re-add the 64 bytes of data I've stripped?



Any helpful thoughts are appreciated.










share|improve this question
















bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    So I've got a DVR and obviously forgot its password. Tried to telnet it, got credentials from internet (I guess they are the same for many resellers since the manufacturer is probably the same), JTR'd password. But this has awaken my curiosity, and now I just want to mess with firmware for the fun of it. I've tried to put a custom logo since it's a really stupid one, and possibly change languages of menus so other people from my family can also operate it.



    Firmware comes as a binary file. Unzipped it to 4 .img files.




    • custom-x.cramfs.img

    • logo-x.cramfs.img

    • romfs-x.cramfs.img

    • user-x.cramfs.img


    I couldn't get to mount them since there was some header bytes added to those images by mkimage, as I was told by some blog posts.



    file command output of one of these images (logo):



    logo-x.cramfs.img: u-boot legacy uImage, linux, Linux/ARM, Standalone Program (gzip), 40960 bytes, Fri Jul  4 06:04:30 2014, Load Address: 0x00770000, Entry Point: 0x00780000, Header CRC: 0xBC5511F0, Data CRC: 0xC6BFF7D1


    After stripping the 64 bytes of data with dd I can get to mount it, and access files. Stuck trying to add some garbage files just to generate a different image file. How would I proceed about repacking the mounted img after doing changes/adding files? And how should I re-add the 64 bytes of data I've stripped?



    Any helpful thoughts are appreciated.










    share|improve this question
















    bumped to the homepage by Community 10 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      So I've got a DVR and obviously forgot its password. Tried to telnet it, got credentials from internet (I guess they are the same for many resellers since the manufacturer is probably the same), JTR'd password. But this has awaken my curiosity, and now I just want to mess with firmware for the fun of it. I've tried to put a custom logo since it's a really stupid one, and possibly change languages of menus so other people from my family can also operate it.



      Firmware comes as a binary file. Unzipped it to 4 .img files.




      • custom-x.cramfs.img

      • logo-x.cramfs.img

      • romfs-x.cramfs.img

      • user-x.cramfs.img


      I couldn't get to mount them since there was some header bytes added to those images by mkimage, as I was told by some blog posts.



      file command output of one of these images (logo):



      logo-x.cramfs.img: u-boot legacy uImage, linux, Linux/ARM, Standalone Program (gzip), 40960 bytes, Fri Jul  4 06:04:30 2014, Load Address: 0x00770000, Entry Point: 0x00780000, Header CRC: 0xBC5511F0, Data CRC: 0xC6BFF7D1


      After stripping the 64 bytes of data with dd I can get to mount it, and access files. Stuck trying to add some garbage files just to generate a different image file. How would I proceed about repacking the mounted img after doing changes/adding files? And how should I re-add the 64 bytes of data I've stripped?



      Any helpful thoughts are appreciated.










      share|improve this question
















      So I've got a DVR and obviously forgot its password. Tried to telnet it, got credentials from internet (I guess they are the same for many resellers since the manufacturer is probably the same), JTR'd password. But this has awaken my curiosity, and now I just want to mess with firmware for the fun of it. I've tried to put a custom logo since it's a really stupid one, and possibly change languages of menus so other people from my family can also operate it.



      Firmware comes as a binary file. Unzipped it to 4 .img files.




      • custom-x.cramfs.img

      • logo-x.cramfs.img

      • romfs-x.cramfs.img

      • user-x.cramfs.img


      I couldn't get to mount them since there was some header bytes added to those images by mkimage, as I was told by some blog posts.



      file command output of one of these images (logo):



      logo-x.cramfs.img: u-boot legacy uImage, linux, Linux/ARM, Standalone Program (gzip), 40960 bytes, Fri Jul  4 06:04:30 2014, Load Address: 0x00770000, Entry Point: 0x00780000, Header CRC: 0xBC5511F0, Data CRC: 0xC6BFF7D1


      After stripping the 64 bytes of data with dd I can get to mount it, and access files. Stuck trying to add some garbage files just to generate a different image file. How would I proceed about repacking the mounted img after doing changes/adding files? And how should I re-add the 64 bytes of data I've stripped?



      Any helpful thoughts are appreciated.







      mount firmware






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 8 '16 at 23:58









      Jeff Schaller

      43.2k1159138




      43.2k1159138










      asked Aug 14 '15 at 21:35









      PedroPedro

      61




      61





      bumped to the homepage by Community 10 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 10 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I assume you want to create squashfs images for SPI flash.
          First create squashfs image from your directory that want:



          mksquashfs yourdir romfs.squashfs -b 64K -comp xz


          Then add the header with correct start and entry points:



          mkimage -A arm -O linux -C gzip -T kernel -a 0x50000 -e 0x430000 -n 'linux' -d romfs.squashfs romfs.squashfs.img 





          share|improve this answer

























            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
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f223317%2fhow-to-repack-an-img-file-extracted-from-a-device-firmware%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









            0














            I assume you want to create squashfs images for SPI flash.
            First create squashfs image from your directory that want:



            mksquashfs yourdir romfs.squashfs -b 64K -comp xz


            Then add the header with correct start and entry points:



            mkimage -A arm -O linux -C gzip -T kernel -a 0x50000 -e 0x430000 -n 'linux' -d romfs.squashfs romfs.squashfs.img 





            share|improve this answer






























              0














              I assume you want to create squashfs images for SPI flash.
              First create squashfs image from your directory that want:



              mksquashfs yourdir romfs.squashfs -b 64K -comp xz


              Then add the header with correct start and entry points:



              mkimage -A arm -O linux -C gzip -T kernel -a 0x50000 -e 0x430000 -n 'linux' -d romfs.squashfs romfs.squashfs.img 





              share|improve this answer




























                0












                0








                0







                I assume you want to create squashfs images for SPI flash.
                First create squashfs image from your directory that want:



                mksquashfs yourdir romfs.squashfs -b 64K -comp xz


                Then add the header with correct start and entry points:



                mkimage -A arm -O linux -C gzip -T kernel -a 0x50000 -e 0x430000 -n 'linux' -d romfs.squashfs romfs.squashfs.img 





                share|improve this answer















                I assume you want to create squashfs images for SPI flash.
                First create squashfs image from your directory that want:



                mksquashfs yourdir romfs.squashfs -b 64K -comp xz


                Then add the header with correct start and entry points:



                mkimage -A arm -O linux -C gzip -T kernel -a 0x50000 -e 0x430000 -n 'linux' -d romfs.squashfs romfs.squashfs.img 






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 14 '17 at 13:05









                schaiba

                5,55912229




                5,55912229










                answered Sep 14 '17 at 12:37









                SunaySunay

                1




                1






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f223317%2fhow-to-repack-an-img-file-extracted-from-a-device-firmware%23new-answer', 'question_page');
                    }
                    );

                    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







                    Popular posts from this blog

                    Loup dans la culture

                    How to solve the problem of ntp “Unable to contact time server” from KDE?

                    Connection limited (no internet access)