Sunday 5 December 2010

Type scanning

Files are usually identifiable by their extension. Whilst we'd expect .jpg to be a JPEG image file, it might actually contain text or executable data. This is a problem in malware scanning because it's trivial to modify the registry to make any file extension to be treated as an executable.

HKEY_CLASSES_ROOT\.abc
    (Default) = "exefile"
    Content Type = "application/x-msdownload"
HKEY_CLASSES_ROOT\.abc\PersistentHandler
    (Default) = "{098f2470-bae0-11cd-b579-08002b30bfeb}" 

I could then rename file.exe to file.abc and run it, and it'd run like a normal program. In the context of anti-malware software, we have to scan every file's data to check that files are in fact what they say they are. To shorten this process, we can use file type signatures. For example, an extremely simple signature for Win32 executable files might be that the file starts with the ASCII characters 'MZ' and also contains the ASCII string 'This program cannot be run in DOS mode'.

There is a project called TrID that aims to do exactly this. It comes with a large list of file type definitions that were generated by comparing hundreds of samples of the same file type. This data can be easily re-generated and compiled into a single database file.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.