Jump to content

CodeCrypter - Encrypt your Script


RTFC
 Share

Recommended Posts

I ran it and with encrypt and obfuscate option enabled and i ran into an error.

It is simply a script with a msgbox but with winapi included.

After i run codecrypter it codes the au3 and it finishes. However i got an error when it is crypted. Global Const + $var always gives me an

error. Everything that is decrared as a const is highlighted as a syntax error.

I attached the script before and after crypted

Edit: IncludeConstants=True for me

guide.rar

Edited by AutID
Link to comment
Share on other sites

The reason it's coming up as an error is that you have to declare a constant with a value, that obfuscated script isn't doing that, seems like a glitch in the codecrypter script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Thanks a lot for your big solution for the encryption.

i have a software with 7566 lines and yesterday I managed to encrypt the software after tow days of "trial and error"(i hope this is the good translation from Google Translate)

You forgot to mention a few things in your guide and it made me be unable to to use your solution at the first time.

1) The AES.au3 should from here:

?do=embed' frameborder='0' data-embedContent>

if not then you will get the error that legend got..

2) In AES.au3 you must to do this fix:

?do=embed' frameborder='0' data-embedContent>page-2#entry896283' title="AutoIt Machine Code Algorithm Collection: post #21">#21

If not, the encryption will not work!
I do not understand how no one has noted it out.

 

Now about my results,

After I encrypted my software, I did not expect that everything will be good. And I was right.

The encryption screwed a lot of things in my software.
I do not even know where to start ..

But I do not blame you ..
This is the fun part (to fix everything and adapt the software for encryption).

Can you tell me what could cause problems?


Thank you very much!

Link to comment
Share on other sites

I need help!

I want to encrypt a script in two stages:
Step 1) Create a obfuscated script based on the original script
Step 2) Create an encrypted script based on the script from Step 1.

so i will have 4 files:

1) the original script

2) the script  without #includes

3) the obfuscated script

4) the obfuscated & encrypted script

For some reason, I can not do it ....


Please help me!

Edited by Guest
Link to comment
Share on other sites

  • 1 month later...

Note to all previous posters: Apologies for the long delay in replying; I've been offline for several months. Please bear with me as I try to catch up with your responses...

Hi MagicSpark,

Thanks for your concise example, very clear. Unfortunately, you've hit an AutoIt quirk that I cannot fix. It has nothing to do with the encryption, but with the Execute command. Consider this example:

SetError(1)
If Execute("@error") Then Beep(1111,50)

This does not work, because the Execute statement has apparently already re-initialised the @error macro to zero prior to executing it (which is annoying :mad: ). A crude way around it is to patch an extra line post-encryption, like this:

SetError(1); <<< encrypted line
$error=@error; unencrypted patch
If Execute("$error") Then Beep(1111,50) ; <<< encrypted line

Note that in this second example we evaluate $error, not @error. It's not pretty, and would require quite a bit of editing for a large project that checks lots of returned error codes.AutoIt regrettably does not support "OnError" interrupts, otherwise this patch could be automated.

The next release of CodeCrypter will either incorporate a better solution or skip decrypting lines containing @error/@extended evaluation altogether. It may take a while though...

Sorry I cannot provide a quick fix in this case. :think:

Edit: I've started a thread in the dev chat forum here:

'?do=embed' frameborder='0' data-embedContent>>

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

@legend,

That's an easy one. As explained at the bottom of my initial post, you need to get Ward's AES.au3 UDF and place it in the same directory as Codecrypter. ;) Then you follow the instructions ca line 90 in MCFinclude.au3, which state:

#include "AES.au3"    ; by Ward
; NB in AES.au3 replace line 16    : Global Const Enum $AES_CBC_MODE, $AES_CFB_MODE, $AES_OFB_MODE
;                            by    : Global Const $AES_CBC_MODE=0, $AES_CFB_MODE=1, $AES_OFB_MODE=2

@gil900: Thanks a lot for your efforts :) . I'll update the link to Ward's AES.au3 so as to avoid any more confusion in future. However, as stated above, I did mention this issue in the code remarks, and luckily it is easily fixed.

Now regarding your issue with obfuscation and encryption, if you want to apply both to your script then you simply enable both options simultaneously in CodeCrypter. Doing it as a two-pass in the way you describe won't work. The basis for all substitutions are the MCF# files generated from your original code. If you were to create an obfuscated code first and then load that to be encrypted instead of the original, then Codecrypter would likely have trouble with the mismatches between what it expects (the original code structure) and what you load (the obfuscated version). When you enable both options, an obfuscated intermediate version of the substitution arrays will be produced first, that then immediately serves as input for the encryption pass. The result is a script that is both obfuscated and encrypted.

