ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Ū Ū <*> DumpExe API version 2.4 <*> Ū Ū Ū Ū by ÜÄÜ Ü ÜÄÜ ÜÄÜ ÜÄÜ ÜÄÜ Ü ÜÄÜ ÜÄÜ Ū Ū Ū Ū ŪÄÜ ßÄÜ ŪÄ ßÄÜ ßÄÜ Ü Ū Ū Ū Ū Ū Ū Ū Ū Ū Ū Ü Ū Ū Ü Ū Ü Ū Ū Ū Ū Ū Ū Ū Ū ßßß ßßß ßßß ßßß ßßß ßßß ß ßßß ß ß 1997 Ū Ū Ū ŪÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŪ Ū Handle Real name Age Profession E-Mail address Group activity Ū ŪÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŪ Ū Bugsy Benjamin Petersen 24 Programmer _bugsy@usa.net Coder, organizer Ū Ū Hendrix Patrick Enoch 21 Study Math _hendrix@usa.net Coder, unpackers Ū Ū Spawn Michael Skovslund 23 Programmer _spawn@usa.net Coder, gfx Ū Ū Icicle Henrik Eiriksson 24 Study IFA _icicle@usa.net Music, art Ū ŪÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŪ Ū Ū Ū PLEASE CHECK OUT OUR INTERNET HOMEPAGE AT : home.t-online.de/home/enoch Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß INDEX History Introduction Installing DumpExe API Tutorial Adding security API documentation ž History Version Release Note 2.4 First release of the API interface as requested by Dark Stalker. ž Introduction By using DumpExe API you will be able to create your own unpackers. So why would you do that when there are programs like CUP, UNP, TRON, and others ? Lets first assume that Mr. X. has made an exepacker. This exepacker has the ability to pack an exefile (make it smaller). This is good because when you pack a file, it will fill less of your disk. It will also make it secure (at least a bit secure). You cannot modify, let's say, a text string that says who made the program, because the text is unreadable while in its packed form. But only until Mr. Cracker makes an unpacker. Then everyone can unpack the file and change it. So what does Mr. X. do ? He (or she) makes a new packer which detects Mr. Crackers unpacker. Then Mr. Cracker makes a new unpacker...... So what we need here is a unit that isn't an unpacker, but still makes it easy to make one. This is what the DumpExe API is about. It isn't an unpacker, just an interface that makes it easier for you to make custom unpackers. Your job is to load and execute the packed program until the VERY first original (unpacked) instruction of the program. Then call DumpExe API a few times, and do it all over again one more time. What you get from this is two dumps that represent an image of the unpacked exefile. You need two dumps due to the nature of Exefiles, unlike comfiles that only need one dump to rebuild a new com file. The next step in order to create an unpacked exefile is to use the utility MakeExe. MakeExe will then compare the two dumps and add a relocation to a relocation table for every word it finds that doesn't match. At last MakeExe creates a new exefile that centers all informations about the new exefile. You don't need to know how this is done, all you need is to make a 'tracer' that detects when the unpacker is finished unpacking the exefile in memory. ž Introduction To install the DumpExe API, just run DUMPAPI.EXE once. To uninstall it just run DUMPAPI.EXE again. Remember to unsecure the session if you secured it, or DumpExe API will just install itself again (twice). ž Tutorial To make use of the DumpExe API, you could follow this cookbook. 1. Execute DUMPAPI.EXE 2. Check for right DumpExe API version 3. Get DumpExe API address and secure session 4. Load packed exefile 5. Execute packed program until the very first unpacked instruction ^ This is the tough part, all others steps are very easy. :-) 6. Fill registers inside DumpExe API 7. Autodetect size (by Stack or by PSP) 8. Dump memory using DumpExe API (part one) 9. Free packed programs environment 10. Shrink packed programs memory to 4 KB (and save a pointer) 11. Load packed exefile again 12. Execute packed program until the very first unpacked instruction 13. Dump memory using DumpExe API (part two) 14. Free packed programs environment 15. Free packed programs memory 16. Free shrinked programs memory 17. Unsecure DumpExe session 18. Unload DumpExe API 19. Execute MakeExe That's all ;-) It isn't as hard as it might sound. I have put a full featured unpacker, and the source code for it, in this package. Check it out to learn more about using DumpExe API and how it works. Oh, btw, remember to switch current PSP every time you start and stop tracing a file. ž Adding security I have added a little security into the DumpExe API. When you call 'Get DumpExe API address and secure DumpExe session', DumpExe API uninstalls ALL hooked interrupt vectors. Please see the example below on how to use the 'Get DumpExe API address and secure DumpExe session' : ;------------------------------------------------------------------------------ Proc Doit mov ah, 00h int 0fbh cmp bx, 0240h jne ErrorInVersion mov ah, 01h ; Get API address and secure DumpExe session int 0fbh mov word ptr APISeg, es mov word ptr APIOfs, di ... mov ah, xxh call APIAddress ... mov ah, 02h ; Unsecure DumpExe session call APIAddress ErrorInVersion: ret EndP Doit ;------------------------------------------------------------------------------ Proc APIAddress pushf ; Emulate an interrupt call db 9ah ; call far xxxx:xxxx opcode APIOfs: dw 0 APISeg: dw 0 ret EndP APIAddress ;------------------------------------------------------------------------------ Just remember to call the 'Unsecure DumpExe API session' before you exit your unpacker or you won't be able to uninstall the API. ž API documentation To call the DumpExe API you need to issue an INT 0FBh. Remember to fill registers, as shown below, before calling INT 0FBh. Functions are demined by register AH, and subfunction by AL. ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Get DumpExe API version Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 00h Ū Ū Ū Ū Output : bh = major version Ū Ū bl = minor version Ū Ū Ū Ū Comment : Use this function to demind the DumpExe API version (0240h) Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Get DumpExe API Address and secure session Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 01h Ū Ū Ū Ū Output : es = segment of DumpExe API address Ū Ū di = offset of DumpExe API address Ū Ū Ū Ū Comment : To make DumpExe API a bit more secure, please call this function.Ū Ū Ū Ū .----------------------------------------------------------------. Ū Ū | PLEASE PUSH FLAGS BEFORE CALLING THE DumpExe API ADDRESS AFTER | Ū Ū | THIS INTERRUPT CALL, SINCE YOU ARE USING THE INTERRUPT HANDLER.| Ū Ū `----------------------------------------------------------------' Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Unsecure DumpExe API session Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 02h Ū Ū Ū Ū Output : None Ū Ū Ū Ū Comment : Remember to CALL this function, before you exits your unpacker. Ū Ū (Only if you are using the DumpExe API security) Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Fill DumpExe API registers Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 03h Ū Ū al = Dump number (1 = first dump, 2 = second dump) Ū Ū ds:si -> DumpExeRegStructure Struc Ū Ū _cs dw ? Ū Ū _ip dw ? Ū Ū _ss dw ? Ū Ū _sp dw ? Ū Ū _psp dw ? Ū Ū DumpExeRegStructure EndS Ū Ū Ū Ū Output : None Ū Ū Ū Ū Comment : When you have executed the packed program, until the very first Ū Ū original instruction, please call this function with the proper Ū Ū register values, found at that moment. PSP is an alias for ES Ū Ū ^^^^ Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Autodetect dump size Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 04h Ū Ū bl = Detection type. (1 = by PSP, 2 = by stack) Ū Ū Ū Ū Output : al = nonzero if error Ū Ū Ū Ū Comment : This function will autodetect the size for BOTH dumps. The most Ū Ū common metode is by stack, since it usually gives smaller dumps. Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Set dump size Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 05h Ū Ū bx = Size in paragraphs (Round up : Size in bytes divided by 16) Ū Ū Ū Ū Output : None Ū Ū Ū Ū Comment : If the autodetect function failes on both types, you can use Ū Ū this function to set a size of your own choice. Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Dump exe-code Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 06h Ū Ū al = Dump number (1 = first dump, 2 = second dump) Ū Ū Ū Ū Output : al = nonzero if error Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ū Snapshot memory Ū ŪÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜŪ Ū Input : ah = 07h Ū Ū Ū Ū Output : al = nonzero if error Ū Ū Ū Ū Comment : Take a snapshot of the first megabyte of memory and dump it into Ū Ū a file called SNAPSHOT.MEM. You can use this function to view if Ū Ū your unpacker/generic tracer works, and for a lot of other stuff.Ū Ū Ū ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß That's it folks, that wasn't so bad after all wasn't it ? [BUGSY/OBSESSiON]