20171121 Wang Pengwei "Malicious Code Analysis" Experimental Report

1. Experiment name

  Malicious code analysis

 

Second, the purpose of the experiment

  1. It is to monitor the running status of your own system to see if suspicious programs are running.

  2. To analyze a malware, analyze the backdoor software generated in Exp2 or Exp3; the analysis tool uses native instructions or sysinternals, SysTracer suite as much as possible.

  3. Assuming that you feel that your host has a problem in future work, you can use this idea in the experiment, first monitor the entire system to see if suspicious objects can be found, and then further analyze the suspicious objects to confirm their specific behavior and nature.

 

3. Experimental content

  3.1 System operation monitoring

  (1) Use such as scheduled tasks to record every minute what programs are on your computer, and where is the connected external IP. Run it for a while and analyze the file to summarize the analysis results. The goal is to find out all the programs connected to the network, where they are connected, and what they have done (you can only guess if you don't capture packets). Do you think it is appropriate to do so? If you want to further analyze, you can capture packets targeted.

  (2) Install and configure the Sysmon tool in Sysinternals, set a reasonable configuration file, and monitor the suspicious behavior of the main things of your host.

The analysis of the actual log also needs to exert its own creativity, combined with the previously learned knowledge such as Linux text processing instructions. The difficulty of analysis lies in analysing the law from a large amount of data and finding out the problems. This all depends on further processing of results filtering, statistics, classification, etc.

  3.2 Malware analysis

Analyze the software when (1) start back connection, (2) install to the target machine (3) and other arbitrary operations (such as process migration or screen capture, the important thing is that you are interested). The backdoor software

  (3) What registry entries are read, added, and deleted

  (4) Which files have been read, added and deleted

  (5) What external IPs are connected and what data is transmitted (capture analysis)

 

4. Basic knowledge and experiment preparation

  1. The method of importing data from txt text into an Excel table: Data—> From Text—> Select Separator—> Select all separators—> Column Data Format, select General—> Click Finish

  2. Sysmon tool in Sysinternals: Sysmon is a lightweight system monitoring tool of Microsoft. It implements process creation, file access and network information recording through system services and drivers, and writes and displays relevant information on Windows In the log file. We can use this tool to record and analyze the activities of system processes to identify malicious or abnormal activities.

  3. SysTracer tool: SysTracer is a system tool that helps users find changes that may be caused by malware on the computer. To discover these changes, SysTracer will perform a system scan, recording information about files and folders, registry keys, system services, drivers, currently active processes, dynamic link libraries, and applications scheduled to run at system startup. Then, SysTracer uses all this information to create a complete snapshot of the system and save it for future reference. Through the snapshot comparison, you can see which files and registry keys have been changed, that is, any content that was created, modified, or deleted.

 

5. Records of the experimental process

  5.1 System operation monitoring

    5.1.1 Use such as scheduled tasks to record every minute which programs of your computer are connected to the network and where the connected external IP is.

    Enter "schtasks / create / TN netstat1121 / sc MINUTE / MO 5 / TR" cmd / c netstat -bn> c: \ duikang_sy4 \ netstatlog.txt "" to create a task plan named "netstat1121". After the creation is successful, double-click the task plan and check "Run with the highest authority".

    Among them, TN means Task Name, SC means SChedule type, MINUTE is used here to count in minutes, MO means Modifier, TR means Task Run, the command to be run is netstat -bn, "-b" parameter means display executable file name , "-N" parameter means to display IP and port in numbers.

    Realized function: start the scheduled task, record which programs are connected to the network every 5 minutes, and write the result into netstatlog.txt.

 

  

    Create a new txt file and enter the following instructions:

    date /t >> c:\duikang_sy4\netstatlog_1121.txt

    time /t >> c:\duikang_sy4\netstatlog_1121.txt

    netstat -bn >> c:\duikang_sy4\netstatlog_1121.txt

    另存为文件为netstatlog_1121.bat,路径为c:\duikang_sy4。.bat文件是Windows批处理文件。

    双击该任务计划,编辑操作,设置程序或脚本为我们刚刚生成的Windows批处理文件netstatlog_1121.bat。

 

    等待netstat1121运行2小时后,删除此任务计划。选择路径c:/duikang_sy4/netstatlog_1121.txt,查看所记录的数据。

    将数据导入Excel中,对数据做统计分析(导入方法已在基础知识和实验准备中描述)。生成数据透视图,做降序排列。

 

    2小时内连网超过20次的应用程序:

    QyClient.exe        爱奇艺(PPS)的客户端进程

    QQ.exe              QQ

    tagsrv.exe           LabVIEW相关程序。LabVIEW是NationalInstruments,Inc.出品的一种图形化的编程语言,用于快速创建灵活的、可升级的测试、测量和控制应用程序

    nimxs.exe            LabVIEW相关程序

    lkads.exe            LabVIEW相关程序

    WinStore.App.exe       隶属Windows Store生态系统

    DingTalk.exe        钉钉

    svchost.exe           是微软Windows操作系统中的系统文件,是从动态链接库 (DLL) 中运行的服务的通用主机进程名称

    lktsrv.exe           LabVIEW相关程序

    lkcitdl.exe           LabVIEW相关程序

    nidmsrv.exe           LabVIEW相关程序

    WeChatStore.exe        执行后会出现微信的二维码登录窗口

    nimdnsResponder.exe     National Instruments Zeroconf Service  NI公司的Zeroconf服务

    WUDFHOST.exe        是一个Windows驱动程序的基础-用户模式驱动程序框架进程,每台硬件设备都必须附带用户模式设备驱动程序,此驱动程序必须安装到Windows中

    SearchUI.exe        小娜(Cortanar)的搜索进程

    MFEAvSvc.exe          隶属杀毒软件McAfee(迈克菲)的进程

    在记录的时间内我主要使用的是QQ、钉钉还有微信,因为电脑中装了很多NI公司的软件,而且经常会有更新,所以这些软件连网也很正常,其次就是一些微软的系统文件。最让我想不明白的是爱奇艺客户端为什么会有这么大量的连网,毕竟在这段时间内我并没有使用它。

    5.1.2安装配置Sysinternals里的Sysmon工具,设置合理的配置文件,监控自己主机的重点事可疑行为。

    从微软官网下载SysinternalsSuite.zip,解压后找到Sysmon64.exe,在属性中查看此应用程序的版本号,为写配置文件做准备。

    在Sysmon64.exe所在的目录下,新建一个txt文件,输入如下:

 

    另存为Sysmon64_1121.xml文件,xml即可扩展标记语言,是一种用于标记电子文件使其具有结构性的标记语言。

    上述代码实现的功能是:

    1.在日志中不记录签名为“microsoft”和“windows”的驱动装载;

    2.过滤掉浏览器的网络连接,记录所有目的端口为80和443的网络连接(80端口的服务为http,443端口的服务为https),但是过滤掉以“MicrosoftEdge.exe”和“MicrosoftEdgeCP.exe”结尾的可执行文件的联网情况,也不记录源IP为127.0.0.1以及源端口号为137的网络连接;

    3.在创建远程线程方面,不记录以“explorer.exe”、“svchost.exe”、“winlogon.exe”和“powershell.exe”结尾的可执行文件所创建的线程。

    以管理员身份运行cmd,在Sysmon64.exe目录下输入“Sysmon64.exe -i  Sysmon64_1121.xml”。

 

    通过事件查看器(本地)—>应用程序和服务日志—>Microsoft—>Windows—>Sysmon—>Operational,可以查看到Sysmon64.exe所记录的服务日志。

 

 

 

    双击一条记录,可以从时间属性中得知记录的时间、进程号、可执行文件名、文件版本等详细信息。

 

  5.2恶意软件分析

    5.2.1静态分析

    (1)使用VirusTotal扫描恶意软件

    此处扫描的是实验2中生成的一个简单的后门程序20171121_backdoor.exe。点开BEHAVIOR,可以看到VirusTotal对此恶意程序的行为分析。

 

    (2)使用PEID查壳工具扫描恶意软件

    扫描不加壳的后门,结果当然是什么都没找到。

 

    扫描加upx压缩壳的后门,结果显示发现UPX壳。

 

    扫描加Hyperion加密壳的后门,惊奇的是,结果却显示什么都没找到。看来PEID只能扫描出压缩壳,对加密壳没有检测能力。

 

    5.2.2动态分析

    (1)使用SysTracer工具分析后门程序(此处使用实验2生成的后门程序20171121_backdoor.exe)

    安装SysTracer,输入监听端口1121

 

    安装完成后,运行SysTracer做5次记录,为控制变量Kali始终在运行状态。

 

  

    Snapshot #1   植入恶意软件前

    Snapshot #2   植入恶意软件后

    Snapshot #3   恶意软件启动回连

    Snapshot #4   控制端使用拍摄指令“webcam_snap”

    Snapshot #5   恶意软件断开连接后

     比较快照1和快照2

 

    植入恶意软件后,可以发现Files类型下增加了20171121_backdoor.exe(上图中间绿色部分)。

 

    与此同时也增加了很多.dll.mui文件。.dll是动态链接库,.mui是Windows多语言用户界面文件。

    比较快照2和快照3

 

    后门回连成功后,可以发现Applications类型下增加了20171121_backdoor.exe,同时增加了4个.dll文件(关键就是这4个动态链接库)。

 

    此处可以发现后门回连的源IP、源端口以及目的IP、目的端口(上图最后一行)。

    比较快照3和快照4

 

    执行“webcam_snap”指令后,系统增加了一些系统服务,路径在HKLM和HKU目录下的居多。

    比较快照4和快照5

 

    后门断开连接后,发现Applications类型下减少了20171121_backdoor.exe,同时减少了了4个.dll文件,对比上文,我们可以发现断开连接减少的这4个.dll文件和回连成功时增加的4个.dll文件正好完全相同,于是我初步猜测这4个.dll文件可以构成后门回连的充要条件。

    (2)使用Wireshark抓包,分析恶意软件和控制端的通信,同时查看Sysmon的服务日志。

    —在Wireshark过滤器中输入筛选条件“ip.addr == 192.168.1.13”

    ·启动回连,Wireshark抓到大量的TCP数据包

 

    ·控制端输入截屏指令“screenshot”,由图发现从靶机IP192.168.1.10向控制机IP192.168.1.13传输了大量的TCP数据包

 

    ·控制端输入拍摄指令“webcam_snap”,由图发现从靶机IP192.168.1.10向控制机IP192.168.1.13同样传输了大量的TCP数据包,但与截屏操作略有不同的是,控制机会回应靶机少量的TCP数据包

 

    —查看Sysmon记录的日志

    ·后门回连成功时,日志中记录下后门程序在主机中创建了进程,且进程号为25636。

 

    ·控制端输入拍摄指令“webcam_snap”时,日志中记录下后门程序在主机中创建了进程,更关键的是此进程运行了如下命令“C:\WINDOWS\System32\svchost.exe -k Camera -s FrameServer”,表示该进程调用了摄像头进行拍摄。(下图中CommandLine)

 

六、问题回答

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

  答:(1)设置任务计划,用netstat指令监控系统联网的情况,一段时间后使用Excel对结果进行统计分析;

    (2)安装配置Sysinternals里的Sysmon工具,设置合理的配置文件,在记录下的日志文件中分析判断是否有恶意程序;

    (3)使用SysTracer工具每间隔一段时间对系统进行快照,比较几次快照的异同。

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

  答:(1)动态分析:使用Wireshark抓包,查看该恶意程序连接了哪些外部IP,做了哪些通信。运行该程序,在系统日志中查看该程序使用了哪些系统功能,使用SysTracer工具在该程序运行前后对系统进行快照对比,观察该恶意程序对系统做了哪些修改。

    (2)静态分析:将程序传至VirusTotal上或用系统自带的杀软扫描该程序,使用PEID等查壳工具对它进行检查。

 

七、实验总结与体会

  通过本次网络对抗技术实验,我第一次尝试去了解我的电脑在空闲时的运行状态,第一次监控自己的系统,统计、分析电脑中的相关服务和应用连网的情况,确认所有的可执行文件都是有来路的,不是恶意程序。

  本次实验我运用了很多微软支持的系统监测工具,比如Sysinternals里的Sysmon工具,通过设置合理的配置文件,在日志中监测系统,以及通过SysTracer工具,对系统进行快照对比,同时还使用Wireshark对回连的后门进行抓包,分析其与回连主机的通信,了解恶意软件在运行时对系统相关文件所做的修改等。

  本次实验令我受益匪浅,通过这几个连贯的实验,我对恶意程序有了系统的认知,期待下次实验能让我对这门课程有更深的理解和感悟。

Guess you like

Origin www.cnblogs.com/loadingwangp/p/12722496.html