Possible to inject resource files into .net assembly? - c#

There's a .net program for students that I've been messing around with in Reflector and Reflexil, but it doesn't look like they can work with resource files. I want to replace the default background with a custom one. How feasible is this?
I've tried exporting the assembly as a C# project and maybe rebuilding with the resource files swapped, but a few classes won't decompile right when exporting and crashes Reflector when I try to view the full source code inside reflector (after clicking 'expand methods')

What type of applicaiton is it? WinForms, WPF, Silverlight, Web? You can do it with ILDasm round triping. If you let me know what type of app it is I'll post the steps you need to take.

Reflexil 1.3 is now able to handle resources.

Quite difficult, probably Hex Editor can help.

Resource Hacker can do it. Follow; Action > Add a new Resource
delphi.icm.edu.pl/ftp/tools/ResHack.zip

I just put out GrayWolf to edit programs, I don't have the ability to edit resource(s) (if you donate$:) yet
but I would think the easy change is to edit the program to load the background from disk (./back1.jpg)
I have others tools that would make it easy to change the background of the running program see
"Hacking .NET" at DefCon18
other tools "GrayDragon"
I have a payload that does just this, it is for DefCon19, but if you send me an e-mail...
Happy hunting

Related

control a wpf from matlab by using a c# dll

i would like to know weather it is possible to control some wpf application written in c# by using a c# dll out of matlab.
what i need is the possibility to start the MainWindow and i have to be able
to get some values into my controller.
What i found so far was things working from c# that use matlab, but the other way round seems not to be that much populatet, as i found nothing i could really use.
I allready tried to import a .net Library, but i dont seem to be able to open a external class from my dll.
So if you could help me on this it would be great.
Regards,
justSomeone
Ok, i did just find out, that i can also import my .exe file into Matlab instead of only dlls .
I am using the function NET.addAssebly('Path.exe') to do this.
Path.exe is just a symbol that it is directed to the place of the .exe file.
I achieved to be able to use my methods as i wanted i do have my instance of the class. So i am happy now. :D
But if you have other solutions which are more handy, dont hesitate to post them. There might still be interesting things to discover :)
Regards,
justSomeone

How to compile C# file without a project?

Is there a way in VS2013 to compile a C# file without a project or solution?
This is useful, e.g. in editing some C# code quickly while preparing a Stack Overflow answer while scrubbing corporate IP from the file (without risking any harm to the "real project").
The build toolbar is grayed-out.
I know one can occasionally see squiggles for errors.
Any other simple ideas?
You can use https://dotnetfiddle.net/
You can specify different things in it. It is best for writing fast answers, also you can post link with your saved work. It is similar to jsfiddle if you aware of it.
You can use Snippet Compiler. You can download it from below URL.
http://www.sliver.com/dotnet/SnippetCompiler/
Its a stand alone light weight small application.
If you have Mono C# installed then C# REPL is awesome tool to execute small chunk of c# code.
http://www.mono-project.com/docs/tools+libraries/tools/repl/

Check file creator before loading to prevent tampering/corrupted data

Informative
I'm working on a project that loads a binary file from the disk. This file has a specific structure to store data and I need to protect this file from being loaded if the data was generated/tampered by third parties.
Resume
I have a file that I must check if the "creator" is me before loading.
Project Specification
The application that loads the file is written in C++.
The application that generates the file is written in C#.
Question
What are my options to accomplish this?
What libraries/algorithms to use?
Can you provide me some steps or guides?
Notes
I have Crypto++ linked to the C++ project if it helps.
What you are looking for is a signing/certifying system wirth asymetric keys. The functionality is built in .Net. A Quick google search shows this example which looks legit.
Keep in mind though, that if you don't have the full control of the certification process (if your application is on a client's computer), someone might decompile the code to bypass the check.
quickly like that i would take a look at LZMA SDK since the SDK support c++ and C# and just compress/encrypt the file
maybe there is a better solution, but this would be my first try

