copy protection

Re: copy protection

Postby Otto » Thu Feb 26, 2009 10:04 am

Silvio,

it protects from running not from copying.

I someone runs the program he needs the license code.

Code: Select all  Expand view
Function main

IF lizenz() = .T.

Here is your code
else

   Msginfo("no lizenz")
ENDIF
Return nil

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: copy protection

Postby Silvio » Thu Feb 26, 2009 10:53 am

But I have another problem
I not want it be copied from anyone
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: copy protection

Postby Otto » Thu Feb 26, 2009 11:12 am

Hello Silvio,

I am not sure what you understand by “copy”. If you understand that someone
copies your exe installs it on another system and runs the program than the
function I posted is a good protection.

You use the bios date, the disk number and if you want the mac address, too.
These are “unique” numbers. Yes I know you can change the bios, clone the
disk number emulate a mac address. But I think in most cases a user does not know
about that.

Regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: copy protection

Postby ukoenig » Thu Feb 26, 2009 11:55 am

Hello Silvio,

it is nearly impossible, to save a application from making a copy.
Many applications are on the market, You can copy everything ( mostly as a image ).
< CLONECD >, < ALCOHOL > and many more. Even to add bad section-parts to a CD / DVD
doesn't help ( it is used on Movie-DVD's ).
Like Otto told You, it is the only way, to connect Your application to any hardware-informations.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: copy protection

Postby Silvio » Thu Feb 26, 2009 12:36 pm

Now
I 'am thinking
to create a connection to my website from fwh application
the procedure must ask to user the name and the user code
and it must to control it into my website
on my site I put a mdb with many record of all users
is it a good Idea?
How I can make i t ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: copy protection

Postby Otto » Thu Feb 26, 2009 1:43 pm

Hello Silvio,

how do you copy protect the mdb from download?
Would you please be so kind to share this knowledge.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: copy protection

Postby Jeff Barnes » Fri Feb 27, 2009 7:05 pm

Hi Silvo,

The method I use is to generate a "reference" number on the users side (basically the hard drive serial number)
The user gives me that number and I run it through my MakeKey() function to generate a "key".
I give this key to the user and they enter it into a field in a config screen.

I put code in my software to Verify this key against the reference number. If VerifyKey() returns "T" it is a valid install and the program runs. Otherwise the program stops.

Here is my code for protecting my software:

Code: Select all  Expand view

#include "Fivewin.ch"

/* KeyGen
   Developed by Jeff Barnes  (jeff@can-soft.net)
   Last Revised: March 18 2004


   MakeKey(nKey, nLicense)     //Returns cKey
   nKey = any numeric value (your "secret" password)
   nLicense = Number of licenses to be allowed
   

   MakeKey()      //Returns cKey
   This will ask for nKey, nSerial and nLicense

   VerifyKey(nKey, nLicense, cKey)   //Retruns logical .t. or .f.
   nKey = numeric value -must be same number as used in MakeKey()
   nLicense = numeric value -must be same number as used in MakeKey()
   cKey = The Key to be verified -generated from MakeKey()

   GetLicense(nKey, cStored)   //Returns nLicense
   nKey = numeric value -must be same number as used in MakeKey()
   cStored = the key returned by MakeKey()

   GetSecretKey( nSerial, cKey ) //Returns Secret Key
   nSerial = serial number of hard drive ( nSerialHD )
   cKey = The ket returned by MakeKey()

*/


Static cStored, cKey, nSerial, oKeyGen

