473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

make program file a few bytes larger

109 New Member
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
15 2278
JosAH
11,448 Recognized Expert MVP
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
niskin
109 New Member
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
JosAH
11,448 Recognized Expert MVP
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
1,764 Recognized Expert Top Contributor
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
niskin
109 New Member
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
InvalidPointers
15 New Member
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
keithl
8 New Member
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
InvalidPointers
15 New Member
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
5,821 Recognized Expert Expert
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
5,821 Recognized Expert Expert
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
niskin
109 New Member
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
5,821 Recognized Expert Expert
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
niskin
109 New Member
Not really sure what you mean about padding it with nulls.
Jun 28 '07 #14
pbmods
5,821 Recognized Expert Expert
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
niskin
109 New Member
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

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

Similar topics

0
2070
by: PeterB | last post by:
Hi! I am using the script below to download files, that are in a non-public directory, from my site. The "smaller files" section works for smaller files. However when the files are getting...
8
12448
by: Alex | last post by:
Hi all, can someone please show me how to get the size of a file with ANSI C? both in text mode and binary mode. thanks in advance.
6
2465
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello all, I recall several threads over the years about how reading file size cannot be done consistantly or portably, but I...
1
5353
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
5
6446
by: Claudio Grondi | last post by:
I have just started to play around with the bsddb3 module interfacing the Berkeley Database. Beside the intended database file databaseFile.bdb I see in same directory also the __db.001...
22
3946
by: petermichaux | last post by:
Hi, I'm curious about server load and download time if I use one big javascript file or break it into several smaller ones. Which is better? (Please think of this as the first time the scripts...
6
5780
by: =?Utf-8?B?VGhvbWFzWg==?= | last post by:
Hi, Is it possible to read a file in reverse and only get the last 100 bytes in the file without reading the whole file from the begining? I have to get info from files that are in the last 100...
34
13300
by: niranjan.singh | last post by:
This is regarding to test an SDK memory stuff. In what situation malloc gets fail. any comment/reply pls.... regards
13
1966
by: Logan Lee | last post by:
Hi. I've written a small program to learn to write in C. But unfortunately the output is all jumbled up and not nice. /* read_file.c The whole point of this code is to read the entire content...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.