Jump to content
RTFC

CodeCrypter - Encrypt your Script

Recommended Posts

Thank you for alerting me to this potential issue;:) a more general fix than your patch will be included in the next release.

BTW: 1) please do not press "Quote" for anything more than a single line of text (at least not in my threads); 2) please do not quote me back in translation. Thank you.

Edited by RTFC

Share this post


Link to post
Share on other sites

wyf,

I agree with RTFC's comment above. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - and certainly do not quote translated posts!

M23

 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Quote

 

 

Hello, Ask for help, look at the picture....Thanks! ! !

test.PNG.745739c78a781395a8a4026887a0746f.PNG

 
Edited by wyf
add information

Share this post


Link to post
Share on other sites

@wyf: 1. CodeCrypter does not officially support Objects, as mentioned in various places (see CodeCrypter Remarks section, for example). If it works, great; if it doesn't, too bad. I do not use objects myself, and I'm not going to start using them to fix your issue.

2. If you ever write any more posts in (what looks to me like) Chinese, I will just ignore them.:mad:

Edited by RTFC

Share this post


Link to post
Share on other sites
Sorry, I used Google Chrome, accidentally translated the browser into Chinese, I did not pay attention, apologize to you again! ! !

Share this post


Link to post
Share on other sites

Temporary resolution:
Modify MCFinclude.au3 UDF _MCFCC_Init():
custom $CCkey[4] and $CCkey[5] . Deprecated _WinAPI_UniqueHardwareID() to solve the object parameter problem. Now the test is all normal, for reference only...
Thank you....

Edited by wyf

Share this post


Link to post
Share on other sites

Glad you got it working.:)

3 hours ago, wyf said:

Modify MCFinclude.au3 UDF _MCFCC_Init():
custom $CCkey[4] and $CCkey[5] .

That's exactly what you should be doing. The provided inputs are merely simple examples, to be replaced by your own, more sophisticated function calls, to cater for your own work environment(s).

Share this post


Link to post
Share on other sites
Even if  modify the $CCkey definition yourself, crypto obfuscation of larger scripts still fails... look forward to your next revision.
Edited by wyf

Share this post


Link to post
Share on other sites
On 5/16/2018 at 12:04 AM, RTFC said:

Glad you got it working.:)

That's exactly what you should be doing. The provided inputs are merely simple examples, to be replaced by your own, more sophisticated function calls, to cater for your own work environment(s).

I thought the provided inputs are the ones i need lol.

Share this post


Link to post
Share on other sites

You're welcome, Rhovanion.^_^ Feel free to stick with the provided key definitions if that floats your boat.

Share this post


Link to post
Share on other sites
On 10/20/2013 at 4:02 AM, RTFC said:
  • anything else you can think of, as long as it's not stored in the script

Your project is huge! Can it read the key from something like %TEMP%\password-inside.txt ?

Share this post


Link to post
Share on other sites

Sure, just write a little function or direct call that does this (e.g., FileRead(" %TEMP%\password-inside.txt")) and stick this into the CCkey definition (in MCFinclude.au3) for the desired keyID. However, storing a password on file is a terrible, terrible idea.

Share this post


Link to post
Share on other sites

May I add a question here?

The whole process of encrypting works flawless. But if I compile the encrypted output file to an *.exe and copy that to another computer, it runs as well - even the environment (username, hd serial number or wahtever...) has changend on the other computer?

Do I understand something wrong? I thought I can protect the script from beeing executet on a "wrong" environment (where username, hd serial number or whatever does not match)? Or is the key only to protect the file from beeing decrypted?

When I open the the MCF0test.au3 file I can see my plain code above and below the #include <MCFinclude.au3> directive, but between about 800 lines of new code.

13-33-10-CodeCrypter.png

Edited by roman

Share this post


Link to post
Share on other sites

Questions are always welcome.:)

Your understanding of Codecrypter's purpose is totally correct; outside the sanctioned environment (as defined by you, through selection/definition of the $CCkey array contents and specified key ID(s)) the encrypted version of your script should not run. However, from your description it sounds to me that either 1. no encryption is actually performed (which would explain why MCF0test still runs on other machines), or 2. you are compiling a different/earlier non-encrypted version of MCF0test.au3 that was generated without encryption.