Function MakeKey(nKey,nLicense,lGetSecretKey, nSerial2)
   Local nTotal1:=0, nTotal2:=1,nTotal3:=0
   Local cDigit, i, lVisable:=.f.
   Local cHash1:=0, cHash2:=0, cHash3:=0, cHash4:=0
   Local cKey:=""
   Local nCount:=0
   Local nSerial:=nSerialHD(), oClp

   IF Empty(lGetSecretKey)
      lGetSecretKey := .f.
   ELSE
      nSerial := nSerial2
   ENDIF

   if Empty(nLicense)
      nLicense:=1
   endif

   if Empty(nKey)
      lVisable:=.t.
      nKey:=1
      nSerial:=0
      MsgGet("Key Generator","Enter Key: ",@nKey)
      MsgGet("Key Generator","Enter Serial Number: ",@nSerial)
      MsgGet("Key Generator","Number of Licenses: ",@nLicense)
   endif
   nCount:=len(alltrim(str(nSerial)))
   For i = 1 to nCount+1
       cDigit := SubStr( alltrim(str(nSerial)) ,i,1)
       nTotal1:=nTotal1+val(cDigit)
       if val(cDigit)<>0
          nTotal2:=nTotal2*val(cDigit)
       endif
       nTotal3:=nTotal3+(val(cDigit)*nCount)
   Next
   cHash1:=alltrim(str(nTotal1*nCount+nKey))
   cHash2:=alltrim(str(nTotal2*nCount+nKey))
   cHash3:=alltrim(str(nTotal3*nCount-nKey))
   cHash4:=alltrim(str(nLicense*nCount*nKey))

   cKey:= cHash1+"-"+cHash2+"-"+cHash3+"-"+cHash4
   
   IF lVisable
      MsgInfo("Serial Number: "+str(nSerial)+CRLF+"Key: "+cKey,"Key Generator")
      Define Window oKeyGen FROM 0,0 to 0,0
      Define CLIPBOARD oClp of oKeyGen
      Activate CLIPBOARD oClp
      oClp:SetText("Serial Number: "+str(nSerial)+CRLF+"Key: "+cKey+CRLF+"Licenses: "+str(nLicense))
      MsgInfo("The KEY has been copied to the clipboard")
      Activate Window oKeyGen on init oKeyGen:End()
   Endif
Return cKey



Function VerifyKey(nKey,cStored)
   If Empty(nKey) .or. Empty(cStored)
      MsgInfo("A value is missing for VerifyKey()","KeyGen Error")
      Return .f.
   endif
   If MakeKey(nKey,GetLicense(nKey,cStored)) = cStored
      Return .t.
   else
      Return .f.
   endif
return nil
   
Function GetLicense(nKey,cStored)
   Local nLicense, i, j:=0, cHash4:="", nCount
   If Empty(nKey) .or. Empty(cStored)
      MsgInfo("A value is missing for GetLicense()","KeyGen Error")
      Return Nil
   endif

   nCount:=Len(alltrim(cStored))
   for i = 1 to nCount
       if substr(cStored,i,1)="-"
          j=j+1
       endif
       if j=3
           if substr(cStored,i,1)<>"-"          
             cHash4:=cHash4+substr(cStored,i,1)
           endif
       endif
   next
   nLicense:=val(cHash4)/nkey/ ( len( alltrim( STR( nSerialHD() ))))
return nLicense


Function GetSecretKey( nSerial, cKey )
   Local cSecret
   if empty(nSerial)
      MsgInfo("You MUST supply a Hard Drive Serial Number","ERROR")
      Quit
   ENDIF
   if empty(cKey)
      MsgInfo("You MUST supply a Key [ made by MakeKey() ]","ERROR")
      Quit
   ENDIF

   DEFINE WINDOW oKeyGen FROM 0,0 to 5,35 TITLE "Key Generator"
   ACTIVATE WINDOW oKeyGen on INIT cSecret:=DoSecret( nSerial, cKey )
Return cSecret

Function DoSecret( nSerial, cKey )
   Local nSecret := 0, lSearching := .t., nCount, i:=0, j
   Local cGetKey, cTempKey:="", cTemp:=""
   Local cHash1:="", cHash2:="", cHash3:="", cHash4:=""
   Local cGetHash1:="", cGetHash2:="", cGetHash3:="", cGetHash4:=""
   Local oSay

   IF ! MsgYesNo("This may take a LONG TIME to run, Continue?","Find Secret Key")
      Quit
   ENDIF

   FOR j = 1 to len(trim(cKey))
      i++
      cTemp := SUBSTR( cKey, i, 1 )
      cTempKey = cTempKey + cTemp
      IF cTemp = "-"
         if EMPTY( cHash1 )
            cHash1:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
         if EMPTY( cHash2 )
            cHash2:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
         if EMPTY( cHash3 )
            cHash3:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
      ENDIF
   NEXT

   lSearching := .t.

   DO WHILE lSearching
      i++
      @ 1,1 SAY "Working..."+STR(i) of oKeyGen COLOR "R+/W"
      SysWait()
      cGetKey := MakeKey( i, 5, .t., nSerial )
      cGetHash1:=left(cGetKey,len(cHash1))
      cGetHash2:=substr(cGetKey,len(alltrim(cHash1))+2,len(alltrim(cHash2)))
      cGetHash3:=substr(cGetKey,len(alltrim(cHash1))+len(alltrim(cHash2))+3,len(alltrim(cHash3)))

      if cHash1=cGetHash1 .and. cHash2=cGetHash2 .and. cHash3=cGetHash3
         @ 1,1 SAY "Done....................." of oKeyGen COLOR "R/w"
         SysWait()
         MsgInfo("You Secret Key is: "+STR(i),"Secret Key Finder")
         oKeyGen:End()
         lSearching := .f.
      endif
   ENDDO
