Jump to content

Recommended Posts

Posted (edited)

i have this script ifea of which was based on TrialSoftware.au3 by Chris Lambert

But because i was not able to figure his script and get full version working once activation code was correct i decided to start my own using his get mac and end/decrypt functions

#Include <String.au3> ;For Encryption
#Include <Date.au3> ;date calculate
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
Global $MAC = GetMac() ;Mac address
Global $ComputerName = @ComputerName ;Computer name
Global $FakeDLL = (@ScriptDir & "AppReg.dll") ;Fake DLL file where registration is written
Global $EnryptionPassword = "aƒc@" ;password used to endcypt/decrypt
Global $StringToEncrypt ;this is used for crypt functions
Global $Demo ;Sets to True if Demo
$DllExist = FileExists ($FakeDLL)
$EncryptedWordMAC = Encrypt ("MAC") ;encrypt given word
$EncryptedMAC = Encrypt ($MAC) ;Encrypt MAC address
$INISection = Encrypt ("CSSII_Registration") ;ini section name
$RequestCode = _StringEncrypt (1, $MAC,$EnryptionPassword) ;request code is encrypted mac address
If RegRead ("HKEY_LOCAL_MACHINESoftwareCSSIM","InitialDate") = "" Then ;if the initial date is blank then write it once
RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM","InitialDate","REG_SZ",_NowCalcDate()) ;write start date to registry once
EndIf
If IniRead ($FakeDLL,$INISection,"InitialDate","") = "" Then ;if the initial date is blank then write it once
IniWrite ($FakeDLL,$INISection,"InitialDate",_NowCalcDate())
EndIf
Global $DaysLimit = 90
Global $ExpirationDate = _DateAdd ("D",$DaysLimit,RegRead ("HKEY_LOCAL_MACHINESoftwareCSSIM","InitialDate"))
CheckActivation() ;check for activation status. If activated, then start the program, otherwise StartActivation()
Func StartActivation()
$ActivateGui = GUICreate ("Activate",300,200)
GUICtrlCreateLabel ("Please activate your application with Activation Code." & @CRLF & "Use 'DEMO' for you activation to get 90 days free Trial" & @CRLF & @CRLF & "Activation can be obtained by sending request code by visiting www.csroom.com",0,0,300,100,$SS_CENTER)
GUICtrlCreateGroup ("Request Code",5,85,290,40)
$RequestCodeInput = GUICtrlCreateInput ($RequestCode,10,100,230,20,$ES_CENTER)
$CopyRequestCodeButton = GUICtrlCreateButton ("Copy",240,100,50,20)
GUICtrlCreateGroup ("Activation Code",5,125,290,40)
$ActivationCode = GUICtrlCreateInput ("DEMO",10,140,230,20,$ES_CENTER)
$CopyActivationCodeButton = GUICtrlCreateButton ("Copy",240,140,50,20)
$ActivateButton = GUICtrlCreateButton ("Activate now",5,170,290,30)
GUISetState (@SW_SHOW,$ActivateGui)
While 1
  $ActivateMSG = GUIGetMsg()
  If $ActivateMSG = $GUI_EVENT_CLOSE Then Exit
  If $ActivateMSG = $CopyRequestCodeButton Then
   ClipPut (GUICtrlRead ($RequestCodeInput))
  EndIf
  If $ActivateMSG = $CopyActivationCodeButton Then
   ClipPut (GUICtrlRead ($ActivationCode))
  EndIf
  If $ActivateMSG = $ActivateButton Then
   $GetGUICode = GUICtrlRead ($ActivationCode)
   $Responce = _StringEncrypt (0,$RequestCode,$EnryptionPassword)
   $R1 = StringReplace ($Responce,":","") ;Remove :'s from mac address
   $R2 = StringTrimLeft (StringTrimRight ($R1,4),4) ;trim 4 characters both from left and right leaving middle part
   $R3 = _StringEncrypt (1,$R2,$EnryptionPassword)
   $CodeRequired = $R3
   If $GetGUICode = "DEMO" Then
    $InitialDate = RegRead ("HKEY_LOCAL_MACHINESoftwareCSSIM", "InitialDate") ;returns time
    Assign ("Demo","True")
    ;I need to initiate countdow from here. maybe simply count days #yday ?
    WriteDLL()
    WriteRegistry()
    MsgBox(0,'',"Your trial will expire on " & $ExpirationDate)
    GUIDelete ($ActivateGui)
    ExitLoop
   ElseIf $GetGUICode = $CodeRequired Then
    MsgBox(0,'','activation is correct')
    Assign ("Demo","False")
    WriteDLL()
    WriteRegistry()
    GUIDelete ($ActivateGui)
    ExitLoop
   EndIf
  EndIf