There's no point compiling until you're sure the encrypted version is produced correctly and performs exactly as the original script. So just take/write a one-line helloworld.au3 test script, add MCFinclude.au3 at the top, run CodeScanner, then let Codecrypter produce an encrypted version. When you open this in Scite, you should see the MsgBox line (at the bottom of the new script) having been replaced by an Execute(_MCFCC(...)) call. If the original MsgBox line is still present, then I have no idea what could be wrong, provided that in CodeCrypter you did tick:

  • "Create MCFO" in Main->File I/O
  • "Encrypt" in Main->CodeCrypter
  • "Phrases" in Encrypt->Content
  • "Strings" in Encrypt->Content

before pressing "Run."

Share this post


Link to post
Share on other sites

Ok, I did exactly what you wrote, but I have the same failure.
 

  1. Created a simple "Hello World" script with file name Test.au3
    #include <MCFinclude.au3>
    MsgBox(0, "", "Hello World")

     

  2. Let run codescanner.au3 over it; on the end I got a window "Code Scanner Main Menu" which I closed.
  3. Started codecrypter.au3, choosed my "Hello World" script with Source button and verified that the 4 checkboxes you mentioned are ticked.
  4. Let run codecrypter by pressing the Run button
  5. Get a new file "MCF0test.au3" the same directory as my "Hello World" script, which shows my MsgBox call in plain text in the last line:
    [...]
    B836F9EDE2C630FE16EF0E51B9C805376FF193B9BEF5E3CA26DB92D3944D3C142E723DFD3095BA3498B92C19C285B313D98B7117BB1CF44AB15719BF5907A54000723B3F3126F636BEA1887169F35B649C88DB0004621D2"))
        $CCkeytype=$type
    EndFunc
    
    MsgBox( 0 ,"","Hello World")

 

 

What the hell do I wrong?  😟

How gets codescanners "output" to codycrypters "input"? Do I have to set something after ending codescanner and before starting codecrypter? I could make a short screen capture video about what I exactly do and provide the link to you? Would this help?

 

PS. I have it tested on another PC, only to be sure it's not a permission issue. But without success.

Edited by roman

Share this post


Link to post
Share on other sites
6 hours ago, roman said:

Let run codescanner.au3 over it

Did you enable CodeScanner's option writeMetaCode in its settings? Is a subdirectory test.au3.CS_DATA produced by codescanner? What does the MCFencoding.log therein contain after running codecrypter? Does the file stringEncrypt.txt contain encryption calls after running codecrypter? Does the file MCF0.txt (not .au3, but .txt extension!) contain metacode such as this (near the end):

{funcA307}( 0 ,{string1},{string2})     ; {file:1}{line:4}
6 hours ago, roman said:

I could make a short screen capture video

That usually doesn't help me. AFAICT, you're doing everything right.

6 hours ago, roman said:

How gets codescanners "output" to codycrypters "input"?

Codecrypter uses the source filename you provide to identify the ...CS_DATA subdirectory from which it reads the files it needs. I don't think the problem lies there.

6 hours ago, roman said:

What the hell do I wrong? 

I have no idea; nothing that I can see at this end.

6 hours ago, roman said:

Do I have to set something after ending codescanner and before starting codecrypter?

Nope. As long as Codescanner writes out the MCF files beforehand, codecrypter only needs the source filename.

Share this post


Link to post
Share on other sites
17 hours ago, RTFC said:

Did you enable CodeScanner's option writeMetaCode in its settings?

Yes. It is/was already enabled per default:

[...]
Global $ExtractMacros=True            ; create a list of all @macros used
Global $WriteMetaCode=True            ; translate script into symbolic metacode for post-processing
Global $showprogress=True            ; True = show progressbars
[...]

 

17 hours ago, RTFC said:

Is a subdirectory test.au3.CS_DATA produced by codescanner?

Absolutely YES.

 

17 hours ago, RTFC said:

What does the MCFencoding.log therein contain after running codecrypter?

This is the whole content of MCFencoding.log:

2019/07/09 08:39:18: MCF Encoding Logging initiated.

