Category: Announcements

Protecting Software with Obfuscation and Software Licensing

Software applications can be secured with two layers of protection. The first layer is software licensing, whose aim is to enforce a license model (eg. by restricting the number of machines where the application can run). The second layer is software obfuscation, where the end goal is to make it hard or impossible for the end users read and alter the source code. In this article, we will focus on obfuscation.

Types of obfuscations

There are two ways of making it harder for the adversary to read or alter the source code. We can either achieve it by altering the source in such a way that more time is necessary to understand how the code works and to make it harder to remove existing licensing logic (eg. for key verification). This is usually what is thought of as obfuscation. The second approach is to move critical code away from the client machine to your own servers and provide it as an API endpoint that your application will call.

Both methods have their pros and cons. In the case of code obfuscation, you can relative easily increase the difficultly of reverse engineering at the cost of that eventually the source code will be reversed engineered or licensing logic bypassed. With custom API endpoints, you always retain control of code execution (since it runs on your servers) and if everything is correctly implemented, it’s impossible to reverse engineer the code. This is at the cost of requiring active internet connection to your server and potentially some regulatory issues (since data has to be transferred to your servers).

Conventional obfuscators

There are many obfuscators out there, some that even are free of charge. For the .NET platform, you can either use Ofuscar or ConfuserEx. The idea behind all of them is to make the IL code (which C# and VB.NET compile to) harder to read for an adversary. They should be quite easy to use, so you can simply add the key verification logic anywhere in the software.

API endpoints

Creating an API endpoint for highly sensitive code is the best way to protect it against reverse engineering. Although it may sound as very cumbersome to set up and maintain, the good news is that most cloud providers today support some form of serverless computing. We will describe how this is achieved using Azure Functions, but it should be fairly similar to other cloud platforms. The reason why we chose the serverless model is because it abstracts most things away, allowing you to focus on expressing the actual method. Moreover, cloud providers tend to allow a “per request” model, meaning that you do not have to pay for the time when the application is idle.

Azure Functions demo

To create an Azure function, go to the Azure portal and create a new “Function App”. You can then select either “consumption plan” or “app service plan” (please see this for more details). Once it’s set up, create a new HTTP Trigger and change the run.csx as shown below. To get the license verification to work, we will need to add an additional file, function.proj (or project.json for older versions of the runtime), which we cover further down in the article.

run.csx
#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

using SKM.V3;
using SKM.V3.Models;
using SKM.V3.Methods;

public static async Task Run(HttpRequest req, ILogger log)
{
    // this function will return 'Hello, <name>' if the correct license key is provided.

    // licensekey and machinecode stored as query string
    if(!KeyVerification(req.Query["licensekey"], req.Query["machinecode"])) 
    {
        return new BadRequestObjectResult("License key verification failed");        
    }
    
    string name = req.Query["name"];

    return name != null
        ? (ActionResult)new OkObjectResult($"Hello, {name}")
        : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}

public static bool KeyVerification(string licenseKey, string machineCode) {

    var RSAPubKey = "<RSA public key>";

    var auth = "<access token>";
    var result = Key.Activate(token: auth, parameters: new ActivateModel()
    {
        Key = licenseKey,
        ProductId = 3349,
        Sign = true,
        MachineCode = machineCode
    });

    if (result == null || result.Result == ResultType.Error ||
        !result.LicenseKey.HasValidSignature(RSAPubKey).IsValid())
    {
        // an error occurred or the key is invalid or it cannot be activated
        // (eg. the limit of activated devices was achieved)
        Console.WriteLine("The license does not work.");
        return false;
    }
    else
    {
        // everything went fine if we are here!
        Console.WriteLine("The license is valid!");
        return true;
    }
}
function.proj

In order to add support for license key verification, we need to add Cryptolens.Licensing. Depending on the version of function apps that you are using, you might either need to create a project.json or function.proj file. The newest version of the runtime uses function.proj.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference Include="Cryptolens.Licensing" Version="4.0.9.2"/>
  </ItemGroup>
 
</Project> 

In case you get any issues with namespaces not being found, it can be useful to try to re-create the function entirely.

Accessing form client side

In order to access your method through the client application, we can use RestSharp or similar library. When you click on “Get function url”, you will get a string similar to “https://<cluster-name>.azurewebsites.net/api/HttpTriggerCSharp1?live=<secret key>”. The live parameter may not be present for some access levels

var client = new RestClient("https://<cluster-name>.azurewebsites.net/api/");
var request = new RestRequest("HttpTriggerCSharp1", Method.GET);
//request.AddParameter("code", "<secret key>"); // depending on access level of the function in Azure

// for licensing
request.AddParameter("licensekey", "AAAA-BBBB-CCCC-DDDD");
request.AddParameter("machinecode", Helpers.GetMachineCode());

// parameter to our function
request.AddParameter("name", "Bob");

var result = client.Get(request);

Console.WriteLine(result.Content);

Console.ReadLine();

If all worked out correctly, we should see “Hello, Bob” in the terminal.

Privacy

The best advice when it comes to privacy is to send as little personal identifiable information as possible. Always ask yourself what data really needs to be processed externally. Even if it is not always possible to make it entirely anonymous, it’s good to strive to at least pseudo-anonymize data (i.e. associate an id to each user instead of using their real name). In some cases, such as with IP address, you can remove the last digits, eg. from 10.1.1.5 to 10.1.1.0 without affecting the geographical data of the IP. For advanced users, you might want to look into homomorphic encryption and follow the recent research.


Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

User Accounts instead of License Keys

The common way of distributing licenses has always been using license keys (or files). Each time a customer needs more features, they have to get a new license key. Thanks to a cloud-based solution such as SKM, it’s possible to limit the number of licenses a customer needs to keep track of, since you can always change the properties of a license in the control panel.

With the “user login authentication” feature, we want to take distribution of licenses a step further and make it even more seamless for you and your customers. Below are some of the benefits of using user login authentication:

Benefits of User Login Authentication

  • Security – an account is much easier to protect than a license key (SKM has many security mechanisms in place, including two-factor authentication).
  • Time – if your customer loses a license key, they will first of all contact you, which will require more maintenance time per customer (SKM account can always be restored automatically and if more support would be needed, we will take care of it).
  • Trust – every user account comes with an easy-to-use control panel that makes it easier for your customers to manage their licenses.

Getting Started

A quick way to get going with user login authentication is by watching a short video and reviewing an example implementation on GitHub.

Note: In addition to SKM Client API, you need to install Cryptolens.SKM, which requires .NET Framework 4.6.2 or above (or .NET Core 1.0 or above). Cryptolens.SKM targets .NET Standard 1.4, so if you target any other .NET friendly platform, you can find more information here.

If you have any feedback or suggestions, please contact us at support (at) skmapp.com.

Useful Facts & Links


Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

Happy New Year (2017)

This year has almost reached its end (at least here in Sweden) and within several hours a new year will begin – 2017.

By looking back on 2016, I’m very happy that we are getting closer to achieve our mission: to make software licensing more accessible. This is thanks to our partners and customers, who continue to support us with new ideas and insights. I’m very thankful to all of you.

Soon 2017 will begin, and I’m convinced that this new year will come with new interesting challenges and opportunities for all of us.

I wish you all the very best! 🙂

/Artem

Lead Developer, Founder

Fixed downtime Dec 18th due to invalid certificate

Today we had a major downtime because the new TLS certificate was not upgraded properly. This caused most of the versions of SKM Client API (aka SKGL Extension) not being able to validate license keys.

I’m very sorry for all the problems that this caused you. Downtimes occur because of various issues; at SKM we are constantly working on making sure to reduce them and their impact.

I’my happy to tell that this issue is now fixed!

/Artem

Lead Developer

New version of SKM Client API available, 4.0.1

Today, we’ve released a new major version of SKM Client API (aka SKGL Extension). To sum up, the new version brings full support for Web API 3 and combines that with all the positive features of the previous versions. The aim is to make all use cases much simpler to implement.


Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

Activation files, de-activations and coming features

Activation Box

This week we’ve finished the “activation file box” that can be found on the product page. Here’s an overview:

The advantage of using it that you can easily add and remove new devices, as well as get an activation file that can be sent to users with no Internet access. The activation box consists of several ideas suggested by our users, so it feels great to add support for it!

Where we are moving

Many of us have experienced that since the last year, the core interface has remained unchanged. However, under the hood, many new functionalities have been added. Our primary focus has always been on the new Web API 3, which, in contrast to Web API 2, gives you more power and customization. Now that we have the foundation up and running, the new changes to the interface are going to occur much faster. Here, our aim is to move to a single-page design that allows you to stay on the same page without having to refresh the page. The goal is to increase productivity by reducing page loading time.

Another point worth mentioning is that we are going to expand the capabilities of the SKM.dll (aka SKGL Extension). Many of us use KeyInformation objects to store license information. However, many things have changed since it was first introduced, and keeping adding new things to it won’t be good from both a design perspective and a usability perspective.Therefore, we plan to add an entirely new class of representing license key information, with fields for customer information, data objects (aka additional variables), etc. Unfortunately, this will require some migration for those of us would like to adapt the new way. But, we will do our best to make it as simple as possible.

This is really exciting and I hope to be able to share some updates with you in the coming weeks! 🙂 You are always able to see the progress here.


Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

Improvements to Payment Forms

Automation of software licensing and distribution greatly reduces the time needed to process orders, and thus allows you to focus on building great products. SKM Payment Forms allow you to easily achieve that automation.

Here are some of the improvements we’ve made in the last couple of weeks:

  • TutorialDesigned a new, comprehensive tutorial about Payment Forms.
  • Receipts: Enabled support for sending receipts on a successful transaction.
  • EmailAdd a requirement to enter an email during for each transaction.This was done to make it easier for you to identify the customers for each transaction, which is good in case something went wrong.
  • PayPal: Allow the IPN to be used with multiple payment forms. Now, you only need to specify one IPN address, i.e. https://serialkeymanager.com/Form/IPN/.

Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

Added Simplicity and Support for Sorting

There are two words that summarize what’s going to be said below: simplicity and productivity. Shortly, we’ve simplified the most difficult operations in the .NET API and added the ability to find/sort your licenses. The aim of all of these changes is to save your time as much as possible.

Simplicity in the .NET client

If you have the recent version of the .NET client SKGL Extension, you might have noticed the extension methods that we’ve added to the Key Information class. The great thing about them is that you can use SKGL Extension as a fluent API (learn more). So, say you would like to set up offline key activation, how would you take an advantage of these methods? Here’s is an example:

Productivity with Search Function

The small search field available on the product page becomes really handy when searching for specific licenses. For instance, you can search based on the creation date, features, notes as well as customer related data (if a key is assigned to a certain customer). Here’s an example of a simple query:

Other things

In addition, here are some of the other changes:

  • If you use SKM15, the key will no longer update during trial activation.
  • The Web API 2 is now entirely compatible with SKM15.
  • The Web API has a new page. Please take a look!
  • Customers can now be created in all subscription types.
  • Everyone can create a payment form as well as activation form (with or without a subscription). In some cases, a small link will be displayed.

Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.