Skip to main content

Secure Your C# Application: Proven Strategies to Prevent Unauthorized Copying




 

This article is all about safeguard your Visual C# application from unauthorized copying

Introduction

Protecting any digital assets is prominent. As a developer, safeguard the digital property from unauthorized copying is curcial to maintaining its integrety and value. unauthorized duplication leads to loss of revenue and increase the security risk.In this article we will discussed on How to avoids the unauthorized copying of an desktop application.

There are various ways to protect the user application like using Activation Keys by limiting users, Designing the login Panel to restrict the unauthorized users or using Online authentication. But in this article we will design a dommy application and restrict the authorized or unauthorized user from multiple copying by tracking the IP address of the authorized PC.

Process to Prevent the C# application


First of all, define the user’s IP address and allow the application to read the PC’s IP address. If the IP addresses match to the predefined ones, then allow the user to use your application; otherwise, show the message box with the message.



Let’s design the Windows application in Visual Studio. Add two textboxes, let’s say textBox1 and textBoxx2. In textBox1, the developer adds the IP address manually. In textBoxx2, the application reads the IP address. Then, if the text in textBox1 equals the text in textBoxx2, allow the user to use the application features; otherwise, display the warning message.


Also Read |  C# App to Read/Write Switch PLC Bits

Application Code 

using System.Net;



  private string GetLocalIPAddress()

   {

       string localIP = "";

       try

       {

           // Get the host name

           string hostName = Dns.GetHostName();



           // Get the IP addresses associated with the host

           IPAddress[] localIPs = Dns.GetHostAddresses(hostName);



           // Find the IPv4 address

           foreach (IPAddress ip in localIPs)

           {

               if (ip.AddressFamily ==            System.Net.Sockets.AddressFamily.InterNetwork)

               {

                   localIP = ip.ToString();

                   break;

               }

           }

       }

       catch (Exception ex)

       {

           MessageBox.Show("Error: " + ex.Message);

       }

       return localIP;

   }

 private void Form1_Load(object sender, EventArgs e)

 {

     string ipAddress = GetLocalIPAddress();



     // Display the IP address in TextBoxx2

     textBoxx2.Text = ipAddress;



 }

 

private void button_Click(object sender, EventArgs e)

 {

     if (textBox1.Text == textBoxx2.Text)

     {

         MessageBox.Show("You are authorized user");

     }

     else

     {

         MessageBox.Show("you are not an authorized user \n" +

             "consult to the Sales department ");

     }



    

 }

Demonstration Videos 



You can also restrict your application from being copied multiple times by tracking the MAC address. This approach would be more efficient for the program developer.

Code to abstract The MAC ADDRESS

private string GetLocalMACAddress()
{
    string localMAC = "";
    try
    {
        // Get the network interfaces
        NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();

        // Find the MAC address of the first non-loopback, operational network interface
        foreach (NetworkInterface nic in interfaces)
        {
            if (nic.NetworkInterfaceType != NetworkInterfaceType.Loopback && nic.OperationalStatus == OperationalStatus.Up)
            {
                localMAC = nic.GetPhysicalAddress().ToString();
                break;
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: " + ex.Message);
    }
    return localMAC;
}
 private void Form1_Load(object sender, EventArgs e)
 {
     string MacAddress = GetLocalMACAddress();

     // Display the IP address in TextBoxx2
     textBoxx2.Text = MacAddress;

 }

Pros and Cons

Proscons
Enhanced SecurityLimited Effectiveness
Monitoring and LoggingPotential for False Positives
Controlled AccessComplexity and Maintenance

Popular posts from this blog

warm clothes distribution program

‘ Small step can make a big difference ’ Rural Women Development Centre from morang,Nepal distributed the warm clothes to the needy people. They manage it possible by collecting fund from working staffs and management committe. Here is the video link of the distribution program. https://youtu.be/AxaHbivcQUM

SMPS of computer

                                            fig:- working principle of SMPS       fig :- SMPS of computer From the above figure, we came to know that the function of SMPS in computer which is to convert  the high 220V-AC to 0-12V DC.SMPS contain several color of wires which carry the different voltage to the different parts of the computer.The following table shows the different color cables and its carrying voltage.      

Multiple mcp23017 interfacing with Arduino

MCP23017 is the I/O port extender that runs on 12C. It is 16-bit I/O expender.in this tutorial we are going to interface the single and multiple  mcp23017 with arduino.  fig:- mcp32017 module IT has 16 I/O ports from PA0 to PA7 and PB0 to PB7. first of all we are going to interface the single mcp23017 with Arduino. For this  connect the circuit as shown on figure. Download the library for mcp23017  from  sketch-- include library -- manage libraries.