Sign in to follow this  
Followers 0
ssalima22

converter hex to acci and acci to exe

13 posts in this topic

#1 ·  Posted (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 by Melba23
Fixed BB tags

Share this post


Link to post
Share on other sites



Any help please

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 :

#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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

ok thank you

Share this post


Link to post
Share on other sites

Sorry but the code it did create the exe file but it run a cmd window instead of the original exe file?

Anyidea

Share this post


Link to post
Share on other sites

What is it supposed to do? Not my code, it's yours and I doubt an exe can be that small.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

look

No 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.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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. :huh:

M23


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

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Also, why don't you use the FileInstall function? In case you are aware of it.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :thumbsup:

is it a nice idea and everything  will be very easy no download needed

what do you thing with this idea?

Share this post


Link to post
Share on other sites

ssalima22,

 

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

That 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. :naughty:

M23


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

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0