Malicious file analysis - Example 01

Malicious file analysis - Example 01

My objective with this series of articles is to show an analysis of examples of malicious files that I presented during my lecture on BSides-Vitória 2022. For this first one, I'll briefly introduce some crucial topics to ease the understanding of the analysis process.

What're malicious files?

  • Files that contains in their internal structure malicious actions that could compromise an environment, account, workstation, server, or user will receive the file.

Some files are more used in attacks

Compressed files

  • ZIP, RAR e 7z

Microsoft Office Documents

  • DOC, DOCX, XLS, XLSX, XLSM

PDF files

Microsoft Office Documents

  • From a security point of view files of the types DOC, DOCX, XLS, XLSX, and XLSM, have a common issue, they can contain macros which are embedded scripts that are executed inside the file.

PDF Files

  • PDF files can be used to execute JavaScript, download files, access URLs, and execute commands.
  • Often instead of very malicious links, and induce the user to click on something.

Static Analysis x Dynamic Analysis

  • Static analysis is done without the execution or opening the file/code.
  • Dynamic analysis is done during the execution or opening the file/code.

Tools

Peframe

  • PEframe is an open source tool to perform static analysis of malware executables and malicious MS Office documents.?
  • Example: peframe file_name

Pdf-parser

  • PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.
  • Example: python2.7 pdf-parser.py file_name

Peepdf

  • peepdf is a Python tool to explore PDF files to find out if the file can be harmful or not.
  • Example: python2.7 peepdf.py file_name

Oletools

  • oletools - python tools to analyze MS OLE2 files (Structured Storage, Compound File Binary Format) and MS Office documents, for malware analysis, forensics, and debugging.
  • olevba?is a script to parse OLE and OpenXML files such as MS Office documents (e.g. Word, Excel), to detect VBA Macros, extract their source code in clear text, and detect security-related patterns such as auto-executable macros, suspicious VBA keywords used by malware, anti-sandboxing, and anti-virtualization techniques, and potential IOCs (IP addresses, URLs, executable filenames, etc).
  • Example: olevba file_name
  • oleobj?is a Python script and module to parse OLE objects and files stored into various MS Office file formats (doc, xls, ppt, docx, xlsx, pptx, etc)
  • Example: oleobj file_name

ExifTool

  • ExifTool is a platform-independent Perl library plus a command-line application for reading, writing, and editing meta information in a wide variety of files.

Wireshark

  • Wireshark is the world’s foremost and widely-used network protocol analyzer. It lets you see what’s happening on your network at a microscopic level and is the de facto (and often de jure) standard across many commercial and non-profit enterprises, government agencies, and educational institutions.

URLscan

urlscan.io - Website scanner for suspicious and malicious URLs.

MXtoolBox

MxToolbox supports global Internet operations by providing free, fast, and accurate network diagnostic and lookup tools. Millions of technology professionals use our tools to help diagnose and resolve a wide range of infrastructure issues.

Example 01 - Static Analysis

Note: All tests were executed in a virtual machine with Linux operating system.

Here I'm going to show in practice how we can use some of the tools above to analyze a malicious file.

We start with ExifTool to try to gather information through metadata.

No alt text provided for this image

Attention points:

  • In the figure above we can identify the name of who made the last modification of the file. (possible attacker name).
  • An alleged creator name (username used to create the file).
  • In the title, it is possible to identify something as if it were the execution of a file or command, but written in reverse.

When I use the rev command to reverse the output of the ExifTool command it is possible to better understand the line, as shown below.

No alt text provided for this image

Using the olevba it's possible to identify malicious macros and their possible actions.

No alt text provided for this image

Attention point:

  • May open a file
  • May write to a file (if combined with Open)
  • May run an executable file or a system command
  • May call a DLL using Excel 4 Macros (XLM/XLF)
  • May create an OLE object
  • May attempt to obfuscate specific strings
  • May run an executable file or a system command using Excel 4 Macros (XLM/XLF)
  • Base64-encoded strings were detected, which may be to obfuscate strings

Using the PEframe it's possible to get a similar result but without the suspicious points shown by olevba.

No alt text provided for this image

Now performing dynamic analysis, I opened the file using the LibreOffice package, and the same generated an alert that the macros can contain viruses.

No alt text provided for this image

The content of the file induces the user to enable the "enable edition" option.

No alt text provided for this image

To according shown above, with some small steps was possible to perform an analysis and have a conclusion that the file is malicious.

See you in the next analysis :)

Abu Baker Gondal

Chief Technologist @ YOTTABYTE | vCISO | Compliance Management

2 年

Good work Zozi :) This is awesome. Hands-on and to the point.

Anderson Gomes

Technical Account Manager at Fortinet

2 年

Great work my friend.

Antonio Rolim

Cyber Security Manager | BlueTeam | ITIL | CHFI

2 年

Muito Bom Brother!! Vlw e parabens.

要查看或添加评论,请登录

Zoziel P.的更多文章

  • From the Zero to Malware Discovery

    From the Zero to Malware Discovery

    Hello people, I was with some time, and I decided to made an analysis using some tools that I commented last post…

    29 条评论
  • Windows Analysis Tips and Tools

    Windows Analysis Tips and Tools

    Hi people, I found some old notes, but useful that I use during an incident, and I decided to share these tools and…

    14 条评论
  • Ransomware is not just a threat, it's a crisis waiting to happen...

    Ransomware is not just a threat, it's a crisis waiting to happen...

    Although I haven't posted anything here, I wanted to share my thoughts on my favorite wicked malware: ransomware. To…

    21 条评论
  • Analyzing Steal Bank Account with Malicious PDF

    Analyzing Steal Bank Account with Malicious PDF

    Hi everyone, as have time I don't post anything, I decided to write one more analysis about stolen bank accounts and…

    11 条评论
  • Analise de arquivos maliciosos - Exemplo 01

    Analise de arquivos maliciosos - Exemplo 01

    English Version O intuito dessa série de artigos é exibir analises de exemplos de arquivos maliciosos que apresentei…

    13 条评论
  • Analisando ataques de phishing que usam PDFs maliciosos

    Analisando ataques de phishing que usam PDFs maliciosos

    Todos os dias nós recebemos muitos ataques de phishing com documentos(Word, Excel) ou PDFs maliciosos. Resolvi dar uma…

    11 条评论
  • Analyzing Phishing attacks that use malicious PDFs

    Analyzing Phishing attacks that use malicious PDFs

    Portuguese version Every day everybody receives many phishing attacks with malicious docs or PDFs. I decided to take a…

    8 条评论
  • PowerShell Introduction

    PowerShell Introduction

    I wrote this article to show a brief introduction about how to use PowerShell daily. Many professionals work…

    9 条评论
  • Carreira em Cybersecurity

    Carreira em Cybersecurity

    English Version Fala galera sempre escrevo artigos, compartilho posts de alguns sites que acompanho e acho relevante…

    10 条评论
  • Cybersecurity career

    Cybersecurity career

    Hey guys, I always write articles, share posts from some sites that I follow and find relevant. Among these various…

    4 条评论

社区洞察

其他会员也浏览了