Jump to content
Sign in to follow this  
Dgameman1

Is it possible to make a program load it's code from a txtfile?

Recommended Posts

Dgameman1

Let's say I have a website called www.Dgameman1.com/AutoIt.txt

Would it be possible so that when the program loads. It goes to www.Dgameman1.com/AutoIt.txt and then the program would use the code on that webpage to run itself? Like..

Can I put the programs code on a txtfile online and when the program loads up, the programs code is taken from that textfile on www.Dgameman1.com/AutoIt.txt ?

I would like this so that there is no download needed when I update my program for others to use.

Any idea?

Edited by Dgameman1

Share this post


Link to post
Share on other sites
Beege

Downloading a script and then launching that script with the compiled exe that you use to download the script is very possible and easy. Reading that code and executing it from the very same script gets really complicated. Theres functions like execute(), assign(), eval() that can be used but like I said, complicated.

Share this post


Link to post
Share on other sites
Unsigned

Here's a quick and dirty solution I wrote up in about 30 seconds. Error checking is left as an exercise for the reader. :graduated:

#Include <File.au3>
 
Func RunScriptFromURL($url)
    Local $tmp = _TempFile(@TempDir, "~", ".au3")
    InetGet($url, $tmp)
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $tmp)
    FileDelete($tmp)
EndFunc

This will work in compiled and uncompiled scripts alike.

Edited by Unsigned

.

Share this post


Link to post
Share on other sites
Dgameman1

Here's a quick and dirty solution I wrote up in about 30 seconds. Error checking is left as an exercise for the reader. :graduated:

#Include <File.au3>
 
Func RunScriptFromURL($url)
    Local $tmp = _TempFile(@TempDir, "~", ".au3")
    InetGet($url, $tmp)
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $tmp)
    FileDelete($tmp)
EndFunc

This will work in compiled and uncompiled scripts alike.

I'm actually very confused on how to use that script. A dumbed down version of that please? =P

Share this post


Link to post
Share on other sites
Beege

To dumb it down, try to think of any "compiled" autoit script as zip file that has the main autoit.exe (the one thats in your ProgramFiles directory) and your au3 script wrapped up into one file. Because the compiled autoit script contains the real autoit.exe inside it, any compiled autoit script is capable of launching any other autoit script the same way scite does for you. Look in the help file under Command Line Parameters for more info about that. The macro @autoitexe has two meanings. Either The full path and filename of the AutoIt executable currently running or for compiled scripts it is the path of the compiled script. This means that

RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $tmp)

is using that internal autoit.exe I just talked about to execute the $tmp script.

Share this post


Link to post
Share on other sites
DeltaRocked

This logic / topic has all the signs of a malware. but anyway . nice. download something from the net and then execute it on the pc... hmmmm

Edited by deltarocked

Share this post


Link to post
Share on other sites
Dgameman1

This logic / topic has all the signs of a malware. but anyway . nice. download something from the net and then execute it on the pc... hmmmm

It's really not. Do you not think that it would be amazing to never have to download something ever and have it constantly updated?

Share this post


Link to post
Share on other sites
DeltaRocked

yup... but due to my job profile I have to always think like a malware author. An obfuscated script will be a bit better... or an encrypted txt file which is decrypted and then executed. after execution the tmp file is overwritten and deleted.

#Include <File.au3>

Func RunScriptFromURL($url)
    Local $tmp = _TempFile(@TempDir, "~", ".au3")
    InetGet($url, $tmp)
    ; decrypt
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $tmp)
    FileDelete($tmp)
EndFunc
Edited by deltarocked

Share this post


Link to post
Share on other sites
Unsigned

This logic / topic has all the signs of a malware. but anyway . nice. download something from the net and then execute it on the pc... hmmmm

How is that different from any program which updates itself via web?

It's really not. Do you not think that it would be amazing to never have to download something ever and have it constantly updated?

I agree with you. However, you should take precautions against the event of a server hijack. If someone was able to modify or replace your downloaded script, it could mean hell for your users (and your PR).

Suggestion: It would be worth looking into asymmetric encryption. Encrypt the server-side copy offline with your private key before uploading. Then have your launcher download it, decrypt it with your public key and run a hash check on it. That way you can be assured nobody has tampered with or replaced it. This method is used by many antivirus providers to secure their updates.

Edited by Unsigned

.

Share this post


Link to post
Share on other sites
Unsigned

I'm actually very confused on how to use that script. A dumbed down version of that please? =P

@AutoItExe automatically expands to the interpreter path. For uncompiled scripts (.au3), this will be the main AutoIt interpreter. For compiled scripts, this will be the .exe itself. Every AutoIt-compiled script contains an instance of the AutoIt interpreter by definition, thus any AutoIt .exe can double as an interpreter by using the /AutoIt3ExecuteScript switch. Edited by Unsigned

.

Share this post


Link to post
Share on other sites
DeltaRocked

Unsigned :

Updating the source with additional modules, I doubt its going to trigger any of the filters .. and AVs are going to miss this unless and until they are into dynamic analysis and blocking. anyway .... but original idea with your insights are gr8 .

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  

×