Richard H.Administrator
(KiX Supporter)
2001-11-28 01:10 PM
UTILITY: KiXcrypt 2.16b - KiXtart encryption

[Moderator (Sealeopard): Moved thread from 'Scripts' to General' forum]

Please see the last messages in this thread for full update information.

Get the small (20 Kb) executable kixcrypt.exe from here.
Get the small (20 Kb) console-less executable wkixcrpt.exe from here.

17 January 2003 Version 2.16b released
Phew, less than a month and another feature release. This release adds the second most requested feature - multiple file inclusion. This means that you can now bundle the KiXtart interpreter, ini files, registry dumps, additional scripts or whatever you fancy with the main script.
Changes
  • Bug fix: A variable scope error meant that files created in a temporary directory using the "-t" feature would not be deleted in some cases.
  • New feature: You may include any number of arbitrary files by using the "-f filename" option. You may repeat the "-f" option as many times as you like, up to a limit of 255 files.
  • New feature: Three environment variables are created when the script is decrypted. These are detailed in a later post.
18 December 2002 Version 2.14b releasedActually, it was released a few days ago, but the board has been down [Frown] It's amazing how much a part of my daily life monitoring the KiXtart BB has become!
Changes
  • A bug in memory allocation causing a failure on Windows XP has been solved. Note, I could not replicate the failure, but testing at the site where the failure occurred suggests it has been resolved. Let me know if it hasn't. Many thanks to ElegantSol for his help in resolving this.
  • The first "cannot find self" error message is no longer displayed. It wasn't particularly useful and would appear on systems which don't expand the command line to include the command extension, such as most NT+ systems.
  • In DEBUG mode non-ASCII characters present on the command line are reported, with their values.
  • Well, you asked for it, now you've got it. Oe of the most popular requests has been for a method of setting the directory that the temporary file is created in. There is now a "-t path" option when you decrypt which will create the temporary file in "path"
Additional Info
The API which retrieves the command line parameters cannot handle 8-bit characters. If you supply an 8-bit character the actual value I get is undetermined.
This restriction has been in place in all version of KiXcrypt, but I have only recently received an email on the subject.
In practice this means that you must stick to 7-bit ASCII characters on the command line. Note, non-printable characters such as the BEL (control-G) or the escape character are fine, so long as you work out a way of passing them on a command line.
7-bit ASCII characters are characters with a decimal value below 128.
The only exception is NULL (Chr(0)), which is an end-of-string terminator. You may have trouble typing CR and LF characters, and the DOS end-of-file mark (control-Z) may cause some oddities as well.

27 March 2002 Version 2.12b released
Changes
  • Feature: The temporary file now overwrites itself before deleting, to avoid exposing the script with undelete utilities.
  • A warning message is issues if the temporary script file does not delete itself, then the file is overwritten and deleted by the controlling program. If the "-k" option has been used the file is overwritten and deleted silently.
5 February 2002 Version 2.10b released
Changes
  • Bug fix: "-s" trojan detection worked ok but didn't exit due to debug code left enabled (Spotter: Roberto M.)
1 February 2002 Version 2.08b releasedChanges
  • Bug fix: Fixed the "Cannot find self" bug. Again.
  • Added "-v" option to display version and full amendment history.
  • Added code to detect and avoid the "Russ Exploit" security issue.
  • Release status changed to beta
7th December Version 2.06a releasedChanges
  • Bug fix: Lazy coding using "realloc()" caused garbage in the command line under Windows XP
  • New option "-c" added. This inhibits "%COMSPEC% /C" being pre-pended to the command.
Thanks go to Peter van der Struis who found the bug and helped in fixing it. The "-c" option was his idea too.
5 December Version 2.04a ReleasedChanges
  • Code now stable enough to optimise [Wink] Compiled with -O2 means is faster, and smaller (back down to 12KB).
  • -p GPF fixed.
  • Temporary file name is now entirely random and changes every time crypted.exe is run. Crypted.exe will attempt 1000 different random file names before giving up.
  • A directory which matches the temporary file name will no longer cause crypted.exe to exit.
30 November Version 2.02a Released- Changed references of KixTart->KiXtart, and KixCrypt->KiXcrypt
- Fixed schoolboy error causing "Cannot open self" bug
- Added alternative syntax "^s" for file name "%s" to avoid environment variable expansion
- Added "-d" debug flag to output previously private debugging information
- Added salt to improve encryption algorithm and deny password attacks.
29 November - "Cannot open self" work-aroundThere is a small bug which means that on some version of windows you may get a "Cannot open self" error, after which the program aborts. The work-around is to use the full program name including the ".exe" extension.
Thanks to KTS for spotting this.
Fixed 30 November

SIMPLE USAGE
The simplest way to use it is:
code:
kixcrypt.exe myscript.kix

This will create an executable called "crypted.exe" in your current directory which contains the encrypted script. NB if there is already a crypted.exe file it will be overwritten without warning. You may rename crypted.exe if you wish. To run the encrypted script, just run crypted.exe. In this mode a random password it used to encrypt the script.

PASSWORD CONTROLLED ACCESS "-p"
If you want to force the user to enter a password to run the script use this form:
code:
kixcrypt -p password myscript.kix

The password is not stored in encrypted.exe.
To run the script use
code:
crypted.exe -p password

The "-p" is optional here so you may just run
code:
crypted.exe password

NB if the wrong password is entered there is no error, but the script which is decrypted will contain garbage.

INHIBIT KIXTART SCRIPT DELETE "-k"
The crypted.exe executable will add KiX script commands to force the file to delete itself when it starts to improve security. If you don't want this feature, use the "-k" switch:
code:
kixcrypt.exe -k myscript.kix

CHANGING THE INTERPRETER COMMAND LINE
By default "kix32.exe" is used to run the script. You may change this by appending a command line to the kixcrypt command. You must include a "%s" on the command line which is replaced with the unencrypted script file name when crypted.exe is run.

You may also want to replace the default command line to pick up KiXtart from a specific directory or share to improve security, or to add KiXtart variables that you don't want to be visible in the script. The command line is encrypted in the binary.

Examples:
1) To avoid trojans, run the version of KiXtart from the logon server:
code:
kixcrypt.exe myscript.kix \\MYLOGONSERVER\NETLOGON\kix32.exe %s

2) Pass the password to the script in case someone grabs the temporary script file:
code:
kixcrypt.exe myscript.kix \\MYLOGONSERVER\NETLOGON\kix32.exe %s "$PASSWORD=OpenSesame"

USING FILES OTHER THAN KIX FILES
Some of you have probably already spotted that kixcrypt can be used to distribute any file, not just KiXtart scripts. Don't forget to use the "-k" switch to stop crypted.exe adding the KiXtart file delete commands. The temprary file will be created with the same suffix as the original file. The command is executed as a "%COMSPEC% /C", so you can use DOS builtins.

Examples:
1) Execute a batch file:
code:
kixcrypt.exe -k mybatch.bat %s

2) Display an html page using the local file association:
code:
kixcrypt.exe -k index.html start %s

3) Distribute a password encrypted update:
code:
kixcrypt.exe -p installpassword -k myprog.exe copy %s myprog.exe

USER DEFINED STARTUP MESSAGE "-m"
If you don't like the startup message displayed by crypted you may define your own using the "-m" option. You may specify the following variables in the text:
$v = KiXcrypt version.
$s = The path of crypted.exe, including the correct name if you have renamed it.
$n = A new line.

Examples:
code:
kixcrypt.exe -m "$s$n$nThis script encrypted with version $v of KiXcrypt" myscript.kix
kixcrypt.exe -m "" myscript.kix

The second example produces no startup message.

CHECKSUM SECURITY "-s"
Ok, so what if you cannot specify the path to a known executable but are worried about someone copying "notepad.exe" to "kix32.exe" and getting access to your script contents?

The "-s" option calculates a checksum for the kix32.exe (or other interpreter) that you would use to execute the script. If you have included a full path for the command line it uses that specific binary, if not it uses the first one it finds in your path. When the "crypted.exe" binary is executed it calculates the checksum for the environment running it and will not decrypt the script if the checksums do not match.