WEnd
Endfunc
;Application starts here if everything is OK
;Otherwise it does not start, but exist
;No need to put your code here, just include this script in your aplication #include <file.au3>
Func CheckActivation()
$RegActivationStatus =  RegRead ("HKEY_LOCAL_MACHINESoftwareCSSIM", "Activated")
$INIActivationStatus = IniRead ($FakeDLL,$INISection,"Activated","")
$RegGetInitialDate = RegRead ("HKEY_LOCAL_MACHINESoftwareCSSIM","InitialDate")
$INIGetInitialDate = IniRead ($FakeDLL,$INISection,"InitialDate","")
$DaysLeft = _DateDiff ("D",_NowCalcDate(),$ExpirationDate)
If $RegActivationStatus = "True" And $INIActivationStatus = "True" Then
  ;Program Is activated on both ends reg and ini
  Assign ("Demo","False")
Else ;otherwise check if Demo is still under trial
  MsgBox(32,'Information',$DaysLeft)
  If $RegGetInitialDate > "" And $RegGetInitialDate > "" Then ;registry and INI have some InitialDate
   If $DaysLeft < $DaysLimit Then
    MsgBox(32,'Information',$DaysLeft & ' days left')
    Assign ("Demo","True")
    WriteRegistry()
    WriteDLL()
   Else
    MsgBox(16,'Error','Activation Error 1: Please Activate your application')
    StartActivation()
   EndIf
  Else
   MsgBox (16,"Error","Activation Error 2: Please Activate your application") ;This is because registry and INI had no trial start time
   StartActivation()
  EndIf
EndIf
EndFunc
Func WriteRegistry()
If $Demo = "True" Then ;write reg for demo
  RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM", $EncryptedWordMAC,  "REG_SZ", $EncryptedMAC)
  RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM", "Activated",  "REG_SZ", "False")
  RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM", "Expiration",  "REG_SZ", $ExpirationDate) ;write expiration date to registry
Else
  RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM", $EncryptedWordMAC,  "REG_SZ", $EncryptedMAC)
  RegWrite ("HKEY_LOCAL_MACHINESoftwareCSSIM", "Activated",  "REG_SZ", "True")
EndIf
EndFunc
Func WriteDLL()
If $Demo = "True" Then ;write ini for demo
  IniWrite ($FakeDLL,$INISection,$EncryptedWordMAC,$EncryptedMAC)
  IniWrite ($FakeDLL,$INISection,"Activated","False")
  IniWrite ($FakeDLL,$INISection,"Expiration",$ExpirationDate) ;write expiration date to ini
  FileSetAttrib ($FakeDLL,"+HS")
Else
  IniWrite ($FakeDLL,$INISection,$EncryptedWordMAC,$EncryptedMAC)
  IniWrite ($FakeDLL,$INISection,"Activated","True")
  FileSetAttrib ($FakeDLL,"+HS")
EndIf
EndFunc
Func GetMac()
$oPc = "."
$oWMI = ObjGet("winmgmts:" & $oPc & "rootcimv2")
$oCol = $oWMI.ExecQuery("Select * From Win32_NetworkAdapter ")
For $oItm In $oCol
  If $oItm.NetConnectionStatus = 2 Then
   $mac = $oItm.MACAddress
    $name = $oItm.Name
  EndIf
Next
Return $mac
EndFunc
Func Encrypt ($StringToEncrypt)
  Return _StringEncrypt (1, $StringToEncrypt, $EnryptionPassword , 1 )
EndFunc ;==> Encrypt()
Func Decrypt ($StringToEncrypt)
Return _StringEncrypt (0, $StringToEncrypt, $EnryptionPassword , 1 )
EndFunc ;==> Decrypt()

Code is in development and most data compared is not encrypted yet, but it works.

I cant figure out how to count how many days left, so i can prompt for activation or something.

any takers willing to modify it, please do.

thanks

Edited by tonycst

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...