Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2005, 14:49
Warren
 
Posts: n/a
EXE files and apis

I want to insert some code at the beginning of a code segment of a .exe file so the application will close when this code will execute.I could write a illegal operation like 00 00 00 and the application will close becouse it tried to execute an illegal instruction.But i want to use windows API's to close the application.I want to use Exitproces API function but i don't know how to call it.
Can i find out the address of ExitProces function by looking in the PE header or how ?
Reply With Quote
  #2  
Old 08-28-2005, 15:26
Hero Hero is offline
VIP
 
Join Date: Jan 2005
Posts: 224
Rept. Given: 2
Rept. Rcvd 1 Time in 1 Post
Thanks Given: 4
Thanks Rcvd at 2 Times in 2 Posts
Hero Reputation: 1
Hi
ExitProcess is a function that normally available in any file.
But I suggest that you make your own IT for this function too.
The best way is adding an small section,making an small IT,that contains ExitProcess
for you.Than in your program directly call The address that located in FirstThunk .
With this way,you can add any function and code to your addlication without any
problem and run it(that include API functions too).

sincerely yours
__________________
I should look out my posts,or JMI gets mad on me!
Reply With Quote
  #3  
Old 09-01-2005, 00:17
polygon_seven
 
Posts: n/a
If you poped all your stuff from stack, and before your code nothing was pushed, then you could use "ret" instruction to return to Windows, but this may not work in all cases.
Reply With Quote
  #4  
Old 09-01-2005, 02:58
XWING
 
Posts: n/a
I didnt understand what you want to do exactly Warren, you want your code to execute before the original application code? If yes, you can just add your assembly code to end of pe and do a jump to and back. Also i didnt understand what you mean by illegal operation, if you are just trying to intercept erros in a debug application then you could just use dbghelp to dump stack details and save a crash dump report to later analyses and replication of the process. Please explain and i will give you more details.

Cya
Reply With Quote
  #5  
Old 09-01-2005, 10:39
FoOLFoXs
 
Posts: n/a
find out the exitprocess's RVA in FirstThunk ,and call it in your code.
Reply With Quote
  #6  
Old 09-01-2005, 12:35
nskSem
 
Posts: n/a
If your application has one thread and it's stack is right (num push = num pop), you can try write "ret". Is't so because after thread proc follow an "ExitThread" call.
Reply With Quote
  #7  
Old 09-01-2005, 16:17
Nacho_dj's Avatar
Nacho_dj Nacho_dj is offline
Lo*eXeTools*rd
 
Join Date: Mar 2005
Posts: 207
Rept. Given: 14
Rept. Rcvd 179 Times in 34 Posts
Thanks Given: 44
Thanks Rcvd at 135 Times in 40 Posts
Nacho_dj Reputation: 100-199 Nacho_dj Reputation: 100-199
Hello:

If you disassemble the code of your a.exe, you could see imports (with wdasm32, for instance) and there all the apis used by the application. Then, select in the import window "ExitProcess" and display it, then you are getting a "call [<address of ExitProcess>]".

You could write down in your new code a call like that you have got, or a jmp to the RVA of that call.

Cheers

Nacho_dj
Reply With Quote
  #8  
Old 09-01-2005, 20:26
MaRKuS-DJM's Avatar
MaRKuS-DJM MaRKuS-DJM is offline
Cracker + Unpacker
 
Join Date: Aug 2003
Location: Virtual World / Network
Posts: 553
Rept. Given: 7
Rept. Rcvd 6 Times in 4 Posts
Thanks Given: 3
Thanks Rcvd at 16 Times in 10 Posts
MaRKuS-DJM Reputation: 6
you don't need an API.
MOV EAX,101
PUSH 0 (exit code)
PUSH -1
MOV EDX,ESP
INT 2E

code directly converted in short form from Debug Me 0.2 / Teerayoot
Reply With Quote
  #9  
Old 09-02-2005, 16:53
SnipER.UA
 
Posts: n/a
Quote:
Originally Posted by MaRKuS-DJM
you don't need an API.
MOV EAX,101
PUSH 0 (exit code)
PUSH -1
MOV EDX,ESP
INT 2E
Very interesting, but does this code work on Windows 9x? I think no. Maybe INT 20 (VxDCall) is usable for this...
Interrupts are platform dependent and using call to ExitProcess is much more versatelite. Interrupts are good to avoiding fast detection 'cause I look first for some API call or SEH usage but not for INT's.
Reply With Quote
  #10  
Old 09-02-2005, 16:59
MaRKuS-DJM's Avatar
MaRKuS-DJM MaRKuS-DJM is offline
Cracker + Unpacker
 
Join Date: Aug 2003
Location: Virtual World / Network
Posts: 553
Rept. Given: 7
Rept. Rcvd 6 Times in 4 Posts
Thanks Given: 3
Thanks Rcvd at 16 Times in 10 Posts
MaRKuS-DJM Reputation: 6
yeah, i forgot to mention this only works on NT-based systems. Windows ME for example will show you the blue screen of death also a way to get the application to shutdown, but not very nice
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
APIs in Olly jump General Discussion 3 09-25-2013 19:03
help patching apis Shub-Nigurrath General Discussion 7 01-26-2006 17:16
How to get files from .flp Maxwish General Discussion 0 12-20-2002 16:04


All times are GMT +8. The time now is 23:03.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )