Pre-compiled over source code - how can I reverse engineer it? - asp.net

Is there a way to reverse engineer a pre-compiled website .... if for example someone 8) was silly enough to publish their site to a virtual directory witha local path set to the project folder in VS2008?
Help :)

Reflector is difficult to use with a precompiled site because of the way it breaks up the pages. It is not always clear and not an easy way to reverse engineer.
In fact, one of the main reasons we precompile sites is becuase it is harder to reverse engineer and update production code.

You should be able to use Reflector to see the source code. There are plugins which will decompile an assembly (.DLL or .EXE) created with .NET into a new Visual Studio project.

I had the similar issue and used Reflector to Decompile it. I got the source code, then changed the bit I wanted, and rebuild it. Then I copied that dll again to Production site. It started to reflect my changes. It was very easy and not at all difficult, maybe because Precompiled site had dlls for every page, and was updatable , so had only code-behind file in dll.
For reference: http://www.reflector.net/

Related

Decompiling .Net precompiled website: How can I tell which dll's hold what source code?

I have several dll's in a pre-compiled website's bin directory. Are the dll's just for each individual change? Is there one dll that holds all the source code or do i have to decompile each ddl then figure if the code is currently relevant? Sorry I can't include a image of the bin directory and the files becauseI don't have enough reputation points.
Probably all the DLL hold some code which in a way help the website to work. There is a main DLL, however it references and uses all the others, because if it wouldn't, they simply won't be there.
So, shortly yes, you will have to decompile all of them.

Configuration of publishing an ASP.NET web site

Forgive my ignorance, though I am new to this. I've search a lot but can't seem to come to a definite conclusion, so any information is appreciated.
So to the question: Is there a built-in configuration for web site publishing in MS Visual Studio called "Release"? The reason I'm asking is that some have told me it is, but I can only find the "Debug" configuration in Visual Studio.
So, if there's supposed to be a "Release" as well, how can I get it or can I manually add a new equivalent?
Go to the Solution Explorer (CTRL+W+S), then find your project. Right click on it and go to its properties. Find the Build tab. The top of the window will contain the active build configuration for your project. You can then change from debug (the default) to release.
By default, projects have two configurations: release and debug. You can make more, but first learn more about those two. The most important differences are explained in the question linked by Nacho in the comments. Good luck and happy codding.
edit: Web Site projects don't have the Release configuration available, but it makes no difference since they are not compiled. Web Application projects, on the other hand, do get compiled and have both configurations available.
It's been a long time (~4,5 years), but I think I might have used a Web Deployment Project for a Web Site Project once, for changing config files (replacing by copying from another directory) (xml node: WebConfigReplacementFiles)
I used Web Deployment Projects before web.config transforms where invented. (If you are interested in web.config transforms, check out my tutorial for VS 2010: http://www.tomot.de/en-us/article/5/asp.net/how-to-use-web.config-transforms-to-replace-appsettings-and-connectionstrings)
Another useful link might be: http://msdn.microsoft.com/en-us/library/377y0s6t(v=vs.100).aspx

How to get MSBUILD to precompile .aspx pages

I am working to setup a build server using Team City to build and deploy asp.net web applications to a staging site with transformed web.configs automatically. Everything is working except that the code that ends up on the website (the aspx files) have the HTML in them when you open them in notepad.
Before all of this I was using web deployment projects with websites, and the code was compiled. If you opened one after it was deployed, it said it was a marker file.
I have tried some tutorials on how this process should work, but the code always ends up in an editable state (the html).
My question is:
What do I need to do to get MSBUILD from the command line to ultimately have precompiled code on the webs server?
Any suggestions, links, pointers, or ideas would be very helpful to me.
You need to invoke the aspnet_compiler tool to do this. There are some limitations or complications depending on exactly what you need to do for things like strong-naming. The MSDN article here has pointers.
I used to have MSBuild project steps that did this, but we decided to drop precompiling because our clients want to integrate our product into their internal portals, and precompiling made things complicated for them.
Are you using MS Web Deploy? I use it regularly for automated deployments from my Team City Build server to dev, staging, QA, etc. And I'm transforming configurations as well.
If you want to check out this alternative you can follow the excellent guide by Troy Hunt:
http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_26.html

Recompile ASP.NET web project without giving it a virtual directory

In my line of work I'm often retrieving very specific versions of crusty ASP.NET web apps from their long-forgotten repositories, making minor changes and then recompiling.
A major annoyance in this process is having to create a virtual directory for every web project that I need to recompile. I don't have any problems with the process, but it's tedious and still a very manual process on .NET 1 projects.
Is there a fairly simple way to recompile the binaries of the csproj without setting up a new virtual directory?
Edit: I don't mind using command line tools, or external solutions, as long as they're fairly simple and straightforward.
I'm not sure there's any other way unless you can convert the project to vs 2005.
I ran into a similar issue when i was dealing with a web project that i needed to manage a few branches that all wanted the same virtual directory. I wrote this small app that does some switching of the virtual for you automagically.
I have added on to the app to make it more functional (supporting more than just one project at once)... and i'm sorry to say i have never update the code on the blog. This might just serve as a good starting place for you to manage your virtual directories.
I will try to get the latest code up on the blog soon and i will update this post when i do.
but in the meantime check out the source here
ps. i know this version of the code needs to be cleaned up this version was just a proof of concept.

How to package an ASP.NET application to prevent customers from modifying it?

Is there a tool or some general approach to packaging all the files of an ASP.NET application into binary form to prevent modification once its deployed? I am thinking there would be a set of signed binaries and a config file for settings that we allow the customer to modify. Has anyone attempted this, is it even possible?
I would pay a reasonable amount for a slick commercial product that did this with minimal hassle.
UPDATE
Sorry, from the answers I can see that I wasn't clear. I meant literally packaging ALL files, not just the code files. This means aspx, scripts, images etc. I'm not trying to prevent reverse engineering... this is a supportability issue, i.e. to avoid dealing with problems brought about by customer messing with the files.
If you made a web application project than you can compile your code into a single dll file. You can find it in the bin folder.
Just use aspnet_compiler.exe to precomple everything and then use aspnet_merge.exe to roll up all of the compiled assemblies into a single assembly. You can use an obfuscation tool like DotFuscator if you want to make it more difficult to reverse-engineer. Visual Studio pro and up include a "lite" edition of Dotfuscator that you can use for this.
Your codebehind files will be compiled in a single dll as ZippyV already mentioned. The aspx files will get deployed normally on the webserver.
But still, your dll files can be disassembled quite easily. So to be sure you have to use an obfuscator.
If you mean ALL files including the aspx you could also consider ngen. It precompiles everything into a dll so you can't even get at the aspx pages.
Although, ngen was designed to get rid of the JIT compiling feature of the framework and is definitely not a generally recommended approach but it may work in your case well.
From VS2008 select the menu option "Tools" and then "Dotfuscator Community Edition". You will have a "Learn More" link after it starts up.
I also sign mine using SN.exe to make it have a strong name. Given all this, I think it is complicated enough to figure out a system if you are given the source code and help.... so I don't worry about it anymore.
maybe Dotfuscator your customer won't be able to modify it nor reverse-engineer it :)

Resources