Sign in to follow this  
Followers 0
manav

compiling one script(exe) using the other

28 posts in this topic

#1 ·  Posted (edited)

Hi guys,

this is my first post on the autoit forum. I am using autoit for a while and I find it can do just about everything vb script can do. Its just awesome. Now a question which is very important for me.

;;;;;;;;;;;;;;I have 2 scripts

;;;;;;;;;;;;;; Script1

#include <GUIConstants.au3>

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0)

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

;;;;;;;;;;;;; Script2

MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)

; END

Now my question :

I do not want to add script 1 in script 2 by using #include<script1.au3> . I know it works but not in the way I want because it will run the script1.au3 always and I do not want that.

1. The IT department just wants to run script1. After running the executable for script1 the values should be passed to script2. Script 2 should now have the values for $domain, $username , $passwd. It should retain this value

2. If 1. is not possible then I want the script1.exe to be run by the IT person and after running it, it should automatically generate a decompilable script2.exe with a msgbox displaying the fields entered in Script1.

In other words Script2.exe should retain the value passed to it once.

Please advise. It is urgent.

Edited by manav

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There's a few thoughts crossing my mind on this.

you can

1) file Install a compiled script2 into script1

2) I take it writing usernames, password, etc is not really a question of writing to a text or ini file so that the second app reads from the first. So use the input/output functionality provided in ConsoleRead, ConsoleWrite, ConsoleWriteError, StdoutRead, StderrRead, StdinWrite, Run. I wrote something on this not so long ago, it should do the job.

here's the link:

Applications that talk to one another

try this

About retaining values, do you mean after exit?

IVAN

Edited by ivan

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi guys,

this is my first post on the autoit forum. I am using autoit for a while and I find it can do just about everything vb script can do. Its just awesome. Now a question which is very important for me.

;;;;;;;;;;;;;;I have 2 scripts

;;;;;;;;;;;;;; Script1

#include <GUIConstants.au3>

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0)

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

;;;;;;;;;;;;; Script2

MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)

; END

Now my question :

I do not want to add script 1 in script 2 by using #include<script1.au3> . I know it works but not in the way I want because it will run the script1.au3 always and I do not want that.

1. The IT department just wants to run script1. After running the executable for script1 the values should be passed to script2. Script 2 should now have the values for $domain, $username , $passwd. It should retain this value

2. If 1. is not possible then I want the script1.exe to be run by the IT person and after running it, it should automatically generate a decompilable script2.exe with a msgbox displaying the fields entered in Script1.

In other words Script2.exe should retain the value passed to it once.

Please advise. It is urgent.

Read the help file on Command Line Parameters.

Script One:

; Script1.au3
; It doesn't matter if you compile this one or not...
$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)
$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0) 
$password = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)
Run(@ScriptDir & '\Script2.exe "' & $domain & '" "' & $username & '" "' & $password & '"')oÝ÷ Ù'+S®¶­sc²67&C"æS0£²×W7B&R6ö×ÆVB267&C"æWRæBâFR6ÖRF&V7F÷'267&Cà¢b33c¶FöÖâÒb33c´6ÖDÆæU³Ð¢b33c·W6W&æÖRÒb33c´6ÖDÆæU³%Тb33c·77v÷&BÒb33c´6ÖDÆæU³5Ф×6t&÷cBÂgV÷Cµ67&BGvògV÷C²ÂgV÷CµFRæf÷&ÖFöâ÷RVçFW&VBgV÷C²fײ5$Äbfײð¢F"fײgV÷C´FöÖã¢gV÷C²fײb33c¶FöÖâfײ5$Äbfײð¢F"fײgV÷CµW6W&æÖS¢gV÷C²fײb33c·W6W&æÖRfײ5$Äbfײð¢F"fײgV÷Cµ77v÷&B¢gV÷C²fײb33c·77v÷&B

:whistle:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Read the help file on Command Line Parameters.

Script One:

; Script1.au3
; It doesn't matter if you compile this one or not...
$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)
$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0) 
$password = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)
Run(@ScriptDir & '\Script2.exe "' & $domain & '" "' & $username & '" "' & $password & '"')oÝ÷ Ù'+S®¶­sc²67&C"æS0£²×W7B&R6ö×ÆVB267&C"æWRæBâFR6ÖRF&V7F÷'267&Cà¢b33c¶FöÖâÒb33c´6ÖDÆæU³Ð¢b33c·W6W&æÖRÒb33c´6ÖDÆæU³%Тb33c·77v÷&BÒb33c´6ÖDÆæU³5Ф×6t&÷cBÂgV÷Cµ67&BGvògV÷C²ÂgV÷CµFRæf÷&ÖFöâ÷RVçFW&VBgV÷C²fײ5$Äbfײð¢F"fײgV÷C´FöÖã¢gV÷C²fײb33c¶FöÖâfײ5$Äbfײð¢F"fײgV÷CµW6W&æÖS¢gV÷C²fײb33c·W6W&æÖRfײ5$Äbfײð¢F"fײgV÷Cµ77v÷&B¢gV÷C²fײb33c·77v÷&B

