Lab 6-1

LABS

The goal of the labs for this chapter is to help you to understand the overall functionality of a program by analyzing code constructs. Each lab will guide you through discovering and analyzing a new code construct. Each lab builds on the previous one, thus creating a single, complicated piece of malware with four constructs. Once you’ve finished working through the labs, you should be able to more easily recognize these individual constructs when you encounter them in malware.

Lab 6-1

In this lab, you will analyze the malware found in the file Lab06-01.exe.

Questions and Short Answers

  1. What is the major code construct found in the only subroutine called by main?

    A: The major code construct is an if statement located at 0x401000.

  2. What is the subroutine located at 0x40105F?

    A: printf is the subroutine located at 0x40105F.

  3. What is the purpose of this program?

    A: The program checks for an active Internet connection. If an active connection is found, it prints “Success: Internet Connection.” If a connection is not found, it prints “Error 1.1: No Internet.” This program can be used by malware to check for a connection before attempting to connect to the Internet.

Detailed Analysis

We begin by performing basic static analysis on this executable. Looking at the imports, we see that the DLL WININET.dll and the function InternetGetConnectedState are imported. The Windows Internet (WinINet) API enables applications to interact with HTTP protocols to access Internet resources.

Using MSDN (InternetGetConnectedState), we learn this Windows API function checks the status of the Internet connection for the local system. The strings Error 1.1: No Internet and Success: Internet Connection hint that this program may check for an active Internet connection on the system.

Next, we perform basic dynamic analysis on this executable. Nothing overly exciting happens when this executable is run from the command line. It simply prints “Success: Internet Connection” and then terminates.

Finally, we load the file into IDA Pro for full analysis. Much of this disassembly is generated by the compiler, so we need to be careful to avoid going down rabbit holes of irrelevant code. Therefore, we start from the main function, which is typically where the code written by the malware author begins. In this case, the main function starts at 0x401040. The main function calls the function at 0x401000, which appears to be a key function of interest because it is the only one called by main. Figure 6-1L shows a flow graph of this function.

Figure 6-1L: Disassembly flow graph of the function at 0x401000

Now we graph this function in IDA Pro using View -> Graphs -> Flow chart. Looking at this graph and code, we see a common code construct: two different code paths depend on the result of the call to InternetGetConnectedState. The cmp instruction is used to compare the result contained in EAX to 0, and then the jz instruction is used to control the flow.

The MSDN page on InternetGetConnectedState further states that the function returns 1 if there is an active Internet connection; otherwise it returns 0. Therefore, the code will take the false branch at \({\color{red}1}\) if the result is 0 because the zero flag (ZF) will be clear; otherwise, it will take the true branch at \({\color{red}2}\). The code construct used in this function is an if statement.

The function calls the subroutine at 0x40105F in two locations, but if we dive into that function, we will quickly get lost in a rabbit hole. This function is printf. Surprisingly, both the IDA Pro commercial and freeware versions will not always recognize and label the printf function. Therefore, we must look for certain signals that hint at an unlabeled call to printf. One easy way to tell is by identifying parameters pushed onto the stack before the call to the subroutine. Here, in both cases, a format string is pushed onto the stack. The \n at the end of a string denotes a line feed. Also, given the context and the string itself, we can deduce that the function is printf. Therefore, we rename the function to printf, so that it is marked as such throughout the code, as shown in Figure 6-1L. Once the printf function is called, we see that EAX is set to either 1 or 0 before the function returns.

To summarize, this function checks for an active Internet connection, and then prints the result of its check, followed by returning a 1 if it is connected and 0 if it is not. Malware often performs a similar check for a valid Internet connection.

Preference

恶意代码分析实战 Lab 6-1 习题笔记

原文地址:https://www.cnblogs.com/d0ct0rx/p/10263863.html

时间: 2024-11-05 19:39:47

Lab 6-1的相关文章

Simulation.Lab.Software.SimLab.Composer.2015.v6.1.MACOSX 1CD

CA Spectrum Linux VM 10.01.00.00.103 Linux 2DVD  Tahoe Design HYDROFLO v3.0.0.4 1CD  CA Spectrum Windows VM 10.01.00.00.103 Win64 2DVD  Delcam Exchange 2016 R2 CR 8.3.1005 Win64 1CD  Delcam PowerSHAPE 2016 SP2 Update only 1CD  ESI Group VA One 2015.0

x01.Lab.StoreApp: XP 停服,微软变脸

