.Net Hacking

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:
One other random plug of something i wasnt aware of before. The Mono Project has developed an open source cross platform .NET runtime and compiler that works on Windows, Mac, Linux, iPhone and Android!

On 10.21.11 - 3:44am Dave wrote:
one other cool thing i read about but havent tried yet, I think it was using the reflector vs pro visual studio addin, it allows you to step into unknown compiled .NET assemblies in the VS debugger and single step etc at decompiled source level. You could really get spoiled working with tools like this.

All the painful old school asm and PE mods I had to learn have been replaced with candy on a plate for .NET reversing.

On 10.21.11 - 10:17am Dave wrote:
Book: Expert .NET Il Assembler
Links: Jason Haley.NET Notes
Debugging IL
Debug Compiler Generated Code
CLR Debugging
.NET profiling and monitoring

Leave Comment:
Email: (not shown)
Message: (Required)
Math Question: 57 + 80 = ? followed by the letter: B 

About Me
More Blogs
Main Site
Posts: (All)
2024 ( 1 )
2023 ( 4 )
2022 ( 5 )
2021 ( 2 )
2020 ( 5 )
2019 ( 6 )
2017 ( 5 )
2016 ( 4 )
2015 ( 5 )
2014 ( 5 )
2013 ( 9 )
2012 ( 13 )
2011 (19)
     Graphing ideas
     .Net Hacking
     Old iDefense Releases
     hll shellcode
     ActionScript Tips
     -patch fu
     scdbg ordinal lookup
     scdbg -api mode
     Peb Module Lists
     scdbg vrs Process Injection
     GetProcAddress Scanner
     scdbg fopen mode
     scdbg findsc mode
     scdbg MemMonitor
     demo shellcodes
     scdbg download
     api hashs redux
     Api hash gen
2010 ( 11 )
2009 ( 1 )