Jump to content

converter hex to acci and acci to exe


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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.
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...