Return i

 



I hope this helps.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: copy protection

Postby Ugo » Fri Feb 27, 2009 10:25 pm

Silvio wrote:Now
I 'am thinking
to create a connection to my website from fwh application
the procedure must ask to user the name and the user code
and it must to control it into my website
on my site I put a mdb with many record of all users
is it a good Idea?

Dear Silvio,
is not a good idea!
Because if I copy from you the program I copy also the "user name" and "user code"!
And your site control that "USER" and "CODE" is right!
At this point my copy is not legal but work perfectly.

Is more secure one of the suggestions of our friends in this thread.
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: copy protection

Postby sambomb » Mon Mar 02, 2009 6:13 pm

I read anywhere to use HD size + HD serial because each HD have a little difference of size and it will give a secure protection to your .exe's, modify the MAC is too simple and some clients can give trouble because they could need to change it... so I don't recommend use it...
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: copy protection

Postby MdaSolution » Sun Aug 21, 2011 8:04 pm

Jeff Barnes wrote:Hi Silvo,

The method I use is to generate a "reference" number on the users side (basically the hard drive serial number)
The user gives me that number and I run it through my MakeKey() function to generate a "key".
I give this key to the user and they enter it into a field in a config screen.

I put code in my software to Verify this key against the reference number. If VerifyKey() returns "T" it is a valid install and the program runs. Otherwise the program stops.

Here is my code for protecting my software:

Code: Select all  Expand view

#include "Fivewin.ch"

/* KeyGen
   Developed by Jeff Barnes  (jeff@can-soft.net)
   Last Revised: March 18 2004


   MakeKey(nKey, nLicense)     //Returns cKey
   nKey = any numeric value (your "secret" password)
   nLicense = Number of licenses to be allowed
   

   MakeKey()      //Returns cKey
   This will ask for nKey, nSerial and nLicense

   VerifyKey(nKey, nLicense, cKey)   //Retruns logical .t. or .f.
   nKey = numeric value -must be same number as used in MakeKey()
   nLicense = numeric value -must be same number as used in MakeKey()
   cKey = The Key to be verified -generated from MakeKey()

   GetLicense(nKey, cStored)   //Returns nLicense
   nKey = numeric value -must be same number as used in MakeKey()
   cStored = the key returned by MakeKey()

   GetSecretKey( nSerial, cKey ) //Returns Secret Key
   nSerial = serial number of hard drive ( nSerialHD )
   cKey = The ket returned by MakeKey()

*/


Static cStored, cKey, nSerial, oKeyGen

Function MakeKey(nKey,nLicense,lGetSecretKey, nSerial2)
   Local nTotal1:=0, nTotal2:=1,nTotal3:=0
   Local cDigit, i, lVisable:=.f.
   Local cHash1:=0, cHash2:=0, cHash3:=0, cHash4:=0
   Local cKey:=""
   Local nCount:=0
   Local nSerial:=nSerialHD(), oClp

   IF Empty(lGetSecretKey)
      lGetSecretKey := .f.
   ELSE
      nSerial := nSerial2
   ENDIF

   if Empty(nLicense)
      nLicense:=1
   endif

   if Empty(nKey)
      lVisable:=.t.
      nKey:=1
      nSerial:=0
      MsgGet("Key Generator","Enter Key: ",@nKey)
      MsgGet("Key Generator","Enter Serial Number: ",@nSerial)
      MsgGet("Key Generator","Number of Licenses: ",@nLicense)
   endif
   nCount:=len(alltrim(str(nSerial)))
   For i = 1 to nCount+1
       cDigit := SubStr( alltrim(str(nSerial)) ,i,1)
       nTotal1:=nTotal1+val(cDigit)
       if val(cDigit)<>0
          nTotal2:=nTotal2*val(cDigit)
       endif
       nTotal3:=nTotal3+(val(cDigit)*nCount)
   Next
   cHash1:=alltrim(str(nTotal1*nCount+nKey))
   cHash2:=alltrim(str(nTotal2*nCount+nKey))
   cHash3:=alltrim(str(nTotal3*nCount-nKey))
   cHash4:=alltrim(str(nLicense*nCount*nKey))

   cKey:= cHash1+"-"+cHash2+"-"+cHash3+"-"+cHash4
   
   IF lVisable
      MsgInfo("Serial Number: "+str(nSerial)+CRLF+"Key: "+cKey,"Key Generator")
      Define Window oKeyGen FROM 0,0 to 0,0
      Define CLIPBOARD oClp of oKeyGen
      Activate CLIPBOARD oClp
      oClp:SetText("Serial Number: "+str(nSerial)+CRLF+"Key: "+cKey+CRLF+"Licenses: "+str(nLicense))
      MsgInfo("The KEY has been copied to the clipboard")
      Activate Window oKeyGen on init oKeyGen:End()
   Endif