If you need a separate obfuscated version too, then of course you can generate that as well. Note however that randomisation will generate new obfuscated names for vars and funcs each time CodeCrypter is called. I don't understand why you would want to split the procedure in two, but maybe I've misunderstood your description. If so, please explain in more detail.

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

@legend,

Please read my previous post and check which version of AES.au3 you've got. If it's the one with "Enum" ca. line 16, please apply the patch as suggested in MCFinclude.au3 ca. line 90. AES.au3 needs to be in the same directory as MCFinclude.au3, or else you need to patch the #include line (see previous post) with the full path of wherever it is placed.

Secondly, does Ward's AEStest.au3 run okay?

I suspect that something is going wrong in your #include; is it possible that a local script AES.au3 exists that is not Ward's? Please check that your local version of AES.au3 indeed contains _AES_Startup().

My Contributions and Wrappers

Link to comment
Share on other sites

Hmm, you shouldn't have to remove _AES_Startup(). Elsewhere other AES UDFs are called. It would be better to find out the underlying cause.

If you cannot see the "Source" button (with which you can browse for input files) then that's really odd, because that button's visibility is not conditional.

Errrm, you did add the line '#include MCFinclude.au3"  in your target script before running it through CodeScanner, didn't you?

My Contributions and Wrappers

Link to comment
Share on other sites

Okay, I've managed to reproduce the error at my end. Once I figure out what's causing it, I'll get back to you...

Yep, it was as I suggested earlier, the message is CodeScanner warning you about a missing function reference. This was actually a debugging statement  of mine I failed to remove (I'll fix that shortly), but if you click okay whenever the message appears, and then study the report that CodeScanner generates for you, you would read there:

Includes not found: 
source file:<your Autoit scripts path>\MCFinclude.au3 line: 89; reference: 
#include "AES.au3" ; by Ward

So You need to make sure that both MCFinclude.au3 and AES.au3 (Enum-patched) are placed in the same directory as your target script, then run CodeScanner to generate the MCF files. And before you start encrypting, you need to check that your code is okay, that is, that CodeScanner does not identify such glaring errors as missing #includes in your script. That was the whole point of writing CodeScanner.  So please read its report, and examine its other outputs.

Once codeScanner can find no such mistakes in your code, then you can start CodeCrypter. Your best first step then would be to do a BackTranslation and check if that works exactly like your original script. Only then would I try an encryption pass.

I know it's a lot of hassle and a lot of hoops to jump through. I would make it easier if I could, believe me. Once you have your environment set up properly it really should work.

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

@AutID:

Many thanks for the example, with which I was able to reproduce the same error that plagued one of the other responders, legend. Please see the previous posts for the solution (and make sure the ENum patch is applied to AES.au3 as well). If you still have difficulties, please let me know; I have no trouble whatsoever encrypting and running your sample code. :)

My Contributions and Wrappers

Link to comment
Share on other sites

CodeCrypter beta version 0.9 released. :party:

Added new feature: you can now also encrypt selected UDFs of your choice. :)  This UDF filter is always applied (do not tick/untick the Subset checkbox in the Encrypt panel, that affects only the global proportion encrypted, not this new feature).  By default all encryptable UDFs are set to "encryption enabled." You can flip this state per UDF for all functions for which encryption is possible and optional, and your ensemble settings are saved/reloaded for future use. This gives you more targeted control over which code sections you protect, while dispensing with the slowdown at runtime of added decryption of trivial code sections.

Secondly, after a dev chat I decided to write a workaround for the issue flagged by MagicSpark in a previous post in this thread. As a result, phrases containing the @error or @extended macros will no longer be encrypted, as Execute (which drives the decryption step) resets their state prior to their evaluation.

Thirdly, I've extended and updated the FAQ (MCFQA.pdf), not just to explain this added feature, but also to clarify in more detail how to set up your environment. This was mostly in response to the issue of Ward's AES.au3 not being found in the local directory where MCFinclude.au3 exepcted it to be. I've also referred to the simple workaround for the Enum version incompatibility issue in AES as decribed in the MCFinclude remarks (some people may not find this description otherwise). :whistle:

The UDF selection feature required MCF.au3 and CodeScanner to be updated too, so either download the bundle, or ensure you get all the latest versions (dated 25 Feb or later). The various code alterations and additions may of course give rise to new bugs and glitches, so beware, this is still a beta release... :unsure:

My Contributions and Wrappers

Link to comment
Share on other sites

  • 3 months later...

Version 1.0 released.

No new bells and whistles, just trying to keep up with the changing times, i.e., AutoIt version 3.3.12.1.

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

  • 2 weeks later...

