20155330 《网络攻防》 Exp4 恶意代码分析

20155330 《网络攻防》 Exp4 恶意代码分析

实验后回答问题

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

  • 使用Windows自带的schtasks指令设置一个计划任务,指定每隔一定时间记录主机的联网记录或端口开放、注册表信息等;
  • 通过sysmon工具,配置需要记录事件的文件,之后在事件查看器里找到相关日志文件查看;
  • 使用Process Explorer工具,监视进程执行情况,查看是否有程序调用了异常的dll库之类的。

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

  • 使用systracer工具分析某个程序执行前后,计算机注册表、文件、端口的一些变化情况。

实验过程

使用schtasks指令监控系统

  • 在C盘目录下建立一个netstatlog.bat文件,用来将记录的联网结果格式化输出到netstatlog.txt文件中,netstatlog.bat内容为:
date /t >> c:\netstatlog.txt
time /t >> c:\netstatlog.txt
netstat -bn >> c:\netstatlog.txt
  • 此时C盘中的文件:
  • 打开Windows下命令提示符,输入指令schtasks /create /TN netstat /sc MINUTE /MO 2 /TR "c:\netstatlog.bat"创建一个每隔两分钟记录计算机联网情况的任务
  • 右键点击“计算机”|“管理”,在计算机管理中点击“任务程序计划”|“任务程序计划库”,双击netstat任务计划项目,点击“操作”页签,“编辑”|修改“程序或脚本”为C:\netstatlog.bat



  • 在“操作”中,将“只有在计算机使用交流电源时才启动此任务”选项取消
  • 过了一会查看netstatlog.txt文件……
  • 再次双击netstat任务计划项目,在“常规”页签中勾选“使用最高权限运行”
  • 隔了大约一天之后,再次查看记录的主机联网日志。
  • 根据张竞予同学的博客,制作了相关表格和饼状图。由于使用的是虚拟机进行实践,所以联网的应用程序种类较少。

使用sysmon工具监控系统

  • 首先创建配置文件Sysmon20155303.xml,内容如下:
<Sysmon schemaversion="3.10">
  <!-- 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 C:\Sysmon20155330.xml安装Sysmon
  • 在“事件查看器”中查看程序相关信息。

  • Sysmon.exe -c C:\Sysmon20155330.xml更改配置文件,监听443和80端口,无异常发生。
<Sysmon schemaversion="3.10">
  <!-- 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>    
</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>

使用VirusTotal分析恶意软件

  • 把后门软件上传到VirusTotal进行扫描,只有16个软件没有检测出病毒……
  • 查看这个恶意代码的基本属性
  • 算法库支持情况

使用Process Monitor分析恶意软件

  • Process Monitor是一个高级的 Windows 系统和应用程序监视工具,使用者可以对系统中的任何文件和注册表操作同时进行监视和记录,通过注册表和文件读写的变化,诊断系统故障或是发现恶意软件、病毒或木马。
  • 以下为软件记录情况(部分)。

使用Process Explorer分析恶意软件

  • Process Explorer让使用者能了解看不到的在后台执行的处理程序,能显示目前已经载入哪些模块,分别是正在被哪些程序使用着,还可显示这些程序所调用的 DLL进程,以及他们所打开的句柄。
  • 后门软件运行情况记录:

使用PEiD分析恶意软件

  • PEiD(PE Identifier)是一款著名的查壳工具。
  • 未加壳扫描结果:
  • 加壳后:

使用systracer分析恶意软件

  • 在kali对windows主机进行回连前后使用软件进行快照,然后对比。
  • 首先是注册表发生了变化:
  • 端口情况

实验体会

通过这次的学习和实践,主要对恶意代码的分析方式有了一定的了解。恶意代码分析主要分为静态分析和动态分析两种方式。通过和上一次的实践相结合,对恶意代码的隐蔽性有了更加深刻的了解。

posted @ 2018-04-17 22:24  20155330  阅读(204)  评论(0编辑  收藏  举报