Return cKey



Function VerifyKey(nKey,cStored)
   If Empty(nKey) .or. Empty(cStored)
      MsgInfo("A value is missing for VerifyKey()","KeyGen Error")
      Return .f.
   endif
   If MakeKey(nKey,GetLicense(nKey,cStored)) = cStored
      Return .t.
   else
      Return .f.
   endif
return nil
   
Function GetLicense(nKey,cStored)
   Local nLicense, i, j:=0, cHash4:="", nCount
   If Empty(nKey) .or. Empty(cStored)
      MsgInfo("A value is missing for GetLicense()","KeyGen Error")
      Return Nil
   endif

   nCount:=Len(alltrim(cStored))
   for i = 1 to nCount
       if substr(cStored,i,1)="-"
          j=j+1
       endif
       if j=3
           if substr(cStored,i,1)<>"-"          
             cHash4:=cHash4+substr(cStored,i,1)
           endif
       endif
   next
   nLicense:=val(cHash4)/nkey/ ( len( alltrim( STR( nSerialHD() ))))
return nLicense


Function GetSecretKey( nSerial, cKey )
   Local cSecret
   if empty(nSerial)
      MsgInfo("You MUST supply a Hard Drive Serial Number","ERROR")
      Quit
   ENDIF
   if empty(cKey)
      MsgInfo("You MUST supply a Key [ made by MakeKey() ]","ERROR")
      Quit
   ENDIF

   DEFINE WINDOW oKeyGen FROM 0,0 to 5,35 TITLE "Key Generator"
   ACTIVATE WINDOW oKeyGen on INIT cSecret:=DoSecret( nSerial, cKey )
Return cSecret

Function DoSecret( nSerial, cKey )
   Local nSecret := 0, lSearching := .t., nCount, i:=0, j
   Local cGetKey, cTempKey:="", cTemp:=""
   Local cHash1:="", cHash2:="", cHash3:="", cHash4:=""
   Local cGetHash1:="", cGetHash2:="", cGetHash3:="", cGetHash4:=""
   Local oSay

   IF ! MsgYesNo("This may take a LONG TIME to run, Continue?","Find Secret Key")
      Quit
   ENDIF

   FOR j = 1 to len(trim(cKey))
      i++
      cTemp := SUBSTR( cKey, i, 1 )
      cTempKey = cTempKey + cTemp
      IF cTemp = "-"
         if EMPTY( cHash1 )
            cHash1:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
         if EMPTY( cHash2 )
            cHash2:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
         if EMPTY( cHash3 )
            cHash3:=Left( cTempKey,len( trim( cTempKey ))-1 )
            cTempKey:=""
            loop
         endif
      ENDIF
   NEXT

   lSearching := .t.

   DO WHILE lSearching
      i++
      @ 1,1 SAY "Working..."+STR(i) of oKeyGen COLOR "R+/W"
      SysWait()
      cGetKey := MakeKey( i, 5, .t., nSerial )
      cGetHash1:=left(cGetKey,len(cHash1))
      cGetHash2:=substr(cGetKey,len(alltrim(cHash1))+2,len(alltrim(cHash2)))
      cGetHash3:=substr(cGetKey,len(alltrim(cHash1))+len(alltrim(cHash2))+3,len(alltrim(cHash3)))

      if cHash1=cGetHash1 .and. cHash2=cGetHash2 .and. cHash3=cGetHash3
         @ 1,1 SAY "Done....................." of oKeyGen COLOR "R/w"
         SysWait()
         MsgInfo("You Secret Key is: "+STR(i),"Secret Key Finder")
         oKeyGen:End()
         lSearching := .f.
      endif
   ENDDO
Return i

 



I hope this helps.















Jeff I have problem with msgget please see this topic viewtopic.php?f=3&t=22216
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests