#1
|
|||
|
|||
Modifying/replacing class in .NET binary
I have a .NET binary (.NET only, no native code). Short of decompiling the entire binary, changing it and recompiling it (not really an option for my particular target), is there a way to take the decompiled code for the one class I am interested in, modify it and either A.Stick it back in the original binary somehow or B.Stick it into a dll file and make the binary use the dll instead of the original code?
Or any other way to modify the code? |
#2
|
||||
|
||||
You should be able to directly replace or modify the decompiled class with dnSpy rather seamlessly, depending on how drastic the changes are:
Code:
https://github.com/0xd4d/dnSpy/releases
__________________
"As the island of our knowledge grows, so does the shore of our ignorance." John Wheeler |
The Following User Gave Reputation+1 to chessgod101 For This Useful Post: | ||
user1 (06-06-2020) |
The Following 3 Users Say Thank You to chessgod101 For This Useful Post: | ||
#3
|
|||
|
|||
Also you can export project from dnspy and load it in VS.
|
#4
|
||||
|
||||
Projects like dnlib, Mono.Cecil, and Harmony are usable for things like this:
https://github.com/0xd4d/dnlib https://github.com/jbevain/cecil https://github.com/pardeike/Harmony
__________________
Personal Projects Site: https://atom0s.com |
#5
|
||||
|
||||
also net reflector with reflexil 2.3 plugin
__________________
Decode and Conquer |
The Following User Says Thank You to niculaita For This Useful Post: | ||
val2032 (06-07-2020) |
#6
|
|||
|
|||
Using some of the the above tools (dnSpy for exemple), you can directly change the code in the binary.
This might be in IL, but it is not too complicated to learn (for small patches it is usually ok) I wonder if new versions are able to change in .net directly (thus builing the IL code automatically. Last time i tried, dnSpy had some issues with this and changing the IL code directly was the way to go... |
The Following User Says Thank You to tusk For This Useful Post: | ||
niculaita (06-22-2020) |
#7
|
||||
|
||||
also, in some cases, the name of patched file have to be same as original one
__________________
Decode and Conquer |
#8
|
|||
|
|||
Quote:
author is responsive and is interested in in keeping his great product up to date and bugless |
The Following User Says Thank You to sendersu For This Useful Post: | ||
tusk (06-27-2020) |
#9
|
|||
|
|||
For small binary files, you can dump the file with dnSpy, load it with Visual Studio, patch then rebuild.
|
#10
|
|||
|
|||
Why VS? Can patch directly in dnspy.
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Replacing ECDSA in Target (arma) | Mynotos | General Discussion | 3 | 11-22-2019 00:49 |
Highly self modifying code | chants | General Discussion | 1 | 09-21-2016 17:46 |
Modifying Assembly Attributes (.NET) | The Old Pirate | General Discussion | 7 | 05-11-2015 00:15 |
Modifying resources of self-checking exe | c4p0ne | General Discussion | 8 | 09-17-2004 21:32 |