Investigate OneNote file - reuteras/dfirws GitHub Wiki

Included tools (not a complete list).

Example

The file is available on Malware Bazaar.

First lets unpack the file.

Unpack file

We can use Yara, file-magic.py, file.exe and trid.exe to check the file.

Check file with Yara, file-magic.py, file and Trid

The tools onenote.py and pyonenote.exe are two tools that can be used to extract files from OneNote documents.

Extract files from OneNote with onenote.py or pyonenote.exe

Output from pyonenote.exe.

Output from pyonenote.exe

Look at file_1.bat (named by pyonenote.exe) in Notepad++. Remove the first line.

Image of file_1.bat

Cut line 61 and save it for later.

Show line 61 File with line 61 Line 61 removed

The last lines of the files looks like this.

Last lines of the file

Change the last line of the file to:

Changed the last lines of the files

Save the file and run it. WARNING This is malware and it can infect your computer!

Copy the command part of the output.

Output

The command in Notepad++. Only two lines when pasted.

Command in Notepad++

Change ";" to "\n".

Change ";" to "\n"

The PowerShell script is now a bit easier to read. Almost the same code, use the second half.

The PowerShell script

We can see that the code gets line 61 from the first bat file.

PowerShell code to read line 61 from the bat file

Modified script with line 61 inserted and a added Write-Host statement and the last lines commented out.

Modified script

Run the command.

Output from the command when executed

Copy and paste the output from the command to CyberChef and use its magic functions.

Output added to Cyberchef

Press the disc icon to save the output to file (a MZ-file).

Save the file

You have to press keep to save the file.

Press keep to save the file

The file is now under ~/Downloads.

The file is in the Downloads directory

We can check the file with capa.exe.

Output from capa.exe

Look at available tools matching PE.

PE tools

Open in pestudio. We can see that it is a 32-bit .Net binary

File opened in pestudio

We can use dnSpy32 to look at it. Let's search for the program.

dnSpy32 and dnSpy64 are available in the sandbox

The file opened at the main function in dnSpy32.

dnspy32 opened the file