:whistle:

Thanks for your post mate but the solution is no useful for me. I know how to use $CmdLine but it is not a olution for me. I want the values from script1.exe to be passed to script2.exe and it(script2.exe) should retain the value or compile another autoit decompilable script say for example script3.exe with those values. Please note that the script3.exe should then run independently and not be dependent on any other script

Share this post


Link to post
Share on other sites

There's a few thoughts crossing my mind on this.

you can

1) file Install a compiled script2 into script1

2) I take it writing usernames, password, etc is not really a question of writing to a text or ini file so that the second app reads from the first. So use the input/output functionality provided in ConsoleRead, ConsoleWrite, ConsoleWriteError, StdoutRead, StderrRead, StdinWrite, Run. I wrote something on this not so long ago, it should do the job.

here's the link:

Applications that talk to one another

try this

About retaining values, do you mean after exit?

IVAN

Thanks for your reply. I tried what you said but autoit3 doesnt have the StdIn and console functions. Also even if they were there I dont think it would be any useful to me.

What I want is this :

I want the values from script1.exe to be passed to script2.exe and it(script2.exe) should retain the value or compile another autoit decompilable script say for example script3.exe with those values. Please note that the script3.exe should then run independently and not be dependent on any other script

OR

Script1.exe after running compiles another decompilable Script2.exe . The values once passed from Script1.exe are used to make Script2.exe. how is that??

Share this post


Link to post
Share on other sites

y dont u turn script one into a function?

Share this post


Link to post
Share on other sites

y dont u turn script one into a function?

I want script1.exe to generate script2.exe with the values passed to it. How to do it, thats what I wanna know?

Share this post


Link to post
Share on other sites

EnvSet() and EnvGet() if you're not going to use $CmdLine[0] (don't understand why). If you really want to get silly, and it's a huge script you could use /AutoIt3ExecuteScript (for true generation) demonstrated here: http://www.autoitscript.com/forum/index.ph...st&p=187268.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

EnvSet() and EnvGet() if you're not going to use $CmdLine[0] (don't understand why). If you really want to get silly, and it's a huge script you could use /AutoIt3ExecuteScript (for true generation) demonstrated here: http://www.autoitscript.com/forum/index.ph...st&p=187268.

I know what you are saying.

Firstly, I want the IT team to use my script to build an exe program. They will not have autoit installed.

They will run script1.exe which will then make script2.exe based on the values input by the user.

Secondly, Using environment variables is not a good option as they would be visible. Once deleted, how can script2.exe retain the values passed to it.

Please suggest..................................

Share this post


Link to post
Share on other sites

I know what you are saying.

Firstly, I want the IT team to use my script to build an exe program. They will not have autoit installed.

They will run script1.exe which will then make script2.exe based on the values input by the user.

Secondly, Using environment variables is not a good option as they would be visible. Once deleted, how can script2.exe retain the values passed to it.

Please suggest..................................

