1. Home >
  2. Apps >
  3. Groups >

How to give privacy to a program?

Question asked by Vishal Sharma in #Coffee Room on Jul 12, 2012
Vishal Sharma
Vishal Sharma · Jul 12, 2012
Rank B3 - LEADER
I created this program, which is later connected to another code to form a software..
Actually, now I want to make my software private. I mean, it must work on a particular system but, when pirated and tried to run on some other system, it must not work.
while surfing on internet I found that the IP address of a system is the unique code for every pc. Is there any way to keep my software private such that it runs on a particular ip address??

here's the half-code:

#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
 
static int i=0;
struct web
{
char name[30],pass[30];
}w[100];
int n;
int login(void);
int reg(void);
int main()
{
system("cls");
printf("\n\n\n\n\n\n\t\t\tWELCOME TO C WORLD!!");
printf("\n\t\t\t^^^^^^^^^^^^^^^^^^^^");
printf("\n\n\n\n\t\t\tPress Enter to proceed...");
if(getche()==13)
  system("cls");
XY:
printf("\n\n\n\t\t\t1. LOGIN\t\t2. REGISTER");
printf("\n\n\n\t\t\t\tENTER YOUR CHOICE: ");
scanf("%d",&n);
switch(n)
  {
    case 1:  system("cls");
        login();
        break;
    case 2:  system("cls");
        reg();
        break;
    default: printf("\n\n\t\t\t\tNO MATCH FOUND");
        printf("\n\n\t\t\tPress Enter to re-Enter the choice");
        if(getche()==13)
        system("cls");
        goto XY;
 
  }
  return 0;
}
int reg()
  {
    FILE *fp;
    char c,checker[30]; int z=0,j=0;
    fp=fopen("Web_reg.txt","ab+");
    printf("\n\n\t\t\t\tWELCOME TO REGISTER ZONE");
    printf("\n\t\t\t\t^^^^^^^^^^^^^^^^^^^^^^^^");
    for(i=0;i<100;i++)
    {
      printf("\n\n\t\t\t\t  ENTER USERNAME: ");
      scanf("%s",checker);
        while(!feof(fp))
        {
        for(j=0;j<100;j++)
        {
          fread(&w[j],sizeof(w[j]),1,fp);
          if(strcmp(checker,w[j].name)==0)
            {
            printf("\n\n\t\t\tUSERNAME ALREDY EXISTS");
            fclose(fp);
            reg();
            break;
            }
        }
            strcpy(w[i].name,checker);
            fclose(fp);
            break;
        }
      fp=fopen("Web_reg.txt","ab+");
      printf("\n\n\t\t\t\t  DESIRED PASSWORD: ");
      while((c=getch())!=13)
        {
          w[i].pass[z++]=c;
          printf("%c",'*');
        }
      w[i].pass[z]='\0';
      fwrite(&w[i],sizeof(w[i]),1,fp);
      fclose(fp);
      printf("\n\n\tPress enter if you agree with Username and Password");
      if(getche()==13)
        {
        system("cls");
        printf("\n\n\t\t\t\tTHANK YOU FOR REGISTERING");
        printf("\n\n\t\t\tYOU ARE SUCCESSFULLY REGISTERED");
        printf("\n\n\n\t\t Press Enter to Login your account");
        if(getche()==13)
          {
            system("cls");
            login();
            break;
          }
 
        }
          break;
      }
    getch();
    return 0;
  }
 
  int login()
    {
      FILE *fp;
      char c,name[30],pass[30]; int z=0;
      int checku,checkp;
      fp=fopen("Web_reg.txt","rb");
      printf("\n\n\t\t\t\tWELCOME TO LOG IN ZONE");
      printf("\n\t\t\t\t^^^^^^^^^^^^^^^^^^^^^^");
        printf("\n\n\t\t\t\t  ENTER USERNAME: ");
        scanf("%s",name);
        printf("\n\n\t\t\t\t  ENTER PASSWORD: ");
        while((c=getch())!=13)
        {
          pass[z++]=c;
          printf("%c",'*');
        }
        pass[z]='\0';
      while(!feof(fp))
        {
        for(i=0;i<100;i++)
        {
          fread(&w[i],sizeof(w[i]),1,fp);
          checku=strcmp(name,w[i].name);
          checkp=strcmp(pass,w[i].pass);
          if(checku==0&&checkp==0)
            break;
        }
          if(checku==0&&checkp==0)
          {
            system("cls");
            printf("\n\n\n\t\t\tYOU HAVE LOGGED IN SUCCESSFULLY!!");
            printf("\n\n\n\t\t\t\tWELCOME!!");
            break;
          }
        else
          {
            printf("\n\n\n\t\t\tYou are not a Registered User\n \t\t\tPress enter to register yourself");
            if(getch()==13)
            {
            system("cls");
            reg();
            }
 
          }
 
      break;
      }
      getch();
      return 0;
    }