Visual Studio - Tool to replace hard coded strings with resources

I have a big ASP.NET project full of hard coded strings, that now have to be extracted to resources. Such strings can be found almost anywhere (in .cs files, .aspx files, .ascx files, etc.) and the amount of files is huge. What I'm looking for is a tool (or any way) to find all these hard coded strings in one shot and put them all together in the resource file, instead of me going manually through each file. Does anything like this exist?
Note: I'm aware that it would have been better to put the strings in resources straight away when they were needed the first time, but this is a 2 years old project where nobody really cared (typical example of "not my problem" philosophy).
Thank you very much.
UPDATE: I tried CodeRush (I couldn't try RGreatEx for obvious reasons), and I'm having difficulties using it. The main issue is that the strings I'm looking for are located mainly in .aspx files, and strings in those files don't have the "Refactor to resource" command available.
For example, I can have elements like this:
<dxwgv:ASPxSummaryItem DisplayFormat="{0}" FieldName="TOTAL" ShowInColumn="Total" SummaryType="Sum" />
The part I need to change is ShowInColumn="Total" and make it like ShowInColumn="<%$ Resources:PortalResource, Total %>". This is not a string assignment in a strict way, but an attribute assignment, so the "Refactor!" command of CodeRush doesn't appear.
My target is to find all of them in one shot and change them in a specific interface (i.e. like a localization tool) instead of looking for them one by one and manually creating the corresponding resource. Refactoring one by one inside each file would be an improvement, but still very time consuming...
You could take a look at the resource refactoring tool at
http://www.codeplex.com/ResourceRefactoring
It's an instance-by-instance tool rather than a batch replacement tool. It's free and standalone so you don't need Resharper or Coderush.
Check out the new open source project VisualLocalizer on CodePlex: VisualLocalizer page. If you have some ideas, post them as issues - the project is under development and we welcome feedback.
VisualStudio lets you search and replace with RegEx. It won't be the "fix all in one shot" solution, but it should cut back on the amount manual work significantly.
Just a thought.
If you have a look at DevExpress' CodeRush it has the functionaility you are looking for, you may need to automate it to do it a all in one shot.
It has a great deal more too!
Kindness,
Dan
Try RGreatEx. This is a plugin for ReSharper:
RGreatEx is the most powerful localizer and coding helper for Visual Studio. Once installed, it lets you localize .NET applications and produce safer code, saving up to 95% of time the developer usually spends on doing the same by hand. Empower yourself with time-saving refactorings, such as "Move to resource" and "Rename resource". The plug-in will automatically analyze string and resource usage and suggest moving strings to resources.
Do you have ReSharper? Then you perhaps should wait for version 5.0. It will have RGreatEx (mentioned by Anton) functionality included. Read the thread from the R# forum on this topic.
Update: The feature will be in R# 5.0. See the official announcement.
I've just published new tool called Jinnee.Package for string refactor. You can find it on Visual Studio gallery:
http://visualstudiogallery.msdn.microsoft.com/7ec5a225-dea4-47ae-8ebc-450d2980937f?SRC=Home

I want to use an exe file programatically

I am using a software named Daisy 2.02 Validator and it is with GUI but i want to access it programatically so that i can control all the validation process through my C# project. I am unable to find any help about it's libraries, any .net Api or any DOS command for controlling it. Please provide me help.
Thanks,
Regard,
Muhammad Waqas
If it's a .NET executable, try and use ILDASM.exe or better still - use Reflector to find out whether it has a public API. You may then be able to add it as a reference (all you need to do is simply rename the .exe to .dll) to your project or alternatively load it as an assembly and use reflection to use its API.
Obviously the first option is much preferred.
If it isn't a .NET executable, you could use scraping, but you would have to profile your app for that first and work out what low level windows messages and controls it responds to. Bit of a nightmare.
from what I see Daisy 2.02 Validator is an open source project.
if the API is not implemented you can just add it yourself
Worst case maybe send keystrokes to it.

Categories