The benefit is that you can be pretty sure that the script is not being run through a trojan, the drawback is that you will need to create a new crypted.exe for each version of KiXtart you want to run it with.

Example:
1) Use the checksum of the first instance of kix32.exe as security:
code:
kixcrypt.exe -s myscript.kix

2) High security - specific executable path and checksum:
code:
kixcrypt.exe -s myscript.kix \\LOGONSERVER\NETLOGON\kix32.exe %s

The first version of this utility had odd problems with platforms other than Win95, but I believe I've made this one portable. Have a go and let me know how you get on.

BUGS
Spaces in script names and paths may cause problems, so avoid them where possible.
Some versions of Windows may produce a "Cannot open self" error - the workaround is to use the full program name with extension i.e. "kixcrypt.exe" rather than just "kixcrypt". Fixed 30 November

Updated BUG and instructions for "kixcrypt.exe" kludge
Changed references from KixTart to KiXtart
Updated for version 2.02a
Updated for version 2.04a
Updated for version 2.06a
Updated for version 2.08b
Updated for version 2.10b
Updated for version 2.12b

[ 27. January 2003, 17:00: Message edited by: sealeopard ]


Bryce
(KiX Supporter)
2001-11-28 04:16 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

wow!!

ShawnAdministrator
(KiX Supporter)
2001-11-28 04:26 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Very nice and well done too. Nicely feature rich !!!

-Shawn

[i wanted to put ten smilies but the UBB filter wouldn't let me - what the heck is going on around here?]

[ 28 November 2001: Message edited by: Shawn ]

Tan Bandradi
(Fresh Scripter)
2001-11-29 04:52 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

It sound very nice, but I could not successfuly create the encrypted file.

I try: kixcrypt kixtart.kix
and the error returned:

kixcrypt: Cannot open self!
kixcrypt: Trying with extension...
kixcrypt: Still cannot open self!
kixcrypt: Bailing out.

I try: kixcrypt d:\kixcrypt\kixtart.kix
and the error returned:

kixcrypt: Cannot open self!
kixcrypt: Trying with extension...
kixcrypt: Still cannot open self!
kixcrypt: Bailing out.

I try: kixcrypt -p password kixtart.kix
and the error returned:

kixcrypt: Cannot open self!
kixcrypt: Trying with extension...
kixcrypt: Still cannot open self!
kixcrypt: Bailing out.

wow!!!

Richard H.Administrator
(KiX Supporter)
2001-11-29 10:16 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Ahhh foo!

I don't know why this happens. One of the first things the program does is to open itself to check if it is in encrypt or decrypt mode. My speciality is Unix rather than Windows, so I'm not experienced enough to tell whether the problem is down to file semantics in different versions of the OS.

Can you guys who've downloaded and tried KixCrypt let me know what version of Windows it ran on and whether or not it worked.

ShawnAdministrator
(KiX Supporter)
2001-11-29 03:17 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard,

I initailially got the same message here. This is what I had to do to get kixcrypt running on my Windows 2000 box:

I created a shortcut called encrypt.lnk with the following specifics:

shortcut->target: c:\kixcrypt.exe c:\test.kix

then I simply started the link from the DOS command prompt. This created an executable called crypted.exe in the root of C:. Hopes this gives you a clue as to waht might be happening !

-Shawn

[ 29 November 2001: Message edited by: Shawn ]

**DONOTDELETE**
(Lurker)
2001-11-29 03:33 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I had the same Problems creating the encrypted KIX-File like Tan Bandradi.

I think the Problem is the call of the Program !!
When you call the program without the extension ".exe"
e.g. "kixcrypt c:\test.kix"
i get an error !!

But when you call the Programm with itīs own extension, like
"kixcrypt.exe c:\test.kix"

it works !!
Hope i could help !!

KST

ShawnAdministrator
(KiX Supporter)
2001-11-29 03:38 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

DOH ! - That works great ... I'm an idiot

Richard H.Administrator
(KiX Supporter)
2001-11-29 03:47 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

No Shawn you are not an idiot, I'm a coding muppet.

The program attempts to open itself - if that fails it adds ".exe" and tries again, so you shouldn't need to do it yourself. This works for Win95 which is the system I'm compiling / testing on. Perhaps the value passed in argv[0] is slightly different on Win2K.

Tan Bandradi - please confirm that using the full executable name "kixcrypt.exe" works for you, and I'll try to dig up a W2K box to play with.

Thanks Shawn, KST for helping debug this.

Tan Bandradi
(Fresh Scripter)
2001-11-30 04:05 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Yes, it works fine now, big thanks!
The encrypted executable file also need to include the .exe extension filename in order to run it.

I need to test it further more on my environment, but actually this is very good, awesome utility and I think this is the more practical and efficient KiXtart script encryption utility, ever!

Tan

Tan Bandradi
(Fresh Scripter)
2001-11-30 10:31 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Hi,
I have couple things that I want to share it with you regarding to this utility, on the following condition:

- KixTart is not installed or copied on all clients and KixTart script extension is not associated to run with Kix32.exe
- All necessary KixTart executable and dll files are copied to netlogon share folder on all DC's, with KXRPC installed.
- I am using Kix 3.63
- All users run KixTart logon script from these DC's, as it is set on User Profile using User Manager. I set my account to run the executable encrypted file for testing.

These are the result according how do I use the kixcrypt command line switchs:

- kixcrypt.exe kixtart.kix
It works fine on WinNT, but I received: 'Bad command or filename' error on Win9x during logon.

- kixcrypt.exe kixtart.kix \\\netlogon\kix32.exe %s
It works fine on Win9x, but I received: 'Script error: failed to find/open script!' on WinNT, it runs kix32.exe but it couldn't find the extracted script.

- kixcrypt.exe kixtart.kix kix32.exe %s
It works on WinNT, but 'Bad command or filename' on Win9x.

Finally, I found out this command line that works on those both Win32's:
kixcrypt.exe kixtart.kix \\\netlogon\kix32.exe kc000000.kix

KC000000.kix is the extracted file of kixtart.kix from the encrypted executable file.

Tan

Richard H.Administrator
(KiX Supporter)
2001-11-30 11:55 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

New version 2.02a released
Main features:
- Changed references of KixTart->KiXtart, and KixCrypt->KiXcrypt
- Running with no parameters gives usage info rather than GPF
- Switches may be defined using Windows syntax e.g. "/d /m message" rather than "-d -m message". This was available in 2.01a, but was undocumented.
- Usage info updated for -m and -d switches
- Fixed schoolboy error causing "Cannot open self" bug
- Added alternative syntax "^s" for file name "%s" to avoid environment variable expansion
- Added "-d" debug flag to output previously private debugging information
- Added salt to improve encryption algorithm and deny password attacks.


Tan, thanks for the excellent feedback. Could you try the new version with the debugging flag set and check what command line is being used - perhaps that will help narrow down the problems you are having.

Also, try these things:
1) Use "%%s" rather than just "%s" - this should stop the OS attempting to expand "%s" to an environment variable. You can also now use "^s" instead of "%%s".
2) The temporary file is created in the current working directory. Make sure this is a writeable directory during the login process.
3) Try forcing a local path e.g.

code:
kixcrypt kixtart.kix \\\netlogon\kix32.exe .\%s


4) The temporary file name is "kcNNNNNN.kix" where NNNNNN starts at 000000. If there is already a kc000000.kix it uses kc000001.kix and so-on, so you should avoid hard-coding the temporary file name.


**DONOTDELETE**
(Lurker)
2001-11-30 01:23 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard !!

Now it looks pretty good
Iīll stay on testing !!
Have a nice Weekend !!

KST

Les
(KiX Master)
2001-12-01 06:35 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard,
Things are looking good. Where I couldn't get your beta version to work at all, 2.02a now works like a charm!


Lofgren
(Lurker)
2001-12-02 08:17 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I would just like to comment that this was very impressive work as well.

ShawnAdministrator
(KiX Supporter)
2001-12-02 09:25 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I'll second that. By the way Richard, are you going to find time to convert your original date math routines to kixtart 4.0 udf's ? That would be bonus !

-Shawn

Tan Bandradi
(Fresh Scripter)
2001-12-03 08:00 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard,
Now the new version works fine, I use ".\%%s" parameter to specify the script filename.

Thanks!
Tan

**DONOTDELETE**
(Lurker)
2001-12-03 08:14 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

You're great!!
I'm work on a highschool and this really solved the problem that students discover how I set up some policies.
KiXcrypt forever!


cj
(MM club member)
2001-12-04 05:40 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

This is fantastic!

I had a similar idea, but I was going to have the new EXE contain the KIX32.exe as well. This would make the encrypted script completely stand alone.

How hard would it be to add that to what you have already done?

cj

pvds
(Hey THIS is FUN)
2001-12-04 08:48 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard,

Is it possible to use "wkix32.exe -i" and get rid of the dos box where crypted.exe is running. We are using wkix32.exe -i for some simple utils, were we do not need any black dos box.

KiXcrypt is the solution for our network with several students who seem to find my kix scripts where ever i put them thanks!!

GR Peter van der Struis

Richard H.Administrator
(KiX Supporter)
2001-12-04 10:56 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Thanks for all the comments guys.

Shawn I never bothered to convert the date math stuff as the functionality is duplicated in the ScriptLogic SerialDate() UDF.

Peter you should be able to run any command as the interpreter. To ensure that the options are not used by KiXcrypt enclose the command in speech marks. Something like:

code:
kixcrypt myscript.kix "wkix32.exe -i .\%%s"

should work. If you are having trouble with the command line use the "-d" flag to generate crypted.exe. When you run crypted.exe it will display the command line it is using.

cj I considered including the kix32 executable earlier on but decided against it. It didn't really add anything so I didn't bother. Having said that it would be very simple to have an option to include the binary (any binary for that matter). For KiXtart specifically there are a couple of issues:
1) Win9x clients will need to have the DLLs present.
2) After all his good works I really don't want to undermine Ruuds "CareWare" policy, and a tool that allows a hidden distribution of KiXtart, however benign, would make me uneasy. Maybe I'm being too sensitive, I dunno. Ruud, if you are following this thread maybe you'd like to comment.

I'm in two minds about it. If there is enough interest and no objections I'll add the functionality and leave it to the user's conscience.

[ 04 December 2001: Message edited by: Richard Howarth ]

MCA
(KiX Supporter)
2001-12-06 12:17 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard,

A very nice upgrade and an excellent job. The first version which doesn't
need a temporary file to past kixtart code to the kix32 binary. The file
is very hard (possible impossible) to catch.
It works fast and is very flexible.
Also the way of passing the password to the script is very nice. Possible
by this one-way encryption method. Encrypting and decrypting program aren't
the same and it is also possible to use all other kind of files/information
to encrypt.
Also a possible security leak with kix32.exe can be catch with the
checksum security -s switch.

Some points:

  • we doesn't get a error message when we want to encrypt a file.
    an example:
    - we have the file "code"
    - 'kixcrypt code' creates the file 'crypted.exe'
    and 'crypted.exe' returns the message 'Script error : failed to find/open script !'
    - 'kixcrypt code.' createsalso the file 'crypted.exe'
    and 'crypted.exe' runs like we expected. no error messages.
  • by using the -d switch the 'crypted.exe' run will also display
    debug information, which can't be stopped.
    is this the wanted result?
  • we get an error when we are using following script with a password
    code:

    ? "kix @kix @build"


    the call are 'kixcrypt -p password script.' and 'crypted password'.
    the output on the screen is:
    code:

    CRYPTED caused a divide error in module CRYPTED.EXE at 014f:00402fe1.
    Registers:
    EAX=00000000 CS=014f EIP=00402fe1 EFLGS=00010246
    EBX=00530000 SS=0157 ESP=0073fc10 EBP=0073fd58
    ECX=78037ca8 DS=0157 ESI=816096fc FS=3a97
    EDX=00000000 ES=0157 EDI=00000000 GS=0000
    Bytes at CS:EIP:
    f7 3d a0 50 40 00 89 d6 89 35 a4 50 40 00 a1 00
    Stack dump:
    00530000 816096fc 815e723c 815bc000 8160de40
    0008160e 000000c0 8160de40 00000010 bff782c8
    815bc000 8160de50 000000c0 00000000 8160de40
    815bc000


    f.e. the same problem we have by encrypted our os.kix of our
    site. without using the -p option we doesn't have any problem.
    we have verify it on a windows95 system for you.
  • we get another error when f.e. the filename 'kc000000' is a directory.
    the message was:
    code:

    Cannot open temp file for writing kc000000.
    Could not open an output script file - aborting


    questions:
    - is it possible to use a random filename, which also check for
    already existing (directory)names.
    - what will happen when the user doesn't have write access to the
    directory for creation of 'kc000000' file.

A nice issue can be the usage of environment variables which can't
prevent running the crypted.exe file in other environments. Specifi-
cations like:
- kixcrypt -p %domain% script.kix
- kixcrypt script.kix \\mylogonserver\netlogon\kix32.exe %s
will always decrypt the script. In the first situation you can simple
enter the another (= required) domain name to bypass it.

we are waiting for an upgrade.
greetings.


btw:
we like to publish your program on our site. let me know what you
think of that idea.

Richard H.Administrator
(KiX Supporter)
2001-12-05 03:28 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

5th December 2001 - Version 2.04a released
New version available here.

Changes

  • Code now stable enough to optimise Compiled with -O2 means is faster, and smaller (back down to 12KB).
  • -p GPF fixed.
  • Temporary file name is now entirely random and changes every time crypted.exe is run. Crypted.exe will attempt 1000 different random file names before giving up.
  • A directory which matches the temporary file name will no longer cause crypted.exe to exit.


Richard H.Administrator
(KiX Supporter)
2001-12-05 04:04 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Hi MCA,
Thanks for your comments, and for doing the quality control testing I should have done before releasing the code

To answer your points:

  • KiXtart script with no suffix.
    The "'Script error : failed to find/open script !" error is a feature (bug?) of KiXtart.
    You will find that "kix32.exe code" will also produce this error, and that "kix32.exe code." will work.
  • -d produces output in crypted.exe
    This is by design. The idea is that you can create a debug version for testing. When you are ready to release to your users you don't use the "-d" flag. NB For security reasons you cannot used the "-d" flag with "crypted.exe" - it has to be set on when you run kixcrypt.exe.
  • -p password causes divide zero error
    Fixed in version 2.04a
  • Temporary file names.
    As of version 2.04a the numbered file name is not used, so cannot easily be guessed. A file name of 8 random upper case letters is used. 1000 of these are tried before the program gives up. Each time crypted.exe is tun the random file names will be different.
  • kc000000 directory.
    As of version 2.04a a directory with the same name as the temporary file will not cause crypted.exe to exit.

The crypted.exe has to create a temporary file because KiXtart cannot accept piped input. The current directory is always used and I probably won't be changing that simply because it would mean a lot of work for very little benefit.
If the directory is not writable by the user you will get the "Cannot open temp file for writing" error.

If you need to redirect the temporary file to another direcectory then "CD" to it before running crypted.exe

You (and anyone else) are more than welcome to publish the KixCrypt utility on your site.

I hope that answers all your questions.

MCA
(KiX Supporter)
2001-12-06 07:54 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard,

We will give it a try.
Soon we will inform you also about the publication of it on our site.
Please inform me when new version will be released.
greetings.

masken
(MM club member)
2001-12-06 05:12 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

This looks great!

..but I feel really dumb here, since I can't figure out the end use of it..?

How do I use this to, for example, make an encrypted script, and then call this script from with in a KiX logonscript? We've got no KiXtart extensions on the clients, and are running v.3.63.

For example, I want to store the password for SU in an encrypted script, and then be able to call it from within my logonscript (and of course it should work with all Win32 clients..)?

It's the calling from within a running script that I don't quite get...

I know i'm [Confused] [Roll Eyes] , but spare with me here [Wink]

Great work btw Richard!

[Moderator disabled malfunctioning link to image]

[ 18. December 2002, 15:52: Message edited by: masken ]


MCA
(KiX Supporter)
2001-12-07 04:28 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard,

We have verify your latest 2.04 version and it works like a charm.
We put it as a Kixtart tool on our site. The general name
will be kixcrypt.exe.
We hope that our description covers your tool.

Symbol on our homepage has been linked to your related http://kixtart.org topic.

Please let me know when a new version is released.
Other input or comment is also welcome.
greetings.

Richard H.Administrator
(KiX Supporter)
2001-12-07 11:21 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

7th December Version 2.06a released
Changes
  • Bug fix: Lazy coding using "realloc()" caused garbage in the command line under Windows XP
  • New option "-c" added. This inhibits "%COMSPEC% /C" being pre-pended to the command.

Thanks go to Peter van der Struis who found the bug and helped in fixing it. The "-c" option was his idea too.

[ 07 December 2001: Message edited by: Richard Howarth ]

Richard H.Administrator
(KiX Supporter)
2001-12-07 02:59 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

7th December: Console-less version

My, the updates are coming thick and fast.

I've compiled a console-less version "wkixcrpt.exe". See the first post of this topic for the URL.

You should be able to use:

code:
wkixcrpt myscript.kix -m "" -c "wkix32.exe -i .\%%s"


To keep the console-less operation. I think.
The '-m ""' is required to stop the startup message being displayed, and '-c' executes the command directly without "%COMSPEC% /C".

wkixcrpt.exe is only available from version 2.06a

klunde
(Lurker)
2001-12-07 03:28 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I've just tried out version 002.06 and find it very usefull except for the fact that the temp file is created in the same directory. Is it possible to specify %temp% or something to change this into a path where users have write access?

I want to use this to encrypt my SU script so that users can install programs under admin account, but now I must create a batch file that moves the users to his/hers temp dir and then fire up the encrypted .exe file

Richard H.Administrator
(KiX Supporter)
2002-02-01 03:43 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

1 February 2002 Version 2.08b released
Changes
  • Bug fix: Fixed the "Cannot find self" bug. Again.
  • Added "-v" option to display version and amendment history.
  • Added code to detect and avoid the "Russ Exploit" security issue.

Full amendment history (from "kixcrypt -v"):

quote:
Version 002.08b
KiXcrypt author: Richard Howarth (rhowarth@sgb.co.uk)

/* AMENDMENT HISTORY:
* 01 February 2002 Version 2.08b R. Howarth
* Promoted to beta release, as it appears to be stable
* Fixed cannot find self bug. Again. Tch.
* Added detection and avoidance for Russ Exploit
* Added '-v' for version info
* Included my name and email address for support purposes. Honest!
* 06 December 2001 Version 2.06a R. Howarth
* (Possibly) fix Windows XP not zeroing realloced area.
* Added '-c' NOCOMSPEC option
* 05 December 2001 Version 2.04a R. Howarth
* Fixed GPF on -p password
* Temporary file is now entirely random (1000 attempts)
* 30 November 2001 Version 2.02a R. Howarth
* Fixed 'Cannot find self' bug.
* Added '-m' to messages.
* Added salt to peturb algorithm, to avoid password attacks.
* KixTart -> KiXtart
* 20 November 2001 Version 2.01a R. Howarth
* Password now assigned automatically
* Simplified output - script.kix -> script.exe
* Command line options allowed.
* 18 September 2001 RMH First public release
*/




Richard H.Administrator
(KiX Supporter)
2002-02-08 05:24 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

5 February 2002 Version 2.10b released
Changes
  • Bug fix: "-s" trojan detection worked ok but didn't exit due to debug code left enabled (Spotter Roberto M.)


Richard H.Administrator
(KiX Supporter)
2002-03-27 11:22 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

27 March 2002 Version 2.12b released
Changes
  • Feature: The temporary file now overwrites itself before deleting, to avoid exposing the script with undelete utilities.
  • A warning message is issues if the temporary script file does not delete itself, then the file is overwritten and deleted by the controlling program. If the "-k" option has been used the file is overwritten and deleted silently.


LonkeroAdministrator
(KiX Master Guru)
2002-03-27 11:29 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

richard, still affraid about the temp-file...
scares like shit.
why you use it when you can crack the piping?


Richard H.Administrator
(KiX Supporter)
2002-03-27 11:38 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

If (when?) KiXtart supports piped input I'll include a switch to avoid the temporary file entirely.

I need to confirm that popen() works with the compiler (MINGW) I'm using and all versions of windows, as I seem to recall that I had some problems with fork() and similar calls.


LonkeroAdministrator
(KiX Master Guru)
2002-03-28 12:07 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

what about pipe script.
like a hack...

call kix with script that has gets $x in it
then that $x is executed with
$=execute($x)

that somewhat does the trick of piping.
what you think?


Richard H.Administrator
(KiX Supporter)
2002-03-28 12:16 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Ahh, there are a couple of problems with the GetS() and Execute() solution.

The first is that I've no idea how KiXtart will manage variable scopes, functions and subroutines when the script is being executed that way. Not to mention loops, conditional structures and so-on. It would work for a strictly linear monolithic script, but I suspect anything more complicated is doomed to failure.

The other more simple problem is what to do when your script has a "Get()" or "GetS()" in it! If you execute them they will pick up the next bit of decrypted script as input [Eek!]


LonkeroAdministrator
(KiX Master Guru)
2002-03-28 12:23 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

yeah...
good point. I thougt that too, but if you parse the code fully to memory and then put it in?
it may (just may) have string limitation...
don't remember what kind of length limitation gets might have?


LonkeroAdministrator
(KiX Master Guru)
2002-03-28 12:27 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

and if script has gets in it...
may want to use 2 kix processes.
say, change lines to open other console for user input/output.


Richard H.Administrator
(KiX Supporter)
2002-03-27 01:58 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I've been playing with this a bit, and it doesn't work very well.

Popen() opens KiXtart and can pipe stuff into GetS, but there is no way of detaching, and it doesn't handle the pipe closeing very well.

What I really need is:
1) A switch for KiX32.exe which will cause it to read the script from stdin rather than a file.
2) When stdin closes, reattach to the tty or console device so that Get and GetS will work.


LonkeroAdministrator
(KiX Master Guru)
2002-03-27 02:38 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

yes yes, but what if that kix process opens new process. isn't the std I/0 also in new process correct?
I know that you need pipe to kix, as many others too.
but it's not gonna happen in near future...


MCA
(KiX Supporter)
2002-03-28 04:22 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard,

Great update. It was already hard to catch temporary file, but now it only
becomes harder to do it.
Possible that Ruud can his current point of view about pipe to kix.
greetings.

btw: this week we will also update our site with it.


**DONOTDELETE**
(Lurker)
2002-07-25 06:42 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

EEP!! I've just redone my scripts and am using KixCrypt to protect the account credentials that I use for SU.EXE from being visible to the users. I thought it was working fine, until now...
Doing a search of my users personal drives, I have now found no less than two dozen of the temporary (randomly named) .kix files that were not deleted after login. These are being left right in the root of my users' personal drives. I'm worse off now that I was before. Now the sensitive password is not only visible to the user, but being presented to them right in their personal drives.

Can anyone offer suggestions?


LonkeroAdministrator
(KiX Master Guru)
2002-07-25 06:59 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

using after logon some sort of deletion stuff which deletes all files ending .kix

also, using my script encryption script does not use any temporary files but only place where the script is decrypted is the memory during execution...

anyway, righard may have something info for you on this...


Richard H.Administrator
(KiX Supporter)
2002-07-26 09:07 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

EEP! indeed.

Jim, can you confirm that you are using version 2.12b?

I've not come across this one before (natch) so any details you can give would help.

KiXcrypt should not output to a file that it cannot delete or overwrite, so the files *should* be deleted, or nulled. KiXtart files contain there own sematics for deleting the file (unless you specify the "-k" switch), so the file is deleted in at least two diffetent places.

Can you confirm that the temporary files contain the script (rather than created empty)?