Well, let's take a completely different approach to your question since you've shot down every idea but /AutoIt3ExecuteScript (and probably shot that down without understanding ho it works (going off your itteration of "exe").

So, since it seems you know what you want, how would you do this in any other language your familiar with, then maybe we can go from there.... Because the only choices I can think of are:

1. Write the values to the Registry from 1.exe and have 2.exe read them

2. Create an ini file and have 1.exe write the values for 2.exe to read

3. Create a file and have 1.exe write the values for 2.exe to read

4. Create a hidden GUI from 1.exe putting values into said GUI and haveing 2.exe read them

5. Use EnvSet/EnvGet

6. Use $CmdLine[0]

7. Use /AutoIt3ExecuteScript from 1.exe to generate 2.exe with ready made variables


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well, let's take a completely different approach to your question since you've shot down every idea but /AutoIt3ExecuteScript (and probably shot that down without understanding ho it works (going off your itteration of "exe").

So, since it seems you know what you want, how would you do this in any other language your familiar with, then maybe we can go from there.... Because the only choices I can think of are:

1. Write the values to the Registry from 1.exe and have 2.exe read them

2. Create an ini file and have 1.exe write the values for 2.exe to read

3. Create a file and have 1.exe write the values for 2.exe to read

4. Create a hidden GUI from 1.exe putting values into said GUI and haveing 2.exe read them

5. Use EnvSet/EnvGet

6. Use $CmdLine[0]

7. Use /AutoIt3ExecuteScript from 1.exe to generate 2.exe with ready made variables

Hmm, I have considered all the things you have suggested. Say for example we put the value in the environment variable using script1.exe. Then script2.exe will read the values from the these environment variable; but only if we do not delete those. In my case I want to delete those.

I tried using what you had earlie suggested. Here is my code for script1.au3

;;;;;;;;;;;;;; Script1 
#include <Constants.au3>
#include <GuiConstants.au3>

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0) 

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

Local $line1 = 'MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)'

$file = FileOpen("script2.au3", 1)
FileWrite("script2.au3", $line1)
FileClose("script2.au3")
Run(@AutoItExe & " /AutoIt3ExecuteScript script2.au3")

;;;;;;; End

Compiling and running the above script I got an uncompiled script2.au3 as below :

MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)

Problems :

1. Script2.au3 was not compiled to form script2.exe

2. How do I pass the values $domain, $username & $passwd

Share this post


Link to post
Share on other sites

You have to remember that this is going to be written to a file, so syntax is important, your quotes are wrong for the MsgBox which is why it isn't working:

;;;;;;;;;;;;;; Script1
#include <Constants.au3>
#include <GuiConstants.au3>

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0)

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

Local $line1 = 'MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & "' & $domain & '" & " Username: " & "' & $username & '" & " Password :" & "' & $passwd & '")'

$file = FileOpen("script2.au3", 2)
FileWrite("script2.au3", $line1)
FileClose("script2.au3")
Run(@AutoItExe & " /AutoIt3ExecuteScript script2.au3")

;;;;;;; End
This is a pain to do, but once you get the hang of it thinking that you have to make it still run as a script would or a compiled .exe would... helps a tad.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Hmm, I have considered all the things you have suggested. Say for example we put the value in the environment variable using script1.exe. Then script2.exe will read the values from the these environment variable; but only if we do not delete those. In my case I want to delete those.

I tried using what you had earlie suggested. Here is my code for script1.au3

CODE

;;;;;;;;;;;;;; Script1

#include <Constants.au3>

#include <GuiConstants.au3>

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1 , 0, 0)

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

Local $line1 = 'MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)'

$file = FileOpen("script2.au3", 1)

FileWrite("script2.au3", $line1)

FileClose("script2.au3")

Run(@AutoItExe & " /AutoIt3ExecuteScript script2.au3")

;;;;;;; End

Compiling and running the above script I got an uncompiled script2.au3 as below :

MsgBox (0, "", "The information you entered" & @CRLF & "Domain: " & $domain & " Username: " & $username & "Password :" & $passwd)

Problems :

1. Script2.au3 was not compiled to form script2.exe

2. How do I pass the values $domain, $username & $passwd

If you want Script1 to write Script2:

; Script1.au3
; Generates code for Script2.au3

$domain = InputBox("Question 1 of 3 ", "What is the domain name", "Domain1", "", -1, -1, 0, 0)

$username = InputBox("Question 2 of 3", "What is the local Administrator account named", "", "", -1, -1, 0, 0)

$passwd = InputBox("Question 3 of 3 ", "Enter the password for the local Administrator account", "", "*", -1, -1, 0, 0)

$file = FileOpen("script2.au3", 2)

$WriteLine = '$domain = "' & $domain & '"'
FileWriteLine($file, $WriteLine)

$WriteLine = '$username = "' & $username & '"'
FileWriteLine($file, $WriteLine)

$WriteLine = '$passwd = "' & $passwd & '"'
FileWriteLine($file, $WriteLine)

$WriteLine = 'MsgBox (64, "Script2 Results", "The information you entered" & @CRLF & "Domain:  " & $domain & @CRLF & "Username:  " & $username & @CRLF & "Password:  " & $passwd)'
FileWriteLine($file, $WriteLine)

FileClose($file)

Run(@AutoItExe & " /AutoIt3ExecuteScript script2.au3")oÝ÷ ØÚ0ü¨»§¶+¢jbçcºË©àzØ^Féåw­¡Ê&¦)^IÊâ¦Ý»|"¶®¶­sdWC&WRæWRöâ67&C"æS

I still don't get the environment that calls for this, but I think that get what you want... :whistle:

