met94 Posted December 22, 2009 Share Posted December 22, 2009 I have encoded autoit code. My program has to decode this and execute. Any ideas how to do it? Encode expandcollapse popup$file = FileOpen("kupa.txt", 0) ;in kupa.txt is autoit code of other program $chars = FileRead($file) $encoded = _Base64Encode($chars) FileWrite("data.dat", $encoded) Func _Base64Encode($input) $input = Binary($input) Local $struct = DllStructCreate("byte[" & BinaryLen($input) & "]") DllStructSetData($struct, 1, $input) Local $strc = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("char[" & DllStructGetData($strc, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($struct), _ "int", DllStructGetSize($struct), _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($strc)) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error encoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Encode Decode expandcollapse popup#include <Security.au3> #include <Process.au3> $file = FileOpen("data.dat", 0) $chars = FileRead($file) $decoded = _Base64Decode($chars) $odkodowany = BinaryToString($decoded) Func _Base64Decode($input_string) Local $struct = DllStructCreate("int") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Decode There is decoding, but I don't know how to execute decoded autoit code from data.dat. Help. Link to comment Share on other sites More sharing options...
Fire Posted December 22, 2009 Share Posted December 22, 2009 (edited) Try this may be it helps: after decode your *.dat it will be contain decode data(autoitscript in this case) and after this just assimilate for .dat assoc .dat=fakefile ftype fakefile="%programfiles%\AutoIt3\AutoIt3.exe" "%1" with run() command. I think this would help to you. And after execution of your .dat file do not forget deassoc .dat to original... EDIT: autoit cli parameter Edited December 22, 2009 by Sh3llC043r [size="5"] [/size] Link to comment Share on other sites More sharing options...
met94 Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks for help, but I can't do it because program has to work on computer without autoit.I tried to use AutoIt3ExecuteLine but it shows me error on line 1 "Unable to parse line."expandcollapse popup#include <Security.au3> #include <Process.au3> $file = FileOpen("data.dat", 0) $chars = FileRead($file) $decoded = _Base64Decode($chars) $odkodowany = BinaryToString($decoded) $cmd = $odkodowany Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"') Func _Base64Decode($input_string) Local $struct = DllStructCreate("int") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64DecodeDecoded data.dat$oMyError = ObjEvent(""AutoIt.Error"",""MyErrFunc"") Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) FileWrite(""Error.txt"", ""COM Error Details:"" & @CRLF & @CRLF & _ ""err.description is: "" & @TAB & $oMyError.description & @CRLF & _ ""err.windescription:"" & @TAB & $oMyError.windescription & @CRLF & _ ""err.number is: "" & @TAB & $HexNumber & @CRLF & _ ""err.lastdllerror is: "" & @TAB & $oMyError.lastdllerror & @CRLF & _ ""err.scriptline is: "" & @TAB & $oMyError.scriptline & @CRLF & _ ""err.source is: "" & @TAB & $oMyError.source & @CRLF & _ ""err.helpfile is: "" & @TAB & $oMyError.helpfile & @CRLF & _ ""err.helpcontext is: "" & @TAB & $oMyError.helpcontext _ ) SetError(1) Sleep(100) EndFuncAutoit msgbox with error:Any ideas how to fix it? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 23, 2009 Developers Share Posted December 23, 2009 (edited) should work with /AutoIt3ExecuteScript: Run(@AutoItExe & ' /AutoIt3ExecuteScript "data.dat"') Edited December 23, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
met94 Posted December 23, 2009 Author Share Posted December 23, 2009 Link to comment Share on other sites More sharing options...
Developers Jos Posted December 23, 2009 Developers Share Posted December 23, 2009 Nice screen capture but I am missing any question in your post.You will have to decode whatever is in the file into readable script lines and save that into a file... then run the file with the command I have given.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fire Posted December 23, 2009 Share Posted December 23, 2009 but I can't do it because program has to work on computer without autoit.So i think to do somethink like what you say you need write your interpreter for autoit.This is really so hard. [size="5"] [/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted December 23, 2009 Developers Share Posted December 23, 2009 So i think to do somethink like what you say you need write your interpreter for autoit.This is really so hard.Why are you making things so complex here?Each compiled script can act as a stub for a new script.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fire Posted December 24, 2009 Share Posted December 24, 2009 Each compiled script can act as a stub for a new script.But how?Sorry i cant seem it yet and i have`nt any ideas somethink like.Any helps will be appreciated in this case. [size="5"] [/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2009 Developers Share Posted December 24, 2009 But how?Sorry i cant seem it yet and i have`nt any ideas somethink like. Any helps will be appreciated in this case. By using: should work with /AutoIt3ExecuteScript: Run(@AutoItExe & ' /AutoIt3ExecuteScript "scriptfile.au3"') @AutoItExe will be your compiled script name when you use this line in your own compiled script. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fire Posted December 24, 2009 Share Posted December 24, 2009 Thank you very much Jos really it works cool . Greatly appreciated.Thank you very-very much Jos. [size="5"] [/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now