20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

问题

(1) 如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么。请设计下你想监控的操作有哪些,用什么方法来监控。

  • 用TCPview,监听观察是否有localport为cifs的

  • 用Schtasks,查看是否有可疑netstat连接

  • 用sysmon,查看id为3的,是否有可以进程进行连接

(2)如果已经确定是某个程序或进程有问题,你有什么工具可以进一步得到它的哪些信息。

  • systracer 可以得到,该进程运行后注册表,文件,进程的变化

系统运行监控

1.计划任务实现

  • 先建立一个netstat20155226.txt文件,在文件中输入
date /t >> c:
etstat20155226.txt
time /t >> c:
etstat20155226.txt
netstat -bn >> c:
etstat20155226.txt
  • 然后将此文件名改为netstat20155226.bat

  • 再建立一个netstat20155226.txt,用来将记录的联网结果格式化输出到其中

  • 将这两个文件剪切到c盘目录下

  • 打开控制面板,搜索计划任务

  • 选择创建任务,名称设为20155226,并选择使用最高权限运行

20155226《网络攻防》 实验4 恶意代码分析

  • 创建触发器

20155226《网络攻防》 实验4 恶意代码分析

  • 创建任务

20155226《网络攻防》 实验4 恶意代码分析

  • 打开netstat20155226.txt,得到如图:

20155226《网络攻防》 实验4 恶意代码分析

Sysinternals工具集

2.Sysmon

  • 首先我们在https://docs.microsoft.com/zh-cn/sysinternals/下载sysmon

  • 对其进行解压,在E盘创建20155226.txt文件在其中输入

<Sysmon schemaversion="4.00">      //4.00为你的版本号,如不知道版本号,可先运行下面的指令,根据所提示的错误进行更改
  <!-- Capture all hashes -->
  <HashAlgorithms>*</HashAlgorithms>
  <EventFiltering>
<!-- Log all drivers except if the signature -->
<!-- contains Microsoft or Windows -->
<DriverLoad onmatch="exclude">
  <Signature condition="contains">microsoft</Signature>
  <Signature condition="contains">windows</Signature>
</DriverLoad>

<NetworkConnect onmatch="exclude">
  <Image condition="end with">chrome.exe</Image>
  <Image condition="end with">iexplorer.exe</Image>
  <SourcePort condition="is">137</SourcePort>
</NetworkConnect>

<CreateRemoteThread onmatch="include">
  <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>
  • 然后,以管理员身份运行命令行,输入Sysmon.exe -i 20155226.txt
    如图:

20155226《网络攻防》 实验4 恶意代码分析

  • 然后我们打开控制面板,搜索事件查看,打开事件查看器,sysmon的日志就在,应用程序和服务日志/Microsoft/Windows/Sysmon/Operational下

如图:

20155226《网络攻防》 实验4 恶意代码分析

我们对日志进行查看
如图:

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

  • 事件ID号类型可参考https://docs.microsoft.com/zh-cn/sysinternals/downloads/sysmon

如图:

20155226《网络攻防》 实验4 恶意代码分析

  • 接下来,我们主要对80,443,5226端口进行监视

  • 利用下面的代码对2015526.txt进行更改,然后使用sysmon.exe -c 20155226.txt,进行更新。

<Sysmon schemaversion="4.00">
  <!-- Capture all hashes -->
  <HashAlgorithms>*</HashAlgorithms>
  <EventFiltering>
<!-- Log all drivers except if the signature -->
<!-- contains Microsoft or Windows -->
<DriverLoad onmatch="exclude">
  <Signature condition="contains">microsoft</Signature>
  <Signature condition="contains">windows</Signature>
</DriverLoad>

<NetworkConnect onmatch="exclude">
  <Image condition="end with">SogouExplorer.exe</Image>
</NetworkConnect>

<NetworkConnect onmatch="include">     
  <DestinationPort condition="is">80</DestinationPort>      
  <DestinationPort condition="is">443</DestinationPort>
  <DestinationPort condition="is">5226</DestinationPort>    
</NetworkConnect>

<CreateRemoteThread onmatch="include">
  <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>

如图:

20155226《网络攻防》 实验4 恶意代码分析

  • 然后我们来查看事件查看器,如图:

20155226《网络攻防》 实验4 恶意代码分析

  • thy52261.exe,利用tcp,进行network连接,目的端口为5226,资源端口为62803

Systracer

  • 首先我们进行下载,安装

  • 然后进行快照,我快照了2次,分别为

  1. 尝试回连

  2. kali输入dir

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

  • 上图对比,发现main.exe在运行,并且新增了svchost服务。

使用virscan分析恶意软件

  • 在virustotal网站查看上次后门软件的文件行为分析:
    先让我们看一下详细报告:

20155226《网络攻防》 实验4 恶意代码分析

20155226《网络攻防》 实验4 恶意代码分析

  • 根据上图,可以看出这个程序是在后门不过的后门了,有第二张图可以发现,本程序使用了ADVAPI32.dllKERNEL32.dllMSVCRT.dllWS2_32.dllWSOCK32.dll,这五个链接库,其中WS2_32.dllWSOCK32.dll是比较熟悉的win上面编写SOCKET用的,这是用来回连使用的,而advapi32.dll是一个高级API应用程序接口服务库的一部分,包含的函数与对象的安全性,注册表的操控以及事件日志有关,从这句解释就可以看出,本后门程序的潜在的威胁,kernel32.dll是Windows 9x/Me中非常重要的32位动态链接库文件,属于内核级文件。它控制着系统的内存管理、数据的输入输出操作和中断处理,当Windows启动时,kernel32.dll就驻留在内存中特定的写保护区域,使别的程序无法占用这个内存区域。而msvcrt.dll是微软在windows操作系统中提供的C语言运行库执行文件(Microsoft Visual C Runtime Library),其中提供了printf,malloc,strcpy等C语言库函数的具体运行实现,并且为使用C/C++(Vc)编译的程序提供了初始化(如获取命令行参数)以及退出等功能,我们基本上每个C程序都会用到。

实验体会

  • 恶意代码处处都有,分析起来也是个麻烦活,平时要小心呀!!