ssalima22 Posted June 26, 2013 Share Posted June 26, 2013 (edited) Hello everyone i am new to Autoit scripting i have this code that can recreate an exe file from its hex code Dim str As String Dim hex As String hex = hex & "4D5A90000300000004000000FFFF0000B80000000000000040000000265" hex = hex & "2072756E20696E20444F53206D6F6460000200000400000000000000" Dim exe As String Dim i As Long Dim puffer As Long i = 1 Do str = Mid(hex, i, 2) 'convert hex to decimal puffer = Val("&H" & str)) 'convert decimal to ASCII exe = exe & Chr(puffer) i = i + 2 If i >= Len(hex) - 2 Then Exit Do End If Loop 'write to file Open "C:\my.exe" For Append As #2 Print #2, exe Close #2 Dim pid As Integer 'and run the exe pid = Shell("C:\my .exe", vbNormalFocus) End Sub i need to make it in autoit thanx in advance Edited June 26, 2013 by Melba23 Fixed BB tags Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 Any help please Link to comment Share on other sites More sharing options...
FireFox Posted June 26, 2013 Share Posted June 26, 2013 (edited) Hi,Welcome to the autoit forum Please use the default font layout (left text align) and use the autoit code tags to post your code, otherwise it's not readable.Moreover, this is NOT a 24/7 support forum, please wait at least 24 hours before bumping your topic.This should work :expandcollapse popup#include <FileConstants.au3> ;Dim str As String Local $str = "" ;Dim hex As String Local $hex = "" ;hex = hex & "4D5A90000300000004000000FFFF0000B80000000000000040000000265" $hex &= "4D5A90000300000004000000FFFF0000B80000000000000040000000265" ;hex = hex & "2072756E20696E20444F53206D6F6460000200000400000000000000" $hex &= "2072756E20696E20444F53206D6F6460000200000400000000000000" ;Dim exe As String Local $exe = "" ;Dim i As Long Local $i = 0 ;Dim puffer As Long Local $puffer = 0 ;i = 1 $i = 1 ;Do While 1 ;str = Mid(hex, i, 2) $str = StringMid($hex, $i, 2) ;convert hex to decimal ;Hex(puffer = Val("&H" & str)) $puffer = Hex($str) ;;convert decimal to ASCII ;exe = exe & Chr(puffer) $exe &= Chr($puffer) ;i = i + 2 $i += 2 ;If i >= Len(hex) - 2 Then If $i >= StringLen($hex) - 2 Then ;Exit Do ExitLoop ;End If EndIf ;Loop WEnd ;;write to file ;Open "C:\my.exe" For Append As #2 Local $hFile = FileOpen("C:\my.exe", $FO_OVERWRITE) ;Print #2, exe FileWrite($hFile, $exe) ;Close #2 FileClose($hFile) ;Dim pid As Integer Local $pid = 0 ;;and run the exe ;pid = Shell("C:\my.exe", vbNormalFocus) $pid = Run("C:\my.exe") ;End Sub ;not translated (missing sub line)Edit: Added indents.Br, FireFox. Edited June 26, 2013 by FireFox Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 ok thank you Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 Sorry but the code it did create the exe file but it run a cmd window instead of the original exe file? Anyidea Link to comment Share on other sites More sharing options...
FireFox Posted June 26, 2013 Share Posted June 26, 2013 What is it supposed to do? Not my code, it's yours and I doubt an exe can be that small.Br, FireFox. Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 look i converted an exe file into hex and then after run my code the exe file will be created in c: my.exe and excuted simply in vb6 it worked very simple the hex is too big not smal that was an example only my exe file is about 150kb Link to comment Share on other sites More sharing options...
FireFox Posted June 26, 2013 Share Posted June 26, 2013 lookNo I'm not your friend.What about this?#include <Constants.au3> Local $hex = "0x" $hex &= "4D5A90000300000004000000FFFF0000B80000000000000040000000265" & _ "2072756E20696E20444F53206D6F64600002000004000000000000000" Local $hFile = FileOpen("C:\my.exe", BitOR($FO_OVERWRITE, $FO_BINARY)) FileWrite($hFile, $hex) FileClose($hFile) Local $pid = Run("C:\my.exe")Br, FireFox. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2013 Moderators Share Posted June 26, 2013 ssalima22,Why are you doing this? The idea of creating exes on the fly and then executing them does not give me a warm fuzzy feeling. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FireFox Posted June 26, 2013 Share Posted June 26, 2013 Also, why don't you use the FileInstall function? In case you are aware of it. Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 No, i am just trying to come with a new idea of downloading files if we provide the hex code of and excutable programe and create it using this code it would be a good idea instead of downloading it i don't know if it works or not but i tried it with small exe files and it works very well --------------------- $hex &= "4D5A90000300000004000000FFFF0000B80000000000000040000000265" & _ "2072756E20696E20444F53206D6F64600002000004000000000000000" i have the $hex &= "4D5A90000300000004000000FFFF0000B80000000000000040000000265" code of my.exe and it is too long i don't know how to get it "2072756E20696E20444F53206D6F64600002000004000000000000000" in my vb6 i just used the full code of $hex &= "4D5A90000300000004000000FFFF0000B80000000000000040000000265" and it worked Link to comment Share on other sites More sharing options...
ssalima22 Posted June 26, 2013 Author Share Posted June 26, 2013 thank you FireFox your second code worked i will explain my idea: if we provide the hex code of any programe ex:Vlc.exe and past its hex code in pastbin each one can just copy past the hex code and run the programe is it a nice idea and everything will be very easy no download needed what do you thing with this idea? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2013 Moderators Share Posted June 26, 2013 ssalima22, No, i am just trying to come with a new idea of downloading filesif we provide the hex code of and excutable programe and create it using this code it would be a good idea instead of downloading itThat makes no sense at all. How do you get the hex code in the first place unless you download it? And as the Hex code is several times larger than the machine code it represents you are just making matters worse.. I am not at all convinced by your explanation and not at all happy about why you want to do this. So...thread locked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts