Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/23/2019 in all areas

  1. Beege

    How to decode this code

    No... Stop with the decoding because it becomes opcode and if you dont understand that you need to study at bit more on what assembly code actually does. The source (with lots of comments to explain what its doing) is in the comments at the bottom of what you posted so I don't know how much more comfort or clarity I can give you here. If you get past cracking base64 (Hint: its right after the $aDecode variable) , you can use a site like below to get an understanding of assembly code vs opcode (shellcode). Look into what sandbox applications are for trust issues with the code. https://defuse.ca/online-x86-assembler.htm
    3 points
  2. This UDF brings the power and flexibility of jq to AutoIt scripts. jq is an open-source, powerful, and flexible command-line based JSON processor. As it says on their website, jq is like 'sed' for JSON. jq can be used for the simplest of tasks like retrieving JSON objects and values (parsing), to very advanced JSON processing using its numerous built-in functions and conditional processing. Its built-in functions can handle math, selection, conditional processing, mapping, object and array manipulation, flattening, reduction, grouping, and much more. You can even create your own jq functions. You can learn more about jq and even play with it in real-time, using jq's online jq playground, all on their website. Here and some helpful links to get you more familiar with jq, what can be done with it, its built-in functions, and its syntax. jq Website: https://jqlang.github.io/jq/ jq Manual: https://jqlang.github.io/jq/manual/ jqWiki (FAQ, Cookbook, Advanced Topics) https://github.com/jqlang/jq/wiki jq is a single 32 or 64 bit executable that has no other dependencies. Just like using the SQLite UDF, the only requirement to use this UDF is that the jq executable reside in a location in which the UDF can execute it. The latest win32 & win64 versions have been included in the UDF download. You can always get newer versions from the jq website. jq at a high level Like 'sed', jq reads JSON in, either through STDIN or one or more files, processes it thru one or more "filters", and outputs the results. You can, optionally, supply "options" that affect how it reads the input, where it gets its "filters", and how it writes its output. It looks a little like this: JSON ---> jq processor (using supplied filters and options) ---> Output So in jq lingo, you basically use "Filters" to tell jq what you want it to do. So in the UDF file, that is why the main functions ( _jqExec() and _jqExecFile() ) refer to filters and options. Please make note that jq works with relatively strict JSON. This means that all JSON read must be conform to the standard. Luckily, jq is pretty good at identifying where a format error exists in non standard JSON. The jq UDF There are 2 main funtions in the UDF file, _jqExec and jqExecFile. With these 2 functions, you can pretty much do anything that jq can do. The only difference between to two functions is whether the JSON is supplied by a string or a file. The 2 primary functions simply call the jq executable with the supplied information, after properly formatting the parameters. There are additional functions in the UDF to easily pretty-print your json, compact-print your json, dump the json data with its associated paths, and see if specific JSON keys exist, but they all just execute the _jqExec or _jqExecFile function with the proper filter. There are also a couple of extra functions to display what version of the UDF and jq executable you are currently using. There are also a couple of functions to enable and disable logging of jq information for debugging purposes. Most of the jq UDF file functions return an @error if unsuccessful. Some also include @extended info. Please see the actual function headers for more information on their usage and return values. The 2 primary functions below just format your jq request and pass it on the jq executable. The functions will also properly escape double quotes (") that are used in the filter. For most simple tasks, you just need to supply the JSON source and a filter. _jqExec($sJson, $sFilter, $sOptions = Default, $sWorkingDir = Default) Or _jqExecFile($sJsonFile, $sFilter, $sOptions = Default, $sWorkingDir = Default) Using jq in your script As stated earlier, the jq executable must reside somewhere where the script can locate and execute it. The _jqInit() function always has to be executed before any jq processing occurs. _jqInit() merely locates the executable or uses the supplied path. It also clears any previous debug log. The jq UDF folder contains a jq example script that has several examples to how to do some of the most common JSON processing tasks. Here are a few examples to get you started: How to pretty-print some JSON #include "jq.au3" ;_jqInit is only needed if the jq executale is not in the PATH or @ScriptDir _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"fruits":[{"Apple":{"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sCmdOutput & @CRLF) How to compact-print some JSON #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sCmdOutput & @CRLF) Dump JSON data (paths and values) #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqDump($sJson) ConsoleWrite(@CRLF & "Dump JSON paths and values" & @CRLF & $sCmdOutput & @CRLF) How to GET JSON values #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana.color' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) or #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'getpath(["Banana", "color"])' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Check for the existence of a key #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | has("color")' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Check for existence of color key within Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Count of how many Items in an object #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | length' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("How many items in the Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) How to PUT/Create/Modify JSON #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sInput = "" $sFilter = 'setpath(["Apple","color"];"Red") | setpath(["Banana","color"];"Yellow") | setpath(["Banana","season"];"Summer")' $sOptions = '-n' ;required if no input supplied $sCmdOutput = _jqExec($sInput, $sFilter, $sOptions) ConsoleWrite("Update/Create JSON" & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) List all of the fruits (top-level keys) #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'keys | .[]' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("List all top-level keys (fruits)" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) Calculate the sum of all of the objects' price * qty #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '[{"id":1,"price":20.00,"qty":10},{"id":2,"price":15.00,"qty":20.25},{"id":3,"price":10.50,"qty":30}]' $sFilter = 'map(.price * .qty) | add' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Calculate the sum of all of the objects' price * qty" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) The examples above, and the ones in the example files, merely scratch the surface of what jq can do. It may look intimidating at first but it really isn't that bad once you start playing with it. You can find several more examples and play around with them or create your own using jqPlayground. jqPlayground is a separate, stand alone, interactive tool for creating, testing and learning JSON processing using jq. If you have any questions regarding the UDF, or how to perform a certain task using jq, I'll try my best to answer them. Since jq has been around for a while now, there's also several jq-related questions and answers on StackOverflow. >>> Download the UDF in the Files Section <<<
    1 point
  3. LAST VERSION - 1.0 25-Jan-15 This is my way to use the API ReadDirectoryChangesW in AutoIt. The problem is that to use this function will not work fully without creating thread. To solve this problem, I wrote the simple DLL that provides work with threads. As a result, the AutoIt script only receives and processes the appropriate data from thread. To evaluate all features of the library, please see the full example with GUI for monitoring directories. For more information, see description for each function within the library. The following are the main features of the RDC UDF library. Creating multiple threads (unlimited) for monitoring different directories.Support for hot (unsafe) unplugging of removable devices such as USB flash drive, etc.Support for network drives.Support for 32- and 64-bit processes (RDC.dll and RDC_x64.dll).Easy to use functions from the library.Full examples, including GUI. Available functions RDC UDF Library v1.0 (x86 and x64) Previous downloads: 17 RDC.zip Examples Simple (Notification mode) Advanced GUI
    1 point
  4. That would be my guess too. The exe is not "official".
    1 point
  5. jchd

    JSON as AutoIt data type

    There's an extra " around the result, but that isn't the whole story: #include <SQLite.au3> Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.dll" ;<-- Change to the location of your sqlite dll Local $aRow ;Init sqlite and create a memory db _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") _SQLite_Open() Local $sTEST_JSON = "Mc'Donald's" & @TAB & 'food / if you call that "food" \' & @CRLF & "this is the last verse." Local $sEscapedJSON = _JSON_SQL_Escape($sTEST_JSON) ConsoleWrite("Escaped JSON = " & $sEscapedJSON & @LF) If _SQLite_QuerySingleRow(-1, "select json_extract(" & $sEscapedJSON & ", '$');", $aRow) = $SQLITE_OK Then ConsoleWrite("Valid JSON = " & $aRow[0] & @LF) EndIf Exit ; Escape chars in JSON strings as per rfc-7159 (http://www.rfc-editor.org/rfc/rfc7159.txt) ; then returns a valid SQL string containing a valid JSON string type. ; ; Literal single & double quotes are escaped to hex to avoid issues ; this is less human-readable but rock-solid (see below for full Unicode) ; ; If you expect Unicode chars outside the BMP (Basic Multilingual Plane) ; you need to convert codepoints > 0xFFFF to their surrogate pair in Hex Func _JSON_SQL_Escape($s) ; escape / \ with a backslash $s = StringRegExpReplace($s, '([\\/])', '\\$1') ; escape single quotes to hex $s = StringRegExpReplace($s, "'", '\\u0027') ; escape solidus, backslash, double quotes and control chars to Hex ; then enclose the whole string in double quotes so that it's then a valid JSON literal string ; then enclose it in single quotes so that the SQL parser sees a valid SQL string Return '''"' & Execute('"' & StringRegExpReplace($s, '(["\x00-\x1f])', '" & "\\u" & Hex(Asc(''$1''), 4) & "') & '"') & '"''' EndFunc
    1 point
  6. Hi, @Danp2, the new release seems to be working stable. Nice work!!! :-) Thank you very much. :-)
    1 point
  7. $A = 65 For $i = 0 to 25 For $j= 0 to 25 For $k = 0 to 25 ConsoleWrite(Chr($A+$i) & Chr($A+$j) & Chr($A+$k) & @CRLF) Next Next Next Edit: didn't know why I put in 32...25 starting from 0 is correct. I do like the recursion used in the other example though.
    1 point
  8. $Letters = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z", ",") Combi("", 3) Func Combi($Str, $MaxLen) if StringLen($Str) = $MaxLen Then FileWriteLine("Test.txt", "Letters list = " & $Str) Return EndIf For $i = 1 to $Letters[0] Combi($Str & $Letters[$i], $MaxLen) Next EndFunc
    1 point
  9. Xandy

    MapIt Quest

    Added a fun feature: NPCs fall from the world if NPC_Position aWorld[0][x][y][tile] = 0. The first layer of tile in world, if it is empty under NPC, NPC status is falling. A blank first layer tile is also treated as a wall by the default NPC_Movement_Type. So NPCs probably won't step off the world, but you can delete the tile under them. Just saying.
    1 point
  10. As @BrewManNH said. I didn't find any other way... Here how to get the right exe to use : #pragma compile(AutoItExecuteAllowed, true) Local $BaseExe = @Compiled ? @ScriptName : @AutoItExe Run ($BaseExe & " /AutoIt3ExecuteScript PartOfMyScript.au3") Now you will have to pass the required variables to PartOfMyScript.au3. You can use CmdLine[ ] array to do that...
    1 point
  11. Look at my post above, it tells you how to do that by running that part of the script as a separate script. I did forget to mention, you will need to add the following line to allow it to execute that script. #pragma compile(AutoItExecuteAllowed, true) NOTE: BTW, you can't use #include to add the code to a compiled script. #includes are only added when the script is compiled, after that the included file is part of the main script inside the exe.
    1 point
  12. Yes, since jq itself is a command line tool, it is a bit slower than say a dll, especially if one is just retrieving a lot of scalar values. However, it is very powerful. I can definitely imagine more advanced scenarios in which jq may not only be faster, but much easier too. If json slicing and dicing is necessary, or if you need to do mathematical functions against json data like averages or summing, or even need to extract, sort, and/or generate json from existing json files, jq may be a better choice and a lot easier to use. In addition, there are many things that jq can do that other json parsers cannot. That's primarily because jq is a json processing tool as opposed to a json parser. In any case, It's just another tool for the tool box. ...And thanks for trying it out.
    1 point
  13. Hi SkySnake - Below you will see a slighly modified version of your script. I identified my modifications by wrapping them in "; =========== Modified =====================" Also notice that I changed the method of validating json by changing the function to json_valid(). #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: TheXman JSON as AutoIt data type Script Function: https://www.autoitscript.com/forum/topic/197243-json-as-autoit-data-type/?do=findComment&comment=1414692 #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <SQLite.au3> example() Func example() ; https://en.m.wikipedia.org/wiki/00_Agent Const $TEST_JSON = _ '{' & _ ' "James Bond": "007",' & _ ' "Randy Enton": "006",' & _ ' "Sam Johnston": "0012"' & _ '}' ;;#CE Const $SQLITE_DLL = "c:\program files\sqlite\sqlite3.dll" ;<-- Change to the location of your sqlite dll Local $aRow Local $hQuery ;Init sqlite and create a memory db _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") _SQLite_Open() ; =========== Modified ===================== Local $sQuery, $sKey Local $vValue ;Example of validating json (Good return means JSON is well-formed) $sQuery = StringFormat("SELECT json_valid('%s')", $TEST_JSON) ConsoleWrite(@CRLF & "Query: " & $sQuery & @CRLF) If _SQLite_Query(-1, $sQuery, $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite("Value: " & $aRow[0] & @CRLF) WEnd EndIf ;Example of validating json (Good return means JSON is well-formed) $sKey = "Stuart Thomas" $vValue = "007" $sQuery = StringFormat("SELECT json_set('%s', '$.%s','%s')", $TEST_JSON, $sKey, $vValue) ConsoleWrite(@CRLF & "Query: " & $sQuery & @CRLF) If _SQLite_Query(-1, $sQuery, $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite("Value: " & $aRow[0] & @CRLF) WEnd EndIf ConsoleWrite(@CRLF) ; =========== Modified ===================== ;Example of extracting data Local $sJSONValueToFind = "e4" ;;;$sJSONQuery = "select json_extract('" & $TEST_JSON & "', '$.e4') ;" $sJSONQuery = "select json_extract('" & $TEST_JSON & "', '$." & $sJSONValueToFind & "') ;" ConsoleWrite($sJSONQuery & @CRLF) If _SQLite_Query(-1, $sJSONQuery, $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite($sJSONValueToFind & ": " & $aRow[0] & @CRLF) WEnd EndIf ;Example of setting data Local $sJSONAttribToSet = "Stuart Thomas" Local $sJSONValueToSet = "005" Local $sJSONValueToFind = "Stuart Thomas" ;;;$sJSONQuery = "select json_extract('" & $TEST_JSON & "', '$.e4') ;" $sJSONQuery = "select json_set('" & $TEST_JSON & "', '$." & $sJSONAttribToSet & "'," & $sJSONValueToSet & ") ;" ConsoleWrite("88 " & $sJSONQuery & @CRLF) If _SQLite_Query(-1, $sJSONQuery, $sJSONQuery) = $SQLITE_OK Then While _SQLite_FetchData($sJSONQuery, $aRow) = $SQLITE_OK ConsoleWrite("91 " & $sJSONValueToFind & ": " & $aRow[0] & @CRLF) Local $improvedJSON = $aRow[0] WEnd EndIf ;Local $improvedJSON = $aRow[0] ConsoleWrite("$improvedJSON " & $improvedJSON & @CRLF) $sJSONQuery = "select json_extract('" & $improvedJSON & "', '$." & $sJSONValueToFind & "') ;" ConsoleWrite("98 " & $sJSONQuery & @CRLF) If _SQLite_Query(-1, $sJSONQuery, $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite("101 " & $sJSONValueToFind & ": " & $aRow[0] & @CRLF) WEnd EndIf ;Close db and shutdown sqlite _SQLite_Close() _SQLite_Shutdown() EndFunc ;==>example By the way, although sqlite has some nice json functionality, you may want to check out my new UDF that lets you run jq. You can read more about it here:
    1 point
  14. jchd

    JSON as AutoIt data type

    JSON is text so you can simply and safely store it in a TEXT column. You need to quote the value, like this: ; Script Start - Add your code below here #include <SQLite.au3> example() Func example() Const $TEST_JSON = _ '{' & _ ' "James Bond": "007",' & _ ' "Randy Enton": "006",' & _ ' "Sam Johnston": "0012"' & _ '}' Const $SQLITE_DLL = "C:\SQLite\bin\sqlite3.dll" ;<-- Change to the location of your sqlite dll Local $aRow Local $hQuery ;Init sqlite and create a memory db _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") _SQLite_Open() ;Example of validating json (Good return means JSON is well-formed) If _SQLite_Query(-1, "select json('" & $TEST_JSON & "');", $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite("Source JSON = " & $aRow[0] & @CRLF) WEnd EndIf ;Example of setting data Local $sJSONAttribToSet = "Stuart Thomas" Local $sJSONValueToSet = "005" Local $sJSONValueToFind = $sJSONAttribToSet ; #### note double quotes around $sJSONValueToSet #### $sJSONQuery = "select json_set('" & $TEST_JSON & "', '$." & $sJSONAttribToSet & "',""" & $sJSONValueToSet & """) ;" Local $sChangedJSON If _SQLite_Query(-1, $sJSONQuery, $sJSONQuery) = $SQLITE_OK Then While _SQLite_FetchData($sJSONQuery, $aRow) = $SQLITE_OK $sChangedJSON = $aRow[0] WEnd EndIf ConsoleWrite("$sChangedJSON " & $sChangedJSON & @CRLF) $sJSONQuery = "select json_extract('" & $sChangedJSON & "', '$." & $sJSONValueToFind & "') ;" ConsoleWrite($sJSONQuery & @CRLF) If _SQLite_Query(-1, $sJSONQuery, $hQuery) = $SQLITE_OK Then While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ConsoleWrite($sJSONValueToFind & ": " & $aRow[0] & @CRLF) WEnd EndIf ;Close db and shutdown sqlite _SQLite_Close() _SQLite_Shutdown() EndFunc ;==>example
    1 point
×
×
  • Create New...