Encoding Settings:
MCF_REPLACE_AUFUNCS = True
MCF_REPLACE_UDFS = True
MCF_REPLACE_VARS = True
MCF_REPLACE_STRINGS = True
MCF_REPLACE_MACROS = True
MCF_REPLACE_OBJECTS = True
MCF_REPLACE_PHRASES = True
MCF_ENCRYPT_SUBSET = False
MCF_WRITE_COMMENTS = False

2019/07/09 08:39:18: 
No problems found.

2019/07/09 08:39:18: MCF Encoding completed.


 

17 hours ago, RTFC said:

Does the file stringEncrypt.txt contain encryption calls after running codecrypter?

It seams so, yes. This file has 7164 lines, here an extract of the first and last 10 lines:

_MCFCC("0xFBA4F8056294DED0FA6D66304CAEE52B38A3B5EBC590C24432927D986996CE6A",3)
_MCFCC("0xC640F880BBCCAB5DECC9BD91F472D88FA1EDDFAF5ED3DC2AED560C0AD0E71633",3)
_MCFCC("0xE48E26D45FC94FCEA643A23E1A55E0B8A05133E2405F6F890CEE7CFBA33E450C",3)
_MCFCC("0x7BEB9A4D99D07F327A017197A7BC865B92C75DEED2EC5C2BC5672A4AEA5FEE7A",3)
"0x3CA86772DB0B25CBD8AC911792C2217A9DD04C218DAE0F4261BD76EF512838FBDE2BDA417829E56D62EDE396B376E2CC"
_MCFCC("0x606952466976C86495F7F0E2CD3BC9CD0EBE89BF75D22AF9824F87D27EDAD70C")
_MCFCC("0xC7E16C8C2EF6C6006F4AAE0FFE4D7A61700BEAA70D9D5C5522E11AC84E27B7C3")
_MCFCC("0x7BC8180C95F46ED51DF7BE9BFFE9670178E98BB1077A30C0BD701F634CD9A542")
_MCFCC("0xD7C848AF17ADD636D34E5657091A9F10D13F0FD21CAE2BFB0216EA11AEAF87C9")
_MCFCC("0x45BFB2586EF67237B327317AF620A3BD818A4ACE4F0EE1AA793047150A0B14B5")
[...]
[...]
[...]
_MCFCC("0x4A05DC62544429DE676645239F5373F877D6C4CF382FE75BAC89CA0FBBB07B94",3)
_MCFCC("0xC25F775F3CAA147C648CEC4C7764C66933D30D3B181A06B13EDED3BD2FFA03CC",3)
_MCFCC("0x0B210913B8F83D48B1AB1C134FCDE1EAAB9450FA2A3D463C5EA4DCE02171E70B",3)
_MCFCC("0xD69884DE6066A1AD8B5A3524EE00B93E4DEBFE1C518717EC79C1048323C3169F",3)
_MCFCC("0xBAC5CEFB4ECC5D4424C59E0EFC2C994A1D70895673DDC6B34C82DF27A12554FB",3)
_MCFCC("0x2CA7447CF1708E3A46A764C723EE006E65A92657B7E5C3234B4F3A0848DA63AC",3)
_MCFCC("0x22A30DDD1D5A92F50CE741FE6CDC2FF49091BC422E2B9FEA001EB64F5034D703",3)
_MCFCC("0xAD549B978F0639B5EAF2ED1B382F7EA7F774FC71FE8DC1E0F1CDC0A5FF5A04EF",3)
_MCFCC("0x55A1F5390529710F269E2C532FAABBCA0166286071B72FC7DDC72BFAACE190FA",3)
_MCFCC("0x99C83E23478C44F955ACD1C8B7CAA11FB1893A430AFE66B97625B2004B536914",3)
_MCFCC("0xA8D1F75E4ADEA48DAA72E9C8C185834F7936C6E15EB842D60C6A64503FBD0734",3)

I attached the whole file.

 

17 hours ago, RTFC said:

Does the file MCF0.txt (not .au3, but .txt extension!) contain metacode such as this (near the end):

{funcA307}( 0 ,{string1},{string2})     ; {file:1}{line:4}

 

Yes, it seams so. Here the last 10 lines of this file:

[...]
If {var9}={string9} Then {var9}=1       ; {file:2}{line:200}
If {var9}<= 0 Or {var9}>{funcA457}({var6})- 1 Then        ; {file:2}{line:201}
{var14}=1       ; {file:2}{line:202}
{var6}[{var14}]={funcA394}({var9})       ; {file:2}{line:203}
Return       ; {file:2}{line:204}
EndIf       ; {file:2}{line:205}
If {var6}[{var9}]={string10} And {var10}= True Then {var6}[{var9}]={funcA279}({string11},{string12},{string13},{string14}, 250 , 140 )       ; {file:2}{line:207}
{var14}={var9}       ; {file:2}{line:208}
EndFunc       ; {file:2}{line:210}

{funcA307}( 0 ,{string1},{string2})       ; {file:1}{line:2}

 

I've attached the final script file as well.
Thank you very much for your support. I'm courious what will come out finally...!  🤔

stringsEncryp.txt

MCF0test.au3

Edited by roman

Share this post


Link to post
Share on other sites

Thanks for the feedback. More questions then.

In Codecrypter's Structure Tab, did you tick "Enable Phrasing"?

In your helloworld CS_DATA subdir, does the last line of phrases.txt look something like this:

{funcA307}( 0 ,{string1},{string2})

