首页 > 系统相关 >进程注入如何通过调用栈,使用ML分类来检测——非常值得借鉴,待实践

进程注入如何通过调用栈,使用ML分类来检测——非常值得借鉴,待实践

时间:2023-08-02 19:34:42浏览次数:38  
标签:调用 ML 借鉴 dll exe clean injection data

4、Machine Learning to Ultimately Defeat Advanced Ransomware Threats

RSA 2022的这个分享主题核心讲解了进程注入如何通过调用栈,使用ML分类来检测。当然,勒索的其他本质特征例如文件加密等没有提到。但是其进程注入的检测值得重点关注。

Ryukas the most advanced form of ransomware payloads (1)

    The initial stages:Planting several executables in the system, for example using the Zloaderbotnet.

    Stopping services, deleting VSS copies, etc.

     

    The advanced stages:Injecting multiple system and trusted processes.

    But keeping the system operational: lsass.exe, csrss.exe and explorer.exe are not changed.

    Detaching the encrypting part from Ryukprocesses.

 

 

 

Challenge: abnormal injection detection.

Important: there are legitimate injection techniques.

   The ML-based solution:Snapshotting of data changes for the thread.

   Detecting stack anomalies with ML models.

   Recovering changed data if ransomware is detected.

   Otherwise discarding the snapshots of data changes.

    

 

Ransomware Shell code injection with CreateRemoteThread

The dropper delivers the payload

   The payload injects itself into legitimateprocesses with OpenProcess

   VirtualAllocEx

   WriteProcessMemorywrites bufferWithTheEncryptor

   CreateRemoteThreadlaunches bufferWithTheEncryptor

   CloseHandle

    

Ransomware shell code injection with APC

The dropper delivers the payload

   The payload injects itself into legitimateprocesses with OpenProcess

   VirtualAllocEx

   WriteProcessMemorywrites bufferWithTheEncryptor

   apcRoutine= bufferWithTheEncryptor

   OpenThread

   QueueUserApc

    

 

Ransomware DLL injection with SetWindowsHookEx

The dropper delivers the payload

   The payload injects itself into legitimateprocesses withLoadLibrary(“hook.dll”)

   Hooker=GetProcAddress(..);

   SetWindowsHookEx

    

              Architecture of the Anti-Ransomware Solution

              Windows File system filter driver, advanced call stack analyzer, Machine Learning system

 

Fighting Advanced Ransomware: Main Steps

Monitor injections using RtlCaptureStackBackTrace.

Analyze injections with Machine Learning Model.

Start data protection per the injection affected process.

Analyze process behavior.

When the detection decision is made, recover the encrypted files and terminate hostile injected objects.

 

 


System service orthe well-known legitimate application,

the Victim

Malicious thread, injected by Ransomware


detection heuristics. Data remediation controls.

Filter Driver

Driver sends call stacks to ML, the verdict is received to mark the thread as suspicious. Full set of heuristics is turned ON if stack anomaly is identified

 

举例:

 

Analysis of injectionsduringexecution

MalwareInject Detection ByAPI Call Sequence

ntdll.dllkernel32.dlln/akernel32.dllntdll.dllwow64.dllwow64cpu.dllwow64.dllntdll.dll ==》ML的输入就这个调用栈

SuspiciousExample:Create Thread operationModulestowhich return addresses on stackbelong

Returnedaddressin theallocated memorydoesn’t belong toany processes

ntdll.dllkernel32.dllTeamViewer.exen/aTeamViewer.exesetupapi.dllntdll.dllwow64.dllwow64cpu.dllwow64.dllntdll.dll  ==>ML的输入就这个

Clean Example: Create Section operation

Just-in-time codecompilation:whitelisted

 

 训练数据集示例:

ntkrnlpa.exe,ntdll.dll,KernelBase.dll, …, clean
KernelBase.dll,kernel32.dll,kernel32.dll, …, clean
NetSetupSvc.dll,ELSCore.dll,ELSCore.dll, …,clean
com.docker.9pdb.exe, n/a,cryptsp.dll, …, infected
ntkrnlpa.exe,ntdll.dll,KernelBase.dll, clean
…
…
…
ntkrnlpa.exe,ntdll.dll,KernelBase.dll, clean
n/a,clr.dll,clr.dll,clr.dll, combase.dll, …, clean

  

 

就是获取了一堆的调用关系链,然后作为ML分类输入检测:

 

==》不过从他给的这个数据,看不出调用关系。

 

Analysis of injections: Models comparison

Samples database:850Mrecords,23Mis unique

New samples:1-2Mper dayStacktrace Analyzer 1.0:

Model: Random Forest

Model details:

Input –fixed number of frames

Output –clean/suspicious

Size –8M

Test results:

Accuracy –0.96

Execution Time: 10-20 ms

Stacktrace Analyzer 2.0:

