How do i add a function to a compiled exe file? 
Author Message
 How do i add a function to a compiled exe file?

Hi everyone

I have a compiled exe file (about 200k in size) and i want to add some
code that should be executed before the the original program.
That code should check a few things and descide if the actual program
should be allowed to run or else it should just quit (without jumping
to the original code).
I have heard that viruses does something like this, they add some code
to the end of the program and changes the header so it executes the
new code first. The problem is that i don't understand how i could put
a value higher than 65535 in IP inside the head and since the original
program is about 200k in size that seems quite impossible to me:(
Can anyone tell me how to do this step by step (or is there any
document describing it?).

Thanks in advance




Thu, 06 Mar 2003 03:00:00 GMT  
 How do i add a function to a compiled exe file?
A very clever chap who goes by the name Greythorne has worked this one out
already for just this purpose.  Go to www.greythorne.cjb.net and look for his
"Symbiote" program.  It comes with full TASM compatible source (it may be in
MASM format... I forget...)  You just have to give it a payload to inset into
the file.
I hope this helps
Adam


Quote:

>Hi everyone

>I have a compiled exe file (about 200k in size) and i want to add some
>code that should be executed before the the original program.
>That code should check a few things and descide if the actual program
>should be allowed to run or else it should just quit (without jumping
>to the original code).
>I have heard that viruses does something like this, they add some code
>to the end of the program and changes the header so it executes the
>new code first. The problem is that i don't understand how i could put
>a value higher than 65535 in IP inside the head and since the original
>program is about 200k in size that seems quite impossible to me:(
>Can anyone tell me how to do this step by step (or is there any
>document describing it?).

>Thanks in advance



--
-=Adam=-



Fri, 07 Mar 2003 03:00:00 GMT  
 How do i add a function to a compiled exe file?
Start of file         +00 word "MZ"
                            +02 word length of image mod 512 byte
(L_m512)
                            +04 word size  of image in 512 bytes page
(L_d512)
                            +08 word size of header in 16 byte
(H_size)
                           +14  word: IP of start of your code 100h ( if
.com)  (IP_start)
                           +16 word: CS in this file in
para                                  (CS_start)

You do :
Old_CS_start=CS_start
Old_IP_start=IP_start
IP_start=100h
CS_start=L_d512*512+L_d512

in your code include :
-at the start
    pusha
   push ds
   push es
-at the end
   mov ax,cs
   add word ptr [cs:tab +2],ax
   pop es
   pop ds
   popa
    jmp dword ptr [cs:tab]

tab dw Old_IP_start, Old_CS_start-CS_start

Now could add your code at the end of the .exe.

        Have fun
        Olivier

Quote:

> Hi everyone

> I have a compiled exe file (about 200k in size) and i want to add some
> code that should be executed before the the original program.
> That code should check a few things and descide if the actual program
> should be allowed to run or else it should just quit (without jumping
> to the original code).
> I have heard that viruses does something like this, they add some code
> to the end of the program and changes the header so it executes the
> new code first. The problem is that i don't understand how i could put
> a value higher than 65535 in IP inside the head and since the original
> program is about 200k in size that seems quite impossible to me:(
> Can anyone tell me how to do this step by step (or is there any
> document describing it?).

> Thanks in advance





Fri, 07 Mar 2003 03:00:00 GMT  
 How do i add a function to a compiled exe file?

On Mon, 18 Sep 2000 13:42:59 GMT, Olivier Cozette

Should i change these values in the original .exe file?

Quote:
>Start of file         +00 word "MZ"
>                            +02 word length of image mod 512 byte
>(L_m512)

filesize mod 512?

Quote:
>                            +04 word size  of image in 512 bytes page
>(L_d512)

Is this including the partial page at +02?
filesize / 512?

Quote:
>                            +08 word size of header in 16 byte
>(H_size)

?

Quote:
>                           +14  word: IP of start of your code 100h ( if
>.com)  (IP_start)

The original file is an .exe file.
Quote:
>                           +16 word: CS in this file in
>para                                  (CS_start)

>You do :
>Old_CS_start=CS_start
>Old_IP_start=IP_start
>IP_start=100h
>CS_start=L_d512*512+L_d512

>in your code include :
>-at the start
>    pusha
>   push ds
>   push es
>-at the end
>   mov ax,cs
>   add word ptr [cs:tab +2],ax
>   pop es
>   pop ds
>   popa
>    jmp dword ptr [cs:tab]

>tab dw Old_IP_start, Old_CS_start-CS_start

>Now could add your code at the end of the .exe.

>        Have fun
>        Olivier

>> Hi everyone

>> I have a compiled exe file (about 200k in size) and i want to add some
>> code that should be executed before the the original program.
>> That code should check a few things and descide if the actual program
>> should be allowed to run or else it should just quit (without jumping
>> to the original code).
>> I have heard that viruses does something like this, they add some code
>> to the end of the program and changes the header so it executes the
>> new code first. The problem is that i don't understand how i could put
>> a value higher than 65535 in IP inside the head and since the original
>> program is about 200k in size that seems quite impossible to me:(
>> Can anyone tell me how to do this step by step (or is there any
>> document describing it?).

>> Thanks in advance





Fri, 07 Mar 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Compiling EXE file with embedded File Version

2. Adding code to EXE Files

3. Compiling in HTTP Resource Files into an EXE -- PLEASE HELP

4. How to compile DBase (prg) to EXE files ??

5. how do I compiled my text files to have a .exe suffix

6. Pickler that handles modules, functions, and builtin functions -- done

7. Sample code for Calling C exe files with System exec function in LabVIEW 6.1

8. Sample code for Calling C exe files with System exec function in LabVIEW 6.1

9. Adding needed file functions to ISO libraries?

10. my EXE doing not well

11. How can I know the .EXE file name, file date, file size

12. what virus cpontains the exe file CFGWIZ32.exe

 

 
Powered by phpBB® Forum Software