If you are calling the encrypted script from a batch file you may want to change directory before running it to a known safe directory (%TEMP% or similar) - the temporary file is created in the current working directory, and if you have locked down access to the users root drive there might be some permissions weirdness going on (raised permissions during logon?)

The only way I can think to cause the files to be left behind is if the "-k" flag has been used to defeat the KiXtart script delete semantics, and the KiXcrypt script abends or is killed.

If changing the directory doesn't help, please answer the questions above and include details of your environment.


JochenAdministrator
(KiX Supporter)
2002-07-26 11:07 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Anyone else can verify that clicking page 2 of this topic tries you to connect to a site called nexusglobe.com prompting for a password [Confused] ??!!??

whats going on here then ...


Richard H.Administrator
(KiX Supporter)
2002-07-26 11:10 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

"Masken" included a graphic link in his post (first on this page) to a site which requires a login to access.

Perhaps a kindly moderator could remove the offending link...


Sealeopard
(KiX Master)
2002-07-26 03:54 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Done!

My first Moderator action [Smile]


Richard H.Administrator
(KiX Supporter)
2002-12-19 12:18 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Get the small (15 Kb) executable kixcrypt.exe from here.
Get the small (15 Kb) console-less executable wkixcrpt.exe from here.

18 December 2002 Version 2.14b released
Actually, it was released a few days ago, but the board has been down [Frown] It's amazing how much a part of my daily life monitoring the KiXtart BB has become!
Changes
  • A bug in memory allocation causing a failure on Windows XP has been solved. Note, I could not replicate the failure, but testing at the site where the failure occurred suggests it has been resolved. Let me know if it hasn't. Many thanks to ElegantSol for his help in resolving this.
  • The first "cannot find self" error message is no longer displayed. It wasn't particularly useful and would appear on systems which don't expand the command line to include the command extension, such as most NT+ systems.
  • In DEBUG mode non-ASCII characters present on the command line are reported, with their values.
  • Well, you asked for it, now you've got it. Oe of the most popular requests has been for a method of setting the directory that the temporary file is created in. There is now a "-t path" option when you decrypt which will create the temporary file in "path"
Additional Info
The API which retrieves the command line parameters cannot handle 8-bit characters. If you supply an 8-bit character the actual value I get is undetermined.
This restriction has been in place in all version of KiXcrypt, but I have only recently received an email on the subject.
In practice this means that you must stick to 7-bit ASCII characters on the command line. Note, non-printable characters such as the BEL (control-G) or the escape character are fine, so long as you work out a way of passing them on a command line.
7-bit ASCII characters are characters with a decimal value below 128.
The only exception is NULL (Chr(0)), which is an end-of-string terminator. You may have trouble typing CR and LF characters, and the DOS end-of-file mark (control-Z) may cause some oddities as well.


ElegantSol
(Fresh Scripter)
2002-12-18 02:18 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Thanks Richard!

I think it would be appropriate for you to be the one to close my original thread in the Starters forum by pointing to this resolution!

Again great job! [Cool]

Steve


Jose
(Seasoned Scripter)
2002-12-18 03:29 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Couple of days ago (before kaos) I downloaded the 1.3 free demo.
First time I used, Its exelent.
I am going foward Exe Package Creator on new release.
I also noticed that when you open a file throught the last four on the file list it doesnt execute and debug. Not the same when you do file open.
Is .exe supposed to execute on netlogon? Or throught application as an independent software? ----- Pardon my ignorance. [Razz]


masken
(MM club member)
2002-12-18 04:04 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

quote:
"Masken" included a graphic link in his post (first on this page) to a site which requires a login to access.
[Embarrassed]

Sorry about that, thanks for editing it out! [Smile]

hmm.. been away from KiX scripting for too long... [Wink]

But if anyone could please give an explanation on how to use this for a 3.63 loginscript where users have the SU service installed, I'd be really grateful...

1. Make a batchfile that calls the application that needs elevated privilegues with the help of SU. For example:
echo mypassword | su username "C:\temp\setup.exe /q"

2. Encrypt this file with KiXCrypt

3. Call the encrypted *.exe from within the loginscript?

[Confused]

I need a vacation [Wink]


Richard H.Administrator
(KiX Supporter)
2003-01-17 02:51 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Major feature release - include support files in encrypted package.

Apologies for the long line.

Get the small (20 Kb) executable kixcrypt.exe from here.
Get the small (20 Kb) console-less executable wkixcrpt.exe from here.

17 January 2003 Version 2.16b released
Phew, less than a month and another feature release. This release adds the second most requested feature - multiple file inclusion. This means that you can now bundle the KiXtart interpreter, ini files, registry dumps, additional scripts or whatever you fancy with the main script.
Changes
  • Bug fix: A variable scope error meant that files created in a temporary directory using the "-t" feature would not be deleted in some cases.
  • New feature: You may include any number of arbitrary files by using the "-f filename" option. You may repeat the "-f" option as many times as you like, up to a limit of 255 files.
  • New feature: Three environment variables are created when the script is decrypted. These are detailed below.
Additional Info
The "-f" option allows you to include arbitrary support files in the package. Note the following features and restrictions:
  • Support files will be unpacked into the same directory as the primary script file.
  • Path information is not kept - all unpacked files will be created in the same directory.
  • Support files are encrypted in the crypted.exe
  • Support files will be created with their original name. Only the primary script file will have a random name.
  • The primary script file is always the last file to be unpacked and the first to be deleted, to reduce the time it is visible in the file system.
  • Support files are not deleted until the primary file has finished executing, so may be visible in the file system for some time.
  • If there is already a file present with the name of the support file being unpacked the process will abort and remove all files unpacked so far. There is no option to overwrite existing files.
It is possible for the process decrypting the file to create them in a directory specified by the "-t" option.
This means that your own scripts may not know where to find the support files.
To get around this, the following environment variables are provided:
KIXCRYPTVER The version of KiXcrypt.
KIXCRYPTDIR The temporary directory that KiXcrypt is unpacking the files in.
KIXCRYPTFILE The full path name of the script being executed.
Note: Some of these values are now also provided by KiXtart macros in recent releases.
Example
The following example creates an encrypted version of the file "update.kix". There are two support files, "control.ini" and "update.gif" which are packaged with it.
code:
kixcrypt.exe update.kix -f control.ini -f splash.gif

When the crypted.exe is run, it will unpack the three files into the current directory (or the directory defined by "-t"). The files "control.ini" and "splash.gif" will be created with their originbal names. The primary script file "update.kix" will be created with a random file name.

Here is a more complicated example:
code:
kixcrypt.exe update.kix -f control.ini -f spash.gif -f c:\winnt\kix32.exe "%%%%KIXCRYPTDIR%%%%\kix32.exe ^s"

This example will add the KiXtart executable to the file. The path will be lost, so the executable will be unpacked in the same directory as the primary script.
To be sure that your are running your version of kix32.exe, the command is defined at the end of the line - the "^s" will be replaced with the primary scripts random file name.
You must use the four "%%%%" characters to represent a single "%" in the final command line.
If you now execute the encrypted file with the command:
code:
crypted.exe -t c:\temp

The four files will be unpacked into the c:\temp directory (assuming no file already exists with the same name).
Assuming the primary script is created with the random file name "WSSHGSMO.kix" the command which will be executed is:
quote:
%KIXCRYPTDIR%\kix32.exe c:\temp\WSSHGSMO.kix


ShawnAdministrator
(KiX Supporter)
2003-01-17 04:13 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard - how about you build us a windows GUI wrapper (not talking Kixforms here) that presents a listbox and a browser dialog and one cound then select the files to be included in the package - maybe allow us to set a few options - then have the proggy generate the exe for us ? Kinda like winzip or some other package builders - just a thought.

Les
(KiX Master)
2003-01-17 04:31 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Great Idea!

OH OH OH, and maybe a Help button. [Wink]


Richard H.Administrator
(KiX Supporter)
2003-01-17 05:08 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Hmmm. Not a bad idea.

I should be able to cobble a simple GUI front-end together using JavaScript. It's just about time to leave for the weekend, so I'll have a butchers next week.

Not too sure about the help button though, takes all the fun out of trial and error [Wink]


ShawnAdministrator
(KiX Supporter)
2003-01-17 05:13 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Java-Script ???

Java-Script ???

Wad-up-wid-dat ?

- Shawn "Trail and Error" Tassie


MightyR1
(MM club member)
2003-01-17 07:36 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard,

could you update the "kixcrypt -?" info?

It doesn't mention the -t, -f and the ^s...

Maybe add the same info in a readme.txt with version history???

TIA


MightyR1
(MM club member)
2003-01-17 08:25 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I've got 2 files:

[tst.vbs]
wscript.echo "Hello World"

[x.kix]
run "wscript tst.vbs //nologo"

I made a crypted.exe with this command:

wkixcrypt.exe -c -m "" x.kix "wkix32.exe -i ^s"

I still get a console flashing by...

What am I doing wrong???


ShaneEP
(MM club member)
2003-01-17 10:18 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

nevermind...Does the same thing for me too.

[ 17. January 2003, 22:22: Message edited by: CitrixMan ]


Richard H.Administrator
(KiX Supporter)
2003-01-20 09:44 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Patrick,
  • "-t" option is for use with the encrypted program "crypted.exe", not with kixcrypt. If you do "crypted.exe /?" (or -h) you will see it documented - you won't see it documented in the kixcrypt message as it is not relevant in that mode.
  • "-f" option - you are quite right, I missed it off the usage message. Will be fixed in the next release.
  • "^s" is an alias for "%s" and is documented in this thread somewhere. I will be writing new documentation at some time, but the GUI interface sounds like a lot more fun [Wink] As the "%s" format is deprecated because it can cause problems I will change the message.
  • Version history - "kixcrypt -v" will give you a full version history. All my errors made public.
The console thing. This comes up a lot, and I really don't have the answer [Frown]
A crypted.exe created with "wkxcrypt" does not create a console when it it executed. Unfortunately, the "system()" call that I use to execute the unencrypted script does create a console.
If anyone has an idea how to execute arbitrary DOS commands from a MinGW compiled exe without creating a console please give me a shout and let me know.


Richard H.Administrator
(KiX Supporter)
2003-01-20 05:19 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

KiXcrypt GUI interface.

As a response to the huge number of request (Hi Shawn) I've knocked together a simple GUI interface to the KiXcrypt utility.

It is basically a KiXtart script using IE COM calls, and some JavaScript.

I'm not posting the script here as it is chock-a-block full of HTML code so it'll be a real problem to post to this forum.

This is beta quality - not all KiXcrypt options are supported, there are no instructions and garbage-in will get you garbage-out.

However it seems to work OK, so I'm looking for some feedback. I'd like to know of any problems, extra features it needs, and whether it is worth me spending any more time on it.

Instructions for use:
1) Download the script from here
2) Ensure that kixcrypt.exe is in an executable location, i.e. your PATH or the current directory
3) Run "kix32.exe kcgen.kix"
4) Fill in the blanks and then hit the "Execute" button.
5) Keep generating the crypted.exe until you are happy (or bored), then close the IE window when you are done.

A temporary file kcgen.html will be created in your %TEMP% directory and removed when your done.

Please let me know how you get on.


Richard H.Administrator
(KiX Supporter)
2003-01-23 04:49 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

What, no takers?

Maybe a screenshot will whet your appetite:
 -


Jack Lothian
(MM club member)
2003-01-23 07:51 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Neat, I suggest you get one of our members to post your code on their site. If it is easier to get more people will take it for a ride.

LonkeroAdministrator
(KiX Master Guru)
2003-01-23 08:02 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I placed the code in general as it has html disabled:
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=14&t=000376

{edit}
now also later in this thread.
{/edit}

[ 27. January 2003, 05:56: Message edited by: Lonkero ]


Tan Bandradi
(Fresh Scripter)
2003-01-24 05:04 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear Richard,

Does the "-k" option on KiXcrypt version 2.16b also applicable to prevent support file deletion (file that added with "-f" option) including the primary script file deletion?

Because I would prefer to delete the support file from the script alternatively, the support file deletion by KiXcrypt sometime fail, and the unpacking process on KiXcrypt will be aborted at the next execution, and the final result is KiXtart script execution will fail.

What I did is to include file kix32.exe, kx16.dll, kx32.dll, and kx95.dll together with the primary script by using the "-f" option. This support file will be unpacked and the kix32.exe will be executed to run the primary script.

I did this because I don't want to put KiXtart files on netlogon share, the script replication on domain controllers sometime fail because the .dll file is in use.

Thank you in advance,
Tan


ShawnAdministrator
(KiX Supporter)
2003-01-24 05:23 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Richard, your appz are gui, gui good. Well done.

Richard H.Administrator
(KiX Supporter)
2003-01-24 10:21 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Tan,

The file deletion process is as follows:
[1] For the primary file only (which is normally your KiXtart script) some extra KiXtart script is tacked onto your script. This extra code immediately attempts first to overwrite, then to delete itself. This works because the entire script is read into memory so the file can be removed. The purpose of this is to leave the unencrypted file around for as short a time as possbile. Once the overwrite/delete has completed control is passed to your own script.

[2] Once your script has finished running the calling program (crypted.exe) checks to see if your script is still present i.e. the delete failed. You will get an warning message that the file is still present, and crypted.exe will itself attempt to overwrite then delete the file.

[3] All support files are then deleted.

In summary, the support files are not deleted until the script has finished running, so you can delete them yourself, rename them, copy them or open/read them in your script.

The only exception to this is if your script "escapes" the controlling crypted.exe, in which case it will think the script has finished and delete the files while the script is running.

You could escape control by RUNning a new process and exiting the original script for instance, or by using the "START" command.

The "-k" option disables step [1] only.
This is useful if your primary file is not a KiXtart script. You might have packaged an executable, an Excel spreadsheet or a DOS batch file in which case adding KiXtart script to the file would render it useless.


LonkeroAdministrator
(KiX Master Guru)
2003-01-25 02:00 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

trying the code in here.

{edit}
code removed as not sure who's code had the error.
{/edit}

[ 27. January 2003, 04:24: Message edited by: Lonkero ]


LonkeroAdministrator
(KiX Master Guru)
2003-01-27 04:51 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

k, I checked my code poster and can't find anything wrong in it. so re-posting the code

{edit}
did I say I hate this board?
{/edit}

[ 27. January 2003, 05:05: Message edited by: Lonkero ]


LonkeroAdministrator
(KiX Master Guru)
2003-01-27 05:14 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption



Break On

;
; Gui interface for creating encrypted KiXtart packages.
;
; This is BETA quality - no serious bugs, but not yet completed.
;
; Enjoy!
;
; Richard Howarth (rhowarth@sgb.co.uk)
;

Global $HTMLFILE
$HTMLFILE="%TEMP%\kcgen.html"

Del $HTMLFILE

"Generating HTML File..." ?
Call fnMakeHTML()

"Starting IE instance..." ?
$oIE = CreateObject("InternetExplorer.Application")
$oIE.Visible=1
$oIE.Navigate($HTMLFILE)
; Wait for page to stop loading...
While $oIE.busy AND $oIE.readystate <4 AND @ERROR = 0 Loop
$oDoc=$oIE.document

$nul=SetConsole("HIDE")
$iStatus=$oDoc.frmMain.Status.value
While @ERROR=0
 If $iStatus=1
  $oDoc.frmMain.Status.value=0
  $nul=SetConsole("SHOW")
  $nul=SetConsole("FOREGROUND")
  Cls
  "Generating crypted.exe - check below for errors..." ?
  "-----OUTPUT BEGINS-----" ?
  Shell $oDoc.frmCommand.textCommand.value
  "-----END OF OUTPUT-----" ?
  "Hit return to continue: " Gets $nul ?
  $nul=SetConsole("HIDE")
  Cls
 EndIf
 Sleep(0.5)
 $iStatus=$oDoc.frmMain.Status.value
Loop
$nul=SetConsole("SHOW")
$nul=SetConsole("FOREGROUND")