And does the tail end of your phrasesNew.txt contain MCFCC decryption calls?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By RTFC
      The CodeScannerCrypterBundle (ca. 2.5 MB unzipped) contains the following UDFs and utilities:
      CodeScanner: analyse AutoIt script structure and content, identify potential issues, generate MCF data files CodeCrypter: front-end GUI for the MCF library, for script encryption (without storing the decryption key(s) in the script!) MetaCodeFile UDF (MCF library): for analysis and user-defined alterations of AutoIt script structure and content MCFinclude.au3: #include this UDF in any AutoIt script that you wish CodeCrypter to process AES.au3, by Ward; machine code UDF for AES encryption (32-bit, patched version) CryptoNG, by TheXman; encryption UDF using Bcrypt dll calls (32/64-bit; various algorithms) StoreCCprofile.au3/readCSdatadump.au3/helloworld.au3: auxiliary utilities and example script HowToCodeCrypt.pdf: a simple guide in five steps CodeCrypterFAQ.pdf: questions and answers, partly based upon exchanges in the CodeCrypter thread. Please follow the links for additional information.
    • By TheXman
      Encryption / Decryption / Hashing
      Purpose
      Cryptography API: Next Generation (CNG) is Microsoft's long-term replacement for their CryptoAPI.  CNG is designed to be extensible at many levels and cryptography agnostic in behavior.  Although the Crypt.au3 UDF that is installed with AutoIt3 still works perfectly, the advapi32.dll functions that it uses have been deprecated.  This UDF was created to offer a replacement for the deprecated functions.  According to Microsoft, deprecated functions may be removed in future release.  Therefore, this UDF will be available when/if that happens.
      Description
      This UDF implements some of Microsoft's Cryptography API: Next Generation (CNG) Win32 API functions.  In its initial release, it implements functions to encrypt text & files, decrypt text and files, generate hashes, and the Password-Based Key Derivation Function 2 (PBKDF2) function.  The UDF can implement any of the encryption/decryption algorithms or hashing algorithms that are installed on the PC in which it is running.  Most, if not all, of the values that you would commonly use to specify that desired algorithms, key bit lengths, and other magic number type values, are already defined as constants or enums in the UDF file.
      To flatten the learning curve, there is an example file that shows examples of all of the major functionality.  This example file is not created to be an exhaustive set of how to implement each feature and parameter.  It is designed to give you a template or guide to help you hit the ground running in terms of using the functions.  I have tried to fully document the headers of all of the functions as well as the code within the functions themselves.    As of v1.4.0, there is also a Help file that includes all of the functions, with examples.
      Current UDF Functions
      _CryptoNG_3DES_CBC_DecryptData _CryptoNG_3DES_CBC_DecryptFile _CryptoNG_3DES_CBC_EncryptData _CryptoNG_3DES_CBC_EncryptFile _CryptoNG_AES_CBC_DecryptData _CryptoNG_AES_CBC_DecryptFile _CryptoNG_AES_CBC_EncryptData _CryptoNG_AES_CBC_EncryptFile _CryptoNG_CreateRSAKeyPair _CryptoNG_DecryptData _CryptoNG_DecryptFile _CryptoNG_EncryptData _CryptoNG_EncryptFile _CryptoNG_EnumAlgorithms _CryptoNG_EnumRegisteredProviders _CryptoNG_GenerateRandom _CryptoNG_HashData _CryptoNG_HashFile _CryptoNG_LastErrorMessage _CryptoNG_PBKDF2 _CryptoNG_Version  
      Related Links
      Cryptography API: Next Generation - Main Page
      Cryptography API: Next Generation - Reference
      Cryptography API: Next Generation - Primitives
      Cryptography API: Next Generation - Cryptographic Algorithm Providers
    • By RTFC
      MetaCode offers a way to:
      separate a script's structure from its content remove all redundant definitions (globals and UDFs) change any content (and some structure) combine (new) structure and (new) content into a new script The most useful applications implemented so far are:
      Fast language translation (not just text strings, also variable names and UDF names) Obfuscation (vars and/or UDFs) Script Encryption (conditionals, calls, and macros) Encryption is powerful because the key is not stored anywhere; you can define it to be a user password, macro, environment spec/variable, server response, something you define yourself, or a combination thereof; anything goes, as long as it's not a fixed string or fixed value. More info in the CodeCrypter thread: ?do=embed' frameborder='0' data-embedContent>'?do=embed' frameborder='0' data-embedContent>>
      ?do=embed' frameborder='0' data-embedContent>
      But MetaCode has more potential than that; it allows you to tinker with any type of content separately, then rebuild a new version. So for example, you can have a single script structure and numerous different language modules you just plug in to create a new version in a different language.
      A brief Tutorial is here: MetaCode Tutorial.pdf
      The MCF library itself can be found in the CodeScannerCrypter bundle.
      And a little example how to use it for translating your GUI into a different language:
       UI_Translator.7z (new version that should work with the new version of Google Translate, see post #13 below)
       
       
      MCF.au3 is just the library plus the MCFinclude.au3 file you need to include in any script you wish to encrypt.
      There is no GUI here. However, I did write a separate front-end for it called CodeCrypter, which you can find here:
      ?do=embed' frameborder='0' data-embedContent>'?do=embed' frameborder='0' data-embedContent>>
      ?do=embed' frameborder='0' data-embedContent>
      MCF uses output generated by my CodeScanner version 2.8+, which you can find here:
      '?do=embed' frameborder='0' data-embedContent>>
      CodeScanner also depends on MCF.au3 now, as it can now call a few of its functions.
      I should also mention Ward's excellent AES.au3 UDFs used for the encryption and decryption calls,  which is now included in the CodeScannerCrypter bundle (thanks to Ward for allowing to include it). You can find the original (unpatched) version here:
      '?do=embed' frameborder='0' data-embedContent>>
      Note: you can replace the encryption/decryption calls with whatever algorithm you like (hint: the native <Crypt.au3> library is too slow for most purposes, better stick to machine code routines)
      So just to be clear:
      CodeScanner (v2.8+) needs MCF (earlier versions won't work!) CodeCrypter needs MCF (plus anything that MCF needs) MCF itself needs MCFinclude (part of MCF zip) MCF also needs readCSdatadump (part of the CodeScanner package, you need the latest version packaged with CodeScanner v2.8; earlier versions won't work!) both MCF and MCFinclude currently rely on AES.au3 by Ward So you basically need to download the whole bundle for any of it to work.
       
      If you have any questions, please start by reading the MCF Tutorial and the CodeCrypter FAQ (you can download the latter separately from the CodeCrypter thread).
      Next, read the extensive Remarks sections in MCF.au3, MCFinclude.au3, and CodeCrypter.au3
      If still no joy, then please post. However, I'm not online that often, and logged in to the forum even less, so response may take a while).
      RT
×
×
  • Create New...