Author: David Zimmer
Date: 10.20.11 - 5:13pm
I have stayed away from .NET for a long time now, but am starting to dabble with it more. I havent really delved into the guts of how it works in terms of PE layout, enumerating methods, offsets, diffing, etc.
I am very versed in the PE format itself and how traditional apps are laid out and the tools to work with them, but .NET is a whole other ball of wax.
So my experience has been dabbling with some misc projects, decompiling .NET stuff to source form, extracting routines like domain name generators and recompiling etc, but there is a bunch of stuff I still had no idea how to do.
Research started a week ago when I wanted to diff changes in a .NET assembly. IDA doesnt give any offsets, bindiff didnt show me anything. So i had to resort to diffing with a hexeditor compare files function. Winhex showed me differences in the files, and the offsets, but now how do I figure out what these offsets represent?!
First I found CFF Explorer which has a nice GUI to examine the .NET directory. It does list the rva values of the .net functions. I am sure you are all familiar with Redgate .Net Reflector which decompiles to source form.
Reflector also supports plugins, one very cool open source one is called reflexil which shows you more details about the methods, raw IL, and even allows you to inject your own code, or modify the existing .NET code right within reflector.
Some of the tricks they can do with .NET code is really pretty cool. As i started looking at reflexil, it lead me to cecil which is a .NET library for analyzing .NET apps and modifying them programatically. The author of cecil has also been working on a version that contains decompiler support. As well as a gui for both in the form of Cecil Studio. Another GUI built on top of Cecil and Cecil.Decompiler is Monoflector. From the posts I have read so far the decompiler is still early in development but already usable for some tasks. (user beware)
For full decompilation it might still be better to go with a Reflector plugin, or you can try to use Reflector as a library to your own code. Did i mention .Net has some cool tricks? (It took me a loooong time to figure out ways to do this same trick for traditionally compiled apps)
So my first project has been a command line tool using cecil to dump the modules, methods, prototypes, and rva start and end offsets. Still looking at how to do an opcode dump to validate the rvas and build on that.
Looking back at teh plugin list link above, also turns out they have a diff plugin already gonna have to check that out.
Anyway.. .NET hacking is .new to me. I didnt want to get into it, but here I am. Glad I waited till there was already a good code base and tools to deal with it!
To all the authors linked in the above. THANK YOU for your hard work!
Comments: (3)On 10.20.11 - 5:28pm Dave wrote:
On 10.21.11 - 3:44am Dave wrote:
On 10.21.11 - 10:17am Dave wrote: