views:

282

answers:

4

I'm wondering whether I will ever get a different result when producing a checksum on an .exe file before and then while or after running that file. I'm more concerned with common practice (such as producing a SHA hash of popular app like firefox.exe) than with boundary cases, but both are interesting. Thanks.

+7  A: 

The hash of a file should be constant for as long as the file is identical (i.e. contains only the same bytes, in the same order). It's very rare to find applications that rewrite their on-disk representation at runtime, so the hash should be constant. There are self-modifying programs, but they tend to operate on the in-memory loaded copy of their code, rather than the disk copy.

Edit: We should consider "Self-updating" applications, but these tend to launch a little helper program to download and update the core application. It's difficult (especially on Windows) to update an execution whilst it's running. UNIX systems tend to operate Copy on Write systems, so it's possible that a software update might change your executable under your feet - but again, this is a "corner case".

Adam Wright
Such on-disk modification of an exe file would probably be flagged by any virus checker as "virus-like" behaviour.
Greg Hewgill
Will the exe itself ever have components or "resources" that, say, contain configuration data that might change as a result of running the exe?
Brian
@Brian, typically not - configuration data is almost always stored seperately
bdonlan
+2  A: 

The hash will only change if the exe changes. That will only happen if the app modifies itself, which isn't going to happen on windows without the app restarting. Firefox might update itself (including a restart), but apart from such cases, the hash will remain the same.

Peter
+2  A: 

The hash will change if the file changes.

EXE files rarely change on their own. firefox.exe would change if the user updates to a new version.

You can check the "date modified" attribute of an EXE file (like firefox.exe) after running it to see whether it has changed, but you'll probably find it hasn't.

Artelius
+1  A: 

If you mean the modification of the last access time, don't worry, it's stored at the filesystem level, not within the file so the hash will remain the same.

jdehaan