Creating .exe or .dll from scratch inside the .exe

Technical Discussions not Related Directly to MHS. For Example, Coding, Hex Editing, General Hacking, Etc.

Moderators: g3nuin3, SpeedWing, WhiteHat

Creating .exe or .dll from scratch inside the .exe

Postby winapicoder » Sat Aug 22, 2009 8:00 am

m trying to make a runtime exe creator (on the fly). i have an .exe that needs to create an another .exe or .dll from scratch, i just want to know what is the best method for this. im thinking of putting .exe or .dll hex codes into my executable in a string , and create binary file from it, but what if i want to patch it on runtime ? the entry points and size will change, everytime i want to create different .exe (say some variables must be different in all exes, like port numbers , program directory etc..) for this i must patch that codes on the fly. Do u guys know any good guide for this ?

Thank You
winapicoder
I Have A Few Questions
 
Posts: 2
Joined: Sat May 02, 2009 11:46 pm

Postby L. Spiro » Sat Aug 22, 2009 8:41 am

You need to create a shell .DLL as a basis.

Create a giant code section in raw ASM. You will need a parser the same as the Auto-Assembler in MHS for this. You will create raw ASM code in exactly the same format with labels etc.

When compiling the code keep track of fix-up offsets. You need these to create a .reloc section in the .DLL.


Compile your code at an assumed address while keeping track of all the fix-up offsets. Set your .DLL’s target address the same as your assumed address (which can be anything) and use your fix-up data to create your .reloc section as per the many documents online that describe the format of this section.


You may optionally create a section for the data in your code, but this is not required if you give your code section full access (by adjusting the flags in the .DLL header, again documented online).


There probably are no guides on how to do all of this.
Instead you must study the PE header and file format and figure out how to make your data fit within the specifications.
The first tool you will need is an Auto-Assembler, which is no simple task.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby winapicoder » Sun Aug 23, 2009 1:42 am

thanx for the reply L.spiro, i'm gonna check pe format on msdn :>
winapicoder
I Have A Few Questions
 
Posts: 2
Joined: Sat May 02, 2009 11:46 pm


Return to Technical Unrelated

Who is online

Users browsing this forum: No registered users and 0 guests

cron