In my upcoming assignment (the one that made me canceled my leave), I was asked to "verify" that a set of assemblies are indeed the compiled product of a set of source codes. *Gee! I'm a walking assembler or what?*
Anyway, here's how it can be done. You will need two tools - fc.exe (to diff files) and ildasm.exe (to disassemble a .NET assembly). You will also need the original source codes.
First, compile the source codes to produce the assembly (.dll or .exe). We will call this our source assembly. The target assembly will be the one already present. Next, use ildasm.exe to disassemble both assemblies and output the result to a file. Example:
ildasm /out=source.txt c:\source\MyAssembly.exe
ildasm /out=target.txt c:\target\MyAssembly.exe
To compare both files, use the fc.exe tool. Example:
fc source.txt target.txt
In the event where both assemblies are indeed produced by the same source codes, the comparison result will only show a minor difference on a comment line. It will be something like:
***** source.txt
.corflags 0x00000001 // ILONLY
// Image base: 0x00250000
***** target.txt
.corflags 0x00000001 // ILONLY
// Image base: 0x009F0000
Take note that the base address will be different on your machine. If no other changes are reported, then it is quite likely that both assemblies come from the same source code.
To compare the differences (i.e line-by-line) at a programming language level, I recommend Reflector and the Reflector.Diff add-in.
Why Not Do A Binary Comparison?
The fc.exe tool has a /b flag to perform binary comparisons. The reason why this will not work is because .NET assemblies are always different whenever they are being recompiled. Therefore, while a binary comparison on an assembly that was originally produced by the same compilation would yield no differences, a binary comparison on an assembly that was compiled on different compilations will reveal differences.
I would like to thank Tom Hollander for bringing up the disassemble and compare idea.
Popular Post
-
I'm a sexy mix between the The Multi-tasker and the All-the-Timer/Compulsive/Voracious/Anything Goes Reader. What are you? What Kind ...
-
S4 / 1.984 cc / 200 PS / 207 ft/lb (280 Nm) @ 1.700 - 5.000 / turbo / AWD (click images for a larger view)
-
With the 2012 Moscow Motor Show (August 31 to September 9 for the public) just around the corner, Mazda has released a full set of photos a...
-
Biodiesel supercar is Brit first British firm Trident has broken the supercar mould with its new Iceni, by marrying stunning performance wi...
-
The Detroit News has the alternative fuel breakdown in the president's budget request, and it isn't pretty. Increases for hydrogen ...
-
S4 / 2.445 cc / 81 PS / 130 ft/lb (176 Nm) (click images for a larger view)
-
Maybe he means it this time. Perhaps the 7th SOTU mention will be the charm. But a story in today's NY Times, Energy Research on a Shoes...
-
Just saw this meme on Murderati , and decided to do my list of 25 writers who've blown my mind: 1. Judy Blume - periods, premarital sex...
-
Because out of it comes gems like these. Mrs. Dalloway by Virginia Woolf “The only good thing to say about this 'literary' drivel i...
-
Here’s a rather phenomenal “live TV studio version” of one of the most popular songs in Denmark at the moment; Fallulah performing the the...
No comments:
Post a Comment