Jump to content

How How I Protect A Program With Autoit?


Recommended Posts

Hey guys, i was wondering if there is like a protection code or something when you have 2 autoit scripts and want 1 to only be executed by the other:

Example: (Both .Exe's were created using AutoIt)

Run 1.exe,

1 does its thing and then executes 2.exe

2 does its thing and then exits (only able to be ran by 1.exe)

2.exe will not be able to be run regularly, only by using 1.exe can 2 be executed!

I'm hope there have been other questions like this, but when i use the search feature i'm at a loss as to what search strings i could use for this topic :ph34r:

Thanks! :(

Link to comment
Share on other sites

Have 1.exe set a variable that 2.exe checks for

Code in 1.exe =

$auth = "ok"

Code in 2.exe =

If Not $auth = "ok" then
MSgBox(0, "Error", Error Message Here")
Exit
EndIf

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

Have 1.exe set a variable that 2.exe checks for

Code in 1.exe =

$auth = "ok"

Code in 2.exe =

If Not $auth = "ok" then
MSgBox(0, "Error", Error Message Here")
Exit
EndIf

<{POST_SNAPBACK}>

Thanks for the advice trids :( Hey Psichosis i used your command but it says

"Variable used without being declared"

Sorry this is a noob question but how to i fix this? Thanks :ph34r:

Link to comment
Share on other sites

The two codes cannot see the variable each other. They are fully separated.

The best way is using a params.

Maybe you can try to set a registry key or a temp file that the second file check if exists before starting. If exists it also delete it.

You dont want leave trace...

Link to comment
Share on other sites

I think psichosis's code works i just dont know how to use it  :ph34r:

It just says Variable used without being declared.

<{POST_SNAPBACK}>

No, it doesn't work. A variable can be seen in the scope of the entire script if and only if it is declared as a global variable. And those cannot be seen outside of the script itself. A 2nd script is not able to use variables set by a different script. Also, I believe variables created without an explicit decloration are local, unless a global variable exists by that name already. Another good reason to declare scope explicitally so you don't run into problems :(

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Why do you need a 2nd script to kick off the main script? Is using the "no decompile" option not enough? You could even delete the exe with a fancy use of batch files if the correct password is not entered. It just seems kind of silly to need to use 2 exe's.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

No - he wants to protect 2.exe: so that it can only be run in a special and secret way (viz. by launching it via 1.exe, which i guess he will cleverly keep on a thumb drive or something :( )

Use $CmdLine to pass the value from 1.exe to 2.exe and you'll be fine

1.exe

;Call 2.exe
    Run("2.exe qwErty")

2.exe

;check if authorised startup
    If $CmdLine[0] <> 1 Then Exit
    If CmdLIne[1] <> "qwErty" Then Exit

;Stuff that we want to protect
  ;code 
  ;code
  ;code

HTH :ph34r:

Edit: Eeep! killed a buglet dead

Edited by trids
Link to comment
Share on other sites

I guess my point is that the "no decompile" option keeps 99.9% of the world out of the file. the other 0.1% is going to fiure it out anyway, by reverse engineering the first file, or making a fake 2nd file that does nothing but record the paramaters the first program passes to it. I still don't see how doing this ultra secret run lots of scripts method offers any more protection than exiting (and potentially destroying the original file.)

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Ezzetabi, could you elaberate on your method?

<{POST_SNAPBACK}>

The first script can make a special temp file like @TempDir & "\MyScriptIsRunning" and allow the execution of the second script ONLY if that file exists.

If it exits the second script delete it and starts otherwise it dont work or leave a error message.

The same idea can be applied with a windows variable or a Registry value.

Is it more clear now?

Link to comment
Share on other sites

No - he wants to protect 2.exe: so that it can only be run in a special and secret way (viz. by launching it via 1.exe, which i guess he will cleverly keep on a thumb drive or something :ph34r: )

Sorry bout that ... was half asleep and had never realized the variable wouldn't be available in the 2nd exe.

Now that i'm awake, i'm curious as to why 2 files are neccessary here. If 1.exe is required to run 2.exe why not just have 1.exe do everything? You could set up parameters to restrict its use. If 1.exe is required to run 2.exe then you could simply fileinstall 2.exe instead of leaving it on the machine ... it's not going to work unless you have access to 1.exe anyway.

 

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

You could use EnvSet and EnvGet..... The variable will only be accessible to 1.exe and 2.exe

;Parent Script 1.exe

EnvSet("foo")

Run("2.exe")

Exit

;Child Script 2.exe

If EnvGet("foo") == "something" Then ....

To answer the question psichosis had:

You sometimes need multiple scripts if you wnat multiple GUI windows:

AutoBuilder contains Main.exe which calls Helper.exe.... But I only want the user to run Main.exe

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

The main problem with using command line parameters is that simple programs like process explorer from sysinternals.com will tell you what command line a program was called with.

<{POST_SNAPBACK}>

Excatally. For what you want, there is reduced security in using more files than is required, since it opens up the ability to break, intercept, or otherwise disrupt the security process.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

To answer the question psichosis had:

You sometimes need multiple scripts if you wnat multiple GUI windows:

AutoBuilder contains Main.exe which calls Helper.exe.... But I only want the user to run Main.exe

<{POST_SNAPBACK}>

This is true ... forgetted 'bout the GUI limitation :ph34r:

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

This is true ... forgetted 'bout the GUI limitation :ph34r:

<{POST_SNAPBACK}>

A way to keep it more secure and still use multipile GUI's with less fear of reverse engineering is to create all 2nd instance code (and other's are required) within the main script as a command line paramater test. Just have the first instsance launch a 2nd instance of the same script with modified paramaters (probably also including the original password.) That way no one could create a 2nd exe to detect the parameters since you can't edit the application while it's running.

Not to say that you're hack-proof, but you're safer than FileInstalling temp files that could theoretically be changed before you run them.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

A way to keep it more secure and still use multipile GUI's with less fear of reverse engineering is to create all 2nd instance code (and other's are required) within the main script as a command line paramater test. ......

:(FAQ #14 shows how to check if a script is already running.... so you could use this idea as follows:

; Primary script 
$g_szVersion = "My Script 1.1"
If WinExists($g_szVersion) Then secondaryScript(); It's already running
AutoItWinSetTitle($g_szVersion)
; Rest of your script goes here 
Exit

Func secondaryScript()
;...
EndFunc

Lots of ways to do this. I'll be watching this thread for other's ideas :lol:

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

What about using processexists() or winexists with a hidden in your 2.exe to look for 1.exe if 1.exe isn't active then 2.exe just quits.

or

write registry key with date/time, 2.exe checks date/time set by 1.exe, if not within X of current date/time; quit.

Link to comment
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
 Share

  • Recently Browsing   0 members

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