Tuesday, May 16, 2017

Protect .Net Source Code (Anti-Reflector) with ConfuserEx

When you build a program on .Net, it can be decompiled easily with some tools if you don't apply any solution to protect.

You can use some commercial tools for protecting your program from reflector, your spent money is worth if the program is your business.

In this post, I'll introduce an open source tool which can help you do that. It's free but it's power as commercial tool. It's ConfuserEx, you can find it on GitHub: https://github.com/yck1509/ConfuserEx

Below is a sample case which can help you start to use this tool right way.

1. In this sample, I will use the source code from my GitHub: https://github.com/vnheros/export-data-set then build it to create my application called: ExportDataGrid.exe

2. After that I use ILSpy from https://github.com/icsharpcode/ILSpy to decompile it, here is result:

Ops... my god... the source code is there. Now let see what ConfuserEx can do.

3. Open ConfuserEx.exe, its interface is like the following:

Click (+) button or drag ExportDataGrid.exe into, then we will see:

Click tab Setting and add some rules, see the following picture for how to:

After setting rules, move to Protect! tab then click Protect button:

4. Almost done now, let check with ILSpy again to see what ConfuserEx did:

What a magic! Oh lah lah...

5. But wait..., let check if the application ExportDataGrid.exe still works properly:

Yeah! We did! ConfuserEx is hero.
That's it. Happy coding! Any comment is welcome!

Thursday, April 13, 2017

Excel: How to remove empty area and make worksheets nicer for printing

Almost time when using Excel, I need to print its worksheets as result of my work.

But sometimes, I use File >> Print Preview to see what the document will look like if I print it, I often see that the document gets many extra blank pages or the columns broken into new pages. If I save the document as a .pdf file, the problem persists in the .pdf file. It's worse.

However, Excel has Page Layout functions groups to help us make worksheets nicer. Below are 2 functions I often use:
  • Page Layout >> Page Setup >> Print Area >> Set Print Area: select area which you want to print and use this function
  • Page Layout >> Scale to fit >> Width: should be set to 1 page, it will help to avoid broken columns.

There are a lot of functions there which you can try and see until you feel it's good.
Yes, let remember to use Print Preview function to check again before printing any document.
Any comment is welcome.

Bye, nice day!

Wednesday, March 29, 2017

How to use Azure File Storage as a backup disk on Windows Server

Azure File Storage (AFS) is a file storage service hosting on Azure cloud, it can be used for backup data, files or accessing files like S3 of Amazon.

In this article, I'll show you how to create a storage, map it as a local disk on Windows Server and backup files in a schedule.

1. Create a storage

Login to your Azure portal >> click Storage accounts menu >> click plus +Add button

Below is an example for a standard storage with lowest cost. You can see Azure Storage Pricing for more details.

Once done, open the storage and copy Access keys (can copy key 1 only):

2. Map the storage as local disk

Open cmd tool and run the command like below to map the storage s a local disk on Windows Server:
net use X: \\xxxStorageName.file.core.windows.net\xxxFileFolder /u:xxxStorageName xxxKey

In which:
X: is the letter of the local disk mapped
xxxStorageName: name of the storage you keyed in step 1 (see Create storage account picture)
xxxKey: access key

To disconnect this disk, use below command:
net use X: /delete

3. Create a .bat file and put into a Task Scheduler

For example, I want to copy logs file from a folder on another disk to this storage disk. So I create a .bat file naming copylogs.bat with content as below:
@echo off
copy D:\daily\*.log X:\daily
del D:\daily\*.log

After that, I create a Task Scheduler to run this .bat file on 1 AM daily:

It's simple. Hope you can save your data or files on the cloud. It's worth when your server is damaged or something like that.

Any comment is welcome!

Monday, January 9, 2017

Install Microsoft Security Essentials In Windows Server 2008 to 2012 R2

Microsoft Security Essentials (MSE) is free tool to help guard your Windows computer against viruses and other malware. In previous years, MSE is not in the list of top security guys for Windows, but now Microsoft is investing a lot on security problem and it is running to the top. So it is worth to have MSE on your Windows server to protect your server. MSE also rather doesn't take many resource vs. the other antivirus program, so it doesn't impact much on server performance.

But unfortunately it runs only on Windows desktop. It cannot run on Windows server by default. However, you can make it serves you by the following steps:

1. Go to this link: https://support.microsoft.com/en-us/help/14210/security-essentials-download then choose right version for your server (32 bit or 64 bit) and download mseinstall.exe

2. Use Administrator user, right click on mseinstall.exe then choose Properties menu

3. Select Compatibility tab, then choose Run this program in compatibility mode for Windows 7. Then click OK.

4. Use command prompt, change folder to the folder containing mseinstall.exe then run below command:
mseinstall.exe /disableoslimit

5. Follow next steps and enjoy MSE installed on your Windows server.

You can download a test EICARs file on the link: https://www.eicar.org/86-0-Intended-use.html for checking if MSE is working.

Note for updating MSE:
When running Windows Update, you may see new update for MSE but the installation will be failed.
After Windows Update tried & failed, open the folder: C:\Windows\SoftwareDistribution\Download\Install, then you may see UpdateInstall.exe file, let do step 3 & 4 above for this file, then you can install new update.

Good bye and good luck!
Any comment is welcome.

Subscribe to RSS Feed Follow me on Twitter!