Jump to content

Recommended Posts

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1.124
; Author:        EXE re-writing functions by Larry
;                 Adabted by joshdb to provide copy protection
;
; Script Function:
;                 Gives copy protection to your script
;                 #include this file to add protection
;
; ----------------------------------------------------------------------------

$Code = "X" & StringRight(MacAddress(), 3)

If @Compiled <> 1 Then Exit

If $CMDLINE[0] = 1 Then KillOrReEncarnate($CMDLINE[1], 1)
If $CMDLINE[0] = 2 Then KillOrReEncarnate($CMDLINE[2], 0)

Global $size = FileGetSize(@ScriptFullPath)
Global $buffer = FileRead(@ScriptFullPath, $size)

Global $check = StringMid($buffer, $size - 11, 4)

$tempfile = @TempDir & StringTrimRight(@ScriptName, 4) & "temp.exe"
FileDelete($tempfile)

If $check <> $Code Then
    If StringLeft($Code,1) = "X" Then
    ; ADD FIRSTRUN CODE HERE <===================================================
        FileWrite($tempfile, StringTrimRight($buffer, 8) & $Code & StringRight($buffer, 8))
        Run("""" & $tempfile & """ """ & @ScriptFullPath & """")
    Else
    ; ADD ERROR CODE HERE <======================================================
        Exit
    EndIf
Else
; ADD CONFIRMATION CODE HERE <===================================================
EndIf

Func KillOrReEncarnate($file, $bReencarnate)
    While FileExists($file)
        FileDelete($file)
        Sleep(50)
    WEnd
    If $bReencarnate Then
        FileCopy(@ScriptFullPath, $file, 1)
        Run("""" & $file & """ kill """ & @ScriptFullPath & """")
    EndIf
    Exit
EndFunc  ;==>KillOrReEncarnate

Func MacAddress($getmacindex = 1)
    $ipHandle = Run(@ComSpec & ' /c ipconfig /all', '', @SW_HIDE, 2)
    $macdashed = StringRegExp(StringStripWS(StdoutRead ($ipHandle), 3), '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3)
    If Not @extended Then Return 0
    If Not IsArray($macdashed) Then Return 0
    If $getmacindex = 0 Then Return UBound($macdashed)
    If $getmacindex < - 1 Then Return 0
    If $getmacindex > UBound($macdashed) Or $getmacindex = -1 Then $getmacindex = UBound($macdashed)
    Return $macdashed[$getmacindex - 1]
EndFunc  ;==>MacAddress

Self explanatory :)

Edited by JoshDB
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

Update: Changed the C to an X becuase from what I've seen C's are more common than X's in MAC adresses.

Also, a note: You must compile the script that #includes Protect.au3 with the latest beta!

Cheers,

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

maybe to make things easier for the original scriptor, you could place this at the top of your script

If @compiled <> 1 then Return

that way they can run/test/edit thier own script without yours creating a problem

just an idea

8)

Edited by Valuater

NEWHeader1.png

Link to post
Share on other sites

After compilation, the program can be run once before being 'set' so that it can only run on the computer it was first run on. It does this by re-writing part of the EXE.

I think that sums it up...

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

Hi,

doesn't work for me. It always prints out "This exe is copy-protected!".

What I'm doing wrong?

I put this at top of the script.

Protect()
MsgBox(64, "Test", "Hello World Mega")

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

I don't see why it wouldn't be working besides the StringInStr functions, as I've never used it before.

Are you compiling before trying your code out?

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

I don't see why it wouldn't be working besides the StringInStr functions, as I've never used it before.

Are you compiling before trying your code out?

HI,

sure I compiled it. And started the exe file. But no chance to reach the "main code", it always jumps out with the Error MsgBox mentioned above.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

GAH it was in the @Compiled...

I had <> 1 instead of = 1

EDIT: I've updated the code o nthe first post. Sorry for that!

Edited by JoshDB
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

GAH it was in the @Compiled...

I had <> 1 instead of = 1

EDIT: I've updated the code o nthe first post. Sorry for that!

Hi,

now it looks better to me. :) I'll have to change a few things, but the idea is great.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

Hi,

now it looks better to me. :) I'll have to change a few things, but the idea is great.

So long,

Mega

HI!

No, the problem isn't solved. Don't halloo till you're out of the wood! :(

If you check for If @compiled = 1 then Return your func will do nothing, I suppose.

So long,

Mega

Edit: You have to test your script. It doesn't work. :">

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

GAH it was in the @Compiled...

I had <> 1 instead of = 1

EDIT: I've updated the code o nthe first post. Sorry for that!

per help

@compiled

Returns 1 if script is a compiled executable; otherwise, returns 0.

so... the test script i gave you should have been correct

8)

NEWHeader1.png

Link to post
Share on other sites

per help

@compiled

Returns 1 if script is a compiled executable; otherwise, returns 0.

so... the test script i gave you should have been correct

8)

Hi Valuater,

yeah you idea is great and will work. The problem is, the script itself does not what it should. :)

JoshDB has to test and change a little bit. Maybe I'll try to fix it myself.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

Alright, it works now. The first version worked, wierd.

Anyways, just #include the file. It'll pass the #include if a confirmation occurs, if it's the firstrun or an error occurs the program will quit.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites

does it work if the file is copied to a different computer??

meger had mentioned this originally wtih larry's post

8)

Hi,

that is what I expected. You compile the script run it one time. It adds a specific information and won't run on another pc. (In this case, because the mac is differnet)

But it prints out first run, even when I had run it on another pc before.

So, I still doesn't do what I expected. :)

So long,

Mega

@Larry is it poosible to increase the size of the things to add? I want to add @ScriptFullPath, so that if you copy the exe after first run it won't work anymore.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to post
Share on other sites

You can change $code to get your desired results. As for the length, I don't know, but you CAN use this:

$Code = "X" & StringRight(@ScriptFullPath, 3)

It's very unlikely that the last 3 digits of any given path will be the same.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to post
Share on other sites
  • 2 weeks later...

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...