Jump to content

Recommended Posts

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:

  1. Fast language translation (not just text strings, also variable names and UDF names)
  2. Obfuscation (vars and/or UDFs)
  3. 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:

CodeScannerCrypter.bundle.v2.3.7z

 

 

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

Edited by RTFC

Share this post


Link to post
Share on other sites

Beta version 0.9 released, added support for CodeCrypter's new UDF filtering feature. This allows the user to apply encryption per individual UDF. For more info, see the updated FAQ (MCFQA.pdf) in the Codecrypter thread.

Share this post


Link to post
Share on other sites

Version 1.1 released (3.3.12 compliant)

One tiny bug squashed. :pirate:

No other cruelties committed.

Edited by RTFC

Share this post


Link to post
Share on other sites

Is it there an overall frontend?

p.s.
(tried MCF.au3, got 32 errors)

"

:unsure:

...AutoItMCFMCF.au3"(360,54) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($FuncEqualsString, $curstring, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(364,55) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($functionsCalled, $curstring, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(387,54) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($functionsCalled, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(388,55) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($FuncEqualsString, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(472,49) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($variablesUsed, $curvar, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(490,100) : error: _ArrayAdd() called with wrong number of args.
If _ArraySearch($macrosUsed, $curmacro, 1) < 1 Then _ArrayAdd($macrosUsed, $curmacro, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(518,56) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($functionsUsed, $previousword, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(525,78) : error: _ArrayAdd() called with wrong number of args.
If $index < 1 Then _ArrayAdd($functionsCalled, $previousword, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(618,46) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($varonce, $curvar, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(620,93) : error: _ArrayAdd() called with wrong number of args.
If _ArraySearch($vartwice, $index, 1) < 1 Then _ArrayAdd($vartwice, $index, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(633,108) : error: _ArrayAdd() called with wrong number of args.
If _ArraySearch($funcalled, $curfuncindex, 1) < 1 Then _ArrayAdd($funcalled, $curfuncindex, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(661,82) : error: _ArrayAdd() called with wrong number of args.
If $index > 0 Then _ArrayAdd($funcorphans, "{funcU" & $index & "}", 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(776,60) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($already_included, $original_filename, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(892,52) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($globalsOrphaned, $MCtag, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(894,92) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($globalsOrphaned, StringStripWS(StringLeft($MCtag, $pos - 1), 2), 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1283,48) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($strings1, $curstring, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1285,48) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($strings2, $curstring, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1332,46) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrases, $curphrase, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1333,47) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrasesUDF, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1344,46) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrases, $curphrase, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1345,47) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrasesUDF, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1372,46) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrases, $curphrase, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1373,47) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrasesUDF, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1388,45) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrases, $curphrase, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1389,46) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($phrasesUDF, $curfunc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(1787,44) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($namesUsed, $newname, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(2250,39) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($markers, 1, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(2251,43) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($locations, $cc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(2254,39) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($markers, 2, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(2255,43) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($locations, $cc, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"...AutoItMCFMCF.au3"(2429,44) : error: _ArrayAdd() called with wrong number of args.
_ArrayAdd($Callstack, $procname, 0, Chr(0))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files (x86)\AutoIt3\Include\Array.au3"(53,40) : REF: definition of _ArrayAdd().
Func _ArrayAdd(ByRef $avArray, $vValue)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
...AutoItMCFMCF.au3 - 31 error(s), 0 warning(s)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Hi Chimp,

The only available front-end at the moment is CodeCrypter, with which you can:

  • translate
  • obfuscate
  • encrypt
  • replace any specific content with any other content you define

I've been toying with the idea of a more general code editing front-end, for example to automate the implementation of script-breaking changes (see below :)), but at the moment I'm too busy with other projects. :unsure:

Regarding the errors you get, it looks like you are mixing AutoIt versions, that is, the current version of MCF (1.1) implements the script-breaking changes Melba23 implemented in <Array.au3> for AutoIt 3.3.12.1. However, you seem to be running the new version of MCF in an older version of AutoIt (please check the MCF header against your AutoIt version). So my advice is to download the current version of AutoIt and try again. ;)

There are several hundred changes implemented in all parts of this environment (older versions of CodeScanner and CodeCrypter won't work anymore either under 3.3.12.1, and the new versions won't work when running older versions of AutoIt. So please check the headers of these scripts, where the AutoIt version under which they should run/compile is always listed.

Upgrading environment is always a nuisance, but it can  be even more work to update all scripts to function in the new environment, I can assure you. :(

 

Edit: To accommodate users unwilling or unable to upgrade to AutoIt version 3.3.12 or higher, I'll make the last 3.3.8.1-compliant bundle available from here. However, none of these outdated versions will be maintained or upgraded, and I won't be fixing any bugs in them anymore. This is a temporary fix; when I run out of storage space it may disappear without advance notice, so get it while you can (but only if you really, really don't wish to upgrade your AutoIt version).

CodeScannerCrypter.bundle.old.zip

Edited by RTFC

Share this post


Link to post
Share on other sites

There is no v3.3.12.1. I have look through the code and though you have put a ton of effort into, I am still having trouble to understand how to "simply" use this. I would prefer to test something in which I can select the script and voila it spits out whatever it is it's meant to spit out.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Hi guinness,

Thanks for the clarification.

Funny thing, serendipity. :o  A few days ago somebody else just PM'ed me with a similar request, to produce a cmdline utility of CodeCrypter (the main front-end for this library) to just spit out an obfuscated and/or encrypted version of any input script. When I have a spare moment, I'll probably be able to rustle something up...

As far as engaging directly with the MCF library (and presuming you studied the Tutorial), CodeCrypter's source is admittedly a complicated example (although it does more or less exactly what you request, see the presets Tab). The problem is that the process is intrinsically multi-step; you have to run CodeScanner first to produce the MCF relevant arrays, which you can then engage with, through CodeCrypter, your own script, or both.

The basic idea is however, really simple:

  1. split the contents of your script up in topical arrays, turning the original script into a collection of placeholder array pointers
  2. duplicate the arrays you wish to change the content of, and make whatever changes you like there
  3. rebuild the script using the metacode pointers, but referring to the new arrays

Codescanner does step 1 for you, whereas CodeCrypter provides examples of steps 2 and 3. Alternatively you can write your own script to change the *New content arrays, and then simply use CodeCrypter's "Create New" option to rebuild.

It's potentially very powerful, because you can also make structural changes in the metacode file itself prior to step 3. In encryption, for example, I replace every function call, macro and conditional with an Execute(<decrypt><string>) wrapper. It's like the ultimate search-and-replace engine for both content and structure, but separately.

But you're right, :( it probably looks forbidding, but it is surprisingly difficult to produce a simple in/out example. I'll have to think about how I might be able to make this library more accessible. :huh2: Beng the designer is a handicap in this case, because I have to place myself in the shoes of somebody who sees the MCF UDFs for the first time, and it's hard to wipe once's subconscious mindset.

Anyway,  your input is much appreciated. ;)

Edited by RTFC

Share this post


Link to post
Share on other sites

Version 1.2 uploaded, plus a small example: UI_translator.

This is basically two MCF calls: CreateSingleBuild, and _RebuildScript. Inbetween it performs the desired script change; in this case, it identifies most GUI-related  AU3 calls and translates all strings parsed directly to these functions, using Google Translate (thanks to akurakkauaaa, see '?do=embed' frameborder='0' data-embedContent>>, post #16). I've added a little helloworld.au3 example for illustration. You may have to patch Google's result manually in your own (translated scripts), because it still makes many mistakes.

It's just a demo to show how to interact with the MCF library, it's not meant to be a robust universal translator.

Hope it helps.

RT

Edited by RTFC

Share this post


Link to post
Share on other sites

Version 1.3 uploaded. Not:e: this concerns only MCF itself; the complete bundle is not yet updated, as I'm still tinkering with the next CodeScanner update.

RegExp pattern strings are now excluded from string processing in certain procedures to avoid various issues.

Edited by RTFC

Share this post


Link to post
Share on other sites

HI RTFC,

I tried out the UI_Translator but  always receive returns of = 0
I run codescanner on helloworld.au3 
in settings I select "write meta code" and rescan
internet connection = on
then I run UI_Translator.au3 selecting helloworld.au3
I get returns of = 0

have I missed something in how its done ?
thanks

 

Share this post


Link to post
Share on other sites

Hi Deye,

Thanks a lot for spotting this. There's nothing wrong with your approach, but my UI_Translator.au3 farms out the actual call to googleTranslate to akurakkauaaa's googletranslate.au3 (see post #16 in that thread), and apparently GoogleTranslate has changed its interface so the UDF in that script no longer works properly. When I have a spare moment I'll see if I can figure out what's wrong, or perhaps dig up an alternative somewhere (suggestions, anyone?) In the meantime, should you have access to some other translation UDF yourself, it may be doable to just replace the two calls to _googleTranslate() ca. line 375 in UI_Translator with your own.

Sorry for the inconvenience; I'll report back either way (but it may take me a few days...)

 

Edited by RTFC

Share this post


Link to post
Share on other sites

Okay, as far as I can tell none of the various Example scripts for querying Google Translate posted on the forum works anymore, because they've moved to a business subscription service model where you have to pay $20 per 1M words, which sucks. In my opinion (and in the spirit of the free, fully accessible internet for all), this kind of service should be free. So while we wait for such a free alternative service to emerge, here's an example of how one could still access Google's new service:

#include <Array.au3>
#include <IE.au3>

Local $tag="* # * # *"
Local $oIE=_IECreate("https://translate.google.com/#auto/es")
Local $oForm=_IEFormGetCollection($oIE,0)
Local $oQuery=_IEGetObjByName($oForm,"text")

_IEFormElementSetValue($oQuery, $tag & @CR & "Hello World" & @CR & "This is a test" & @CR & $tag)
_IEFormSubmit($oForm)
_IELoadWait($oIE)

Local $oText=_IEGetObjById($oIE,"gt-res-data")
$lines=StringSplit(_IEPropertyGet($oText,"innerText"),@CRLF,1)
_IEQuit($oIE)

_ArrayDelete($lines,_ArraySearch($lines,$tag,1,0,0,1,0) & "-" & $lines[0])
_ArrayDelete($lines,"1-" & _ArraySearch($lines,$tag,1,0,0,1,1))
$lines[0]=UBound($lines)-1
_ArrayDisplay($lines)

Doubtless this will change again at some point and no longer work. I'm consciously not providing a fully-fledged UDF, just a simple example to illustrate how this could be done, if one were so inclined. And moderators, please let me know if this contravenes forum rules, then I'll remove it again (I'm not sure...).

@Deye, I still have to implement this in my UI_Translator when I have some more time, maybe this weekend.

 

Edited by RTFC
minor bug fix

Share this post


Link to post
Share on other sites

@Deye (and all others wishing to translate their GUI text strings into 90 different languages), I've uploaded the new version of UI_Translator in the first post of this thread, based upon the example code in my previous post (immediately above).

No guarantees how long this will work, ask Google.:lol:

Share this post


Link to post
Share on other sites

Hello,

 

I have big problem when i try encrypt  """data""". After encyrpt the code is ""data"" instate of "data".

 

Have some one the same problem

Share this post


Link to post
Share on other sites

@sprzetok: I can encrypt the following test script with triple double-quotes without a problem:

#include <GUIConstantsEx.au3>
#include <MCFinclude.au3>

MsgBox (0, "Test","""Hello, World!""")

Example()

Func Example()  ; adapted from Help file, first example for GuiCreate
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("This is an Example")
    Local $idOK = GUICtrlCreateButton("Press to Quit", 140, 200, 120, 30)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

Moreover, a backtranslation shows that the triple quotes have been retained.

Please post a reproducer script (one that re-creates the error) adapted from the above template, if possible. And technically, you should have reported this in the CodeCrypter thread (see my signature), not here.:(

Hint: you can always edit the appropriate stringsNew.txt list with your own manually edited version to force a particular string to be output the way you want it. Please consult the documentation.

PS: Welcome to the AutoIt Forums!:)

Edited by RTFC

Share this post


Link to post
Share on other sites

@Skysnake: Tutorial downoad link added in first post. Sorry for the delay in replying.

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

  • Similar Content

    • By Colduction
      I had created login form and this form first goes to de-crypting file that encrypted then read the saved credentials by de-cryptied file, but doesn't work properly!
      I want just read encrypted data without saving de-crypted file, just read! 
      #NoTrayIcon #include <Crypt.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;==================================Variables=================================== ;Encryption settings _Crypt_Startup() $PEK = _Crypt_DeriveKey("BS#Password", $CALG_AES_256, $CALG_SHA_512) $DefaultCredFile = "[Credentials]" & @CRLF & "BUsername=NoAdmin" & @CRLF & "BPassword=NoAdmin" & @CRLF & "[Process]" & @CRLF & "ProcessKillingTimeout=3600" $EncryptDefaultCred = _Crypt_EncryptData($DefaultCredFile, $PEK, $CALG_AES_256) $IniReadCredPassword = IniRead(@WindowsDir & "\Config\GUIDecCred.dat", "Credentials", "BPassword", "") $IniReadCredUsername = IniRead(@WindowsDir & "\Config\GUIDecCred.dat", "Credentials", "BUsername", "") ;==================================Variables=================================== AuthForm() Func AuthForm() Global $LoginForm = GUICreate("Login", 201, 161, -1, -1) Global $CloseBTN = GUICtrlCreateButton("Close", 23, 126, 75, 25) Global $SignInBTN = GUICtrlCreateButton("Sign-in", 103, 126, 75, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $PasswordInput = GUICtrlCreateInput("admin", 8, 88, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) Global $UsernameInput = GUICtrlCreateInput("admin", 8, 40, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) Global $UsernameLBL = GUICtrlCreateLabel("Username:", 8, 21, 55, 17) Global $PasswordLBL = GUICtrlCreateLabel("Password:", 8, 68, 53, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SignInBTN AuthProcess() EndSwitch WEnd EndFunc AuthProcess() Func AuthProcess() $ReadEnteredUsername = GUICtrlRead($UsernameInput) $ReadEnteredPassword = GUICtrlRead($PasswordInput) If Not FileExists(@WindowsDir & "\Config\GUIEncCred.dat") Then FileDelete(@WindowsDir & "\Config\GUIDecCred.dat") ;Delete previous de-crypted credentials FileWrite(@WindowsDir & "\Config\GUIEncCred.dat", $EncryptDefaultCred) ;Write en-crypted credentials as "*.dat" file FileClose(@WindowsDir & "\Config\GUIEncCred.dat") ;Close en-crypted credentials file _Crypt_DecryptFile(@WindowsDir & "\Config\GUIEncCred.dat", @WindowsDir & "\Config\GUIDecCred.dat", $PEK, $CALG_AES_256) ;Write de-crypted file from an en-crypted file as "*.dat" file Else _Crypt_DecryptFile(@WindowsDir & "\Config\GUIEncCred.dat", @WindowsDir & "\Config\GUIDecCred.dat", $PEK, $CALG_AES_256) ;Write de-crypted file from an en-crypted file as "*.dat" file EndIf Sleep(25) If $ReadEnteredUsername == $IniReadCredUsername And $ReadEnteredPassword == $IniReadCredPassword Then ;Username and Password verify stage MsgBox(64, "", "Welcome!") FileDelete(@WindowsDir & "\Config\GUIDecCred.dat") Exit Else MsgBox(14, "", "Incorrect!") FileDelete(@WindowsDir & "\Config\GUIDecCred.dat") Sleep(25) EndIf EndFunc How Can i? 
    • By Beege
      I found this article and enjoyed it so much I had play with some code since the numbers are small enough. 
      https://thatsmaths.com/2016/08/11/a-toy-example-of-rsa-encryption/
       
      Standard Encryption's vs RSA Encryption (Public Key Encryption) Fundamental Differences
      If you read that and couldn't immediately clarify the difference then let me blow your mind because its simple:
      STANDARD ENCRYPTION'S:
      ORIGINAL_DATA + Password(or KEY) = Encrypted DATA
          Then to decrypt -> 
              Encrypted DATA + (SAME Password(or SAME KEY)) = ORIGINAL_DATA
              
      RSA:
              ORIGINAL_DATA + Password(or PUBLIC_KEY) = Encrypted DATA
          Then to decrypt -> 
              Encrypted DATA + (DIFFERENT Password(or PRIVATE_KEY)) = ORIGINAL_DATA
      Are we all caught up? Did the colors help? I think they did
      That's crazy right? Don't answer. It is. And crazier its used EVERY TIME we make a secure connection to a server over the internet. But here's the craziest part to me that I recently got clarity on from the toy example and that is the simplicity of this very very very very important algorithm that has yet to be cracked (fingers crossed):
                 Mod($vData ^ $key, $n)
          
      So ya. That's it. That's the magic algorithm. 3 values. Oh and $n is also a shared known value that will be in the certificate with the public key that your browser reads when it makes a connection:

      That's just mind blowing to me so couldn't resist getting something going in AUT. After playing with this code, I got a much better understanding of how its not just that algorithm that makes this whole thing possible. The numbers that we pick to form the public key and n are just as important and also how important it is to be random! 
      Let me know if you have any problems. Enjoy!
      #include <array.au3> _Toy_RSA_Example() ;https://thatsmaths.com/2016/08/11/a-toy-example-of-rsa-encryption/ Func _Toy_RSA_Example() Local $p, $q, $n, $nT, $e, $d Local $aPublicKeys, $aCrypt, $sDecrypt, $sMsg ;Pick two random primes (they will be between 1000-10000) $p = _GetRandomPrime() $q = _GetRandomPrime() $sMsg = 'p= %i \t\t| Prime 1 - [NOT SHARED!]\nq= %i \t\t| Prime 2 - [NOT SHARED!]\n' ;Calculate lowest common multiple $nT = _LCM($p - 1, $q - 1) $sMsg &= 'nT= %i \t| _LCM(p - 1,q - 1) - [NOT SHARED!]\n' ;Calculate n. This is a shared number $n = $p * $q $sMsg &= 'n= %i \t| p * q - [Shared]\n' ;Get a small random list of possible public keys to pick from. Only searching for 100ms $aPublicKeys = _GetPublicKeys($nT) _ArrayDisplay($aPublicKeys, "Possible Public Keys Found") ;Pick a random public (encryption) key from array $e = $aPublicKeys[Random(1, $aPublicKeys[0], 1)] $sMsg &= 'e= %i \t| Public (Encryption) Key - [Shared]\n' ;Generate our private (decryption) key $d = _GetPrivateKey($e, $nT) $sMsg &= 'd= %i \t| Private (Decryption) Key - [NOT SHARED!]\n' ;format our msg (rsa details) to encrypt $sMsg = StringFormat($sMsg, $p, $q, $nT, $n, $e, $d) ;encrypt message $aCrypt = _RSA($sMsg, $e, $n) _ArrayDisplay($aCrypt, 'Encrypted RSA messsage') ;Decrypt array back $sDecrypt = _RSA($aCrypt, $d, $n) MsgBox(0, 'Decrypted RSA messsage', $sDecrypt) EndFunc ;==>_Toy_RSA_Example ;Function will perfrom Mod($v ^ $key, $n) on each char/element. ;Excepts Arrays or Strings. If input is array a string is returned and vice versa. Func _RSA($vDat, $key, $n) Local $bIsStr = IsString($vDat) If $bIsStr Then $vDat = StringToASCIIArray($vDat) For $i = 0 To UBound($vDat) - 1 $vDat[$i] = _Modular($vDat[$i], $key, $n) Next Return $bIsStr ? $vDat : StringFromASCIIArray($vDat) EndFunc ;==>_RSA ;algorithm is from the book "Discrete Mathematics and Its Applications 5th Edition" by Kenneth H. Rosen. Func _Modular($iBase, $iExp, $iMod) ; Mod($v ^ $key, $n) Local $iPower = Mod($iBase, $iMod) Local $x = 1 For $i = 0 To (4 * 8) - 1 If BitAND(0x00000001, BitShift($iExp, $i)) Then $x = Mod(($x * $iPower), $iMod) EndIf $iPower = Mod(($iPower * $iPower), $iMod) Next Return $x EndFunc ;==>_Modular ;Generate a "random" list of possible valid public keys to choose from based on $nT Func _GetPublicKeys($nT, $iMs = 100) Do Local $aKeys[10000] = [0], $iTime = TimerInit() Local $i = (Mod(@SEC, 2) ? Int($nT / 2) : Int($nT / 4)) ; randomize where we start Do If _IsPrime($i) And _IsCoPrime($i, $nT) Then $aKeys[0] += 1 $aKeys[$aKeys[0]] = $i EndIf $i += (Mod(@MSEC, 2) ? 1 : 100) ; randomize step size Until ($i >= ($nT - 1)) Or (TimerDiff($iTime) > $iMs) ReDim $aKeys[$aKeys[0] + 1] Until $aKeys[0] > 5 ; Ive seen 200+ returned sometimes and 0 on others. Make sure we have at least a few choices Return $aKeys EndFunc ;==>_GetPublicKeys ;https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ - _ModInverse(a,m) Func _GetPrivateKey($a, $m) If ($m = 1) Then Return 0 ; Local $t, $q, $y = 0, $x = 1, $m0 = $m While ($a > 1) $q = Int($a / $m) ;q is quotient $t = $m ; $m = Mod($a, $m) ;m is remainder now, process same as Euclid's algo $a = $t ; $t = $y ; $y = $x - $q * $y ;Update y and x $x = $t ; WEnd Return $x < 0 ? $x + $m0 : $x EndFunc ;==>_GetPrivateKey ;Pick the next nearest prime from a random number (or number you cho0se) Func _GetRandomPrime($iStart = Default) Local $iPrime = ($iStart = Default ? Random(1000, 10000, 1) : $iStart) Do $iPrime += 1 Until _IsPrime($iPrime) Return $iPrime EndFunc ;==>_GetRandomPrime #Region Math Functions Func _IsPrime($n) For $i = 2 To (Int($n ^ 0.5) + 1) If Mod($n, $i) = 0 Then Return False Next Return True EndFunc ;==>_IsPrime Func _IsCoPrime($a, $b) Return _GCD($a, $b) = 1 EndFunc ;==>_IsCoPrime Func _GCD($iX, $iY) Local $iM While 1 $iM = Mod($iX, $iY) If $iM = 0 Then Return $iY $iX = $iY $iY = $iM WEnd EndFunc ;==>_GCD Func _LCM($iX, $iY) Return ($iX * $iY) / _GCD($iX, $iY) EndFunc ;==>_LCM #EndRegion Math Functions  
      You should get a message box displaying the decrypted message with details of the values used:

       
      rsa.au3
    • By SolemnStrike
      Hey, 
      I know the title sounds weird, but i couldn't find better words for it...
      I finally managed to have a working image search (yes yes i know image search is evil :p).
      I noticed that even if the script is compiled, the images have to be in my script folder.
      But i don't want that the images i'm searching for on the screen can be viewed, edited etc by every user.
      Is there a way to... uhm... put them in a file like .rar, but one that can't be easily opened? 🤔
       
      Edit: Now that i think of .rar, maybe using a .rar which is protected by a password... Can autoit search, open, extract, use and delete that? (I guess so, I didn't search for this yet, going to google that asap)
    • By colombeen
      Hi everyone, I created a function to gather bitlocker information. It can tell you whether or not a drive is protected, which encryption method is being used, ...
      I tried to cover all the details in the function description
       
      The function (and 3 "internal" functions) :
      ; #FUNCTION# ==================================================================================================================== ; Name...........: _BitlockerDriveInfo ; Description ...: Get Bitlocker information for one or multiple drives ; Syntax.........: _BitlockerDriveInfo([$sDrive[, $sComputer = @ComputerName[, $bDebug = False]]]) ; Parameters ....: $sDrive - Optional: The drive. Allowed values are: ; |"" - Get the info for all available drives ; |Letter: - Get the info for the specific drive ; $sComputer - Optional: The computer from which the info should be requested ; $bDebug - Optional: Shows the hex ReturnValue from the WMI methods if set to True ; Return values .: Success - Returns a 2D array with the following information ; |[string] Drive Letter ; |[string] Drive Label ; |[string] Volume Type ; |[bool] Initialized For Protection ; |[string] Protection Status ; |[string] Lock Status ; |[bool] Auto Unlock Enabled ; |[bool] Auto Unlock Key Stored ; |[string] Conversion Status ; |[string] Encryption Method ; |[int] Encryption Percentage ; |[string] Wiping Status ; |[int] Wiping Percentage ; |[array] Key Protectors (Or [string] "None" if the drive isn't protected) ; Failure - 0, sets @error to: ; |1 - There was an issue retrieving the COM object. @extended returns error code from ObjGet ; |2 - The specified drive in $Drive doesn't exist ; |3 - There was an issue running the WMI query ; Author ........: colombeen ; Modified.......: ; Remarks .......: Requires to be run with admin elevation. Windows Vista or newer! ; A BIG THANKS to everyone from the community who contributed! ; Related .......: ; Link ..........: ; Example .......: #include <Array.au3> ; $Header = "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|" & _ ; "Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption " & _ ; "Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors" ; _ArrayDisplay(_BitlockerDriveInfo(), "Bitlocker Drive Info", "", 64, Default, $Header) ; =============================================================================================================================== Func _BitlockerDriveInfo($sDrive = "", $sComputer = @ComputerName, $bDebug = False) Local $aConversionStatusMsg[7] = ["Unknown", "Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"] Local $aEncryptionMethodMsg[9] = ["Unknown", "None", "AES_128_WITH_DIFFUSER", "AES_256_WITH_DIFFUSER", "AES_128", "AES_256", "HARDWARE_ENCRYPTION", "XTS_AES_128", "XTS_AES_256"] Local $aKeyProtectorTypeMsg[11] = ["Unknown or other protector type", "Trusted Platform Module (TPM)", "External key", "Numerical password", "TPM And PIN", "TPM And Startup Key", "TPM And PIN And Startup Key", "Public Key", "Passphrase", "TPM Certificate", "CryptoAPI Next Generation (CNG) Protector"] Local $aLockStatusMsg[3] = ["Unknown", "Unlocked", "Locked"] Local $aProtectionStatusMsg[3] = ["Unprotected", "Protected", "Unknown"] Local $aVolumeTypeMsg[3] = ["Operating System Volume", "Fixed Data Volume", "Portable Data Volume"] Local $aWipingStatusMsg[5] = ["Unknown", "Free Space Not Wiped", "Free Space Wiped", "Free Space Wiping In Progress", "Free Space Wiping Paused"] Local $iRow = 0 Local $sRunMethod, $objWMIService, $objWMIQuery, $sDriveFilter, $iProtectionStatus, $iLockStatus, $bIsAutoUnlockEnabled, $bIsAutoUnlockKeyStored, $iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage, $iEncryptionMethod, $aVolumeKeyProtectorID, $aVolumeKeyProtectors, $iKeyProtectorType $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If @error Then Return SetError(1, @error, 0) If $sDrive <> "" Then Local $iDriveType = _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $sDrive & "'", Default, $sComputer) If @error Or ($iDriveType <> 2 And $iDriveType <> 3) Then Return SetError(2, 0, 0) $sDriveFilter = " WHERE DriveLetter='" & $sDrive & "'" EndIf $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume" & $sDriveFilter, "WQL", 0) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) Local $aResult[$objWMIQuery.count][14] For $objDrive In $objWMIQuery If $bDebug Then ConsoleWrite(@CRLF & "+> " & $objDrive.DriveLetter & @CRLF) If _WMIMethodExists($objDrive, "GetConversionStatus") Then $sRunMethod = $objDrive.GetConversionStatus($iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage) If $bDebug Then ConsoleWrite("!> GetConversionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iConversionStatus = -1 $iWipingStatus = -1 $iEncryptionPercentage = 0 $iWipingPercentage = 0 EndIf If _WMIMethodExists($objDrive, "GetEncryptionMethod") Then $sRunMethod = $objDrive.GetEncryptionMethod($iEncryptionMethod) If $bDebug Then ConsoleWrite("!> GetEncryptionMethod 0x" & Hex($sRunMethod) & @CRLF) Else $iEncryptionMethod = 0 EndIf If _WMIMethodExists($objDrive, "GetKeyProtectors") Then $sRunMethod = $objDrive.GetKeyProtectors("0", $aVolumeKeyProtectorID) If $bDebug Then ConsoleWrite("!> GetKeyProtectors 0x" & Hex($sRunMethod) & @CRLF) Else $aVolumeKeyProtectorID = 0 EndIf If _WMIMethodExists($objDrive, "GetLockStatus") Then $sRunMethod = $objDrive.GetLockStatus($iLockStatus) If $bDebug Then ConsoleWrite("!> GetLockStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iLockStatus = -1 EndIf If _WMIMethodExists($objDrive, "GetProtectionStatus") Then $sRunMethod = $objDrive.GetProtectionStatus($iProtectionStatus) If $bDebug Then ConsoleWrite("!> GetProtectionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iProtectionStatus = 2 EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockEnabled") Then $sRunMethod = $objDrive.IsAutoUnlockEnabled($bIsAutoUnlockEnabled) If $bDebug Then ConsoleWrite("!> IsAutoUnlockEnabled 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockEnabled = "Unknown" EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockKeyStored") Then $sRunMethod = $objDrive.IsAutoUnlockKeyStored($bIsAutoUnlockKeyStored) If $bDebug Then ConsoleWrite("!> IsAutoUnlockKeyStored 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockKeyStored = "Unknown" EndIf If IsArray($aVolumeKeyProtectorID) And UBound($aVolumeKeyProtectorID) > 0 Then Dim $aVolumeKeyProtectors[UBound($aVolumeKeyProtectorID)][2] For $i = 0 To UBound($aVolumeKeyProtectorID) - 1 $aVolumeKeyProtectors[$i][0] = $aVolumeKeyProtectorID[$i] If _WMIMethodExists($objDrive, "GetKeyProtectorType") Then If $objDrive.GetKeyProtectorType($aVolumeKeyProtectorID[$i], $iKeyProtectorType) = 0 Then $aVolumeKeyProtectors[$i][1]= $aKeyProtectorTypeMsg[$iKeyProtectorType] Else $aVolumeKeyProtectors[$i][1]= "Unknown" EndIf Else $aVolumeKeyProtectors[$i][1] = "Unknown" EndIf Next Else $aVolumeKeyProtectors = "None" EndIf ; DriveLetter $aResult[$iRow][0] = $objDrive.DriveLetter ; DriveLabel $aResult[$iRow][1] = _WMIPropertyValue("VolumeName", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) ; VolumeType If _WMIPropertyExists($objDrive, "VolumeType") Then $aResult[$iRow][2] = $aVolumeTypeMsg[$objDrive.VolumeType] Else If $objDrive.DriveLetter = _WMIPropertyValue("SystemDrive", "Win32_OperatingSystem", "", Default, $sComputer) Then $aResult[$iRow][2]= $aVolumeTypeMsg[0] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 3 Then $aResult[$iRow][2]= $aVolumeTypeMsg[1] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 2 Then $aResult[$iRow][2]= $aVolumeTypeMsg[2] Else $aResult[$iRow][2]= "Unknown" EndIf EndIf ; IsVolumeInitializedForProtection If _WMIPropertyExists($objDrive, "IsVolumeInitializedForProtection") Then $aResult[$iRow][3] = $objDrive.IsVolumeInitializedForProtection Else $aResult[$iRow][3] = "Unkown" EndIf ; ProtectionStatus $aResult[$iRow][4] = $aProtectionStatusMsg[$iProtectionStatus] ; LockStatus $aResult[$iRow][5] = $aLockStatusMsg[$iLockStatus + 1] ; IsAutoUnlockEnabled $aResult[$iRow][6] = $bIsAutoUnlockEnabled ; IsAutoUnlockEnabled $aResult[$iRow][7] = $bIsAutoUnlockKeyStored ; ConversionStatus $aResult[$iRow][8] = $aConversionStatusMsg[$iConversionStatus + 1] ; EncryptionMethod $aResult[$iRow][9] = $aEncryptionMethodMsg[$iEncryptionMethod + 1] ; EncryptionPercentage $aResult[$iRow][10] = $iEncryptionPercentage ; WipingStatus $aResult[$iRow][11] = $aWipingStatusMsg[$iWipingStatus + 1] ; WipingPercentage $aResult[$iRow][12] = $iWipingPercentage ; KeyProtectors $aResult[$iRow][13] = $aVolumeKeyProtectors $iRow += 1 Next _ArraySort($aResult) Return $aResult EndFunc ;==>_BitlockerDriveInfo Func _WMIPropertyExists($Object, $Property) If Not IsObj($Object) Then Return False For $sProperty In $Object.Properties_ If $sProperty.Name = $Property Then Return True Next Return False EndFunc ;==>_WMIPropertyExists Func _WMIMethodExists($Object, $Method) If Not IsObj($Object) Then Return False For $sMethod In $Object.Methods_ If $sMethod.Name = $Method Then Return True Next Return False EndFunc ;==>_WMIMethodExists Func _WMIPropertyValue($sProperty = "", $sClass = "", $sFilter = "", $sNamespace = Default, $sComputer = @ComputerName) Local $objWMIService, $objWMIQuery If $sClass = "" Or $sProperty = "" Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter = " " & $sFilter If $sNamespace = Default Then $sNamespace = "\root\CIMV2" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & $sNamespace) If @error Then Return SetError(2, @error, 0) $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM " & $sClass & $sFilter, "WQL", 0x30) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) For $objItem In $objWMIQuery For $Property In $objItem.Properties_ If $Property.Name = $sProperty Then Return $Property.Value EndIf Next Next Return SetError(4, 0, 0) EndFunc ;==>_WMIPropertyValue  
      Example 1:
      #RequireAdmin #include <array.au3> ; Get information on all available drives Global $test = _BitlockerDriveInfo() If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then _ArrayDisplay($test, "Bitlocker Drive Info", "", 64, Default, "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors") ; Display the Key Protectors for the first record If IsArray($test[0][13]) Then _ArrayDisplay($test[0][13]) EndIf Example 2:
      #RequireAdmin #include <array.au3> ; Get information on the C-drive of the current computer + show extra information in the console Global $test = _BitlockerDriveInfo("C:", @ComputerName, True) If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then ConsoleWrite("Bitlocker information on the " & $test[0][0] & " drive" & @CRLF) ConsoleWrite("Protection Status: " & $test[0][4] & @CRLF) EndIf  
      Screenshot for the first example:

       
      Suggestions? Bugs?
      Just let me know
       
      TODO:
      ???  
      Version 1.0:
      Initial release Version 1.1:
      Fixed: Drive Label will not work when you request the information from a remote system (currently using DriveGetLabel) Fixed: The current fix for the missing VolumeType property in some Windows versions will only work locally Added: New internal function (_WMIPropertyValue()) Version 1.2:
      Fixed: The drive exists & drive type check only worked locally when a drive was specified in $sDrive
    • By colombeen
      Hi guys,
      I'm trying to get some information using WMI, from the Win32_EncryptableVolume class.
      I exec my query, filter out the C-drive, but when I need more info using the objects methods, I only get 1 value back and I can't seem to retrieve the other out params that should be there.
      A very minimal version of what I'm trying to do (no error checking etc, very basic). You need to start SciTE as admin or you won't see any results in the console!
      #RequireAdmin $strComputer = @ComputerName $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter='C:'", "WQL", 0) For $objDrive In $objWMIQuery ConsoleWrite("> " & $objDrive.GetConversionStatus() & @CRLF) ConsoleWrite("> " & $objDrive.GetConversionStatus().ConversionStatus & @CRLF) ConsoleWrite("> " & $objDrive.GetConversionStatus().EncryptionPercentage & @CRLF) Next The result from the console is : 
      > 0 > > What I'm expecting to get back is : 
      > 0 > 0 > 0 When using powershell I get this (run as admin is required!!!) : 
      PS C:\WINDOWS\system32> (Get-WmiObject -namespace "Root\cimv2\security\MicrosoftVolumeEncryption" -ClassName "Win32_Encryptablevolume" -Filter "DriveLetter='C:'").GetConversionStatus() ... ConversionStatus : 0 EncryptionFlags : 0 EncryptionPercentage : 0 ReturnValue : 0 ... All I seem to be getting is the ReturnValue when I use the method.
      I've tried this on multiple methods, always ending up with the same result
      Anyone here who has experience with this type of thing?
       
      Greetz
      colombeen
×
×
  • Create New...