Skip to Content
Learning Malware Analysis
book

Learning Malware Analysis

by Monnappa K A
June 2018
Beginner
510 pages
13h 7m
English
Packt Publishing
Content preview from Learning Malware Analysis

1.3 Determining File Type Using Python

In Python, the python-magic module can be used to determine the file type. The installation of this module on Ubuntu Linux VM was covered in Chapter 1Introduction to Malware Analysis. On Windows, to install the python-magic module, you can follow the procedure mentioned at https://github.com/ahupp/python-magic.

Once the python-magic is installed, the following commands can be used in the script to determine the file type:

$ pythonPython 2.7.12 (default, Nov 19 2016, 06:48:10)>>> import magic>>> m = magic.open(magic.MAGIC_NONE)>>> m.load()>>> ftype = m.file(r'log.exe')>>> print ftypePE32 executable (GUI) Intel 80386, for MS Windows

To demonstrate the use of detecting file type, let's take an example ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Malware Analysis

Practical Malware Analysis

Michael Sikorski, Andrew Honig
Mastering Malware Analysis

Mastering Malware Analysis

Alexey Kleymenov, Amr Thabet
Evasive Malware

Evasive Malware

Kyle Cucci

Publisher Resources

ISBN: 9781788392501Other