Practical Malware Analysis - Pdfs.semanticscholar

Transcription

Practical MalwareAnalysisCh 2: Malware Analysis in VirtualMachinesUpdated 1-16-17

Dynamic Analysis Running malware deliberately, whilemonitoring the results Requires a safe environment Must prevent malware from spreading toproduction machines Real machines can be airgapped –nonetwork connection to the Internet or toother machines

Real Machines Disadvantages– No Internet connection, so parts of themalware may not work– Can be difficult to remove malware, so reimaging the machine will be necessary Advantage– Some malware detects virtual machines andwon't run properly in one

Virtual Machines The most common method We'll do it that way This protects the host machine from themalware– Except for a few very rare cases of malwarethat escape the virtual machine and infectthe host

VMware Player Free but limited Cannot take snapshots VMware Workstation or Fusion is a betterchoice, but they cost money You could also use VirtualBox, Hyper-V,Parallels, or Xen.

Windows XP The malware we are analyzing targetsWindows XP, as most malware does Win XP has passed its end-of-life, so we'lluse Windows Server 2008

Configuring VMware You can disable networking bydisconnecting the virtual network adapter Host-only networking allows networktraffic to the host but not the Internet

Connecting Malware to the Internet NAT mode lets VMs see each other and theInternet, but puts a virtual routerbetween the VM and the LAN Bridged networking connects the VMdirectly to the LAN Can allow malware to do some harm orspread – controversial You could send spam or participate in aDDoS attack

Snapshots

Risks of Using VMware for MalwareAnalysis Malware may detect that it is in a VM andrun differently VMware has bugs: malware may crash orexploit it Malware may spread or affect the host –don't use a sensitive host machine All the textbook samples are harmless

Practical Malware AnalysisCh 3: Basic Dynamic Analysis

Why Perform Dynamic Analysis? Static analysis can reach a dead-end, dueto– Obfuscation– Packing– Examiner has exhausted the available staticanalysis techniques Dynamic analysis is efficient and will showyou exactly what the malware does

Sandboxes: The Quick-andDirty Approach

Sandbox All-in-one software for basic dynamicanalysis Virtualized environment that simulatesnetwork services Examples: Norman Sandbox, GFI Sandbox,Anubis, Joe Sandbox, ThreatExpert,BitBlaze, Comodo Instant Malware Analysis They are expensive but easy to use They produce a nice PDF report of results

Running Malware

Launching DLLs EXE files can be run directly, but DLLscan't Use Rundll32.exe (included in Windows)rundll32.exe DLLname, Export arguments The Export value is one of the exportedfunctions you found in DependencyWalker, PEview, or PE Explorer.

Launching DLLs Example– rip.dll has these exports: Install and Uninstallrundll32.exe rip.dll, Install Some functions use ordinal values insteadof names, likerundll32.exe xyzzy.dll, #5 It's also possible to modify the PE headerand convert a DLL into an EXE

Monitoring with ProcessMonitor

Process Monitor Monitors registry, file system, network,process, and thread activity All recorded events are kept, but you canfilter the display to make it easier to finditems of interest Don't run it too long or it will fill up allRAM and crash the machine

Launching Calc.exe Many, many events recorded

Process Monitor ToolbarStart/StopCaptureEraseFilterDefault FiltersRegistry, File system, Network,Processes

Filtering with Exclude One technique: hide normal activitybefore launching malware Right-click each Process Name and clickExclude Doesn't seem to work well with thesesamples

Filtering with Include Most useful filters: Process Name,Operation, and Detail

Viewing Processes withProcess Explorer

Coloring Services are pinkProcesses are blueNew processes are green brieflyTerminated processes are red

DLL Mode

Properties Shows DEP (DataExecution Prevention)and ASLR (AddressSpace LayoutRandomization) status Verify button checksthe disk file'sWindows signature– But not the RAMimage, so it won'tdetect processreplacement

Strings Compare Image toMemory strings, ifthey are verydifferent, it canindicate processreplacement

Detecting Malicious Documents Open the document (e.g. PDF) on asystem with a vulnerable application Watch Process Explorer to see if itlaunches a process The Image tab of that process's Propertiessheet will show where the malware is

Comparing Registry Snapshotswith Regshot

Regshot Take 1st shotRun malwareTake 2nd shotCompare them tosee what registrykeys were changed

Faking a Network

Using ApateDNS to Redirect DNSResolutions

ApateDNS Does Not Work I couldn't get it to redirect any traffic inWin XP or 7 nslookup works, but you don't seeanything in a browser or with ping I decided to ignore it and use INetSiminstead

Ncat Listener Using Ncat.exe, you can listen on a singleTCP port in Windows In Linux, use nc (netcat) This will allow malware to complete a TCPhandshake, so you get some rudimentaryinformation about its requests But it's not a real server, so it won't replyto requests after the handshake

Monitoring with Ncat(included with Nmap)

Packet Sniffing with Wireshark

Follow TCP Stream Can savefilesfromstreamshere too

Using INetSim

inetsim

INetSim Fools a Browser

INetSimFoolsNmap

Basic Dynamic Tools inPractice

Using the Tools Procmon– Filter on the malware executable name andclear all events just before running it Process ExplorerRegshotVirtual Network with INetSimWireshark

monitoring the results Requires a safe environment Must prevent malware from spreading to . Examples: Norman Sandbox, GFI Sandbox, Anubis, Joe Sandbox, ThreatExpert, BitBlaze, Comodo Instant Malware Analysis . Monitors registry, file system, network, process, and thread activity All recorded events are kept, but you can