变脸,川剧的一种表演形式,除了哄哄小孩,似乎别无用处.而川剧变脸从业者何其多也,存在时间何其长也.以如此多的从业者,如此长的时间,来进行科研,其成果一定是斐然吧.推而广之,试问天下谁能敌! 微软变脸,足以改变世界.这次变脸,不仅是形式上的,而且是骨子里的.为适应手机.平板的性能苛求,其应用商店程序是建立在 WinRT 的基础上,而 WinRT 是建立在 COM 基础上.即面向对象,又拥抱底层,可谓鱼与熊掌兼得.不仅如此,其开发者许可,应用商店成立,无一不在显示微软的掌控能力."天下英雄,尽入毂中

Citrix Provisioning Services LAB時出現Unable to contact th database Server

今天在執行PVS LAB時出現下圖 後來發現為SQL連入的要調整如下圖1.Machine Account2.對應DB3.DB權限 如果是用SA帳戶作為本機的SQL,就是調這組帳戶 調完後對應就可以使用PVS 感謝

Lab颜色空间进行颜色提取 及其实现

这段时间在做车灯检测,晚上有些尾灯偏黄色亮度偏弱,仅用灰度度是不够的,经比较了在RGB.HSV.Lab颜色空间下进行颜色提取,发现Lab颜色模型的效果是最好的.下面介绍Lab的原理及其代码实现. Lab颜色模型由三个要素组成,一个要素是亮度(L),a 和b是两个颜色通道.a包括的颜色是从深绿色(低亮度值)到灰色(中亮度值)再到亮粉红色(高亮度值):b是从亮蓝色(低亮度值)到灰色(中亮度值)再到黄色(高亮度值).因此,这种颜色混合后将产生具有明亮效果的色彩.(这段百度的,哈哈 ) RGB转换到La

Lab - Hot Standby Router Protocol

Topology Objective Configure inter-VLAN routing with HSRP to provide redundant, fault-tolerant routing to the internal network. Background Hot Standby Router Protocol (HSRP) is a Cisco-proprietary redundancy protocol for establishing a fault-tolerant

MIT OS lab Makefile 分析

lab1 中的Makefile主要是根目录下的GNUMakefile, kern/Makefrag, boot/Makefrag, 后两者通过include直接包含到GNUMakefile中. 1 # 2 # This makefile system follows the structuring conventions 3 # recommended by Peter Miller in his excellent paper: 4 # 5 # Recursive Make Considere

CSAPP 3e : Data lab

/* * CS:APP Data Lab * * <Please put your name and userid here> * * bits.c - Source file with your solutions to the Lab. * This is the file you will hand in to your instructor. * * WARNING: Do not include the <stdio.h> header; it confuses the

CSAPP 3e: Bomb lab (phase_1)

这一个lab拖了好久才开始慢慢完成,花的时间比较多,我也是没想到会需要这么多时间来折腾.考虑到如果把所有关卡的内容都一次发出来,太长了.所以分开操作吧. 然后,有一点是,在开始解题前的确该好好认识一下GDB,因为要使用这个工具.虽然我也感觉有些东西是可以等需要的时候再查的,但是后来找到了一篇介绍gdb命令的,写的比较详细,就下载了打印出来,占用了几节课的时间好好看了一下,就感觉特别有用,比之前更加熟悉了GDB.大概是在网页上看的时候比较急躁,所以吸收不好吧23333.还有,在解题过程中参考了不少

CSAPP 3e: Bomb lab (phase_2) + lab中的GDB 使用

这里是第二关,在这里分享一些在解题过程中用到的GDB功能. 首先,要进行断点,比如,在第二关中,断点操作有: 81: input = read_line(); 82: phase_2(input); 83: phase_defused(); break 81; break 82; break 83; 分别在read_line,phase_2,phase_defused,三个函数入口进行了断点. 另外,还有一个地方需要断点,那就是explode_bomb:操作:break explode_bomb

x01.Lab.StreetApp: MVVM

Store App 特别适用于 MVVM 模式.由于要用到 SQLite,Bing Maps,所以第一步从网上搜索并安装这两个扩展.很难想象在智能手机上运行 SQL Server 这种巨无霸型数据库,SQLite 便成为首选.运行 SQLite,需要 C++ 扩展,而解决方案属性 => 配置管理中,CPU 也不能是 Any,应改为 x86.安装后,其添加引用窗口的 扩展 项如下: 第二步,当然是下载源代码了.可到我的置顶随笔 x01.Lab.Download 中获取.解压后,双击 Lab.sln