.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:
Name:
Email: (not shown)
Message: (Required)
 



Twitter
RSS

About Me
More Blogs
Main Site
Posts:
IDA python over IPC
dns wildcard blocking
64bit IDA Plugins
Twitter Feed
anterior lines
misc news/updates
KANAL Mod
Decoders again
CDO.Message Breakpoints
SysAnalyzer Updates
SysAnalyzer and Site Updates
crazy decoder
ida js w/dbg
flash patching #2
JS Graphing
packet reassembly
Delphi IDA Plugin
scdbg IDA integration
API Hash Database
Winmerge plugin
IDACompare Updates
Guest Post @ hexblog
TCP Stream Reassembly
SysAnalyzer Updates
Apilogger Video
Shellcode2Exe trainer
scdbg updates
IDA Javascript w/IDE
Rop Analysis II
scdbg vrs ROP
flash patching
x64 Hooks
micro hook
jmp api+5 *2
SysAnalyzer Updates
InjDll runtime config
C# Asm/Dsm Library
Shellcode Hook Detection
Updates II
findDll
Java Hacking
Windows 8
Win7 x64
Graphing ideas
.Net Hacking
Old iDefense Releases
BootLoaders
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
Retro XSS Chat Codes
Exe as DLL
Olly Plugins
Debugging Explorer
Attach to hidden process
JS Refactoring
Asm and Shellcode in CSharp
Fancy Return Address
PDF Stream Dumper
Malcode Call API by Hash
WinDbg Cheat Sheet
GPG Automation