Sign in to follow this  
Followers 0
Skrip

_DriveValidate()

5 posts in this topic

#1 ·  Posted (edited)

I just whipped this together to help prevent stealing of my compiled programs. (My usb was recently stolen, that's why I made this) So I thought I would share.

Place _DriveValidate() at the top of your script.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1
Author:      DS. Firestorm
Description: This will validate your harddrive, so it can only be used on your HD. Mostly used for developing software.

    Read $dTest for important usage information!
    
Script Function:
    _DriveValidate($dTest = 0, $dSerial = "YOUR HD SERIAL HERE", $dSpace = "YOUR HD TOTAL SPACE HERE", $dLetter = @HomeDrive)
        $dTest is a test function that will return only the serial for $dLetter and the total space. ($dSerial and $dSpace)
            these numbers returned should be placed under the second and third args.
                Default is set to 0.
        $dSerial is where you place the serial code for your harddrive.
                No Default.
        $dSpace is where you place the total amount of space available on your HD.
            Only enter a number returned by $dTest or it will likely fail!
                No Default.
        $dReturn is where you specify if you want a messagebox to appear with a
            pass or fail message.
                Default set to 0.
        $dLetter is where you place the drive name (C:\) to be validated.
                Default is set to @HomeDrive
        
#ce ----------------------------------------------------------------------------

_DriveValidate(1, "954584499", "294959.015625", 1)

Func _DriveValidate($dTest = 0, $dSerial = "", $dSpace = "", $dReturn = 0, $dLetter = @HomeDrive)
    If $dTest = 1 Then
        ConsoleWrite("_DriveValidate(0, " & DriveGetSerial($dLetter) & ", " & DriveSpaceTotal($dLetter) & ")" &@CRLF)
    Else
        If DriveGetSerial($dLetter) = $dSerial and DriveSpaceTotal($dLetter) = $dSpace Then
       ;Passed Authentication
            If $dReturn = 1 Then MsgBox(0, "Passed", "You passed authentication. Good job.")
        Else
       ;Failed Authentication
            If $dReturn = 1 Then MsgBox(0, "Failed", "You failed authentication.")
            Exit
        EndIf
    EndIf
EndFunc ;==>_DriveValidate
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@Firestorm

Perhaps Ive understood perhaps not...

Ive made this script for auto get serial and space but after msgbox nothing happend...

What I have to do ?

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:         DS. Firestorm
    Description: This will validate your harddrive, so it can only be used on your HD. Mostly used for developing software.
    
    Read $dTest for important usage information!
    
    Script Function:
    _DriveValidate($dTest = 0, $dSerial = "YOUR HD SERIAL HERE", $dSpace = "YOUR HD TOTAL SPACE HERE", $dLetter = @HomeDrive)
    $dTest is a test function that will return only the serial for $dLetter and the total space. ($dSerial and $dSpace)
    these numbers returned should be placed under the second and third args.
    Default is set to 0.
    $dSerial is where you place the serial code for your harddrive.
    No Default.
    $dSpace is where you place the total amount of space available on your HD.
    Only enter a number returned by $dTest or it will likely fail!
    No Default.
    $dReturn is where you specify if you want a messagebox to appear with a
    pass or fail message.
    Default set to 0.
    $dLetter is where you place the drive name (C:\) to be validated.
    Default is set to @HomeDrive
    
#ce ----------------------------------------------------------------------------
$Drive = InputBox("DriveValidate", "Enter Letter of your drive to Validate", "C:", "", 250, 75)
If Not @error Then
    $serial = DriveGetSerial($Drive)
    ConsoleWrite("Serial : " & $serial & @CRLF)
    $space = DriveSpaceTotal($Drive)
    ConsoleWrite("Total space : " & $space & @CRLF)
    _DriveValidate(0, $serial, $space, 1, $Drive)
EndIf

Func _DriveValidate($dTest = 0, $dSerial = "", $dSpace = "", $dReturn = 0, $dLetter = @HomeDrive)
    If $dTest = 1 Then
        ConsoleWrite("Writeout for drive: " & $dLetter & " Serial: " & DriveGetSerial($dLetter) & " Total Space: " & DriveSpaceTotal($dLetter) & @CRLF)
    Else
        If DriveGetSerial($dLetter) = $dSerial And DriveSpaceTotal($dLetter) = $dSpace Then
            ;Passed Authentication
            If $dReturn = 1 Then MsgBox(0, "Passed", "You passed authentication. Good job.")
        Else
            ;Failed Authentication
            If $dReturn = 1 Then MsgBox(0, "Failed", "You failed authentication.")
            Exit
        EndIf
    EndIf
EndFunc   ;==>_DriveValidate

Edit : This is for detect if serial or space has changed ?

Thats not secure your compiled scripts ?

Best regards, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This detects the total space of your specified drive and serial number of such drive. If either are not equal, then it returns a fail.

Also, I tried your script, and I do not understand the issue. What exactly was the purpose of that script? The UDF was not designed for that.

The actual purpose is to eval the serial of the drive, and see if it matches the correct number you specify under $dSerial and $dSpace. If those numbers do not match (specified and the number it gets) then it returns a fail and exits the script. Otherwise it will continue.

In your script above, you have it get the Serial and Space for the current drive, then you tell the script that those are the correct numbers. When in fact, they could be incorrect - if used on another computer.

--

Does that make sense?

EDIT: Also I just updated the $dTest func so it returns exactly what you need to type in for the function. You can just copy and paste the output into SciTe.

Code used:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1
Author:      DS. Firestorm
Description: This will validate your harddrive, so it can only be used on your HD. Mostly used for developing software.

    Read $dTest for important usage information!
    
Script Function:
    _DriveValidate($dTest = 0, $dSerial = "YOUR HD SERIAL HERE", $dSpace = "YOUR HD TOTAL SPACE HERE", $dLetter = @HomeDrive)
        $dTest is a test function that will return only the serial for $dLetter and the total space. ($dSerial and $dSpace)
            these numbers returned should be placed under the second and third args.
                Default is set to 0.
        $dSerial is where you place the serial code for your harddrive.
                No Default.
        $dSpace is where you place the total amount of space available on your HD.
            Only enter a number returned by $dTest or it will likely fail!
                No Default.
        $dReturn is where you specify if you want a messagebox to appear with a
            pass or fail message.
                Default set to 0.
        $dLetter is where you place the drive name (C:\) to be validated.
                Default is set to @HomeDrive
        
#ce ----------------------------------------------------------------------------

_DriveValidate(1)

Func _DriveValidate($dTest = 0, $dSerial = "", $dSpace = "", $dReturn = 0, $dLetter = @HomeDrive)
    If $dTest = 1 Then
        ConsoleWrite(@CRLF & "_DriveValidate(0, " & DriveGetSerial($dLetter) & ", " & DriveSpaceTotal($dLetter) & ")" & @CRLF & @CRLF)
    Else
        If DriveGetSerial($dLetter) = $dSerial and DriveSpaceTotal($dLetter) = $dSpace Then
       ;Passed Authentication
            If $dReturn = 1 Then MsgBox(0, "Passed", "You passed authentication. Good job.")
        Else
       ;Failed Authentication
            If $dReturn = 1 Then MsgBox(0, "Failed", "You failed authentication.")
            Exit
        EndIf
    EndIf
EndFunc ;==>_DriveValidate

Output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files\AutoIt3\test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams  
+>20:05:43 Starting AutoIt3Wrapper v.1.10.1.4   Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 3  CPU:X86)
>Running AU3Check (1.54.13.0)  from:C:\Program Files\AutoIt3
+>20:05:43 AU3Check ended.rc:0
>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\test.au3"    

_DriveValidate(0, 954584499, 294959.015625)

+>20:05:43 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 1.093
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

@Firestorm

This one uses a more complex algorithm to be sure it's the right system and if not then it actually deletes the compiled file. The data is stored encrypted in the registry and the file thet you #include from the standard AutoIt3\Includes\ folder is obfuscated.

A3 copy protect.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

@FireStorm

Humm... Ive understood, its nice idea :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0