📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Brainstorms - General  >>  creating win32 api == ?

Topic created on: May 4, 2008 05:34 CDT by shakuni .

While researching for a book that I am writing ("Malware : Writing Malicious Code"), I came across this-

"Some malware goes so far as to avoid importing any functions from available
DLLs. Instead, it emulates all of the APIs it needs. This means that you cannot list the
functions, so you cannot easily set breakpoints on them, as all API calls will just be
a part of the malware code.In some cases, malware authors even use this to trap reverse engineers: they
may import functions that are never used (having used the emulated ones instead)."

Now my question is-

How can I write win32 api without using win32 or native api. For example, How can I write code that'll manipulate windows registry without using win32 or native api?


or if you've heard of any virus that emulates API, give me its name. The rest (like, retrieving the API emulating code from the virus) I'll manage.

  Sellmi     May 4, 2008 07:04.53 CDT
A full emulation is not possible, at some point it has to call
a system call, thus you can always bpx the API calls.
The themida protector (http://www.oreans.com), for example, emulates some high-level windows API. You can download the demo.

  nezumi     May 4, 2008 10:16.42 CDT
1) some APIs (GetModuleHandle for example) don't use native APIs at all, so we can rewrite them and there is no way to catch us. break points will be absolute useless (since, there is no access to OS kernel);

2) well-know trick - skip the first five bytes of the API function and pass control to the sixth:
most of APIs begin with one of standard prologs and there is a way to determine which prolog we're dealing with by reading sixth byte and further. knowing the type of prolog, we can emulate skipped machine commands, so break point on the first DWORD of the function will not work;

3) well-know trick - copy the API function to heap or stack:
break point on access will work, but break point on execute - ops (remember, if you copy an API function to the heap/stack you have to check first byte: CCh means software break point and to avoid crash you must to recover the original byte; second: you're supposed to rebuild all external relative references; and the last: don't forget about DEP and executable attribute);

  b0ne     May 5, 2008 12:51.48 CDT
Forgive my bluntness, but for someone writing a book, who is usually a subject matter expert or at least reasonably familiar with a subject, it sounds to me like you have zero experience analyzing malware.

Keeping this point in mind and observing you asking lots of questions about how these techniques work leave me with some concerns about your motivation.  (If you can't read between the lines, you might be asking the openrce community for help in implementing actual malware?)

  shakuni   May 5, 2008 13:58.26 CDT
Don't worry dear, execpt the kind of virus that emulates the api (I doubt wheather such virus exit at all ?) I know almost everything about malware (especially viruses).

Regarding my other posts, I was looking for some simple trick since the software that cleans registry and flags suspicious processes doesn't uses heuristics, sandboxing etc. (I am sure). This is why I asked it here so that people here who probably have much more experience than me can point me in the right direction.
Anyways thank you for your reply.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit