AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encryption

Discuss and share scripts and script files...
Post Reply
Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encryption

Post by Enternal »

AX(Y)Crypt_0.6.zip
(1.13 MiB) Downloaded 633 times
Updated April 10, 2013 - Version 0.6
* Remove almost all reliance on permanent variables. Only two permanent variables are used and those are paths to AxCrypt.exe and the Messenger.
* Some modifications of the code to fully work with PFA. Using PFA, you can now Encrypt, Decrypt, and Open encrypted files. Instead of the sorry mess before, the PFA is now simply:

Code: Select all

"AxCrypt - Open|<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe" axx>::Load "<xydata>\Scripts\AX(Y)Crypt.xys", "Open";
"AxCrypt - Encrypt|<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe" axx>::Load "<xydata>\Scripts\AX(Y)Crypt.xys", "Encrypt";
"AxCrypt - Decrypt|<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe" axx>::Load "Decrypt";
* Changed variable naming scheme. All variables with prefix "P_" are permenent variables, "G_" are global variables, and the rest are local variables.
Updated April 01, 2013 - Version 0.5
* Added icons. Menu looks much better now.
* Improperly used <curitem> variable. Now using <selitems> instead.
* Removed "Edit Script" since it's not needed.
Updated March 27, 2013 - Version 0.4
* Further code cleanup and some optimizations.
* Clean up itself after script is finished.
Updated March 26, 2013 - Version 0.3
* Implemented Customizable Secure Wipes
* Now uses a configuration file that allows configuration for:
-Encrypt to Self-Decrypting Executable
-Wipe Passes - The number of wipe passes for the original files after encryption and decryption.
-Wipe Passes on Demand - The number of wipe passes for secure wipe of selected files. Seperate from Wipe Passes above.
-Retain Original - Retain original files after encryption or decryption.
-Randomize Encrypted File Names
-Always quit AxCrypt - You will no longer have the convenience of cached keyphrases but you won't need to remember to quit AxCrypt. Also more secure.
* Cleaned up code.
Updated March 26, 2013 - Version 0.2
* Thanks to highend, finally combined folder & file encryption functions into one function.
* Wrote AX(Y)Script instead of AX(Y)Crypt in several places. Changed all back to AX(Y)Crypt.
* File layout have changed. AX(Y)Crypt.xys will be in the main <xyscripts> while the rest of the files will be in <xyscripts>\AX(Y)Crypt\. Help reduce clutter. Basically:
<XYScripts>
....\AX(Y)Crypt\
....AX(Y)Crypt.xys
....AX(Y)Crypt_Readme.txt

AxCrypt is an Explorer shell extension that is proven in stability, reliability, performance, and is generally well updated. It's also open sourced with very lenient permissions to freely modify and distribute. Although it's a shell extension, it can be called from the command line. The command line is fully featured and support every features that the shell extension offers.

One really nice feature is it allows you to edit encrypted files "on-the-fly". Basically it decrypt the file into a temporary location, open up the file using Windows type association, allows you to edit/view the file, waits for you to finish, and then automatically re-encrypt the file if it was edited.
"Double-click integration makes it as easy to open, edit and save protected files as it is to work with unprotected files." -Axantum
Although this feature is for use with Windows Explorer, it's actually usable even without being installed because there is actually a command line option for it which I made it work with XYplorer's PFA using Marco's slightly modified XYplorer Messenger. Using PFA, an encrypted file (extension .axx) is decrypted using AxCrypt that then sends the path of the temporary decrypted file to the messenger (AX(Y)Crypt_Hermes.exe) as a command parameter. The messenger then once again forward the control and path parameter to XYplorer as a command -::open "path"- which allows PFA to still be in effect.

Features
Portable
"Live Edit" Encrypted File with PFA: Can "live edit" encrypted files while still maintain PFA association. Double click to open an encrypted image -> PFA kicks in automatically with the temporary decrypted file -> Edit the file and close -> AxCrypt automatically re-encrypt the edited file without your intervention. Quicker and less hassle than: Decrypt File -> Double Click to Open File -> Edit/Save/Close File -> Start AX(Y)Crypt to Re-encrypt File.
Randomize File Names: Can randomize encrypted file names. Original names are restored upon decryption.
Customizable Secure Wipes

Setup

:!: :!: Remember to backup your files. I don't guarantee anything. :!: :!:

Requirements:
+ XYplorer Version 12.10.0001+
+ Scripting Enabled
+ AxCrypt (Included In Zip)

Extract all the contents of AX(Y)Crypt_{Version}.zip to the script folder. Then run AX(Y)Crypt_Button_Setup.xys or run ::Snippet from the address bar and paste in the following code:

Code: Select all

Snip: CTB 1
    XYplorer 12.30.0000, 03.25.2013 00:00:00
Action
    NewUserButton
Name
    AX(Y)Crypt
Icon
    <xyscripts>\AX(Y)Crypt\AxCrypt.exe
ScriptL
    ::load "<xyscripts>\AX(Y)Crypt.xys";
ScriptR
    
FireClick
    0
For PFA, you can use:

Code: Select all

/*
AX(Y)Crypt 0.6 April 10, 2013 - Portable File Encryption With AxCrypt - By Enternal
http://www.axantum.com/AxCrypt/
http://www.xyplorer.com/
Many thanks to Marco, highend

==== Main Files
AX(Y)Crypt.xys - Main Script
AX(Y)Crypt_Button_Setup - User Button Setup
AX(Y)Crypt_Hermes.exe - AX(Y)Crypt PFA Messenger - Slight Modification of Marco's XYplorer Messenger
AX(Y)Crypt_Hermes.a3u - AX(Y)Crypt PFA Messenger Source
AX(Y)Crypt_PFA - Raw PFA Code (Optional)

==== AxCrypt Files
AxCrypt.exe, AxDecrypt.exe, Config.xml, License.rtf, Messages.dll, ShellExt.dll, Sigs.xml

==== AxCrypt Command Line Information. For More Commands, Go to http://www.axantum.com/AxCrypt/CmdLine.html
-b n -> "Define a tag, or batch id, to be used with subsequent pass phrases."
-c -> Retain orinal files after encryption or decryption.
-g -> Do not encrypt already encrypted files.
-e -a -> Set Keyphrase (-e) and Prompt User (-a)
-m -> Recurse
-z -> Encrypt. Automatically wipes originals.
-d -> Decrypt
-h -> "Renames the to anonymous names. original names will be restored on decryption."
-J -> Encrypt to Self-Decrypting Files. Does not automatically wipes originals.
-w -> Wipe. Depends on -V n for how many wipe passes. Asks for confirmation before starting.
-s -> Same as -w but no confirmation.
-V n ->
"Sets the global persistent default number of wipe passes when overwriting, 1-7.
Default if not set is 1. The full set of 7 passes will overwrite in the following
sequence: random, ones, zeroes, random, zeroes, ones, random. Thus, -V 3 corresponds
to the DoD 5220.22-M standard for sanitizing data on fixed hard disks."
*/




"_Initialize"
	Perm $P_AxCrypt = "<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe"; // Path to AxCrypt.exe
	Perm $P_Messenger = "<xydata>\Scripts\AX(Y)Crypt\AX(Y)Crypt_Hermes.exe"; // Path to AX(Y)Crypt_Hermes.exe

	$INI =<<<INI
[Settings]
;0 - Don't Randomize Encrypted File Names.
;1 - Randomize Encrypted File Names.
;Names will be restored upon decryption.
;Default is 0
RandomizeNames=0

;0 - Encrypt to .axx File
;1 - Encrypt to Self-Extractable File. Does not require AxCrypt
;to decrypt file on computers that does not have AX(Y)Crypt or
;AxCrypt installed.
;Default is 0
SelfExtractable=0

;0 - Automatically wipe the originals on encrypt and decrypt.
;1 - encryption and decryption retain originals.
;Default is 0
RetainOriginals=0

;How many passes to wipe file. 3 passes meets the DoD
;5220.22-M standard for sanitizing data on fixed hard disks.
;7 passes will overwrite in the following sequence:
;random, ones, zeroes, random, zeroes, ones, random.
;Default is 3
WipePasses=3

;Same as WipePasses but for File Wiping on demand.
;Default is 3
WipePassesDemand=3

;0 - Keep AxCrypt running. Allows the usage of cached keyphrase
;to make encrypting and decrypting sessions easier and more
;convenient. However you must always remember to "Quit" every
;time. Otherwise AxCrypt.exe will continue to run.
;1 - Clear cache and quit everytime the script finishes.
;Default is 0
AlwaysQuit=0