; Clean up and exit.
Del $HTMLFILE
Exit 0

Function fnMakeHTML()
    $nul=RedirectOutput($HTMLFILE)
    "<HTML>
     <SCRIPT Language=JAVASCRIPT>
     function fnAddSupportFile() {
      if(fnSelectionExists(frmMain.selFiles,frmAddSupport.fileSupport.value)==false) {
       if(frmAddSupport.fileSupport.value!='') {
           frmMain.selFiles.options[frmMain.selFiles.options.length]=new Option(frmAddSupport.fileSupport.value)
       }
      }
      fnMakeCommand();
      return true;
     }
   
     function fnDeleteSupportFile() {
      var iLoop
      for(iLoop=frmMain.selFiles.options.length;iLoop--;) {
       if(frmMain.selFiles.options[iLoop].selected){
        frmMain.selFiles.options[iLoop]=null
       }
      }
      frmAddSupport.reset();
      fnMakeCommand();
      return true;
     }
   
     function fnSelectionExists(selList,sValue) {
      var iLoop
      for(iLoop=selList.options.length;iLoop--;) {
       if(selList.options[iLoop].text==sValue)
        return true
      }
      return false
     }
   
     function fnMakeCommand() {
      var iLoop
      frmCommand.textCommand.value=''
      if(frmPrimaryFile.filePrimary.value=='')
       return false;
      frmCommand.textCommand.value='kixcrypt';
      if(frmOptions.radioDebug[0].checked==true)
       frmCommand.textCommand.value=frmCommand.textCommand.value + ' -d'
      if(frmOptions.radioIsKix[0].checked==false)
       frmCommand.textCommand.value=frmCommand.textCommand.value + ' -k'
      if(frmOptions.radioUseCOMSPEC[0].checked==false)
       frmCommand.textCommand.value=frmCommand.textCommand.value + ' -c'
      if(frmOptions.textPassword.value!='')
       frmCommand.textCommand.value=frmCommand.textCommand.value+' -p "
 '"' "'+frmOptions.textPassword.value + '" '"' "'
      for(iLoop=frmMain.selFiles.options.length;iLoop--;) {
       frmCommand.textCommand.value=frmCommand.textCommand.value+' -f "
 '"' "'+frmMain.selFiles.options[iLoop].text + '" '"' "'
      }
      frmCommand.textCommand.value=frmCommand.textCommand.value+' -m "
 '"' "'+frmOptions.textMessage.value + '" '"' "'
      frmCommand.textCommand.value=frmCommand.textCommand.value+' "
 '"' "'+frmPrimaryFile.filePrimary.value + '" '"' "'
      if(frmOptions.textProgram.value!=''){
       frmCommand.textCommand.value=frmCommand.textCommand.value+' '
       if(frmOptions.radioExeInPackage[0].checked==true){
        frmCommand.textCommand.value=frmCommand.textCommand.value + '%%%%KIXCRYPTDIR%%%%\\'
       }
       frmCommand.textCommand.value=frmCommand.textCommand.value+frmOptions.textProgram.value
      }
      return true;
     }
   
     function fnExecuteCommand() {
      frmMain.Status.value=1
     }
   
     </SCRIPT>
    <HEAD>
     <TITLE>KiXcrypt command line generator</TITLE>
    </HEAD>
    <BODY>
     <TABLE Align=Center>
     <FORM Name=frmPrimaryFile>
      <TR BGCOLOR=LightBlue>
       <TD>Primary file to encrypt:</TD>
       <TD><INPUT Type=FILE Name=filePrimary onChange='fnMakeCommand();'></TD>
      </TR>
     </FORM>
     <FORM Name=frmOptions>
      <TR>
       <TD>Is this a KiXtart script file?</TD>
       <TD>
        Y<INPUT Type=RADIO Name=radioIsKix Checked onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
        N<INPUT Type=RADIO Name=radioIsKix onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
       </TD>
      </TR>
      <TR BGCOLOR=LightBlue>
       <TD>Display DEBUG output?</TD>
       <TD>
        Y<INPUT Type=RADIO Name=radioDebug onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
        N<INPUT Type=RADIO Name=radioDebug Checked onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
       </TD>
      </TR>
      <TR>
       <TD>Include %COMSPEC% in command line?</TD>
       <TD>
        Y<INPUT Type=RADIO Name=radioUseCOMSPEC Checked onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
        N<INPUT Type=RADIO Name=radioUseCOMSPEC onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
       </TD>
      </TR>
      <TR BGCOLOR=LightBlue>
       <TD>Password:</TD>
       <TD><INPUT Type=TEXT Name=textPassword Size=20 Value='' onChange='fnMakeCommand()'></TD>
      </TR>
      <TR>
       <TD>
        Start up message:<BR>
        <FONT SIZE=-1>You may include the following in your text:<BR>
        &nbsp;&nbsp;$s : Replaced with the program name<BR>
        &nbsp;&nbsp;$v : Replaced with the program version<BR>
        &nbsp;&nbsp;$n : Replaced with a newline<BR></FONT>
       </TD>
       <TD VALIGN=Top><INPUT Type=TEXT Name=textMessage Size=40 Value='' onChange='fnMakeCommand()'></TD>
      </TR>
      <TR BGCOLOR=LightBlue>
       <TD>
        Command to execute unencrypted file:<BR>
        <FONT SIZE=-1>&nbsp;&nbsp;The '^s' will be replaced with the unencrypted filename</FONT>
       </TD>
       <TD VALIGN=Top><INPUT Type=TEXT Name=textProgram Size=40 Value='kix32.exe ^s' onChange='fnMakeCommand()'></TD>
      </TR>
      <TR>
       <TD>Is interpreter (e.g. kix32.exe) included in package?</TD>
       <TD>
        Y<INPUT Type=RADIO Name=radioExeInPackage onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
        N<INPUT Type=RADIO Name=radioExeInPackage Checked onclick ='fnMakeCommand()' onChange='fnMakeCommand()'>
       </TD>
      <TR>
     </FORM>
     <TR BGCOLOR=LightBlue>
      <TD Valign=TOP>Additional support files:</TD>
      <TD>
       <FORM Name=frmAddSupport>
       <INPUT Type=FILE Name=fileSupport Value='abcd' onSelect='fnAddSupportFile()' onChange='fnAddSupportFile()'>
       </FORM>
       <FORM Name=frmMain>
       <INPUT Type=HIDDEN Name=Status Value=0>
       <SELECT Name=selFiles Size=3 Multiple WIDTH=40></SELECT><BR>
       <INPUT Type=BUTTON Value='Remove Selected Files' onclick ='fnDeleteSupportFile()'>
       </FORM>
      </TD>
     </TR>
     <FORM Name=frmCommand>
      <TR>
       <TD ColSpan=2 Align=CENTER>
        <TEXTAREA Name=textCommand ROWS=3 COLS=70 onFocus='this.blur();'>
        </TEXTAREA>
       </TD>
      </TR>
      <TR>
       <TD ColSpan=2 ALIGN=CENTER>
        <INPUT Type=BUTTON Name=btnExecute Value='Execute Command!' onclick ='fnExecuteCommand()'>
       </TD>
     </FORM>
     </TABLE>
    </BODY>
    </HTML>"

    $nul=RedirectOutput("")
    Return
EndFunction



Richard H.Administrator
(KiX Supporter)
2003-01-28 09:30 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Any particular reason that this has been moved into General Discussions?

JochenAdministrator
(KiX Supporter)
2003-01-28 10:12 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

[Eek!]

Hehe ... this is probably the first Topic in General that has html Code inside (See Jooels Reply)

Maybe the control meachanisms aren't that good when topics are moved !


Sealeopard
(KiX Master)
2003-01-28 03:39 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Actually, two reasons. KiXCrypt is not a script example and does not contain (KiXtart) scripts. Also, as a utility/tool it would be better served in the 'General' forum as it does not qualify for any of the other forums.

LonkeroAdministrator
(KiX Master Guru)
2003-01-28 03:44 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

but this GUI peace separately in it's own topic/thread would fit to scripts...

better to com though.


