Jump to content
giangnguyen

Public Private Key encryption?

Recommended Posts

giangnguyen

Anybody knows how I can apply Public-Private Key encryption? I found several threads but they are all outdated 

Any ideas? I don't think it is included in advapi32 either, which is used by AutoIt atm

Share this post


Link to post
Share on other sites
giangnguyen

Bump, still needing this. 

Share this post


Link to post
Share on other sites
VIP

_Crypt_EncryptFile() and _Crypt_DecryptFile()  not working ?

or you mean is create Public Key and Private Keys (.cer, .pvk, .pfx) from MakeCert.exe, pvk2pfx.exe and SignTool.exe ?


Regards,
 

Share this post


Link to post
Share on other sites
mLipok

Maybe you mean PGP / GPG ?


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library
 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-10-15

Share this post


Link to post
Share on other sites
AutoBert
On 2.6.2016 at 5:52 AM, giangnguyen said:

I found several threads but they are all outdated 

Are  there any changes in logic. I think no, so you have to read the changelog and update the found source to actual stable or to wait until some one else needs it and is so kind to share.

Share this post


Link to post
Share on other sites
mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library
 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-10-15

Share this post


Link to post
Share on other sites
Skysnake

Generate keys.  Keep Private key. Distribute public key. Compare keys on demand.

Perhaps your question is not clearly defined?


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
giangnguyen

Like _Crypt_DecryptData but with RSA encryption and decryption. That is my goal here.

Share this post


Link to post
Share on other sites
VIP

 

 

 

o_0

 

 


Regards,
 

Share this post


Link to post
Share on other sites
BahadirM

I'm pretty much interested in RSA Functionality in AutoIt, however, these old links provided from @Trong are either outdated, unreadable or there's simply no correct help.

When I use

https://www.autoitscript.com/forum/topic/104025-rsa-publicprivate-encryption/

$CALG_RSA_KEYX = 0x0000a400 ; RSA public key exchange algorithm.
$CALG_RSA_SIGN = 0x00002400 ; RSA public key signature algorithm.

with the provided encryption tool from AutoIt install itself and encrypt any string, I get "-1" as output and when decrypting I get "ÿÿÿÿ" (0xFFFFFFFF).

I'm probably doing something wrong there, but can't get my finger on what...

Which led me to the same problem this user had:

Problem
https://www.autoitscript.com/forum/topic/151577-rsa-algorithm/#comment-1085259

User who linked the site below
https://www.autoitscript.com/forum/topic/151577-rsa-algorithm/?page=2#comment-1085384

Russian _RSA_crypt
http://autoit-script.ru/index.php/topic,8343.msg56412.html#msg56412

And when I continued reading, the last post of that thread leads me to an _RSA_Crypt function, which is completely on russian and so totally unreadable...

Best of it, the file is locked in Dropbox because of traffic...

 

The last one is the tool from peethebee, which sadly used a removed function in AutoIt. It's "PluginOpen" and "PluginClose".

https://www.autoitscript.com/forum/topic/40776-rsa-encryption-plugin/

That site is broken with his RSA.dll, which isn't downloadable anymore from autoit.de, but I could extract the broken text.


#include
#include "bigint.h"

#include

#include

#include

#include "au3plugin.h"

using namespace std;

#define RBI RossiBigInt

/*

*

* AutoIt v3 Plugin RSA

*

* Copyright © 1999-2006 Jonathan Bennett

* Copyright © 2006-2007 peethebee

* The rules of GPL apply to this work!

*

* RSA.c

*

*/

/****************************************************************************

* Function List

*

* This is where you define the functions available to AutoIt. Including

* the function name (Must be the same case as your exported DLL name), the

* minimum and maximum number of parameters that the function takes.

*

****************************************************************************/

/* "FunctionName", min_params, max_params */

AU3_PLUGIN_FUNC g_AU3_Funcs[] =

{

{"RSA_GenerateKeys", 3, 3},

{"RSA_Encrypt", 2, 2},

{"RSA_Decrypt", 2, 2}

};

/****************************************************************************

* AU3_GetPluginDetails()

*

* This function is called by AutoIt when the plugin dll is first loaded to

* query the plugin about what functions it supports. DO NOT MODIFY.

*

****************************************************************************/

AU3_PLUGINAPI int AU3_GetPluginDetails(int *n_AU3_NumFuncs, AU3_PLUGIN_FUNC **p_AU3_Func)

{

/* Pass back the number of functions that this DLL supports */

*n_AU3_NumFuncs	= sizeof(g_AU3_Funcs)/sizeof(AU3_PLUGIN_FUNC);

/* Pack back the address of the global function table */

*p_AU3_Func = g_AU3_Funcs;

return AU3_PLUGIN_OK;

}

