Exp4:恶意代码分析

使用schtasks指令监控系统运行

  • 在对应文件夹创建netstatlog.txt用于记录,创建netstatlog.bat监控系统运行。netstatlog.bat命令如下:
date /t >> c:
etstatlog.txt
time /t >> c:
etstatlog.txt
netstat -bn >> c:
etstatlog.txt
  • 创建任务计划
    利用命令 schtasks /create /TN netstat /sc MINUTE /MO 2 /TR "c:xxx etstatlog.bat"指令创建一个每隔两分钟记录计算机联网情况的任务。如果出现
请求的操作需要提升。   

是由于编写的.bat文件运行没有管理员权限,可以写一个批处理文件获得管理员权限或者利用管理工具中的任务计划程序创建任务计划,并勾选使用最高权限运行选项。

用excel可以做一个统计,如下图所示。

使用sysmon工具监控系统运行

sysmon是微软Sysinternals套件中的一个工具,在官网可以下载。软件需要利用命令 Sysmon.exe -i安装,Sysmon.exe -c filenameXXX.xml(XXX)更新配置文件。
可用的标签如下:

选取进程创建(Event ID 1: Process creation)、进程创建(Event ID 2: A process changed a file creation time)、网络链接(Event ID 3: Network connection)、时间远程线程创建(Event ID 8: CreateRemoteThread)。
xml文件配置如下:

<Sysmon schemaversion="4.0">
  <!-- Capture all hashes -->
  <HashAlgorithms>*</HashAlgorithms>
  <EventFiltering>
<!-- Log all drivers except if the signature -->
<!-- contains Microsoft or Windows -->

<ProcessCreate onmatch="include"> 
 <ParentImage condition="end with">cmd.exe</ParentImage>
</ProcessCreate>

<FileCreateTime onmatch="include"> 
  <Image condition="end with">cmd.exe</Image>
</FileCreateTime>


<NetworkConnect onmatch="include">     
  <DestinationPort condition="is">80</DestinationPort>      
  <DestinationPort condition="is">443</DestinationPort>    
</NetworkConnect>
    
 <NetworkConnect onmatch="exclude">     
     <Image condition="contains">chrome.exe</Image>    
  <Image condition="contains">firefox.exe</Image> 
</NetworkConnect>


<CreateRemoteThread onmatch="exclude">
  <TargetImage condition="end with">explorer.exe</TargetImage>
  <TargetImage condition="end with">svchost.exe</TargetImage>
  <TargetImage condition="end with">winlogon.exe</TargetImage>
  <SourceImage condition="end with">powershell.exe</SourceImage>
</CreateRemoteThread>
  </EventFiltering>
</Sysmon>

启动后,可以在事件查看器中查看。

使用Process Explorer分析恶意软件

使用Windows XP系统上的Process Explorer对恶意软件进行分析。

可以看到回连的主机号和端口号。
之后在kali进行进程迁移,多次尝试发现,很难迁移到windows主控程序中去,最后选择了文本文档(notepad)。

后门程序迁移之后,在tcpip标签下无法找到了,但是在threadStart Address中出现了ntdll.dll!......,查实验时同学问我迁移以后怎么看到后门程序,我直觉认为这一条就是,当时的判断是基于我在攻击机(kali)发送指令时,Cycles Delta 出现过变化,想验证猜想有两个方法:

  • 执行一条需要占用许多计算机资源的命令,如截图、视频通话、ping命令等。
  • 结束ntdll.dll!......项,观察后门连接是否中断。
    第一个方式验证是出现了如下错误:

    简单的指令例如pwddir之类的没有出现运行问题,但是如果执行截屏、视频通话之类的操作会出现这个错误。
    第二种方式能证明猜测是正确的。
    之后查阅资料了解到:
  • Cycles Delta 是最近一秒钟CPU运行这个线程所需的时钟个数
  • ntdll.dll是重要的Windows NT内核级文件。描述了windows本地NTAPI的接口。
  • RtlUserThreadStart:指令指针寄存器被设为RtlUserThreadStart函数(此函数是NTDLL.dll导出的)的地址。
    这些都和线程调用有关。

其他工具

  • virscan 报告中可以得到被分析程序的行为描述和详细信息,懒得翻墙就没去尝试
  • systracer 拍摄系统快照可以得到前后程序发生的改变,比如后门程序的植入和其所建立的TCP连接以及其打开的句柄,比较可以分析注册表值的改变。
  • wireshark 可以捕捉到电脑流量,分析数据包来源和发送情况,需要自己编写分析条件,扔到ip查询网址插卡服务器位于哪里。
  • Process Monitor 微软进程监视器,很多后门、恶意软件、外挂都喜欢伪装成Explorer.exe进程,可以用程序列出列表,分析哪些是伪装的。
原文地址:https://www.cnblogs.com/ikari/p/8850146.html