2

It looks like all EXE files begin with MZ when they are opened in ASCII mode, is there an ASCII identified for vbs, com and bat files as well? i can't seem to find a pattern...

Or maybe there's another way to identify them? aside from just the extension...

tshepang
  • 12,111
  • 21
  • 91
  • 136
Madam Zu Zu
  • 6,437
  • 19
  • 83
  • 129

3 Answers3

0

TrID seems to have a "standalone" application you could probably use and pass the file in and read the contents out and see what file it is. It prides itself on the ability to pass it a generic file (extension or without) and it uses the headers of the file to discover what file type it actually is.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
0

See if this tutorial is helpful (How to detect the types of executable files 3 part series). He has even presented a step by step algorithm on how to do this.

Also see this post: How to determine if a file is executable?

Community
  • 1
  • 1
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
0

No, not really (Windows executables can have PE or PK at the beginning instead of MZ - see this for other possible formats).

For other types of files, there are certain heuristics you can use (e.g. GIF files start with "GIF89", Bash shell scripts usually start with #!/bin/bash, BAT files often execute @echo off at the beginning, VBS scripts use apostrophe at the start of line as a comment marker), but they aren't always 100% reliable (a file can be both a BAT script and a Bash shell script; or a file that's both a valid ZIP archive and a valid GIF image (like that stegosaurus image), for example).

See e.g. this article for further reading.

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222