/****************************************************************************

* DllMain()

*

* This function is called when the DLL is loaded and unloaded. Do not

* modify it unless you understand what it does...

*

****************************************************************************/

BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)

{

switch (ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

case DLL_THREAD_ATTACH:

case DLL_THREAD_DETACH:

case DLL_PROCESS_DETACH:

break;

}

return TRUE;

}

RBI euklid(RBI a, RBI :whistle: {

RBI h;

while (b != RBI(0)) {

h = a % b;

a = b;

b = h;

}

return a;

}

RBI _minus_mod(RBI a, RBI b, RBI m) {

if (a > :) {

return (a- :lol: % m;

} else {

return m - (b-a) % m;

}

}

RBI extended_euclid(RBI a, RBI n) {

RBI v3(n);

RBI g(a);

RBI v1(0);

RBI t1(1);

RBI t3;

RBI temp;

RBI q;

do {

q = g / v3;

t3 = g % v3;

if (t3 > RBI(0)) {

q = (v1*q) % n;

q = _minus_mod(t1, q, n);

t1=v1;

v1=q;

g=v3;

v3=t3;

}

} while (t3 != RBI(0));

return v1;

}

RBI fast_exp(RBI b, RBI e) {

RBI result(1);

// Ist die aktuelle Bitstelle von e gesetzt (1),

// das Ergebnis mit b multiplizieren.

while (e > RBI(0)) {

if ((e & RBI(1)) == RBI(1)){

result = (result * :) ;

}

// den Exponenten in der Binärdarstellung um

// 1 nach rechts verschieben, sodass der nächste

// Durchlauf die nächste Bitstelle bearbeitet.

e >>= 1;

// b quadrieren, da es an der nächsten Bitstelle

// eine entsprechend höhere Wertigkeit hat.

b = b * b;

}

return result;

}

RBI fast_exp_mod(RBI b, RBI e, RBI m) {

RBI result(1);

while (e > RBI(0)) {

// Ist die aktuelle Bitstelle von e gesetzt (1),

// dann das Quadrat der Basis zum Ergebnis addieren.

// Dabei gleich den Modulus einbeziehen, damit das

// Ergebnis nicht unnötig groß wird.

if ((e & RBI(1)) == RBI(1)){

result = (result * :( ;

result = (result % m);

}

// den Exponenten in der Binärdarstellung um

// 1 nach rechts verschieben, sodass der nächste

// Durchlauf die nächste Bitstelle bearbeitet.

e >>= 1;

// b quadrieren, da es an der nächsten Bitstelle

// eine entsprechend höhere Weritgkeit hat.

b = (b * B) % m;

}

return result;

}

/*

int miller_rabin_is_prime(RBI n, int steps) {

long small_primes[10] = {2,3,5,7,11,13,17,19,23,29};

RBI d, a, t, y;

d = n-RBI(1);

while (RBI(d & RBI(1)) == RBI(0)) {

d >>= 1;

}

for (int b=0;b

a = RBI(small_primes);

t = d;

y = fast_exp_mod(a,t,n);

while (t != n-RBI(1) && y != RBI(1) && y != n-RBI(1)) {

y = (y * y) % n;

t <<= 1;

}

//if (y != n-RBI(1) && RBI(t & RBI(1)) == RBI(0)) return 1;

if ((y != n-RBI(1)) && (RBI(t & RBI(1)) == RBI(0))) {

MessageBox(NULL, "nicht prim", "MR", MB_OK);

return 1;

}

}

MessageBox(NULL, "prim", "MR", MB_OK);

return 0;

}*/

int witness(RBI n, RBI a) {

MessageBox(NULL, "witness", "anfang", MB_OK);

RBI t, u, x, y, i;

for(t = RBI(0); ((n - RBI(1)) & (fast_exp(RBI(2),(t+RBI(1))))) == RBI(0); t++); //My hack way of finding t and u

u = (n - RBI(1)) / (fast_exp(RBI(2), t)); //such that 2^t * u = n - 1 where u is odd

y = fast_exp_mod(a, u, n); //This is described in the next section

for(i = RBI(1); i <= t; i++) {

x = (y * y) % n;

if((x == RBI(1)) && (y != RBI(1)) && (y != (n - RBI(1)))) {

MessageBox(NULL, "oben", "return 1", MB_OK);

return 1;

}

}

if(x != RBI(1)) {

MessageBox(NULL, "unten", "return 1", MB_OK);

return 1;

}

return 0;

}

int miller_rabin_is_prime(RBI n, int s) {

long small_primes[10] = {2,3,5,7,11,13,17,19,23,29};

if(n == RBI(3))

return 1;

RBI a;

int j;

for(j = 0; j < s; j++) {

a = RBI(small_primes[j]);

if(witness(n, a)) {

MessageBox(NULL, "nicht prim", "MR", MB_OK);

return 0;

}

}

MessageBox(NULL, "prim", "MR", MB_OK);

return 1;

}

int fermat_is_prime(RBI n) {

RBI result2(0);

RBI result3(0);

RBI result5(0);

// Fermattest mit Basis 2

result2 = fast_exp_mod(RBI(2), n - RBI(1), n);

// Fermattest mit Basis 3

result3 = fast_exp_mod(RBI(3), n - RBI(1), n);

// Fermattest mit Basis 5

result5 = fast_exp_mod(RBI(5), n - RBI(1), n);

// Das probabilistische Ergebnis zurückgeben.

// Rückgabewert 1 steht für wahrscheinlich prim,

// Rückgabewert 0 steht für sicher nicht prim.

return (result2 == RBI(1) && result3 == RBI(1) &&

result5 == RBI(1)) ? 1:0;

}

RBI find_prime_number(double bitlength){

int fermat_res = 0;

RBI rand_nr;

// Zufallszahl berechnen

srand(time(NULL));

//gewünschte Bitlänge herstellen

RBI minimum_value(fast_exp(RBI(2), RBI(bitlength)));

do {

// Zufallszahl generieren

rand_nr = RBI(rand());

rand_nr = (fast_exp(rand_nr, RBI(4))+RBI(1)) % (fast_exp(RBI(2),

RBI(bitlength-1)) + 1);

// Summe aus 2 hoch Bitlänge und Zufallszahl bilden und

// Ergebnis auf Primalität testen

fermat_res = fermat_is_prime(minimum_value + RBI(rand_nr));

} while (fermat_res == 0);

// wenn Fermat keine zusammengesetzte Zahl erkannt hat,

// dann Zahl als Primzahl zurückliefern

return minimum_value + RBI(rand_nr);

}

AU3_PLUGIN_DEFINE(RSA_GenerateKeys)

{

AU3_PLUGIN_VAR	*pMyResult;

double key_bitlength;

key_bitlength = AU3_GetDouble(&p_AU3_Params[0]);

//miller_rabin_is_prime(RBI(key_bitlength), 2);

string keypath;

keypath = AU3_GetString(&p_AU3_Params[1]);

//keypath = keypath::replace("\\", "\\\\" );

string keyname;

keyname = AU3_GetString(&p_AU3_Params[2]);

// Zwei Primzahlen p und q suchen

RBI p(find_prime_number(key_bitlength / 2));

RBI q;

// Sicherstellen, dass p ungleich q

do {

q = find_prime_number(key_bitlength / 2);

}

while (q == p);

// n berechnen

RBI n(p * q);

// phi(n) berechnen:

RBI phi((p - RBI(1)) * (q - RBI(1)));

// e setzen

RBI e;

e = RBI(65537); //RBI(fast_exp(RBI(2), RBI(16))+1);

// d berechnen

srand(time(NULL));

RBI d = extended_euclid(e, phi);

// öffentlichen Schlüssel in eine Datei schreiben

string pubpath=keypath + keyname + ".pubkey";

ofstream pubkeyfile;

pubkeyfile.open(pubpath.c_str());

pubkeyfile << n;

pubkeyfile << "\n";

pubkeyfile << e;

pubkeyfile << "\n";

pubkeyfile << key_bitlength << " bit";

pubkeyfile << "\n";

pubkeyfile << "";

pubkeyfile.close();

// privaten Schlüssel in eine Datei schreiben

string privpath=keypath + keyname + ".privkey";

ofstream privkeyfile;

privkeyfile.open(privpath.c_str());

privkeyfile << n;

privkeyfile << "\n";

privkeyfile << d;

privkeyfile << "\n";

privkeyfile << key_bitlength << " bit";

privkeyfile << "\n";

privkeyfile << "";

privkeyfile.close();

/* Ergebnisse in Datei ausgeben

string logpath="C:\\rsa.log";

ofstream logfile;

logfile.open(logpath.c_str());

logfile << "RSA-Schluesselgenerierung" << endl << endl;

logfile << "p: " << p << endl;

logfile << "q: " << q << endl;

logfile << "n: " << n << endl;

logfile << "phi(n): " << phi << endl;

logfile << "e: " << e << endl;

logfile << "d: " << d << endl;

logfile << "de mod phi: " << (RBI(d)*e) % phi << endl << endl;

logfile << "Schluessel gespeichert als " << keyname <<

".privkey und " << keyname << ".pubkey im Ordner " <<

keypath << endl;

logfile.close();*/

pMyResult = AU3_AllocVar();

AU3_SetInt32(pMyResult, 1);

*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;

return AU3_PLUGIN_OK;

}

AU3_PLUGIN_DEFINE(RSA_Encrypt)

{

AU3_PLUGIN_VAR *pMyResult;

pMyResult = AU3_AllocVar();

string text;

text = AU3_GetString(&p_AU3_Params[0]);

string keyfilename;

keyfilename = AU3_GetString(&p_AU3_Params[1]);

//keyfilename = string_replace(keyfilename, "\\", "\\\\");

//MessageBox(NULL, text.c_str(), keyfilename.c_str(), MB_OK);

// öffentlichen Schlüssel auslesen

ifstream pubkeyfile;

string line;

pubkeyfile.open(keyfilename.c_str());

// erste Zeile auslesen und gleich n setzen

getline(pubkeyfile, line);

RBI n(line, 10);

// zweite Zeile auslesen und gleich e setzen

getline(pubkeyfile, line);

RBI e(line, 10);

// Plaintext zeichenweise durchgehen

// immer 2 Zeichen sammeln um eine einfache

// Blockchiffre umzusetzen

//MessageBox(NULL, text.c_str(), keyfilename.c_str(), MB_OK);

string res_str;

// Stringlänge auf geraden Wert bringen

if (text.length() % 2 == 1) {text = text + " ";}

for (int i=0;i

// ASCII-Code der Zeichens berechnen

int mi1 = int(text);

int mi2 = int(text[i+1]);

// Verkettung

RBI mi;

mi = RBI(mi2) * fast_exp(RBI(2), RBI(7)) + RBI(mi1);

// Eigentliche Verschlüsselung

RBI ci(fast_exp_mod(mi, e, n));

// Ergebnis anhängen (als Hex-Wert, mit Trennzeichen #)

res_str = res_str + ci.getstr_pure_hex_value() + "#";

}


/* Ergebnis in eine temporäre Datei schreiben

MessageBox(NULL, "test", "test", MB_OK);

string tempfile="C:\\rsa.enc";

ofstream encfile;

encfile.open(tempfile.c_str());

encfile << res_str;

encfile.close(); */


//AU3_SetString(pMyResult, res_str.c_str());

//MessageBox(NULL, res_str.c_str(), "test", MB_OK);

AU3_SetString(pMyResult, res_str.c_str());

//MessageBox(NULL, "test", "test", MB_OK);


*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;

//MessageBox(NULL, "test", "test", MB_OK);


return AU3_PLUGIN_OK;

}



AU3_PLUGIN_DEFINE(RSA_Decrypt)

{

AU3_PLUGIN_VAR	*pMyResult;

pMyResult = AU3_AllocVar();

string text;

text = AU3_GetString(&p_AU3_Params[0]);

string keyfilename;

keyfilename = AU3_GetString(&p_AU3_Params[1]);

//keyfilename = string_replace(keyfilename, "\\", "\\\\");


//MessageBox(NULL, text.c_str(), "test", MB_OK);

//MessageBox(NULL, keyfilename.c_str(), "test", MB_OK);


// privaten Schlüssel auslesen

ifstream privkeyfile;

string line;

privkeyfile.open(keyfilename.c_str());

// erste Zeile auslesen und gleich n setzen

getline(privkeyfile, line);

RBI n(line, 10);

// zweite Zeile auslesen und gleich d setzen

getline(privkeyfile, line);

RBI d(line, 10);


// Ciphertext an Trennzeichen spalten

string res_str;

string collect_string;

for (int i=0;i

if (text == '#') {

// Entschlüsselung

RBI mi(fast_exp_mod(RBI(collect_string, 16), d, n));

// beide Zeichen aus mi extrahiere

RBI mi1;

RBI mi2;

mi1 = mi % fast_exp(RBI(2), RBI(7));

mi2 = mi / fast_exp(RBI(2), RBI(7));

// mi1 und mi2 an Ergebnis-String anhängen

res_str = res_str + (char)mi1.get_pure_ulong();

res_str = res_str + (char)mi2.get_pure_ulong();

// Sammel-String wieder leeren

collect_string = "";

} else {

// Zeichen ist noch Teil des Blockes

collect_string = collect_string + text;

}

}


/* Ergebnis in eine temporäre Datei schreiben

string tempfile="C:\\rsa.dec";

ofstream decfile;

decfile.open(tempfile.c_str());

decfile << res_str;

decfile.close();*/


AU3_SetString(pMyResult, res_str.c_str());

*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;


return AU3_PLUGIN_OK;

Since I don't know how to build DLL's, I'd like to ask some of you people to do this and provide a help, how to do DllCalls for this C++ code.

 

Share this post


Link to post
Share on other sites
jchd

AutoIt plugin support has been abandonned long ago.

 


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Terenz

Need to convert the plugins things

; author Neonium - DLL by peethebee
#include <GUIConstants.au3>

PluginOpen("rsa.dll")
#AutoIt3Wrapper_plugin_funcs = RSA_GenerateKeys, RSA_Decrypt, RSA_Encrypt

Opt("GUIOnEventMode", 1)

$Form1_1 = GUICreate("RSA Encryption", 347, 275, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1_1Close")
$tab = GUICtrlCreateTab(10, 10, 325, 260)
$tab0 = GUICtrlCreateTabItem("File")
$vschluessel = GUICtrlCreateButton("Crypt", 40, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "vschluesselClick")
$nschluessel = GUICtrlCreateButton("Decrypt", 180, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "nschluesselClick")
$Public = GUICtrlCreateLabel("PublicKey File", 20, 124, 70, 17)
$Priv = GUICtrlCreateLabel("PrivateKey File", 20, 152, 74, 17)
$PrivFile = GUICtrlCreateInput("", 104, 152, 117, 21)
$Pubfile = GUICtrlCreateInput("", 104, 120, 117, 21)
$BrowsePub = GUICtrlCreateButton("Browse", 236, 120, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePubClick")
$BrowsePrv = GUICtrlCreateButton("Browse", 236, 152, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePrvClick")
$BrowseDat = GUICtrlCreateButton("Browse", 236, 52, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowseDatClick")
$Label1 = GUICtrlCreateLabel("File to crypt", 28, 37, 168, 17)
$Datei = GUICtrlCreateInput("", 28, 56, 197, 21)
$privfilegen = GUICtrlCreateButton("Key Files Generator", 100, 190, 125, 25, 0)
GUICtrlSetOnEvent(-1, "privfilegenClick")

$tab1 = GUICtrlCreateTabItem("Password")

$vschluesselp = GUICtrlCreateButton("Crypt", 40, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "vschluesselpClick")
$nschluesselp = GUICtrlCreateButton("Decrypt", 180, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "nschluesselpClick")
$Publicp = GUICtrlCreateLabel("PublicKey File", 20, 124, 70, 17)
$Privp = GUICtrlCreateLabel("PrivateKey File", 20, 152, 74, 17)
$PrivFilep = GUICtrlCreateInput("", 104, 152, 117, 21)
$Pubfilep = GUICtrlCreateInput("", 104, 120, 117, 21)
$BrowsePubp = GUICtrlCreateButton("Browse", 236, 120, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePubpClick")
$BrowsePrvp = GUICtrlCreateButton("Browse", 236, 152, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePrvpClick")
$privfilegenp = GUICtrlCreateButton("Key Files Generator", 100, 190, 125, 25, 0)
GUICtrlSetOnEvent(-1, "privfilegenClick")
$Label1p = GUICtrlCreateLabel("Password clear", 60, 37, 200, 17)
$Dateip = GUICtrlCreateInput("", 60, 56, 197, 21)
$Label2p = GUICtrlCreateLabel("Password crypted:", 60, 78, 200, 17)
$pwp = GUICtrlCreateInput("", 60, 93, 197, 21)
$clipputp = GUICtrlCreateButton("Copy", 265, 93, 60, 21)
GUICtrlSetOnEvent(-1, "clipputpClick")

GUISetState(@SW_SHOW)

$var = IniRead(@WorkingDir & "\file.ini", "privkey", "key", "")
GUICtrlSetData($PrivFile, $var)
$var = IniRead(@WorkingDir & "\file.ini", "pubkey", "key", "")
GUICtrlSetData($Pubfile, $var)
$var = IniRead(@WorkingDir & "\file.ini", "privkeyp", "key", "")
GUICtrlSetData($PrivFilep, $var)
$var = IniRead(@WorkingDir & "\file.ini", "pubkeyp", "key", "")
GUICtrlSetData($Pubfilep, $var)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $tab Then
        ; display the clicked tab
        If GUICtrlRead($tab) = 0 Then WinSetTitle("My GUI Tab", "", "My GUI Tab0")
        If GUICtrlRead($tab) = 1 Then WinSetTitle("My GUI Tab", "", "My GUI Tab1")
    EndIf
WEnd

Func AForm1_1Close()
    $readpriv = GUICtrlRead($PrivFile)
    $readpub = GUICtrlRead($Pubfile)
    $readprivp = GUICtrlRead($PrivFilep)
    $readpubp = GUICtrlRead($Pubfilep)

    IniDelete(@ScriptDir & "\file.ini", "privkeyp")
    IniDelete(@ScriptDir & "\file.ini", "pubkeyp")
    IniDelete(@ScriptDir & "\file.ini", "privkey")
    IniDelete(@ScriptDir & "\file.ini", "pubkey")

    If $readpriv <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "privkey", "key", $readpriv)
    EndIf
    If $readpub <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "pubkey", "key", $readpub)
    EndIf

    If $readprivp <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "privkeyp", "key", $readprivp)
    EndIf
    If $readpubp <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "pubkeyp", "key", $readpubp)
    EndIf
    Exit
EndFunc   ;==>AForm1_1Close

Func BrowseDatClick()
    $readdatei = GUICtrlRead($Datei)
    $var = FileOpenDialog("Datei", $readdatei, "Text (*.txt)", 1)
    GUICtrlSetData($Datei, $var)
EndFunc   ;==>BrowseDatClick

Func BrowsePrvClick()
    $readpriv = GUICtrlRead($PrivFile)
    $var = FileOpenDialog("Datei", $readpriv, "Private (*.privkey)", 1)
    GUICtrlSetData($PrivFile, $var)
EndFunc   ;==>BrowsePrvClick

Func BrowsePubClick()
    $readpub = GUICtrlRead($Pubfile)
    $var = FileOpenDialog("Datei", $readpub, "Public (*.pubkey)", 1)
    GUICtrlSetData($Pubfile, $var)
EndFunc   ;==>BrowsePubClick

Func nschluesselClick()
    $readpriv = GUICtrlRead($PrivFile)
    $read = GUICtrlRead($Datei)
    If $readpriv = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        FileMove($read, "c:\tmp\test.txt")
        FileChangeDir("C:\tmp")
        $file = FileOpen("test.txt", 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $line = FileRead($file)
        FileClose($file)
        $line = RSA_Decrypt($line, $readpriv)
        $file = FileOpen("test.txt", 2)
        FileWrite($file, $line)
        FileClose($file)
        FileMove("C:\tmp\test.txt", $read)
        MsgBox(0, "", "Successful")
    EndIf
EndFunc   ;==>nschluesselClick

Func vschluesselClick()
    $readpub = GUICtrlRead($Pubfile)
    $read = GUICtrlRead($Datei)
    If $readpub = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        FileMove($read, "C:\tmp\test.txt")
        FileChangeDir("C:\tmp")
        $file = FileOpen("test.txt", 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $line = FileRead($file)
        FileClose($file)
        $line = RSA_Encrypt($line, $readpub)
        $file = FileOpen("test.txt", 2)
        FileWrite($file, $line)
        FileClose($file)
        FileMove("C:\tmp\test.txt", $read)
        MsgBox(0, "Successful", "Encrypted success")
    EndIf
EndFunc   ;==>vschluesselClick

Func privfilegenClick()
    $folder = FileSelectFolder("Keyfiles Location", Default, 1)
    $folder = $folder & "\"
    $bitlen = InputBox("Bit length", "Key bit length", "50")
    $name = InputBox("Store name", "Memory name Keyfiles")
    If $folder <> "" And $name <> "" And $bitlen <> "" Then
        RSA_GenerateKeys($bitlen, $folder, $name)
        MsgBox(0, "Successful", "Keys were created successfully")
    Else
        MsgBox(0, "Error", "Please provide all information")
    EndIf
EndFunc   ;==>privfilegenClick

Func BrowsePrvpClick()
    $readpriv = GUICtrlRead($PrivFilep)
    $var = FileOpenDialog("Datei", $readpriv, "Private (*.privkey)", 1)
    GUICtrlSetData($PrivFilep, $var)
EndFunc   ;==>BrowsePrvpClick

Func BrowsePubpClick()
    $readpub = GUICtrlRead($Pubfilep)
    $var = FileOpenDialog("Datei", $readpub, "Public (*.pubkey)", 1)
    GUICtrlSetData($Pubfilep, $var)
EndFunc   ;==>BrowsePubpClick

Func nschluesselpClick()
    $readpriv = GUICtrlRead($PrivFilep)
    $read = GUICtrlRead($pwp)
    If $readpriv = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        $pw = RSA_Decrypt($read, $readpriv)
        GUICtrlSetData($Dateip, $pw)
    EndIf
EndFunc   ;==>nschluesselpClick

Func vschluesselpClick()
    $readpub = GUICtrlRead($Pubfilep)
    $read = GUICtrlRead($Dateip)
    If $readpub = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        $pw = RSA_Encrypt($read, $readpub)
        GUICtrlSetData($pwp, $pw)
    EndIf
EndFunc   ;==>vschluesselpClick

Func clipputpClick()
    ClipPut(GUICtrlRead($pwp))
EndFunc   ;==>clipputpClick

 

RSA.dll


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
BahadirM
22 hours ago, jchd said:

AutoIt plugin support has been abandonned long ago.

 

Yeah, that's what I wrote in my reply above.

Now the only problem is (Terenz already wrote), how does one now convert the PluginOpen/Close functions to DLLCalls? It needs documentation.

Share this post


Link to post
Share on other sites
mLipok

Here is an example showing some other concepts:

Indeed it is using crypto card, but I believe that using Certificate Enrollment API  you can do what you need, all is a matter of your own involmend.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library
 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-10-15

Share this post


Link to post
Share on other sites
giangnguyen

Still needing this.

mLipok, I think your script basically prints out the detail of a certificate? Not sure how that helps, since I am not signing but encrypting and decrypting to secure data (since autoit is easily decompiled, and therefore AES keys can be stolen. However RSA can't because it is public/private key)

Share this post


Link to post
Share on other sites
giangnguyen

Still needing this, please help me!

Share this post


Link to post
Share on other sites
AutoBert
On 11.6.2016 at 3:01 PM, mLipok said:

Indeed it is using crypto card, but I believe that using Certificate Enrollment API  you can do what you need, all is a matter of your own involmend.

What are the issue by coding a test script using the Certificate Enrollment API? Please show script. Or is there any  Oozlum bird that eaten your script and fly away?

Share this post


Link to post
Share on other sites
mLipok

So reading here:

About the Certificate Enrollment API

Quote

The Certificate Enrollment API enables you to create client applications that can be used to request and install certificates.

There is nothing about singnig/encrypting.

 

After some diging I comes to this:
Cryptography API: Next Generation
About CNG
Encrypting Data with CNG

Please check this above links and say what you think.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library
 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-10-15

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

    • colombeen
      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
    • colombeen
      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
    • careca
      By careca
      Let's say you have some files you dont want anyone to know what they are,
      and you dont want anyone to be able to open them, you could encrypt them,
      but if the files are big it'll take a long time to do the operations for you to be able to open those files.
      I made this to make this process faster, and still not easy for someone to open the files, or even know what type they are.
      What it does is change the filename to a random number with 8 digits and .inc extension.
      The original filename is encrypted in the file itself, with a PIN provided by the user up to 4 digits, this PIN is also a number that's going to be used to split the file and change it internally, so the end result is a file with a header that's got the original filename encrypted, and the rest of the file scrambled a bit.
      The way it works is simple, place the application in a folder where you want to hide the files, it will ask for a pin, after you press ok, the application asks :
      Encrypt or decrypt?
      If encrypt, the files will become the 8 digit .inc files.
      The originals will stay, the user can delete the originals or do whatever.
      Then to open the files back, same process, but this time choose decrypt, and a listview will show the random filenames and the corresponding decrypted/original filenames and extension, uppon double click they open with whatever application is the default for them. There's a search feature, and an "extract all" button, to get all files back to original/unencrypted versions.
      Feedback is wellcome.
    • Overkill
      By Overkill
      Hi all,
      I am working on a GUI program to update Google's Dynamic DNS (API at https://support.google.com/domains/answer/6147083?authuser=1&hl=en if you scroll to bottom). I am not a programmer by any means - just a sysadmin who has picked up on some things along the way. I am sure that there's better ways to do a lot of things in this script; I'm just going with what I know.
      My challenge right now is that I'd like a better way to store the credentials both in memory as well as in system registry or INI file (not sure which way I want to go for local storage). How should I convert the passwords to a secure string in a manner that can't be easily reversed, yet is still accessible to the script? Is that even an option in AutoIt?
      Can anybody provide me with links to good reference posts, or coding suggestions for how best to achieve this in the script below? I am using the WinHTTP UDF (https://github.com/dragana-r/autoit-winhttp/releases) to make my API calls.
      #include<WinHTTP.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<iNet.au3> #include<Array.au3> DIM $aDomainList[1][4] $aDomainList[0][0] = 0 $gMainGUI = GUICreate("Overkill's Google DNS Updater",800,800) $gDomainLabel = GUICtrlCreateLabel("FQDN",21,8) $gDomainInput = GUICtrlCreateInput("",60,5,300) $gUserLabel = GUICtrlCreateLabel("Username",5,36) $gUserInput = GUICtrlCreateInput("",60,32,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gPasswordLabel = GUICtrlCreateLabel("Password",6,64) $gPassInput = GUICtrlCreateInput("",60,60,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gAddButton = GUICtrlCreateButton("ADD DOMAIN",200,31,160,52) $gCurrentIP = GUICtrlCreateLabel("Current IP: " & _CheckIP(),5,780) $gDomainList = GUICtrlCreateListView("Domain | Resolved IP | Update Status",5,120,600,600) GUISetState(@SW_SHOW,$gMainGUI) while 1 $m = GUIGetMsg() IF $M = $GUI_EVENT_CLOSE then Exit IF $M = $gAddButton Then $sAddDomain = GUICtrlRead($gDomainInput) $sAddUser = GUICtrlRead($gUserInput) $sAddPass = GUICtrlRead($gPassInput) $sResolveIP = _DNSCheck($sAddDomain) ;Google wants you to avoid sending updates when there are no changes If StringCompare($sResolveIP,_CheckIP()) = 0 Then $sStatus = "No change, not sending update" Else $sStatus = _DNSUpdate($sAddDomain,$sAddUser,$sAddPass) EndIf ;Check to make sure all fields are completed before continuing IF StringLen($sAddDomain) = 0 OR StringLen($sAddUser) = 0 OR StringLen($sAddPass) = 0 Then MsgBox(0,"","Please complete all fields") Else ; If the fields all have data, then continue ;Check to see if the entry exists in the array already $iSanity = _ArraySearch($aDomainList,$sAddDomain) IF $iSanity = 0 Then _ArrayAdd($aDomainList,$sAddDomain & "|" & $sAddUser & "|" & $sAddPass ) If @error = 0 Then $aDomainList[0][0] += 1 $aDomainList[$aDomainList[0][0]][3] = GUICtrlCreateListViewItem($sAddDomain & "|" & $sResolveIP & "|" & $sStatus,$gDomainList) Else MsgBox(0,"","Error adding input to list") EndIf Else ; If $iSanity <> 0 ; Update existing info in array and listviewitem $aDomainList[$iSanity][0] = $sAddDomain $aDomainList[$iSanity][1] = $sAddUser $aDomainList[$iSanity][2] = $sAddPass GUICtrlSetData($aDomainList[$iSanity][3],$sAddDomain & "|" & $sResolveIP & "|" & $sStatus) EndIf ; If $iSanity = 0 EndIf ; If StringLen... EndIf ; If $m = $gaddbutton WEnd ;---------------------------------------------------------------------------------------- Func _DNSCheck($sFQDN) $sJSON = _INetGetSource("https://dns.google.com/resolve?name=" & $sFQDN & "&cd=1") ConsoleWrite($sJSON & @CRLF) $sIPAddress = StringRegExpReplace($sJSON,'^.*data": "(.*?)".*?$',"\1") Return $sIPAddress EndFunc ;---------------------------------------------------------------------------------------- Func _DNSUpdate($sFQDN,$sUser,$sPass) Local $sGoogleAPIURI = "https://domains.google.com" Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $sGoogleAPIURI) Local $sHeader = _ 'Authorization: Basic ' & _Base64Encode($sUser & ":" & $sPass) & @CRLF & _ 'Accept: */*' & @CRLF & _ 'User-Agent: AutoITScript/' & @AutoItVersion & @CRLF & _ 'Content-Type: application/x-www-form-urlencoded' Local $aHTTPResponse = _WinHttpSimpleSSLRequest($hConnect, "POST", "/nic/update", Default, "hostname=" & $sFQDN, $sHeader, True, Default, Default, Default, True) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If IsArray($aHTTPResponse) Then $sHTTPResponse = "Header:" & @CRLF & $aHTTPResponse[0] & @CRLF & "Data:" & @CRLF & $aHTTPResponse[1] & @CRLF & @CRLF & @CRLF Return $aHTTPResponse[1] Else $sHTTPResponse = "NO REPLY" Return "No reply from " & $sGoogleAPIURI EndIf EndFunc ;---------------------------------------------------------------------------------------- Func _Base64Encode($sData) Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;---------------------------------------------------------------------------------------- Func _CheckIP() Return _INetGetSource("https://domains.google.com/checkip") EndFunc ;----------------------------------------------------------------------------------------  
    • RTFC
      By RTFC
      CodeCrypter enables you to encrypt scripts without placing the key inside the script.
      This is because this key is extracted from the user environment at runtime by, for example:
      password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here):
      Latest version: 2.3, (18 Jan 2018): CodeScannerCrypter.bundle.v2.3.7z
       
      Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly.
       
      How the bits and pieces fit together:
      CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here:
      '?do=embed' frameborder='0' data-embedContent>>
      The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init().
      From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely:
      In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really.
      Not convinced? Check out this updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:
      CodeCrypterFAQ.pdf
       
      For additional explanations/examples in response to specific questions by forum members (how it works, what it can/cannot do), see elsewhere in this thread, notably:
      Simple analogy of how it works: post #53, second part General Explanation and HowTo: post #9, 51, 75, 185/187, 196, 207, 270, 280 (this gets a bit repetitive) BackTranslation: post #179 Obfuscation: post #36 (general), 49 (selective obfuscation) Specific features and fixes: post #3 (security), 84 (redefining the expected runtime response), 169 (Curl Enum fix), 185/187 (using license keys), 194 (replacing Ward's AES UDF with different encryption/decryption calls), 251 (AV detection issue), 262 (extract key contents to USB on different target machine prior to encryption) Limitations: post #26 (@error/@extended), 149 (FileInstall), 191 (AES.au3 on x64) Not recommended: post #46/249 (static encryption), 102 (programme logic error), 237 (parsing password via cmdline)  
      Technical notes:
      BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want).
      CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for  example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples.
      Encryption currently relies on Ward excellent AES UDF, but you can replace this with any other algorithm you like; just edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry(), see post #194 in this thread.
      AES.au3, by Ward is now also included in bundle (with thanks to Ward), see '?do=embed' frameborder='0' data-embedContent>>
      Going to lie down now...
      RT
      CodeCrypterFAQ.pdf
×