1.由main函数调用的唯一子过程中发现的主要代码结构是什么?
先进行基础的静态分析
InternetGetConnectState
函数用于检查本地系统的网络连接状态。
GetACP
获取当前系统的代码页编码,如简体中文是 936。
GetCPinfo
取得与指定代码页有关的信息。
使用strings
GetCommandLineA
获取命令行输入参数
Error 1.1: No Internet
Success: Internet Connection
该程序可能检查系统中是否存在可用的网络连接。
动态运行——只打印了Success: Internet Connection即退出了。
使用ida pro加载,从main函数(.text:00401040)开始。
sub_401000比较关键,进入查看
使用cmp对保存结果的eax寄存器与0比较,使用jz指令控制执行流。存在可用连接时,InternetGetConnectedState返回1,否则返回0。返回1时,零标志位(ZF)会被清除,jz指令进入false分支。两个分支mov eax, 1即为1,连接成功;xor eax, eax即为0,失败。
代码结构为if语句。
2.位于0x40105F
的子过程是什么?
printf函数
本身的实现
int __cdecl printf (
const char *format,
...
)
/*
* stdout 'PRINT', 'F'ormatted
*/
{
va_list arglist;
int buffing;
int retval;
va_start(arglist, format);
_ASSERTE(format != NULL);
_lock_str2(1, stdout);
buffing = _stbuf(stdout); // 记住这个函数_stbuf
retval = _output(stdout,format,arglist); // 还有记住这里调用了一次外部函数
_ftbuf(buffing, stdout); // 记住这个函数_ftbuf
_unlock_str2(1, stdout);
return(retval);
}
题目中:
FILE <0, 0, 0, 2, 1, 0, 0, 0>
windows的文件描述符(file descriptor)
struct _iobuf {
char *_ptr; // -> 0
int _cnt; // -> 0
char *_base; // -> 0
int _flag; // -> 2
int _file; // -> 1
int _charbuf; // -> 0
int _bufsiz; // -> 0
char *_tmpfname; // -> 0
};
typedef struct _iobuf FILE;
_file
代表打开的文件在系统中的编号,一般我们编程的时候打开的句柄(也就是文件描述符)编号都比较大【本身系统就已经打开了比较多的文件】,但是一般有三个文件的文件描述符是固定写死的,还比较小,那就是stdin、stdout、stderr,在系统中对应的值就是
stdin -> 0
stdout -> 1
stderr -> 2
3.这个程序的目的是什么?
检查是否存在可用的Internet连接,如果存在,打印结果并返回1,不存在则返回0。
参考
1.斯科尔斯基, 哈尼克. 恶意代码分析实战[M]. 电子工业出版社, 2014.
2.恶意代码分析实战 Lab 6-1 习题笔记