175210 Exp4恶意代码分析

一、实践内容

1、使用schtasks指令监控系统

1、将内容写入脚本文件 netstat5210.bat

date /t >> d:
etstat5210.txt
time/t >> d:
etstat5210.txt
netstat -bn >> d:
etstat5210.txt

解释一下

  • -b 表示显示在 创建每个连接或侦听端口时涉及的可执行程序
  • -n 表示 以数字形式显示地址和端口号

2、使用命令 schtasks /create /tn netstat5210 /sc MINUTE /mo 1 /tr "cmd /c d: etstat5210.bat"

解释一下参数

  • TN是TaskName的缩写,我们创建的计划任务名是netstat5210

  • sc表示计时方式,我们以分钟计时填MINUTE

  • TR是Task Run,运行脚本netstat5210.bat

以管理员身份打开 windows terminal

然后发现管理员模式能执行上述的每条指令,但创建的计划任务没有这权限……

3、所以 schtasks /create /TN netstat5210 /sc MINUTE /MO 1 创建任务

要勾选 使用最高权限运行

4、过一段时间就可以观察数据了,先要结束这个计划任务

schtasks /delete /tn netstat5210

可以看到运行的有 code.exe (visual code), psql.exe (postgresql), mysql.exe(mysql), vmware.exe(虚拟机)等

2、使用sysmon工具监控系统

1、下载 Sysinternals 套件,Sysmon是该套件中的一个工具,可以监控几乎所有的重要操作。

2、创建 5211config.xml 确定要监控的目标,对信任的程序设置白名单。

<Sysmon schemaversion="10.42">
  <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>

    <ProcessTerminate onmatch="include" >
      <Image condition="end with">MsMpEng.exe</Image>
    </ProcessTerminate>


    <FileCreateTime onmatch="exclude" >
      <Image condition="end with">chrome.exe</Image>
    </FileCreateTime>

    <ImageLoad onmatch="include">
      <Signed condition="is">false</Signed>
    </ImageLoad>

    <ProcessAccess onmatch="include">
      <TargetImage condition="end with">lsass.exe</TargetImage>
      <TargetImage condition="end with">winlogon.exe</TargetImage>
    </ProcessAccess>
	
	  <ProcessAccess onmatch="exclude">
		  <SourceImage condition="contains">vmware</SourceImage>
	  </ProcessAccess>

    <NetworkConnect onmatch="exclude">      
		  <Image condition="end with">chrome.exe</Image>
		  <Image condition="end with">svchost.exe</Image>
		  <Image condition="contains">vmware</Image>
          <Image condition="end with">psql.exe</Image>
          <Image condition="end with">postgres.exe</Image>
          <Image condition="end with">msedge.exe</Image>
          <Image condition="end with">svchost.exe</Image>
          <Image condition="contains">clash</Image>
          <Image condition="end with">Code.exe</Image>
          <Image condition="contains">mysqld</Image>
	  </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>
	    <SourceImage condition="end with">cmd.exe</SourceImage>
    </CreateRemoteThread>

  </EventFiltering>

</Sysmon>

过滤了很多东西,数据库,clash,vmware,IDE 都加入了白名单

3、使用命令 Sysmon.exe -i ..5210config.xml 安装

可以在 事件查看器/应用程序和服务日志/Microsoft/Windows/Sysmon/Operational里看到记录

3、恶意软件分析

使用实验三中的后门回连kali虚拟机

1、观察 Sysmon 日志

我们可以在 Sysmon日志中看到进程创建

同时也检测到网络连接

可以清楚地看到源 ip,目的 ip,端口

2、wireshark 抓包

可以清楚地看到三次握手的过程,由 windows10 发起

使用后门程序对Win10进行各种操作查看抓包和事件

1、使用webcam_snap调用摄像头

1.1 wireshark 抓包

传递了好多数据,没看出啥

1.2 查看 Sysmon 日志

出现两条相关记录,任务类别均为 Driver loaded(驱动加载),但签名无效

使用Systracer进行分析

1、Systracer 能用快照对比的方式全面地监控系统。我拍下了后门启动前、启动后、提权后、断开连接后四个快照。

2、比较启动前和启动后,我在 Application 中找到了后门 sc.exe

注册表也变了不少,但并没有发现有价值的东西

3、getsystem 提权

进程,服务等并没有什么改变,只能观察到攻击机和被攻击机在提权过程中重新连接了一次

注册表也改了不少,看不出什么

4、实验后问题回答

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

  • 使用schtasks对机器进行监听
  • 使用Sysmon对事件进行记录,通过事件查看器的任务类别,判断有没有可疑的行为或连接记录
  • 使用Systracer拍摄几个不同时间的快照,对比不同时间的快照判断是否有可疑的行为

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

  • 通过systracer工具进行相关的分析,查看它对注册表和文件的修改

5、实验总结

这次实验做的不理想,并没有观察到多少有价值的信息,有变化的地方我也看不明白。

原文地址:https://www.cnblogs.com/mtzf/p/12728851.html