Social sharing has become one of the most powerful way to reach out to larger number of audience. Whenever we publish anything new it is always better to promote it on popular social networks to gain some immediate traffic. Integrating popular social sharing buttons on your site might drive more traffic if the reader likes your content and shares it.

One way of adding social share buttons is by adding JavaScript snippets provided by Facebook, LinkedIn, Twitter and Google+ or by using services like AddThis and ShareThis but it is not the optimal way of doing it, reasons for that are:

  1. Additional JavaScript will increase page size.
  2. Icons cannot be customized.
  3. More HTTP requests.

So what is the better way of doing this? All you need is a simple anchor (with URL?QueryString) and your own social sharing custom icons. You can also combine all those icons into single image this technique is called CSS Sprite. Using sprites will reduces number of HTTP request to the server and save bandwidth.

Facebook

<a href=https://facebook.com/sharer.php?u={URL} target="_blank">Facebook</a>

Linked In

<a href=http://www.linkedin.com/shareArticle?mini=true&url={URL}&title={Title} target="_blank">LinkedIn</a>

Twitter (Via and HashTags are optional)

<a href=https://twitter.com/intent/tweet?url={URL}&text={Title}&via={UserName}&hashtags={HashTags} target="_blank">Twitter</a>

Google Plus

<a href=https://plus.google.com/share?url={URL} target="_blank">Google+</a>

You can check out the sample for the same on CodePen here or check out the embedded pen below.

See the Pen jEzEGB by Arun Endapally (@arunendapally) on CodePen.

Now that we have seen how to add sharing with simple anchor, lets continue to make it look good by adding background image to the anchors.

You can download some free icons from here or here there are almost similar, I used the same in this blog or else if you have experience with photoshop you can also download icons.psd from here and customize them as required. To combine those individual icons into one image you can use this online sprite generator, combining into one image will reduce number of request to the server.

You can check out the sample for the same on CodePen here or check out the embedded pen below.

See the Pen WbzvXJ by Arun Endapally (@arunendapally) on CodePen.

We can also get the share count by sending request to the url which returns json and then we can retrieve the count from json, though it is possible avoid retrieving the count because by doing that will increase the requests and the time to your load the page will increase.

You can check out the sample for the same on CodePen here or check out the embedded pen below.

See the Pen LEdpNy by Arun Endapally (@arunendapally) on CodePen.

Note: I did not cover getting share count for google+ as it needs API_KEY and also for twitter to get the correct count you need to add the count for request with www and without www (Example: http://arunendapally.com and http://www.arunendapally.com will fetch different count).

Many developers are still not aware that Portable Executable (PE) files can be decompiled to readable source code. Before learning how to prevent or make it hard for the decompilers to reverse engineer the source code, we need to understand few basics concepts.

What is a Potable Executable file?

When source code is complied it generates a Portable Executable (PE) file. Portable Executable (PE) is either a dll or an exe. PE file contains MSIL (Microsoft Intermediate Language) and Metadata. MSIL is ultimately converted by CLR into the native code which a processor can understand. Metadata contains assemble information like Assembly Name, Version, Culture and Public Key.

How can we get source code from dll or exe?

Yes, we can get the source code from dll or exe. To demonstrate this let create a simple application first.

Open visual studio, create a new project and select console based application.

image

Add some sample code into the Program.cs

using System;

namespace MyConsoleApp
{
  internal class Program
  {
    private static void Main(string[] args)
    {
      Console.WriteLine(PublicMethod());
      Console.WriteLine(PrivateMethod());
    }

    public static string PublicMethod()
    {
      // Your source code here
      return "Public Method";
    }

    private static string PrivateMethod()
    {
      // Your source code here
      return "Private Method";
    }
  }
}

Now build the application, an exe will be generated in the bin/debug folder

image

Now lets try to get the source code from the exe file. For the first open visual studio command prompt.

image

Type ildasm and hit enter. IL DASM is MSIL Disassembler. It basically has an ability to read Intermediate Language.

image

IL DASM will open, now open the exe file we created.

image

As we can see IL DASM disassembles the exe and lots of useful information can be retrieved, though it do not provide the original source code completely a lot can be interpreted. The easy way to reverse engineer and get the exact source code there decompliers available in the market for free such as Telerik JustDecompile and Jet Brains dotPeek through which can convert the Intermediate Language into the original source code.

image

As we can see in the above screenshot when we open the exe with Telerik JustDecompile we are able to see the original source code, this can lead to piracy and ultimately you can loose your profits.

How to prevent exe and dll from getting decompiled?

The process of protecting the exe and dll from getting decompiled into original source code is called Obfuscation. There are lot of paid and free software available to Obfuscate the .Net assemblies, Dotfucator from PreEmptive Solutions is one of the popular and their community edition is free and included with the visual studio, if you are interested in buying other version check out this comparisons. The Dofuscator community edition has limited features and the professional edition is very expensive. So instead of gaining profits by protecting them from reverse engineering we will end up spending a lot on Obfuscation.

The one of best alternate utility for obfuscating is ConfuserEx it is a completely free and opensource. You can ConfuserEx download from here.

After downloading, extract the zip into a folder and then run ConfuserEx.exe

image

Drag and drop the exe you want to protect on the ConfuserEx or you can manually select Base Directory, Output Directory and add the ddl or exe.

image

Once you have done setting up the directories and adding dll or exe, go to the Settings tab in ConfuserEx. You can either add rules to Gobal settings or set individually for each dll or exe.

image

Click on “+” button, you will see “true” under Rules. Now click on edit rule (button below “-”).

image

On clicking edit rule a new window will appear as shown below. Click on “+” button

image

You can select different ways of add levels of protection. If you want to learn Obfuscation in depth check out this article.

image

Select only with “Anti IL Dasm” and “Anti Tamper”, that is enough for making it hard enough to reverse engineer for the decompilers.

image

After you click on Done, go to Protect tab and click on Protect button.

image

image

You can find the protected dll or exe in the output directory selected.

image

Test the exe or dll generated by ConfusedEx and check if it is working as usual. Now try to decompile it with a decompiler.

image

As we can see the confused dll or exe which gets generated by ConfuserEx cannot be decompiled any more.