Posted in: #Coffee Room
Uday Bidkar
Uday Bidkar · Jul 13, 2012
Rank D3 - MASTER
Don't use IP in your code to restrict it to a machine, as it "may" change the next time when you come online (depends upon the DHCP server). Use MAC address instead (https://en.wikipedia.org/wiki/MAC_address). You can find plenty of examples to get the MAC address of the machine programatically (e.g. https://stackoverflow.com/questions/1779715/how-to-get-mac-address-of-your-machine-using-a-c-program). If you are using windows, running ipconfig/all from command line will reveal the MAC of your machine against "Physical Address". On unix/linux ifconfig should give you this information.
Vishal Sharma
Vishal Sharma · Jul 13, 2012
Rank B3 - LEADER
Uday Bidkar
Don't use IP in your code to restrict it to a machine, as it "may" change the next time when you come online (depends upon the DHCP server). Use MAC address instead (https://en.wikipedia.org/wiki/MAC_address). You can find plenty of examples to get the MAC address of the machine programatically (e.g. https://stackoverflow.com/questions/1779715/how-to-get-mac-address-of-your-machine-using-a-c-program). If you are using windows, running ipconfig/all from command line will reveal the MAC of your machine against "Physical Address". On unix/linux ifconfig should give you this information.
Yeah, using MAC address is good! I could get the MAC address for my pc using the code, but how to use it to avoid the misuse of the software?
how to store this MAC address?? How to compare it with the MAC address of some other pc?
Uday Bidkar
Uday Bidkar · Jul 13, 2012
Rank D3 - MASTER
I don't understand, if you have mac of your machine and a way to get it programatically, why can't you just store your machine's mac as a string in your program and compare to one you get programatically in your code? If it's the same, proceed, if different, abort, or am I missing something here?
Harshad Italiya
Harshad Italiya · Jul 13, 2012
Rank A1 - PRO
In our company we had used MAC ID to protect one of our Application its the best way to protect your code or application.
Vishal Sharma
Vishal Sharma · Jul 13, 2012
Rank B3 - LEADER
Uday Bidkar
I don't understand, if you have mac of your machine and a way to get it programatically, why can't you just store your machine's mac as a string in your program and compare to one you get programatically in your code? If it's the same, proceed, if different, abort, or am I missing something here?
If i store the MAC address of my system as a string, then the software will be running only in my system, in that way I'll not be able to distribute it to anyone. 😐 Am I right???
Vishal Sharma
Vishal Sharma · Jul 13, 2012
Rank B3 - LEADER
godfather
In our company we had used MAC ID to protect one of our Application its the best way to protect your code or application.
I think your company used MAC code, to protect the app from employees. I mean, the application may be used only in the company no one can use it outside the company!
Harshad Italiya
Harshad Italiya · Jul 13, 2012
Rank A1 - PRO
Vishal0203
If i store the MAC address of my system as a string, then the software will be running only in my system, in that way I'll not be able to distribute it to anyone. 😐 Am I right???
If you want to distribute it then you can add such routine which asks you first to enter Password or something like that.
Harshad Italiya
Harshad Italiya · Jul 13, 2012
Rank A1 - PRO
Vishal0203
I think your company used MAC code, to protect the app from employees. I mean, the application may be used only in the company no one can use it outside the company!
No in our case we have to do installation at client PC so we made small routine which was first checking for MAC and after that we make it as a security in Final Application.
Vishal Sharma
Vishal Sharma · Jul 13, 2012
Rank B3 - LEADER
godfather
If you want to distribute it then you can add such routine which asks you first to enter Password or something like that.
I tried that, but if the other person gives the installer to his friend or anyone, even that person will be able to login using username and password provided to the 1st user.
I think password would be helpful, if the software is network based!
Harshad Italiya
Harshad Italiya · Jul 13, 2012
Rank A1 - PRO
Vishal0203
I tried that, but if the other person gives the installer to his friend or anyone, even that person will be able to login using username and password provided to the 1st user.
I think password would be helpful, if the software is network based!
Then there is one more option first ask them to send you MAC ID of their PC then implement in your software. So perticular that software will work only on that PC if they want to change PC charge them Extra.
Vishal Sharma
Vishal Sharma · Jul 14, 2012
Rank B3 - LEADER
godfather
Then there is one more option first ask them to send you MAC ID of their PC then implement in your software. So perticular that software will work only on that PC if they want to change PC charge them Extra.
Nice idea.. 😀 it'll be good.. Hope they know how to get the MAC address.. Anyway, I'm gonna try for that now.

Hahaha.. or else, I can even say that, "You bought it using your money, why are you giving it to someone else, who has not payed for it" 😁 may be, this will click the selfish nature of a human being.. 😏
Vishal Sharma
Vishal Sharma · Jul 14, 2012
Rank B3 - LEADER
godfather do you have any idea? how to extract MAC address using C in windows??? I surfed the entire internet, but i could find it only for LINUX
Harshad Italiya
Harshad Italiya · Jul 14, 2012
Rank A1 - PRO
Vishal0203
godfather do you have any idea? how to extract MAC address using C in windows??? I surfed the entire internet, but i could find it only for LINUX
Not sure but there should be such app which can get MAC address.
Vishal Sharma
Vishal Sharma · Jul 14, 2012
Rank B3 - LEADER
godfather
Not sure but there should be such app which can get MAC address.
using command prompt we can see the address but, it is of no use until we can extract it
Uday Bidkar
Uday Bidkar · Jul 14, 2012
Rank D3 - MASTER
Well, if you can't find anything, a crud way will be to use system() to call getmac or ipconfig/all redirecting the output to a file, read the file and parse it to get mac out of it.
Vishal Sharma
Vishal Sharma · Jul 14, 2012
Rank B3 - LEADER
Uday Bidkar
Well, if you can't find anything, a crud way will be to use system() to call getmac or ipconfig/all redirecting the output to a file, read the file and parse it to get mac out of it.
Hey, I could get the address using the following code, but how to store the things present on output screen to a file???

#include
#include
int main()
 
{
    system("ipconfig/all");
    getch();
        return 0;
}
[Prototype]
[Prototype] · Jul 14, 2012
Rank B1 - LEADER
The best way is always to generate a GUID.
Other possible methods could be generating a uid based on the processor id or mobo id. Problem with this technique is that, few of the processor/mobo do not have these, but most of the machine will have it.

You can also use online authentication system, but it'll require internet on clients computer before it can be used.
Uday Bidkar
Uday Bidkar · Jul 15, 2012
Rank D3 - MASTER
Vishal0203
Hey, I could get the address using the following code, but how to store the things present on output screen to a file???

#include
#include
int main()
 
{
    system("ipconfig/all");
    getch();
        return 0;
}
Try system("ipconfig/all > ipconfig.txt");
Vishal Sharma
Vishal Sharma · Jul 15, 2012
Rank B3 - LEADER
[Prototype]
The best way is always to generate a GUID.
Other possible methods could be generating a uid based on the processor id or mobo id. Problem with this technique is that, few of the processor/mobo do not have these, but most of the machine will have it.

You can also use online authentication system, but it'll require internet on clients computer before it can be used.
I thought of that before, but yea, it'll need internet connection, as well as, i'll have to connect the software to internet, which is not possible using C.
Vishal Sharma
Vishal Sharma · Jul 15, 2012
Rank B3 - LEADER
Uday Bidkar
Try system("ipconfig/all > ipconfig.txt");
It does nothing...
Hey, the things on our output screen are stored in the Buffer memory!
why can't we use fprintf(fp,"%s",stdout); will that work????
Vishal Sharma
Vishal Sharma · Jul 15, 2012
Rank B3 - LEADER
Uday Bidkar
Try system("ipconfig/all > ipconfig.txt");
Sorry, It actually worked 😀
now there's a file named ipconfig.txt
Now the next task is to extract the mac address from it...
Thanks a lott Uday Bidkar
😀
You've been helping me a lot!
[Prototype]
[Prototype] · Jul 15, 2012
Rank B1 - LEADER
Vishal0203
I thought of that before, but yea, it'll need internet connection, as well as, i'll have to connect the software to internet, which is not possible using C.
Why not? Its totally possible to use internet. Windows provides API for communication.
Vishal Sharma
Vishal Sharma · Jul 15, 2012
Rank B3 - LEADER
[Prototype]
Why not? Its totally possible to use internet. Windows provides API for communication.
Well, then I don't know how to do that! 😐

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up