INI;

	If Exists("<xydata>\Scripts\AX(Y)Crypt.ini") == 0 {
		WriteFile("<xydata>\Scripts\AX(Y)Crypt.ini", "$INI");}

	Global $G_RandomizeNames = GetKey("RandomizeNames", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");
	Global $G_SelfExtractable = GetKey("SelfExtractable", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");
	Global $G_RetainOriginals = GetKey("RetainOriginals", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");
	Global $G_WipePasses = GetKey("WipePasses", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");
	Global $G_WipePassesDemand = GetKey("WipePassesDemand", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");
	Global $G_AlwaysQuit = GetKey("AlwaysQuit", "Settings", "<xydata>\Scripts\AX(Y)Crypt.ini");

	If $G_SelfExtractable == 1 {
		$SE = "-J"; }
	ElseIf $G_SelfExtractable == 0 {
		$SE = "-z"; }
	If $G_RetainOriginals == 1 {
		$RO = "-c "; }
	ElseIf $G_RetainOriginals == 0 {
		$RO = ""; }

	Global $G_Setup = "-V $G_WipePasses -b 2 -e -a";
	Global $G_EncryptP = "-b 2 $RO-g -m $SE"; // To Encrypt to Self-Extractable, Change -z to -J (Uppcase).
	Global $G_DecryptP = "-b 2 $RO-m -d";


"_Terminate"
	Global $G_AlwaysQuit;
	If $G_AlwaysQuit == 1 {
		Run """$P_AxCrypt"" -t -x",,2,0; }
	Unset $P_AxCrypt, $P_Messenger;
	/* If AlwaysQuit option is turned on, AxCrypt.exe will always clear its cache
	and then quit when the script finishes. */




// Functions
"Encrypt File(s) / Folder(s)|<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe : Encrypt"
	Sub "_PFAInitialize";
	End ("<selitems>"==""),"Nothing Is Selected!";
	Global $G_RandomizeNames, $G_SelfExtractable, $G_RetainOriginals, $G_WipePasses, $Files;
	Global $G_Setup, $G_EncryptP;
	Run """$P_AxCrypt"" $G_Setup",,2,0;
	$SelectedItems = Get("SelectedItemsPathNames","|");
	If $G_SelfExtractable == 1 && $G_RetainOriginals == 0 {
		ForEach($Item,$SelectedItems,"|") {
			If Exists($Item) == 1 {
				$Files = "$Item"."|"."$Files"; }
			ElseIf Exists($Item) == 2 {
				$FFiles = FolderReport("files","r",$Item,"r",,"|");
				$Files = "$FFiles"."|"."$Files"; } } }
	$Files = FormatList("$Files","e");
	ForEach($Item,$SelectedItems,"|") {
		$FileOrFolder = (Exists($Item) == 2) ? "$Item\*.*" : $Item;
		Run """$P_AxCrypt"" $G_EncryptP ""$FileOrFolder""",,2,0;
		If ($G_RandomizeNames == 1) {Run """$P_AxCrypt"" -m -h *.axx",,2,0} }
	If $G_SelfExtractable == 1 && $G_RetainOriginals == 0 {
		ForEach($Item,$Files,"|") {
			Run """$P_AxCrypt"" -V $G_WipePasses -s ""$Item""",,2,0; } }
	Msg "Encryption Finished.";
	Sub "_PFATerminate";

"Decrypt File(s) / Folder(s)|<xydata>\Scripts\AX(Y)Crypt\AxCrypt.exe : Decrypt"
	Sub "_PFAInitialize";
	End ("<selitems>"==""),"Nothing Is Selected!";
	Global $G_Setup, $G_DecryptP;
	Run """$P_AxCrypt"" $G_Setup",,2,0;
	$SelectedItems = Get("SelectedItemsPathNames","|");
	ForEach($Item,$SelectedItems,"|") {
		$FileOrFolder = (Exists($Item) == 2) ? "$Item\*.*" : $Item;
		Run """$P_AxCrypt"" $G_DecryptP ""$FileOrFolder""",,2,0; }
	Msg "Decryption Finished.";
	Sub "_PFATerminate";

"Open AxCrypt File(s)|:openwith : Open"
	Sub "_PFAInitialize";
	End ("<selitems>"==""),"Nothing Is Selected!";
	Run """$P_AxCrypt"" -V 3 -b 2",,2,0;
	$SelectedItems = get("SelectedItemsPathNames","|");
	ForEach($Item,$SelectedItems,"|") {
		Run """$P_AxCrypt"" -O ""$P_Messenger"" ""$Item""",,2,0; }
	Sub "_PFATerminate";
	/* "Open the given file(s) with the appropriate application after temporary
	decryption and decompression. If they are modified after application exit,
	they are re-encrypted with the same pass phrase."
	You Can only open 1 file at a time so you must close each file when
	you're done before the next file will open. */

"Wipe File(s) / Folder(s)|:wipe"
	End ("<selitems>"==""),"Nothing Is Selected!";
	$WipeConfirm = Confirm("This Process Is Irreversible. Are You Sure?");
	End ($WipeConfirm == 0), "Wipe Cancelled.";
	Global $G_WipePassesDemand;
	$SelectedItems = Get("SelectedItemsPathNames","|");
	ForEach($Item,$SelectedItems,"|") {
		$FileOrFolder = (Exists($Item) == 2) ? "$Item\*.*" : $Item;
		Run """$P_AxCrypt"" -V $G_WipePassesDemand -s ""$FileOrFolder""",,2,0; }
	ForEach($Item,$SelectedItems,"|") {
		If Exists($Item) == 2 {delete 0, 0, "$Item";} }
	Msg "Wipe Finished.";

" "
"Edit Configuration|:conf"
	Open "<xydata>\Scripts\AX(Y)Crypt.ini";
"Quit|:del"
	$Quit = Confirm("Are You Sure You Want To Quit?");
	End ($Quit == 0), "";
	Run """$P_AxCrypt"" -t -x",,2,0;
	Unset $P_AxCrypt, $P_Messenger;
	/* This is needed for PFA because if PFA is used, AxCrypt.exe will continue
	to run in memory with cached keyphrase. Use this to make sure AxCrypt's
	cache is empty and then quit. */

"_PFAInitialize"
	If IsSet($P_AxCrypt) ==0  && IsSet($P_Messenger) == 0 {
		Msg "Initial";
		Global $PFARUN = 1;
		Sub "_Initialize"; }
"_PFATerminate"
	Global $PFARUN;
	If $PFARUN == 1 {
		Sub "_Terminate"; }
The slightly modified XYplorer Messenger by Marco - AX(Y)Crypt_Hermes.au3 which compiles into AX(Y)Crypt_Hermes.exe:

Code: Select all

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Comment=Original Source By Marco (XYPlorer Messenger): http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9216
#AutoIt3Wrapper_Res_Description=AX(Y)Crypt Hermes
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Original Source By Marco (XYPlorer Messenger): http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9216
; Slightly Modified For Use With AX(Y)Crypt By Enternal
$Script = "::open "&"'"&$CmdLineRaw&"'"
$WM_COPYDATA = 0x004A
$hWnd = WinGetHandle("[CLASS:ThunderRT6FormDC]")
$dwData = 0x00400001
$iSize = StringLen($Script)
$pMem = DllStructCreate("wchar[" & $iSize & "]")
DllStructSetData($pMem, 1, $Script)
$pCds = DllStructCreate("dword;dword;ptr")
DllStructSetData($pCds, 1, $dwData)
DllStructSetData($pCds, 2, ($iSize * 2))
DllStructSetData($pCds, 3, DllStructGetPtr($pMem))
DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_COPYDATA, "wparam", 0, "lparam", DllStructGetPtr($pCds))
Attachments
User Button Popout
User Button Popout
01.jpg (34.33 KiB) Viewed 8820 times
AxCrypt Passphrase Dialog
AxCrypt Passphrase Dialog
02.jpg (67.45 KiB) Viewed 8920 times
Last edited by Enternal on 11 Apr 2013 01:46, edited 14 times in total.

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: AX(Y)Script 0.1 - Portable File Encryption Using AxCrypt

Post by highend »

I still have some issues though such as not being able to figure out how to encrypt selected combinations of files and folders.
Just check if the foreach loop if the current item (from $SelectedPathNames) is a folder (via the sc exists() ) and set the variable appropriately. No need to handle files / folders with different labels.

I've just changed the variable names and added the ternary condition for the new $FileOrFolder variable.

E.g.:

Code: Select all

"Encrypt File(s) / Folder(s)"
	End ("<curitem>"==""),"Nothing Is Selected!";
	$SelectedItems = Get("SelectedItemsPathNames","|");
	Run """$AxCrypt"" $Setup",,2,0;
	ForEach($Item,$SelectedItems,"|") {
		$FileOrFolder = (exists($Item) == 2) ? "$Item\*.*" : $Item;
    	Run """$AxCrypt"" $EncryptP ""$FileOrFolder""",,1,0;
    	If ($Randomize == 1) {Run """$AxCrypt"" -m -h *.axx",,1,0}
	}
Hth,
Highend
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AX(Y)Script 0.1 - Portable File Encryption Using AxCrypt

Post by Enternal »

highend wrote:
I still have some issues though such as not being able to figure out how to encrypt selected combinations of files and folders.
Just check if the foreach loop if the current item (from $SelectedPathNames) is a folder (via the sc exists() ) and set the variable appropriately. No need to handle files / folders with different labels.

I've just changed the variable names and added the ternary condition for the new $FileOrFolder variable.

E.g.:

Code: Select all

"Encrypt File(s) / Folder(s)"
	End ("<curitem>"==""),"Nothing Is Selected!";
	$SelectedItems = Get("SelectedItemsPathNames","|");
	Run """$AxCrypt"" $Setup",,2,0;
	ForEach($Item,$SelectedItems,"|") {
		$FileOrFolder = (exists($Item) == 2) ? "$Item\*.*" : $Item;
    	Run """$AxCrypt"" $EncryptP ""$FileOrFolder""",,1,0;
    	If ($Randomize == 1) {Run """$AxCrypt"" -m -h *.axx",,1,0}
	}
Hth,
Highend
Oh my goodness! Thank you! :biggrin: *prances around the room
I did not know about the feature of the "exists" function. That's a surprisingly very useful feature that tells you whether it's a file, url, or directory! I should really try to read every single function instead of trying to guess what they do by their function name. Will upload a new version sometime tomorrow. Too sleepy now...

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AX(Y)Crypt 0.4 (March 27, 2013) - Portable File Encrypti

Post by Enternal »

The script is now feature finished since there's not much else feature-wise that I can add from AxCrypt. Even if you guys don't use it, could you take a look at the code and give me some feedback? Perhaps there are better ways to doing certain things than what I'm currently doing since I do ended up using a lot of loops and such.

giuliastar
Posts: 365
Joined: 14 Sep 2013 07:22

Re: AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encrypti

Post by giuliastar »

how can i install it?
is there a way to add a standard header , to find the crypted files with the find feature?

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encrypti

Post by Enternal »

Hello! You can just download it and extract it to some directory. Preferely you extract it to XYplorer scripts folder <xyscripts> since that would make it easier for you to add it to the toolbar. The way I made it was mainly to be used as a custom toolbar item so go to Customize Toolbar, add User Button. Now edit the User Button and in the On click field, type in the location to the AX(Y)Crypt.xys file. You can also add give it an icon in the Icon field by just typing the location to the AxCrypt.exe file. For example, I extracted the contents of the zip folder into the AX(Y)Crypt folder in the XYplorer scripts folder. So my On click and Icon are:
On click: ::load "<xypath>\Data\Scripts\AX(Y)Crypt.xys";
Icon: <xypath>\Data\Scripts\AX(Y)Crypt\AxCrypt.exe

In terms of searching for the encrypted file, this uses AxCrypt so the file extensions is *.axx
You can then use any tool to find any file with that extension including XYplorer's search feature itself.

giuliastar
Posts: 365
Joined: 14 Sep 2013 07:22

Re: AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encrypti

Post by giuliastar »

Enternal wrote:Hello! You can just download it and extract it to some directory. Preferely you extract it to XYplorer scripts folder <xyscripts> since that would make it easier for you to add it to the toolbar. The way I made it was mainly to be used as a custom toolbar item so go to Customize Toolbar, add User Button. Now edit the User Button and in the On click field, type in the location to the AX(Y)Crypt.xys file. You can also add give it an icon in the Icon field by just typing the location to the AxCrypt.exe file. For example, I extracted the contents of the zip folder into the AX(Y)Crypt folder in the XYplorer scripts folder. So my On click and Icon are:
On click: ::load "<xypath>\Data\Scripts\AX(Y)Crypt.xys";
Icon: <xypath>\Data\Scripts\AX(Y)Crypt\AxCrypt.exe

In terms of searching for the encrypted file, this uses AxCrypt so the file extensions is *.axx
You can then use any tool to find any file with that extension including XYplorer's search feature itself.
thanks a lot!

giuliastar
Posts: 365
Joined: 14 Sep 2013 07:22

Re: AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encrypti

Post by giuliastar »

hi
sorry for my question
about key -file ?
what can i use to generate it?
is there a program to create it? pwgen has a feature create random data file , can i use it?

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AX(Y)Crypt 0.6 (April 10, 2013) - Portable File Encrypti

Post by Enternal »

AxCrypt itself can generate a keyfile but I have not implemented. I could possibly in the future but too busy as of now. Instead you can indeed use PWGen to create your random key file. In fact, you can use anything as your key file. Of course, a random key file that is generated is more secure.

EDIT: I have attached a test version of my script that does use AxCrypt's Key File generator. Try and see if it works for you.
AX(Y)Crypt.xys
AX(Y)Crypt 0.7 Beta - Added Key File Gen
(8.07 KiB) Downloaded 469 times

Post Reply