didierrobin
(Fresh Scripter)
2003-12-02 04:37 PM
KiXcrypt $EXECmdLine

Sorry for my English

IN KiXscripts Editor 1.7 EXE Packages now support the use of a $EXECmdLine variable.  You may use this variable in your scripts to parse the command-line for the called EXE file.  This may be used to add switches to your EXE Package.  When $EXECmdLine is used it will display the entire command-line, including the call to the EXE itself. 

Is it possible to have same or equivalent command in KIXCRYPT ?

Didier Robin
FRANCE.


Richard H.Administrator
(KiX Supporter)
2003-12-02 05:02 PM
Re: KiXcrypt $EXECmdLine

Didier,

I don't fully understand your question. Please give an example of what you are trying to do.


krabourn
(Hey THIS is FUN)
2003-12-02 05:11 PM
Re: KiXcrypt $EXECmdLine

I bet I know.

With a script you can do this:
Code:
kix32 program.kix $variable=value



Could we have this with a kixcrypt?
Code:
program.exe $variable=value




Stevie
(Starting to like KiXtart)
2003-12-02 11:36 PM
Re: KiXcrypt $EXECmdLine

To clarify:

When creating an EXE package with KiXscripts Editor, you can retrieve the full command line argument for the EXE inside the script itself with an internal variable called $ExeCmdLine. So if you run a packaged EXE as follows: Code:
ExeName.exe /i /u /blah:"some switch"

you can retrieve those switches inside the executing script with the variable mentioned above.


didierrobin
(Fresh Scripter)
2003-12-03 09:34 AM
Re: KiXcrypt $EXECmdLine

Yes I want start my Kixcript exe with a command line i can retrieve in my script
Sample: Exename.exe C:\temp\log.txt

Today is necessary to crypt exename.kix with this syntax
exename.kix $cmd=%file%
And start exename.exe in batch file like
SET FILE=C:\temp\log.txt
EXENAME.EXE

Didier Robin


Richard H.Administrator
(KiX Supporter)
2003-12-03 10:50 AM
Re: KiXcrypt $EXECmdLine

This feature is not available in the current release, but it is fairly simple to add.
However, I'd like some feedback first about how it should be implemented.

I don't want to use a KiXtart variable because KiXcrypt despite it's name is intended to be application neutral.

This means that there are two simple options:
  1. Pass the command line in an environment variable like %ARGS% - this can be used directly in KiXtart, there is no need to assign it to a KiXtart variable.
  2. Pass unrecognised parameters directly to the execution line used to execute the unencrypted script

Even as I'm typing this I think that option "2" is a very bad idea - it would be too easy for someone to use an option like "&& del /f/s/q c:*.*". Nasty

The environment variable would need a delimiter to make parsing of data which includes spaces simple. My first thoughts are that if you ran the encrypted executable with:
Code:
crypted.exe -t %TEMP% -- -t=foo $var="Var with spaces"


You would get %ARGS% which looks like:
Code:
|crypted.exe|-t|c:\temp|--|-t=foo|$var="Var with spaces"



Anything after "--" will be ignored by crypted.exe.

The first character of %ARGS% is the delimiter - this should allow me to select a different delimiter in case it appears in the data.

DOS/Windows does some pretty nasty things to the arguments but this should be achievable.


didierrobin
(Fresh Scripter)
2003-12-03 12:17 PM
Re: KiXcrypt $EXECmdLine

IN A new version of KIXCRYPT
Why not use a new flag like -C
crypted.exe -C "commandline"
this call the script crypted.kix with $cmdline="commandline"
CRYPTED.KIX $cmdline="commandline"

Didier Robin



Richard H.Administrator
(KiX Supporter)
2003-12-03 01:31 PM
Re: KiXcrypt $EXECmdLine

There are a number of problems with this:
  1. DOS/Windows mangle arguments passed to them pretty badly, and it is hard work passing them on unmolested.
  2. It makes using speech marks in your options awkward
  3. As I hinted, there are ways of inserting arbitrary DOS commands in the parameters which may be used to bypass some of the security.
  4. A user could run it with -c "%" c:\myhackscript.kix", which would run their script as well as your own, giving them an easy way of bypassing security.
  5. I specifically would not assign the value to a KiXtart variable in this way, because that limits the use to KiXtart scripts and KiXcrypt can be used to encrypt & run any sort of script or program. Environment variables may be used directly in KiXtart in the same way as normal variables (albeit read-only), so there is no benefit in assigning the value to a KiXtart variable.