Hi jack71,

Obfuscation is quite easy to accomplish. Just follow these simple steps:

  1. Start CodeScanner, and load it with your script.  Once loaded, a scan will be performed.
  2. Check CodeScanner's report and/or its other outputs for any major mistakes that might cause your script to malfunction (like missing includes, etc), and fix these. Don't worry about any "redundant include" warnings.
  3. Make sure CodeScanner's switch WriteMetaCode (checkbox in the Settings panel) is enabled, and do another scan, then Exit CodeScanner.
  4. Start CodeCrypter, and load it with your script (press the <Source> button under the <Main> Tab).
  5. Press the Tab <Presets> and click <Obfuscate> (this just changes the selected CodeCrypter settings, no action is taken yet)
  6. Press the Tab <Main> and click  <Run>
  7. If all is well, the obfuscated version of your script called MCF0test.au3 is placed in the same directory as your original script.
  8. Test your obfuscated script. If it display unexpected behaviour (unlikely in this case), follow the steps in the MCFQA.pdf FAQ to identify and fix the problem.
  9. You're done. :)

 

PS I just found a tiny mistake in the latest version of the MCF library (for AutoIt 3.3.12.1+); I'll update this post as soon as I've uploaded the corrected version.

Edit: okay, updated everywhere.

Note: even though you do not need all additional files of the MCF environment for your particular purpose, you will still need to set up the complete environment (including Ward's AES.au3) for CodeCrypter, otherwise it will fail to run or compile.

Don't hesitate to ask if you need more info. ;)

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

Hello legend,

Yes, well, what did CodeScanner tell you about your script? :ermm:  I would hazard a guess that it has trouble locating the required include AES.au3, which you have to download separately and put where MCFinclude.au3 can find it. So open MCFinclude.au3 and check the very first #include line against where you actually put AES.au3, and make sure these two agree (so either move AES.au3 to the expected path or edit the include line to match the current path of AES.au3).

If this does not solve your problem, then please submit the smallest-possible test script that reproduces the problem, and I'll have a look.

Edited by RTFC

My Contributions and Wrappers

Link to comment
Share on other sites

Hi jack71,

Obfuscation is quite easy to accomplish. Just follow these simple steps:

  1. Start CodeScanner, and load it with your script.  Once loaded, a scan will be performed.
  2. Check CodeScanner's report and/or its other outputs for any major mistakes that might cause your script to malfunction (like missing includes, etc), and fix these. Don't worry about any "redundant include" warnings.
  3. Make sure CodeScanner's switch WriteMetaCode (checkbox in the Settings panel) is enabled, and do another scan, then Exit CodeScanner.
  4. Start CodeCrypter, and load it with your script (press the <Source> button under the <Main> Tab).
  5. Press the Tab <Presets> and click <Obfuscate> (this just changes the selected CodeCrypter settings, no action is taken yet)
  6. Press the Tab <Main> and click  <Run>
  7. If all is well, the obfuscated version of your script called MCF0test.au3 is placed in the same directory as your original script.
  8. Test your obfuscated script. If it display unexpected behaviour (unlikely in this case), follow the steps in the MCFQA.pdf FAQ to identify and fix the problem.
  9. You're done. :)

 

PS I just found a tiny mistake in the latest version of the MCF library (for AutoIt 3.3.12.1+); I'll update this post as soon as I've uploaded the corrected version.

Edit: okay, updated everywhere.

Note: even though you do not need all additional files of the MCF environment for your particular purpose, you will still need to set up the complete environment (including Ward's AES.au3) for CodeCrypter, otherwise it will fail to run or compile.

Don't hesitate to ask if you need more info. ;)

Thanks RTFC.  I downloaded your bundle, plus Ward's bundle (extracted the AES.au3) and put that inside a folder called "CodeCrypter" inside my AutoIt dir.  I ran the codescanner.au3 and I get this error:

Global Const Enum $AES_CBC_MODE, $AES_CFB_MODE, $AES_OFB_MODE

error: syntax error

error: Statement cannot be just an expression

"C:Program Files (x86)AutoIt3CodeCrypterAES.au3"(16,14) : error: syntax error

What did I do wrong?

Thanks again!

Link to comment
Share on other sites

@jack71,

Great :thumbsup: , now if you scroll back up to post #27 in this thread you'll find the answer.

It's also mentioned at the top of the second page in  the FAQ (MCFQA.pdf).

Detailed instructions can be found in the header remarks of MCFinclude.au3 (basically you have to patch one line of Ward's code, explciitly assigning a few values to globals. That's all. :guitar:

RT

My Contributions and Wrappers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...