• 2017-2018-2 20155224『网络对抗技术』Exp4:恶意代码分析


    原理与实践说明

    1. 实践目标
    • 监控你自己系统的运行状态,看有没有可疑的程序在运行。
    • 分析一个恶意软件,就分析Exp2或Exp3中生成后门软件;分析工具尽量使用原生指令或sysinternals,systracer套件。
    • 假定将来工作中你觉得自己的主机有问题,就可以用实验中的这个思路,先整个系统监控看能不能找到可疑对象,再对可疑对象进行进一步分析,好确认其具体的行为与性质。
    1. 实践内容概述
    • 系统运行监控

      • 使用如计划任务,每隔一分钟记录自己的电脑有哪些程序在联网,连接的外部IP是哪里。运行一段时间并分析该文件,综述分析结果。
      • 安装配置sysinternals里的sysmon工具,设置合理的配置文件,监控自己主机的重点事可疑行为。
    • 分析该软件在(1)启动回连,(2)安装到目标机(3)及其他任意操作时(如进程迁移或抓屏,重要是你感兴趣)。该后门软件

      • 读取、添加、删除了哪些注册表项
      • 读取、添加、删除了哪些文件
      • 连接了哪些外部IP,传输了什么数据
    1. 基础问题回答
    • 问:如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么。请设计下你想监控的操作有哪些,用什么方法来监控。

      • 使用windows自带的schtasks指令设置一个计划任务,每隔一定的时间对主机的联网记录等进行记录。
      • 使用sysmon工具,通过修改配置文件,记录相关的日志文件。
      • 使用Process Explorer工具,监视进程执行情况。
    • 问:如果已经确定是某个程序或进程有问题,你有什么工具可以进一步得到它的哪些信息。

      • 使用Wireshark进行抓包分析,监视其与主机进行的通信过程。
      • 使用systracer工具分析恶意软件。

    实践过程记录

    1. 使用schtasks指令监控系统

    • 使用schtasks /create /TN netstat5224 /sc MINUTE /MO 5 /TR "cmd /c netstat -bn > c: etstatlog.txt"命令创建计划任务

    其中,TN是TaskName的缩写,我们创建的计划任务名是netstat5303;sc表示计时方式,我们以分钟计时填MINUTE;TR=Task Run,要运行的指令是 netstat -bn,b表示显示可执行文件名,n表示以数字来显示IP和端口。

    • 在C盘中创建一个netstat5303.bat脚本文件

    在其中写入以下内容:

    date /t >> c:
    etstatlog.txt
    time /t >> c:
    etstatlog.txt
    netstat -bn >> c:
    etstatlog.txt
    

    • 打开任务计划程序,可以看到我们新创建的这个任务:

    • 双击这个任务,点击操作并编辑,将“程序或脚本”改为我们创建的netstatlog.bat批处理文件,确定即可。

    • 可以在netstatlog.txt文件中查看记录结果

    2. sysmon工具监控系统

    • 下载Sysmon程序,并创建配置文件Sysmon5224.xml。配置文件内容如下:
    <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">chrome.exe</Image>
          <Image condition="end with">iexplorer.exe</Image>
          <Image condition="end with">firefox.exe</Image>
          <SourcePort condition="is">137</SourcePort>
          <SourceIp condition="is">127.0.0.1</SourceIp>
          <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">firefox.exe</TargetImage>
          <TargetImage condition="end with">svchost.exe</TargetImage>
          <TargetImage condition="end with">winlogon.exe</TargetImage>
          <SourceImage condition="end with">powershell.exe</SourceImage>
        </CreateRemoteThread>
        
        <ProcessCreate onmatch="include">
          <Image condition="end with">chrome.exe</Image>
          <Image condition="end with">iexplorer.exe</Image>
          <Image condition="end with">firefox.exe</Image>
        </ProcessCreate>
        
        <FileCreateTime onmatch="exclude" >
          <Image condition="end with">firefox.exe</Image>   
        </FileCreateTime>
        
        <FileCreateTime onmatch="include" >
          <TargetFilename condition="end with">.tmp</TargetFilename>       
          <TargetFilename condition="end with">.exe</TargetFilename>  
        </FileCreateTime>
        
      </EventFiltering>
    </Sysmon>
    
    • 使用Sysmon.exe -i C:Sysmon20155303.xml安装sysmon。

    • 打开开始菜单右击->事件查看器->应用程序和服务日志->Microsoft->Windows->Sysmon->Operational。在这里,我们可以看到按照配置文件的要求记录的新事件,以及事件ID、任务类别、详细信息等等。

    • 可以看到有不同的时间类型,如事件2、事件3等

    • 不知道为什么没有看到自己的后门程序对应的事件()

    3. 使用VirusTotal分析恶意软件

    把生成的恶意代码放在VirusTotal进行分析,基本情况如下:

  • 相关阅读:
    Socket通信
    浏览器调用打印机
    python dict操作
    python list操作
    python 模块Example链接
    python random模块
    python configparser模块
    python unittest模块
    python timeit模块
    python datetime模块
  • 原文地址:https://www.cnblogs.com/nxy970408/p/8999889.html
Copyright © 2020-2023  润新知