Edit: Tweaked for FileWriteLine()...

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I still think the problem is not laid out clearly. It would seem to you and any reasonable person that certain values should be inaccessible because of their mere nature, namely account loggin data, read this as user names & passwords.

So, writing to a file would compromise security and would probably be undesired (either txt or ini).

This probably led you to think of your procedure, which sounds altogether complex, to say the least, and a bit out of my league.

So, you might say, why am I trying to offer a contribution if no solution is proposed? Because you might want to reconsider writing to a file...

This is a little dirty trick I've been meaning to do for a while, but haven't really gotten to develop totally, yet...

I've done this manually and know it works, but haven't automated the solution, so I'll share it with you so that you can give it a shot.

Take a bmp file you don't really care about, change the extention manually to a standard text, open it in notepad, delete a large chunk of the file so it's under 8 kb, write some text in it, save it back to as bmp.

Now you really fucked up the file, but it's safe for text reading, so next time you want to read text from it, change the estention back to text and try to locate the text in the file.

In order to automate the procedure, you can write a constant in the file which does not repeat itself, or even better, work out your own algorithm, say every n chars increased by m, locate char x, and put your encrypted text in it. Close this by another algorithm and you have a safe confidential info saving location. If you want to rename the file every time you open it, you can change the time date stamp on the file to a year you can recognize, say 1969, when led zeppelin launched album I. Locate the file in a really obscure place where people will never find it. This, because you don't want people to delete it, rather than crack you

Do the inverse mechanism on the secon exe.

If someone cracks you, they deserve a medal, otherwise you can remain happy.

If you know what to look for (say davinci code finders), or how to find it (that's you) you'll get yout info.

And by the way, don't go round saying you've got a really good way of storing confidential data, as it might tempt others to shut you up.

IVAN

Edited by ivan

Share this post


Link to post
Share on other sites

Manav:You are wanting to release a trojan to your IT department for them to deploy across your organisation to find everybody's security attributes? Good luck - you'll need it for job hunting. Make sure your mom knows what prison to bring you food to.

Ivan: If I find a file that shouldn't be there and it has recently been modified, then I would be looking at it very closely. How long do you think it would take somebody to reverse your algorithm, or even track back to the source of the modifying program?

Share this post


Link to post
Share on other sites

Manav:You are wanting to release a trojan to your IT department for them to deploy across your organisation to find everybody's security attributes? Good luck - you'll need it for job hunting. Make sure your mom knows what prison to bring you food to.

Ivan: If I find a file that shouldn't be there and it has recently been modified, then I would be looking at it very closely. How long do you think it would take somebody to reverse your algorithm, or even track back to the source of the modifying program?

Well Mr. Confuzzled, I am doing more deep coding than you can think off. Obviously I cannot release the details here for security reasons. If I can get script1.exe to write a program script2.exe with the values passed by the user then my problem is solved. Gotcha buddy?? but I havent got any solution to it till now. If anyone has please lemme know.

To SMOKE_N . your solution doesnt work. It just runs in loops. compile the cript and try please

Cheers

Share this post


Link to post
Share on other sites

Works for me... What AutoIt are you using?

P.S., if it's a security risk to post something your doing here in AutoIt... you may want to look at doing what you want in another language.... It's not a very secure method of performing "Top Secret" type of things.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Works for me... What AutoIt are you using?

P.S., if it's a security risk to post something your doing here in AutoIt... you may want to look at doing what you want in another language.... It's not a very secure method of performing "Top Secret" type of things.

I am using AutoitV3. I know it is not a very secure method but the script is good I guess as long as it it is decompilable.

Also Script1.exe that you sent me runs in loops. On running script1.exe script2.au3 is created but the actual values entered by the user are not passed across. It just contains $domain, $username and $passwd. So yea. No .exe file is created.

Share this post


Link to post
Share on other sites

It's not decompilable (even if you check it not to be, that's why I said what I said)...

You can't compile an .exe from within a script with out using Aut2Exe.exe.

You can run a "script" from an .exe as an .exe but it's not compiled period.

I didn't send you anything, I merely showed you your mistakes, and it does work... should be using AutoItv3.2 not 3.1.1


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

It's not decompilable (even if you check it not to be, that's why I said what I said)...

You can't compile an .exe from within a script with out using Aut2Exe.exe.

You can run a "script" from an .exe as an .exe but it's not compiled period.

I didn't send you anything, I merely showed you your mistakes, and it does work... should be using AutoItv3.2 not 3.1.1

mate, can u send me script1.exe then please. The one u have compiled using your auto it version. I am using 3.1.1

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