Leaderboard
Popular Content
Showing content with the highest reputation on 07/17/2021 in all areas
-
Hi All, I have been working on an enhancement to the WebDriver UDF that will make _WD_ExecuteCDPCommand compatible with all major browsers instead of Chrome only. This involves using WebSockets to pass commands back and forth to the browser. Attached to this post are two files -- winhttp_websocket.au3 -- This is a modified version of code originally posted to the forum by @FireFox. genericcdp.au3 -- This contains the enhanced version of _WD_ExecuteCDPCommand (original version by @TheDcoder) and a new function named _WD_GetCDPSettings You can run genericcdp.au3 for a brief example of how the new functionality works. Comment / uncomment the appropriate lines near the beginning to control while browser gets tested. Prerequisites You'll obviously need the WebDriver UDF installed and working for this code to have a chance of working correct. 🙄 You need to be running an OS that supports WebSockets natively (ie: Windows 8 / Windows Server 2012 or newer) Caveats Chromium-based browsers return some unexpected status codes in response to _WinHttpWebSocketClose and _WinHttpWebSocketQueryCloseStatus, so I've included checks to ignore these. Needs I would appreciate it if I could get some feedback / suggestions for improvement on these proposed changes. FWIW, I have only performed these basic CDP commands. Feel free to experiment with other CDP commands and report back on your successes / failures. Thanks, Dan genericcdp.au3 winhttp_websocket.au33 points
-
EasyCodeIt - cross-platform AutoIt implementation
TheSaint and 2 others reacted to JockoDundee for a topic
Wow, did not know. For me it’s often the other way around, in a loop I keep adding a comma to a concatenated string and then have to remember to lop off the last one. This is so brilliant it’s inspired me to song: Comma, Comma, Comma, Comma, Comma, Chameleon, You come and go, you come and go, Adapted from the Original3 points -
Very true. I will update the OP. That makes sense given the above prerequisite. P.S. Thanks for testing!1 point
-
_FileListToArrayRec specific files within specific folders
FrancescoDiMuro reacted to Musashi for a topic
Provides an array ($aFiles) which contains all PDF files which occur in directories named Batch*. #include <File.au3> #include <Array.au3> Local $sBaseDir = "c:\files", $aFolders[0], $aFiles[0], $aArr[0] $aFolders = _FileListToArrayRec($sBaseDir, "Batch*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) If @error Then Exit MsgBox(BitOR(4096, 16), "Message : ", "Error or no folders found" & @CRLF) For $i = 1 To $aFolders[0] $aArr = _FileListToArrayRec($aFolders[$i], "*.pdf", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_FULLPATH) If Not @error Then For $k = 1 To $aArr[0] _ArrayAdd($aFiles, $aArr[$k]) Next EndIf Next _ArrayDisplay($aFiles, "matching pdf-files :")1 point -
please @jugador, do me a favor, rename those functions to __2Dto1DArray and __1Dto2DArray instead of using "multidimensional" .....1 point
-
EasyCodeIt - cross-platform AutoIt implementation
JockoDundee reacted to TheDcoder for a topic
@jpm Oops, thanks, fixed /* Macro or Variable */ [@$][A-Za-z0-9_]+ return *yytext == '$' ? VARIABLE : MACRO; I also removed the limitation of not being able start a variable (or macro) with a digit, seems arbitrary as we already have a special symbol to denote a variable. LOL, indeed, normally it shouldn't be there but it is allowed since C99... patches are cleaner if you change those values because you don't have to add that extra comma at that time.1 point -
perhaps you miss "_" for VARIABLE I don't remember if MACRO can have them too Cheers1 point
-
This applies for all code, anything you store in your program can be easily extracted and decrypted... even big companies which specialize in anti-tampering technology fail. This is a fundamental flaw which arises from the fact that you want the machine to know the secret but not the user, in other words, you can't have your cake and eat it too1 point
-
I got busy with work again, but luckily I didn't take another month long break I implemented support for #include and #include-once in the lexer, which means the lexer part is more or less done. Here is the new code: // lexer.l %option batch noyywrap nounput nodefault yylineno %{ /* * This file is part of EasyCodeIt. * * Copyright (C) 2021 TheDcoder <TheDcoder@protonmail.com> * * EasyCodeIt is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> struct BufferStack { struct BufferStack *prev; char *code; YY_BUFFER_STATE state; size_t line; char *file; } *lex_buffer = NULL; static char *token_str = NULL; static size_t token_len = 0; static size_t comment_level = 0; #define YY_USER_ACTION token_str = yytext; token_len = yyleng; enum { // Token Types UNKNOWN = 420, WS, COMMENT, DIRECTIVE, NUMBER, STRING, BOOL, WORD, MACRO, VARIABLE, OPERATOR, BRACKET, DOT, COMMA, }; #include "parser.h" static source_reader read_file; static bool push_file(char *file); static bool pop_file(void); %} %x INCLUDE %x DIRECTIVE_LINE %x ML_COMMENT WS [ \t\r\n]+ NL \r?\n? DIGIT [0-9] XDIGIT [0-9A-Fa-f] QUOTE [\'\"] %% /* Include File */ /* TODO: #include-once */ ^"#include"{WS}[\"<] BEGIN INCLUDE; <INCLUDE>[^\n\">]+ { int c; while((c = input()) && c != '\n') /* Eat up any leftover junk in the include line */; ++yylineno; push_file(yytext); BEGIN INITIAL; } <INCLUDE>.|\n /* Ignore bad include line */; "#include-once" { /* Add current file to "include once" list*/ read_file(lex_buffer->file, NULL, true); } /* Whitespace */ {WS} ; /* Directive */ "#" {BEGIN DIRECTIVE_LINE; yymore();}; <DIRECTIVE_LINE>.+ {BEGIN INITIAL; return DIRECTIVE;}; /* Comment */ <INITIAL,ML_COMMENT>"#cs"|"#comment-start"{WS} {BEGIN ML_COMMENT; ++comment_level;}; <ML_COMMENT>"#ce"|"#comment-end" if (--comment_level == 0) BEGIN INITIAL; <ML_COMMENT>(?s:.) ; ;[^\r\n]* return COMMENT; /* Number */ {DIGIT}+(\.{DIGIT}+(e{DIGIT}+)?)? return NUMBER; 0[xX]{XDIGIT}+ return NUMBER; /* String */ \"[^\n\"]*\" return STRING; \'[^\n\']*\' return STRING; /* Bool */ (?i:"True"|"False") return BOOL; /* Word */ [A-Za-z][A-Za-z0-9]* return WORD; /* Macro or Variable */ [@$][A-Za-z][A-Za-z0-9]* return *yytext == '$' ? VARIABLE : MACRO; /* Operator */ /* IDEA: Make a parser mode where the character will be returned literally */ [+\-*/^&=<>?:] return OPERATOR; /* Misc */ [[\]()] return BRACKET; \. return DOT; \, return COMMA; /* Pop file and terminate if top-level */ <<EOF>> if(!pop_file()) yyterminate(); /* Catch-all for everything else */ . return UNKNOWN; %% #include <stddef.h> #include <stdio.h> static void print_token(char *str, int type) { puts("---### TOKEN ###---"); char *token_type; switch (type) { case UNKNOWN: token_type = "Unknown"; break; case WS: token_type = "Whitespace"; break; case COMMENT: token_type = "Comment"; break; case DIRECTIVE: token_type = "Directive"; break; case NUMBER: token_type = "Number"; break; case STRING: token_type = "String"; break; case BOOL: token_type = "Boolean"; break; case WORD: token_type = "Word"; break; case MACRO: token_type = "Macro"; break; case VARIABLE: token_type = "Variable"; break; case OPERATOR: token_type = "Operator"; break; case BRACKET: token_type = "Bracket"; break; case DOT: token_type = "Dot"; break; case COMMA: token_type = "Comma"; break; default: token_type = "Unnamed"; break; } fputs("Type: ", stdout); puts(token_type); fputs("Data: ", stdout); puts(str); } static void scan() { int type; for (;;) { type = yylex(); if (!type) break; print_token(token_str, type); } } bool parse(char *file, source_reader read_func) { read_file = read_func; push_file(file); scan(); return true; } static bool push_file(char *file) { size_t code_len; file = strdup(file); if (!file) return false; char *code = read_file(file, &code_len, false); if (!code) { free(file); return false; } struct BufferStack *new_buffer = malloc(sizeof *new_buffer); if (!new_buffer) return false; if (lex_buffer) lex_buffer->line = yylineno; *new_buffer = (struct BufferStack){ .prev = lex_buffer, .code = code, .state = yy_scan_buffer(code, code_len + 2), .file = file, .line = yylineno = 1, }; lex_buffer = new_buffer; yy_switch_to_buffer(lex_buffer->state); return true; } static bool pop_file() { struct BufferStack *prev_buffer = lex_buffer->prev; yy_delete_buffer(lex_buffer->state); free(lex_buffer->code); free(lex_buffer->file); free(lex_buffer); lex_buffer = prev_buffer; if (!lex_buffer) return false; yylineno = lex_buffer->line; yy_switch_to_buffer(lex_buffer->state); return true; } // eci.c /* * This file is part of EasyCodeIt. * * Copyright (C) 2020 TheDcoder <TheDcoder@protonmail.com> * * EasyCodeIt is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ static char *provide_code(char *file, size_t *size, bool once) { static char **once_list = NULL; static size_t once_list_len = 0; if (once) { // Add the file to "include once" list if (!once_list) { once_list = malloc(sizeof(char *)); if (!once_list) return NULL; ++once_list_len; } else { char **expanded_list = realloc(once_list, sizeof(char *) * ++once_list_len); if (!expanded_list) { --once_list_len; return NULL; } once_list = expanded_list; } once_list[once_list_len - 1] = strdup(file); return NULL; } else { // Skip if the file is in the "include once" list for (size_t i = 0; i < once_list_len; ++i) { if (strcmp(once_list[i], file) == 0) return NULL; } } // Open the source file char *code; FILE *source_file = fopen(file, "r"); if (source_file) { // Read the source file code = readfile(source_file); fclose(source_file); if (!code) die("Failed to read from source file!"); } else { code = malloc(1); code[0] = '\0'; } // The following is required because the parser needs a string with two null terminators *size = strlen(code); char *code_padded = realloc(code, *size + 2); if (!code_padded) { free(code); die("Failed to expand code buffer"); } code_padded[*size + 1] = '\0'; return code_padded; } int main(int argc, char *argv[]) { if (argc < 2) die("No arguments!"); // Parse the code parse(argv[1], provide_code); return EXIT_SUCCESS; } It was surprisingly easy to write a fully featured scanner/tokenizer in flex, guess I should have used it from the beginning. Now I can start work on the parser, hopefully it will be easy too, surely easier than writing it all manually 🥵 Source: https://forum.dtw.tools/d/28-easycodeit-update-flex-bison-parser/21 point
-
Security questions for AutoIT approval
TheDcoder reacted to argumentum for a topic
lol, anyone that can not answer these questions by him/her self, should not be doing that job, as THAT is not the way to get those answers. There. A free lesson. ( Do click like -or HaHa- if you get to read this )1 point -
@BradBurke Just out of curiosity, have you also sent this list of questions to, say, Microsoft, regarding the use of .Net development software. If so, I would be interested in the answer (if you ever received one). AutoIt scripts compiled as .exe contain, in simple terms, a tokenized version of the source code, along with the appropriate AutoIt Interpreter itself. So you should never store e.g. passwords or other sensitive data in the source code. However, this is explicitly not a weakness of AutoIt, it was simply not designed for this purpose. You should be far more concerned about what data will be sent from your operating system behind the scenes .1 point
-
With all respect, but what are you expecting as answer to your dumped list of questions of which several are totally void? Did you do any research yourself before asking as many are asked before and answered. ... and to be honest: How much trust should one put in the creators answer anyways? Jos1 point
-
Hi everyone, I already posted an update yesterday where I mentioned that I have started work on the new parser which uses Flex and Bison to generate C code for parsing. So far the experience has been very nice, I am able to test and develop things very fast compared to doing it all on my own. I have completed the initial version of the tokenizer/scanner/lexer, it should be able to scan all tokens which could possibly occur in a valid script %option noyywrap nodefault %{ #include <stdlib.h> #include <string.h> char *token_str = NULL; size_t token_len = 0; size_t comment_level = 0; //#define YY_USER_ACTION free(token_str); token_str = strndup(yytext, token_len = yyleng); #define YY_USER_ACTION token_str = yytext; token_len = yyleng; enum { // Token Types UNKNOWN = 420, WS, COMMENT, DIRECTIVE, NUMBER, STRING, BOOL, WORD, MACRO, VARIABLE, OPERATOR, BRACKET, DOT, COMMA, }; %} %x ML_COMMENT WS [ \t\r\n]+ NL \r?\n? DIGIT [0-9] XDIGIT [0-9A-Fa-f] QUOTE [\'\"] %% /* Whitespace */ {WS} ; /* Comment */ <INITIAL,ML_COMMENT>"#cs"|"#comment-start"{WS} {BEGIN ML_COMMENT; ++comment_level;}; <ML_COMMENT>"#ce"|"#comment-end" if (--comment_level == 0) BEGIN INITIAL; <ML_COMMENT>(?s:.) ; [;#][^\r\n]* return *yytext == ';' ? COMMENT : DIRECTIVE; /* Number */ {DIGIT}+(\.{DIGIT}+(e{DIGIT}+)?)? return NUMBER; 0[xX]{XDIGIT}+ return NUMBER; /* String */ \"[^\n\"]*\" return STRING; \'[^\n\']*\' return STRING; /* Bool */ (?i:"True"|"False") return BOOL; /* Word */ [A-Za-z][A-Za-z0-9]* return WORD; /* Macro or Variable */ [@$][A-Za-z][A-Za-z0-9]* return *yytext == '@' ? MACRO : VARIABLE; /* Operator */ [+\-*/^&=<>?:] return OPERATOR; /* Misc */ [[\]()] return BRACKET; \. return DOT; \, return COMMA; /* Catch-all for everything else */ . return UNKNOWN; %% #include <stddef.h> #include <stdio.h> static void print_token(char *str, size_t len, int type) { puts("---### TOKEN ###---"); char *token_type; switch (type) { case UNKNOWN: token_type = "Unknown"; break; case WS: token_type = "Whitespace"; break; case COMMENT: token_type = "Comment"; break; case DIRECTIVE: token_type = "Directive"; break; case NUMBER: token_type = "Number"; break; case STRING: token_type = "String"; break; case BOOL: token_type = "Boolean"; break; case WORD: token_type = "Word"; break; case MACRO: token_type = "Macro"; break; case VARIABLE: token_type = "Variable"; break; case OPERATOR: token_type = "Operator"; break; case BRACKET: token_type = "Bracket"; break; case DOT: token_type = "Dot"; break; case COMMA: token_type = "Comma"; break; default: token_type = "Unnamed"; break; } fputs("Type: ", stdout); puts(token_type); fputs("Data: ", stdout); puts(str); } int main(void) { int type; for (;;) { type = yylex(); if (!type) break; print_token(token_str, token_len, type); } return 0; } I passed this "script" as the input: #cs #cs nested comment #ce #ce ; Calm Mints 42 0xDEADBEEF 3.14 6.02214076e23 "Hell'o World" '"To C or not to C"' True true fAlSe False tRUe @TheTruth $TheFact -((1 + 2) / 3) * 4 And here is the output: ---### TOKEN ###--- Type: Comment Data: ; Calm Mints ---### TOKEN ###--- Type: Number Data: 42 ---### TOKEN ###--- Type: Number Data: 0xDEADBEEF ---### TOKEN ###--- Type: Number Data: 3.14 ---### TOKEN ###--- Type: Number Data: 6.02214076e23 ---### TOKEN ###--- Type: String Data: "Hell'o World" ---### TOKEN ###--- Type: String Data: '"To C or not to C"' ---### TOKEN ###--- Type: Boolean Data: True ---### TOKEN ###--- Type: Boolean Data: true ---### TOKEN ###--- Type: Boolean Data: fAlSe ---### TOKEN ###--- Type: Boolean Data: False ---### TOKEN ###--- Type: Boolean Data: tRUe ---### TOKEN ###--- Type: Macro Data: @TheTruth ---### TOKEN ###--- Type: Variable Data: $TheFact ---### TOKEN ###--- Type: Operator Data: - ---### TOKEN ###--- Type: Bracket Data: ( ---### TOKEN ###--- Type: Bracket Data: ( ---### TOKEN ###--- Type: Number Data: 1 ---### TOKEN ###--- Type: Operator Data: + ---### TOKEN ###--- Type: Number Data: 2 ---### TOKEN ###--- Type: Bracket Data: ) ---### TOKEN ###--- Type: Operator Data: / ---### TOKEN ###--- Type: Number Data: 3 ---### TOKEN ###--- Type: Bracket Data: ) ---### TOKEN ###--- Type: Operator Data: * ---### TOKEN ###--- Type: Number Data: 4 Which is very similar if not exactly the same as what our old parser would have produced The next step is to add support for including files (#include <...>) and then I will start work on the syntactic analysis, which is the actual "parsing" to convert list of words into actions. Hopefully I won't get held up by last time due to all the fatigue, using these tools should speed up the process significantly. Stay tuned for more updates this week! Source: https://forum.dtw.tools/d/28-easycodeit-update-flex-bison-parser1 point
-
Func _ChangeWallpaper($sFile,$iType) ; Changes the wallpaper to $sFilename using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if £sFile is not a .bmp file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'bmp' Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','1') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','2') Case Else ; EndSelect RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("user32","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) Return 0 EndFunc1 point