Exetools

Exetools (https://forum.exetools.com/index.php)
-   General Discussion (https://forum.exetools.com/forumdisplay.php?f=2)
-   -   Writing to a running (in-use) executable file (https://forum.exetools.com/showthread.php?t=8472)

omidgl 11-12-2005 12:42

Writing to a running (in-use) executable file
 
There are some methods of writing to an in-use file like ForceDel but they can't write to a running executable file. Maybe some Ring-0 instructions can do this job ?!!!!!!! :confused:

willii 11-12-2005 14:21

Writing to a file running is very danger. When system has lower memory. It may reload code from the file. If you modify the file. It may crash.

omidgl 11-12-2005 15:10

I know my job. Thanx 4 Your Advice.

Cigan 11-12-2005 23:25

Windows XP SP2 don't block execute file. You may delete,write,and execute again him.

omidgl 11-13-2005 03:41

:eek: no this is not true. I'm using SP2.

Sten 11-13-2005 19:39

omidgl, I think it would be too hard to write to the file being executed since the file is exclusively locked by windows for write access - it is nessesary for the memory manager be behave correctly.

There is a tool called Unlocker that can close exclusive file handles (it uses kernel mode driver internally). But Unlocker won't help you in this case - it say's it failed to find exclusive file handles for the process being executed.

The best you can do is to rename the executable (WinNT dosn't prevent this), then copy the file data back to the original file and modify the original file as you need.

heXer 11-13-2005 19:56

How does ollydbg works when copy to executale and overwrite the old exe?

MaRKuS-DJM 11-13-2005 20:09

@heXer
i don't know 100%, but to me it seems olly writes modifications back when closing / restarting the exe.

deroko 11-14-2005 10:55

@heXer:
olly creates backup file at : 44d8f1 and moves specified exe to backup with movefilea which will delete running file and you can write to it's place whatever you want. Old trick I've been using long time ago.

goldenegg 11-14-2005 14:55

Quote:

Originally Posted by heXer
How does ollydbg works when copy to executale and overwrite the old exe?

You can't use od to overwrite an existing running executable file.
od lets you save as a new one.

fly [CUG] 11-14-2005 15:16

@deroko:
You are right.It will create a bak file,the bak file is locked,and the old exe can be write freely by other program.But od itself can modify one time only.
@goldenegg :
I can use od to overwrite the exefile being debugged.

memo-5 11-14-2005 18:00

The finall result and the answer is that it's not possible to overwrite a running exe, dll file because the system use the exe file pages instead of using the system page file.

heXer 11-14-2005 21:29

1 Attachment(s)
My test app:
1. Run the running.exe.
2. Run the unlock_running.exe.
3. Modify running.exe use any editor.
4. Have you write to running.exe success?

Teerayoot 11-15-2005 00:02

@heXer

your attachment .
Threat detected by nod32.

Win32/PSW.Legendmir.SY trojan
but i see any harmfull to my computer :)


Quote:

4. Have you write to running.exe success?
After runn unlock_running.exe
i can write to running.exe.

Git 11-15-2005 00:16

Don't forget cache implications...

Git

Franeppe 11-15-2005 01:25

Quote:

Originally Posted by heXer

4. Have you write to running.exe success?

Yes, i can write to running.exe file.

How did you solve the problem?

heXer 11-15-2005 08:47

@Teerayoot
The nod32 is too foolish.

Sten 11-15-2005 22:42

Quote:

Originally Posted by Franeppe
How did you solve the problem?

He uses:

MoveFileA(<original.exe>, <original.bak>);
CopyFileA(<original.bak>, <original.exe>);
WaitForSingleObject(hProcess, INIFINITE);
DeleteFileA(<original.bak>);

Just as I've proposed above. Nothing extremely interesting. :)

Maximus 11-16-2005 09:02

If you have time to spend and admin rights on the system, you might try to play with "\\.\PhysicalDriveN" access -be careful, anyway.
(CreateFile&DeviceIOControl)

Kerlingen 11-16-2005 17:15

If your file system is NTFS, you could get into very big trouble when accessing the drive on psysical level, since much of NTFS is still undocumented and many structures change with every Windows version (or even service pack).

My idea would be to use WinHex scripting. I don't know if this works, but with the normal WinHex you can hex-edit files directly on disk when browsing psysical or logical disks. So I guess with the WinHex scripting system you could do the same.

Maximus 11-17-2005 00:54

And buggy...
I faced an incredible NTFS bug that blocked, in order:
WinXp, Win2k, WinXp Installer CD, Win2k Installer CD, UBCD winXP(!!).
I installed Linux on an fresh mounted hd -the only way to run sw-, formatted 1st partition to fat, and recovered there.
*deadly* code somewhere...


All times are GMT +8. The time now is 05:55.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX