CrazyEngineers
  • How to give privacy to a program?

    Vishal Sharma

    Member

    Updated: Oct 24, 2024
    Views: 1.1K
    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;
        }
    
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Uday Bidkar

    MemberJul 12, 2012

    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 (<a href="https://en.wikipedia.org/wiki/MAC_address" target="_blank" rel="nofollow noopener noreferrer">Mac Address</a>). You can find plenty of examples to get the MAC address of the machine programatically (e.g. #-Link-Snipped-#). 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 12, 2012

    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 (<a href="https://en.wikipedia.org/wiki/MAC_address" target="_blank" rel="nofollow noopener noreferrer">Mac Address</a>). You can find plenty of examples to get the MAC address of the machine programatically (e.g. #-Link-Snipped-#). 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?
    Are you sure? This action cannot be undone.
    Cancel
  • Uday Bidkar

    MemberJul 13, 2012

    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?
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberJul 13, 2012

    In our company we had used MAC ID to protect one of our Application its the best way to protect your code or application.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    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???
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    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!
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberJul 13, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberJul 13, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    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!
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberJul 13, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    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.. 😏
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    #-Link-Snipped-# 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
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberJul 13, 2012

    Vishal0203
    #-Link-Snipped-# 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 13, 2012

    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
    Are you sure? This action cannot be undone.
    Cancel
  • Uday Bidkar

    MemberJul 14, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 14, 2012

    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<conio.h>
    #include<stdlib.h>
    int main()
     
    {
        system("ipconfig/all");
        getch();
            return 0;
    }
    
    Are you sure? This action cannot be undone.
    Cancel
  • [Prototype]

    MemberJul 14, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Uday Bidkar

    MemberJul 14, 2012

    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<conio.h>
    #include<stdlib.h>
    int main()
     
    {
        system("ipconfig/all");
        getch();
            return 0;
    }
    
    Try system("ipconfig/all > ipconfig.txt");
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 14, 2012

    [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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 14, 2012

    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????
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 14, 2012

    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 #-Link-Snipped-#
    😀
    You've been helping me a lot!
    Are you sure? This action cannot be undone.
    Cancel
  • [Prototype]

    MemberJul 14, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJul 14, 2012

    [Prototype]
    Why not? Its totally possible to use internet. Windows provides API for communication.
    Well, then I don't know how to do that! 😐
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register