make program file a few bytes larger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niskin
    New Member
    • Apr 2007
    • 109

    make program file a few bytes larger

    Hi my program file is 602,384 bytes, but I want it to be 602,624 so that it fits perfectly with something else, however whenever I add a random function that has no affect on the program it either does nothing or goes straight to 602,896 bytes which is too much.

    Is there any way to add one byte at a time or something?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by niskin
    Hi my program file is 602,384 bytes, but I want it to be 602,624 so that it fits perfectly with something else, however whenever I add a random function that has no affect on the program it either does nothing or goes straight to 602,896 bytes which is too much.

    Is there any way to add one byte at a time or something?
    Why do you want to do that?

    kind regards,

    Jos

    Comment

    • niskin
      New Member
      • Apr 2007
      • 109

      #3
      Originally posted by JosAH
      Why do you want to do that?

      kind regards,

      Jos
      Well autoconv.exe in windows xp is 602624 bytes and I am helping to increase security on a network. We currently use a software restriction policy and the hash rule performs a cryptographic calculation on the number of bytes in a file. Autoconv.exe is allowed to run, meaning any file with the exact same number of bytes is allowed to run also, no matter where it is located on the hard drive of the computer I want to run my program on. The software restriction policy hash rule relies on the fact that it is very unlikely any other file on the computer will have the same number of bytes in the file. The administrator of the network is allowing me to find ways round his security and then report back to him. I want to be able to give him a file which will operate despite his software restriction policy, but the file needs 602624 bytes and it can't be any lower for various reasons to do with the main function of the program.

      Hope that makes sense

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by niskin
        Hope that makes sense
        Yep, it makes sense; add an initialized char array to your program, e.g.

        [code=cpp]
        char filler[] ="thisisjustdum mytextofthecorr ectlength";
        [/code]

        stick that array in an already existing source file.

        kind regards,

        Jos

        Comment

        • Savage
          Recognized Expert Top Contributor
          • Feb 2007
          • 1759

          #5
          Originally posted by JosAH
          Yep, it makes sense; add an initialized char array to your program, e.g.

          [code=cpp]
          char filler[] ="thisisjustdum mytextofthecorr ectlength";
          [/code]

          stick that array in an already existing source file.

          kind regards,

          Jos
          Cheating!!!

          :)

          Savage

          Comment

          • niskin
            New Member
            • Apr 2007
            • 109

            #6
            It's gone up to 602896 bytes with that in. Do you think my compiler (Dev-C++) is just not bothering with showing the exact number of bytes or windows isn't?

            Comment

            • InvalidPointers
              New Member
              • Jun 2007
              • 15

              #7
              Methinks you've discovered why the security method is actually effective. It's statistically very difficult to get your file to *exactly* the right size when you factor in all the little optimizations/variations/base size requirements/storage overhead for some functions/variables. (lol @ huge number of slashes there XD)

              Maybe try adding two plain chars, no pointers or anything, if that fails perhaps you can add some dummy assembly routines somewhere to pad stuff out. I'm admittedly no expert in software security, but it seems that those solutions may be viable.

              Comment

              • keithl
                New Member
                • May 2007
                • 8

                #8
                Hi,

                Sounds more like either your compiler or file system has block increments of 512bytes specified. Thjis is very normal on a unix based system - the larger block size uses more disk space but inreases other efficiencies.

                I would suggest you investigate that route, then you should find you can add chunks to your code and get the more precise size changes you require.

                Keith

                Comment

                • InvalidPointers
                  New Member
                  • Jun 2007
                  • 15

                  #9
                  Ah-- I should have caught that since I've been working on a chunk/block-based memory manager/allocator myself! Good point.

                  Comment

                  • pbmods
                    Recognized Expert Expert
                    • Apr 2007
                    • 5821

                    #10
                    Originally posted by niskin
                    Well autoconv.exe in windows xp is 602624 bytes and I am helping to increase security on a network. We currently use a software restriction policy and the hash rule performs a cryptographic calculation on the number of bytes in a file. Autoconv.exe is allowed to run, meaning any file with the exact same number of bytes is allowed to run also, no matter where it is located on the hard drive of the computer I want to run my program on. The software restriction policy hash rule relies on the fact that it is very unlikely any other file on the computer will have the same number of bytes in the file. The administrator of the network is allowing me to find ways round his security and then report back to him. I want to be able to give him a file which will operate despite his software restriction policy, but the file needs 602624 bytes and it can't be any lower for various reasons to do with the main function of the program.
                    Wow. Post this to WTF!

                    [EDIT: Why not just create a list of allowed programs? Is Autoconv.exe really going to move around that much?]

                    Comment

                    • pbmods
                      Recognized Expert Expert
                      • Apr 2007
                      • 5821

                      #11
                      Question: Can you Hex-edit your executable file and add null characters to the end of the file, or will this break the app?

                      Comment

                      • niskin
                        New Member
                        • Apr 2007
                        • 109

                        #12
                        Originally posted by pbmods
                        Wow. Post this to WTF!

                        [EDIT: Why not just create a list of allowed programs? Is Autoconv.exe really going to move around that much?]
                        Lol! I'm afraid you misunderstand that I'm not the network administrator, I am trying to hack it for him to analyse security... don't think you quite understand my question...

                        Comment

                        • pbmods
                          Recognized Expert Expert
                          • Apr 2007
                          • 5821

                          #13
                          Originally posted by niskin
                          Lol! I'm afraid you misunderstand that I'm not the network administrator, I am trying to hack it for him to analyse security... don't think you quite understand my question...
                          Oh yeah. The WTF was directed at your network admin :)

                          I dunno. I can think of too many situations where this model would break down. Please break it!

                          P.S., can you pad your executable file directly with nulls? Or does that break it?

                          Comment

                          • niskin
                            New Member
                            • Apr 2007
                            • 109

                            #14
                            Not really sure what you mean about padding it with nulls.

                            Comment

                            • pbmods
                              Recognized Expert Expert
                              • Apr 2007
                              • 5821

                              #15
                              Heya niskin.

                              Not sure how you'd do it in Windows, but on my Mac, I could boot up my handy copy of HexEdit and append to the end of the file.

                              Alternatively, I copied TextEdit.app from my Applications folder to my Desktop and then I executed the following command:

                              [code=sh]echo " " >> ~/Desktop/TextEdit.app/Contents/MacOS/TextEdit[/code]

                              Double-clicking on the TextEdit icon on my desktop launches TextEdit as normal. So I would assume that appending to an executable file in Mac OS X does not necessarily break the application.

                              In Mac OS X. I dunno about Windows, though.

                              Comment

                              Working...