Model: Gradient Boosting Tree

Model details:

Input –deduplicated frames

Output –clean/suspicious

Size –900K

Test results:

Accuracy –0.98

Execution Time: 1-5 ms

 

DEMO

    We launch the Real-world ransomware and demonstrate how the injection is detected and malicious file data modifications are rolled back:The video that demonstrates how the injected stacks are detected https://drive.google.com/file/d/1KKptRRvGEy0ri-2DsdV8U1N203Qh9Eg5/view?usp=sharing  

    The video that shows the post-mortem analysis of files encryption and recovery https://drive.google.com/file/d/1o68zFgRioNEgteaMhhgMXKbEq4pWA3Ti/view?usp=sharing

     

              Dealing with false positives of the call stack anomaly detection

              Find methods to reduce false positives, connect with other methodologies and detections

              How to Reduce False Positives

      The knowledge of injection source helps to reduce false positives.

      Sensors: file system mini-filter callbacks, user mode or hypervisor assisted hooking.

      Validation: whitelisted services or behavior models.

 

Enhance anti-ransomware defense with ML

Gather all types of injections routinely.

Develop the model training infrastructure.

Start with simple models like Random Forest.

Update your model regularly.

Automate the data annotation process.

Apply ML to behavior analysis.

标签:调用,ML,借鉴,dll,exe,clean,injection,data
From: https://blog.51cto.com/u_11908275/6941859

相关文章

  • 进程注入检测 —— RtlCaptureStackBackTrace 获取当前函数的调用栈函数
    https://stackoverflow.com/questions/590160/how-to-log-stack-frames-with-windows-x64 https://cpp.hotexamples.com/examples/-/-/RtlCaptureStackBackTrace/cpp-rtlcapturestackbacktrace-function-examples.html  例子参考  平日里用VS开发工具在调时在Debug下有一个选......
  • 【逆向】x64程序逆向基础——调用约定和栈使用
    【逆向】x64程序逆向基础 主要区别1.所有地址指针都是64位。2.增加和扩展新的寄存器,并兼容原32位版本的通用寄存器。3.原指令指针寄存器EIP扩展为RIP。寄存器1.64位寄存器兼容原32位寄存器。2.新增加8个XMM寄存器(XMM8-XMM15)。3.扩展原32位寄存器的64位版本,并增加8个......
  • UML建模之状态图(Statechart Diagram)
     状态图目录:一、状态图简介(Briefintroduction)二、状态图元素(StateDiagramElements)1、状态(States)2、转移(Transitions)3、动作(StateActions)4、自身转移(Self-Transitions)5、组合状态(CompoundStates)6、进入节点(EntryPoint)7、退出节点(ExitPoint)8、历史状态(HistoryStates)9、并发......
  • mule9.0 springappcation.xml
    <?xmlversion="1.0"encoding="UTF-8"?><mulexmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"xmlns:vm="http://www.mulesoft.org/schema/mule/vm"xmlns:db="http://www.mulesoft......
  • HTML | HTML设置语言
    主要作用:让浏览器显示对应的翻译提示。有利于搜索引擎优化。具体写法:<htmllang="zh-CN">扩展知识:lang属性的编写规则(作为一个课外扩展知识,了解即可)。第一种写法(语言-国家/地区),例如:zh-CN:中文-中国大陆(简体中文)zh-TW:中文-中国台湾(繁体中文)zh:中文en......
  • HTML
    HTML1.块级标签标题:<h1>一级标题</h1>div:<div>这是一个div标签</div>p:<p>这是一个p标签,段落标签</p><!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>HTML块级标签</t......
  • HTML | HTML全局属性
    全局属性是所有HTML元素共有的属性;它们可以用于所有元素,即使属性可能对某些元素不起作用。我们可以在所有的HTML元素,甚至是在标准里没有指定的元素上指定全局属性。这意味着任何非标准元素仍必须能够允许应用这些属性,即使使用这些元素意味着文档不再是HTML5兼容的。例如,虽......
  • Winform两个项目间的调用
    Winform1:staticclassProgram   {       ///<summary>       ///应用程序的主入口点。       ///</summary>       [STAThread]       staticvoidMain(string[]args)       {           Application.Ena......
  • WebApi接口的调用和传参
    publicCommon.mdlResultModel<mdlGetHistoryData>GetHistoryDataByCondition(intpDeviceId,intpPageIndex,intpPageSize,stringpStartTime,stringpEndTime)       {           Common.mdlResultModel<mdlGetHistoryData>objResult=newCommon.m......
  • HTML | meta元信息
    HTML<meta>元素表示那些不能由其他HTML元相关(meta-related)元素表示的元数据信息。如:<base>、<link>、<script>、<style>或<title>。配置字符编码<metacharset="utf-8">针对IE浏览器的兼容性配置。<metahttp-equiv="X-UA-Compatible"con......