Sealeopard
(KiX Master)
2003-01-28 03:46 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Then you might want to post the GUI script into it's own thread. I'd prefer it that way anyway. Call it KiXCrypt GUI and refer to the KiXCrypt thread for the .EXE package.

[ 28. January 2003, 15:48: Message edited by: sealeopard ]


Richard H.Administrator
(KiX Supporter)
2003-01-28 04:53 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I guessed that was the reason, I just wanted to make sure it hadn't been moved in error - I didn't spot the notice edited onto the first post.

First posted in November 2001 - do you remember when we only had three (four?) forums, and KiXtart COM automation was only attempted by Absinthe drinking pot smokers who weren't entirely sane.


Sealeopard
(KiX Master)
2003-01-28 04:55 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Yeah, the good old times...drifting away soaking in nearly-lost memories of times long gone...

JochenAdministrator
(KiX Supporter)
2003-01-28 04:56 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Those were the Times !

But what would several Absynth drinking Pot smoking people do without being able to COM [Eek!] [Razz]


LonkeroAdministrator
(KiX Master Guru)
2003-01-28 05:17 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

j, you asking from me?

ofcourse drink some more!


**DONOTDELETE**
(Lurker)
2003-01-29 05:19 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

ok... It might just be me who just don't get this.. I'm in a big need for a way to encrypt my scripts. The utility have to work that so that my global variables and functions are fully operationel thru all the scripts.
I've tried the crypter.kix by Lonkero, which i modified to operate as a function (and then i made this script crypted with Kixcrypt.exe), and this worked out fine until the big if/endif statements (and actually some loop statements and so on). So.. Now i'm (by advise from Lonkero) am looking more into KixCrypt..
What seems to be my problem here is to keep the variables and functions all the way thru the 10-30 scripts i have.

Any suggestions how to solve this ? Someone must have done this before ?

-Tommy


Richard H.Administrator
(KiX Supporter)
2003-01-30 09:43 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

I've very recently added new features to KiXcrypt so that you can include scripts made up of more than one file.

I strongly suggest that you use the GUI interface to generate you encrypted script. The reason is that the command line can end up very long, and you cannot type it all in (on Win95 anyway).

When you run the script, the files are all unencrypted and execute as if they were run normally. The only differences are:
  • The main script has a random file name. Keep all your secure information in the main script.
  • The main script is deleted as soon as it starts, so it is not re-entrant. The additional scripts are not deleted until the main script has finished executing.
Assuming that your main script it called "Master.kix" and your additional scripts are "Groups.kix", "Printers.kix", "Shares.kix" and "Functions.kix" the GUI will look like this:
 -
Hit the "Execute Command" button and it will create a "crypted.exe".

You can find a link to the GUI code (and the script itself if you want to cut'n'paste) on page 3 of this thread.


LonkeroAdministrator
(KiX Master Guru)
2003-01-30 09:46 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

mm...
cut&paste code is also at page 3 [Wink]


Richard H.Administrator
(KiX Supporter)
2003-01-30 09:48 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Err, yeah. I believe I just said that [Confused]

LonkeroAdministrator
(KiX Master Guru)
2003-01-30 09:50 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

damn, you are right.

read your words wrong... going blind I quess...

age doesn't come alone, you know [Razz]


**DONOTDELETE**
(Lurker)
2003-01-30 09:54 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Most greatfull... Will try this...

Thanks a lot...

-Tommy


**DONOTDELETE**
(Lurker)
2003-01-31 10:19 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

first of all... This utility did exactly what i needed.. Thanks a lot [Smile]

Then i still have a question.. It seems to me that the .exe decrypt/unpack the files into the dir where the .exe was first started.. This is not good. Then i read that, There is now a "-t path" option when you decrypt which will create the temporary file in "path", post on the original post.
This -t option i cant fint documented, neither can i make it happend...

Any suggestions ?

-T

[ 31. January 2003, 10:20: Message edited by: X-mine ]


Richard H.Administrator
(KiX Supporter)
2003-01-31 10:46 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Thanks for the feedback [Smile]

The "-t" option only applies when you decrypt the file.

To decrypt to a different directory:
code:
crypted.exe -t c:\windows\temp

or even
code:
crypted.exe -t %TEMP%



**DONOTDELETE**
(Lurker)
2003-01-31 11:01 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

hmm.. ok.. thanks..
That would make it possible for someone to add this option and then get all the svcriptfiles from the optional directory.?.?

Any workarounds for this ? What im looking for is a way to make it at hard as possible to get the script files.. Today i have some scripts running into a sort of menu. Then the menu waits for userinput before continuing. In this "break" the user would then be able to get the files from the specified directory..

Any suggestions about how to solve this ?

-T


Richard H.Administrator
(KiX Supporter)
2003-01-31 11:57 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

How would that help?

If the user can access the crypted.exe to execute it then they can copy it and execute anywhere, so denying the "-t" option won't make it any more secure.

Hard-coding the directory into the crypted.exe may be possible, but you will have to convince me that it will provide an additional useful deterrent.

You could force the files to be created on a hidden share on a server, but that is so easy to circumvent that it is pointless. All that it does is to give a false sense of security.

The problem is a balance. A malignant user with sufficient know-how to break through the other security devices won't be at all deterred by the files being written to a hard-coded directory path. The sort of user who will be deterred by a hard-coded directory path will already have been put off by the existing features.

You need your additional scripts to remain in place, because at some point you will want to CALL or otherwise execute them. If they are deleted before you call them it is going to seriously hamper the functionality of your script [Wink]

There are two things that you can do to increase security:
  • Put any security sensitive code in the primary script. This script is recreated with a random name to make it hard to catch, and is immediately deleted when it is started. The script is deleted even if you are paused at an input prompt.
  • Create all extra code in your additional scripts as functions. This allows you to CALL your additional script as the very first action of your main script. Once each has been called it you can delete it. The functions are loaded in memory, so you can call the functions later on in your scripts even though the original source files no longer exist.
Remember, with any of the encrypting solutions available for KiXtart that the purpose is to make it hard enough for someone to get access that it is not worth their while. At some point the script has to be available in it's original form because that is the only way that KiXtart can interperet it.


**DONOTDELETE**
(Lurker)
2003-02-01 12:20 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

hmmm.. ok.. thanks.. i agree with the arguments, but it would be nice to have the possibility to set the decrypt path (and block the -t option) anyway.. This way i could atleast (maybe) get the feeling that they are a little more secure..

But.. I'll go through the scripts and see if i can do something like you suggested...

-T


Richard H.Administrator
(KiX Supporter)
2003-02-01 12:25 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Next time I'm digging around in the code I will see how hard it would be to add.

If it's trivial it might make it in.


Frank Buzin
(Fresh Scripter)
2003-01-31 07:49 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

quote:
The console thing. This comes up a lot, and I really don't have the answer
A crypted.exe created with "wkxcrypt" does not create a console when it it executed. Unfortunately, the "system()" call that I use to execute the unencrypted script does create a console.

Can you use CreateProcess() instead of system() and make sure there is no creation flag for new console?

FB

[ 31. January 2003, 19:50: Message edited by: Frank Buzin ]


LonkeroAdministrator
(KiX Master Guru)
2003-02-01 02:56 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

system call, eh?
how about shell.run call...


Richard H.Administrator
(KiX Supporter)
2003-02-03 04:22 PM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Frank,
Many thanks for that pointer - initial simple testing shows some good results.

I'll try to incorporate it into KiXcrypt and get a new release out over the next couple of weeks.

I think that I'll start a new thread though, this ones getting a bit unwieldly.

I knew if I kept asking someone would have the answer [Wink]


MCA
(KiX Supporter)
2003-02-17 04:25 AM
Re: UTILITY: KiXcrypt 2.16b - KiXtart encryption

Dear,

On our site pages Home - Kix Tools or Summary of Site you find now two ZIP files.

kixcrypt216b.zip which includes kixcrypt.exe & wkixcrypt.exe

kixcrypt300b.zip which includes kcgen.kix, kixcrypt.doc, kixcrypt.exe & wkixcrypt.exe

greetings.