USB KEY WITH APPS

I have a portable application that runs on Linux, Windows and Mac OS.
Since it is important that an application must not be copied but is distributed absolutely FREE and contain special psychometrics software.
I would need a solution at no cost to protect it.
I deploy the application on a USB stick
Then create a hidden partition that contains the license file or a security key that can not be erased.
Or even, as another solution to read id of the volume of the primary partition of the USB stick with xojo by Linux, windows and mac os.
If the code written in a costant variable is equal to volume id, then the application works otherwise it does not work

Ho un applicazione portatile che funziona su Linux, Windows e Mac OS.
Siccome un applicazione importante che non deve essere copiata assolutamente ma distribuita GRATIS.
Mi servirebbe una soluzione a costo zero per proteggerla.
Pensavo di distribuire l’applicazione su chiavetta USB
Quindi creare una partizione nascosta che contiene il file di licenza o una chiave di protezione che non pu essere cancellata.
Oppure anche, come altra soluzione leggere id del volume della partizione primaria della chiavetta con xojo da Linux, windows e mac os.
Se, il codice scritto in una costante uguale al codice del volume allora l’applicazione funziona altrimenti non funziona

If you use drives such as sandisk you can simply read the drive serial from it in the open event.

Apologies for the delay, my phone died…Here is how to get the USB filesystem serial numbers…

WINDOWS: For windows the serial number is the subkey under HKLM\SYSTEM\CCS\Enum\USB\Vid_xxxx&Pid_yyyy (use the registry class to find this), when a usb is attached to the system, the serial to the USB filesystem will end up here.
-or-
use a Xojo Shell and WMIC as such:

wmic diskdrive get serialnumber

replacing diskdrive with the proper volume.

LINUX: For linux use the Xojo shell class and invoke

su - lsusb -v
this will render a bunch of information about the drive, but what you are looking for is “iSerial” under “device descriptor”

MAC: run an applescript and parse the usb serial number from the returned data of:

do shell script "system_profiler SPUSBDataType"

Io ho avuto la stessa identica idea x le mie app, ma temo che basti fare un immagine della chiavetta x piratarti il software…

On the Mac, you can also use the NSURL object to get the volume serial number (providing one has been set).

However this would require that each copy of the application be hard coded to each USB key. Each USB key would have to contain at least 1 Windows compatible partition and 1 Mac compatible partition (for the Mac app to run correctly).

[quote=80859:@Sam Rowlands]On the Mac, you can also use the NSURL object to get the volume serial number (providing one has been set).

However this would require that each copy of the application be hard coded to each USB key. Each USB key would have to contain at least 1 Windows compatible partition and 1 Mac compatible partition (for the Mac app to run correctly).[/quote]

Or you could do what rabbitTV does, by placing an encrypted textfile on the USB that contains the usb serial, and when the application loads it verifies the serial in the textfile with the actual drive serial :slight_smile: that way you compile your application once, And create a “license file generator” application that makes the encrypted textfiles, and simply place the generated keyfile and a copy of your software on the usb drive. No partitions, no mess, guaranteed to work.

… ERR 999 Max is confused …

Dim s As Shell
s = New Shell
#If TargetWin32 Then
s.Execute(“vol”)
#Elseif TargetMacOS
s.Execute(“wmic diskdrive get serialnumber”)
#Elseif TargetLinux
s.Execute(“su -”)
s.Execute(“lsusb -v”)
#Endif
If s.ErrorCode = 0 Then
TextArea1.Text = s.Result
Else
MsgBox("Error code: " + Str(s.ErrorCode))
End If

Oh my…

Dim s As Shell
s = New Shell
#If TargetWin32 Then
s.Execute("vol") <--[[??? No]
#Elseif TargetMacOS 
s.Execute("wmic diskdrive get serialnumber") <--[[[MacOSX does not have WMIC. You will need to use the applescript provided above. This code belongs under TargetWin32 and you must replace "diskdrive" with the appropriate volume of the USB drive.]]]
#Elseif TargetLinux
s.Execute("su -")
s.Execute("lsusb -v") <--[[CORRECT]]
#Endif
If s.ErrorCode = 0 Then
TextArea1.Text = s.Result
Else
MsgBox("Error code: " + Str(s.ErrorCode))
End If

All necessary code and methodology is provided in my first response.

Hi

The following is a very simplistic code. It looks for a license.key file. This file would contain the serial number for the USB and the code when executed it finds the USB and returns true if the key matches the USB serial and false otherwise.

I found this to be an easy solution

sub ValidateLicense as boolean
  //For Mac use: ioreg -Src IOUSBDevice | grep "USB Serial Number"
  //For PC use: WMIC diskdrive get pnpdeviceid
  Dim sh As New Shell
  
  #If TargetWin32 Then
    sh.Execute("WMIC diskdrive get pnpdeviceid")
  #Else
    sh.Execute(" ioreg -Src IOUSBDevice | grep 'USB Serial Number'")
  #Endif
  
  Dim serialCodes,LicenseKey As  string
  serialCodes=""
  LicenseKey=""
  serialcodes=sh.result
  
  
  Dim i,n as Integer
  Dim f as FolderItem
  Dim b as boolean
  b=false
  
  //See if we can find a license key on any device
  n= VolumeCount-1
  For i=0 to n
    f=Volume(i).Child("license.key")
    if f.Exists then
      //if a license key is found then we compare with serial
      // Be aware that TextInputStream.Open coud raise an exception
      Dim t As TextInputStream
      Try
        t = TextInputStream.Open(f)
        t.Encoding = Encodings.MacRoman
        //read the key
        LicenseKey= t.ReadAll
      Catch e As IOException
        t.Close
        MsgBox("Error accessing file.")
      end try
        //Check to see if the key is found on the serials
      //Licensekey cannot be empty
      if LicenseKey <> "" then
          if serialCodes.InStr(LicenseKey) >0 then
            b=true
        end if
      end if
      
    end if
  Next
  return b
end sub

[quote=81345:@Matthew Combatti]#Elseif TargetLinux
s.Execute(“su -”)
s.Execute(“lsusb -v”) <–[[CORRECT]]
#Endif[/quote]

The su - is unlikely to work