By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,470 Members | 924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,470 IT Pros & Developers. It's quick & easy.

make program file a few bytes larger

100+
P: 109
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?
Jun 16 '07 #1
Share this Question
Share on Google+
15 Replies


Expert 10K+
P: 11,448
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
Jun 16 '07 #2

100+
P: 109
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
Jun 16 '07 #3

Expert 10K+
P: 11,448
Hope that makes sense
Yep, it makes sense; add an initialized char array to your program, e.g.

Expand|Select|Wrap|Line Numbers
  1. char filler[] ="thisisjustdummytextofthecorrectlength";
  2.  
stick that array in an already existing source file.

kind regards,

Jos
Jun 17 '07 #4

Savage
Expert 100+
P: 1,764
Yep, it makes sense; add an initialized char array to your program, e.g.

Expand|Select|Wrap|Line Numbers
  1. char filler[] ="thisisjustdummytextofthecorrectlength";
  2.  
stick that array in an already existing source file.

kind regards,

Jos
Cheating!!!

:)

Savage
Jun 17 '07 #5

100+
P: 109
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?
Jun 17 '07 #6

P: 15
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.
Jun 17 '07 #7

P: 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
Jun 18 '07 #8

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

pbmods
Expert 5K+
P: 5,821
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?]
Jun 24 '07 #10

pbmods
Expert 5K+
P: 5,821
Question: Can you Hex-edit your executable file and add null characters to the end of the file, or will this break the app?
Jun 24 '07 #11

100+
P: 109
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...
Jun 26 '07 #12

pbmods
Expert 5K+
P: 5,821
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?
Jun 26 '07 #13

100+
P: 109
Not really sure what you mean about padding it with nulls.
Jun 28 '07 #14

pbmods
Expert 5K+
P: 5,821
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:

Expand|Select|Wrap|Line Numbers
  1. echo "     " >> ~/Desktop/TextEdit.app/Contents/MacOS/TextEdit
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.
Jun 28 '07 #15

100+
P: 109
Thanks for all your posts, I have now changed the nature of my .exe and it no longer needs to be of a certain number of bytes as it can approach the problem in a slightly different way.

Thankyou for all your comments.
Jun 29 '07 #16

Post your reply

Sign in to post your reply or Sign up for a free account.