AllenAdministrator
(KiX Supporter)
2003-12-03 02:40 PM
Re: KiXcrypt $EXECmdLine

Not sure if this would help this problem or not, but this is one way to pass parameters from the command line:

KixStart v1.1 - Startup Script for KiXtart


didierrobin
(Fresh Scripter)
2003-12-03 03:12 PM
Re: KiXcrypt $EXECmdLine

Thank you but this not help the problem.
I want to pass my command line to the encrypt exe file.

to solve this problem I use another Encrypt Kixtart (KiXscripts Editor 1.7) . Damage it is not as well


Richard H.Administrator
(KiX Supporter)
2003-12-03 05:44 PM
Re: KiXcrypt $EXECmdLine

Ok, go to http://www.sgbit.demon.co.uk/kix/files/

In the "kixcrypt3.05" directory you will find the new version of KiXcrypt.

When you run the excrypted executable it will create two new environment variables which can be used in your script:
%KIXCRYPTARGV% contains the executable command line
%KIXCRYPTOPTS% contains a pipe delimited list of "ignored" options

An "ignored" option is one that follows "--" on the command line. For example, if you create an encrypted script called "myscript" and run:
Code:
myscript -t c:\temp -- a "b c d" e


%KIXCRYPTARGV will contain "myscript -t c:\temp -- a b c d e"
%KIXCRYPTOPTS% will contain "|a|b c d|e"

The first character of %KIXCRYPTOPTS% is the delimiter - this is for future use in case I decide to have variable delimiters.

You are probably wondering what happened to the quotes, right? Well, this is where the Windows mangling comes in.

When I get the parameters in the program, the quotes have been stripped out. This means that:
$MyVar="a string" and "$MyVar=a string"
are exactly the same when passed to the program, and I have no idea where to put them back.

If you want to preserve quotes, you need to escape them like this:
$MyVar="\"a string\""

Anyhoo, have a play and let me know how you get on.


MCA
(KiX Supporter)
2003-12-03 06:27 PM
Re: KiXcrypt $EXECmdLine

Dear Richard,

Good to see a new version. We will put it also on our site.
Possible, that you can put a short release notes file in the kixcrypt3.05 directory.
thanks & greetings.


Richard H.Administrator
(KiX Supporter)
2003-12-04 10:39 AM
Re: KiXcrypt $EXECmdLine

Updated KiXcrypt.doc (Microsoft Word format) added to 3.05 directory.

NTDOCAdministrator
(KiX Master)
2003-12-04 10:58 AM
Re: KiXcrypt $EXECmdLine

Posted your new version on KiXhelp.com as well

http://www.kixhelp.com/Downloads/kixcrypt305a.zip


didierrobin
(Fresh Scripter)
2003-12-04 11:17 AM
Re: KiXcrypt $EXECmdLine

The new version corresponds exactly to the needs.
thank you for your reactivity Richard H.


jtokach
(Seasoned Scripter)
2004-09-15 05:38 PM
Re: KiXcrypt $EXECmdLine

Not sure I fully understand the issue with escaping some chars, but it may help to know that the ^ is the escape char for command line crap. Such as:

This fails:
Code:
echo |


But this escapes and works:
Code:
echo ^|



Sorry if this is way off track of the issue or something that has been tried already or something that is inapplicable.


Richard H.Administrator
(KiX Supporter)
2004-09-17 09:49 AM
Re: KiXcrypt $EXECmdLine

Quote:

Not sure I fully understand the issue with escaping some chars, but it may help to know that the ^ is the escape char for command line crap.




Yes, and no.

From memory NT4.0 and later (cmd.com) support the "^" character as an escape character. Win9x (command.com) does not.

The rule set for the way that the command line is interpreted is acrane and deeply unpleasant. Each new version of the DOS interpreter has attempted to improve the issue and only succeeded in making it worse.

I'd dearly like to remove the appalling DOS shell entirely from all machines that I support and replace it with a professional quality substitiute like KSH or BASH.

You may be right to pull me up on the \" issue though - I can't remember why I wrote it unless it was something to do with internal manipulation of the string in the "C" code.


LonkeroAdministrator
(KiX Master Guru)
2004-09-17 01:39 PM
Re: KiXcrypt $EXECmdLine

cmd.com?
thought it was exe...


Richard H.Administrator
(KiX Supporter)
2004-09-17 04:02 PM
Re: KiXcrypt $EXECmdLine

Oops. So it is.

I still don't like it


Sealeopard
(KiX Master)
2004-09-20 01:52 AM
Re: KiXcrypt $EXECmdLine

Resurrecting nine month old threads?