首页
社区
课程
招聘
[求助]以下代码是IDA反汇编DLL的一个输出函数,请教如何分析输入参数和返回值啊?我是新兵,恳请高手们指导。
发表于: 2008-12-11 12:27 7643

[求助]以下代码是IDA反汇编DLL的一个输出函数,请教如何分析输入参数和返回值啊?我是新兵,恳请高手们指导。

2008-12-11 12:27
7643
以下代码是IDA反汇编DLL的一个输出函数,请教如何分析输入参数和返回值啊?
我是新兵,恳请高手们指导。

.text:10001530 ; =============== S U B R O U T I N E =======================================
.text:10001530
.text:10001530 ; Attributes: bp-based frame
.text:10001530
.text:10001530 GetData_0        proc near               ; CODE XREF: GetDataj
.text:10001530
.text:10001530 var_60          = byte ptr -60h
.text:10001530 var_20          = dword ptr -20h
.text:10001530 NumberOfBytesRead= dword ptr -1Ch
.text:10001530 var_18          = qword ptr -18h
.text:10001530 Buffer          = word ptr -10h
.text:10001530
.text:10001530                 push    ebp
.text:10001531                 mov     ebp, esp
.text:10001533                 sub     esp, 60h
.text:10001536                 push    ebx
.text:10001537                 push    esi
.text:10001538                 push    edi
.text:10001539                 lea     edi, [ebp+var_60]
.text:1000153C                 mov     ecx, 18h
.text:10001541                 mov     eax, 0CCCCCCCCh
.text:10001546                 rep stosd
.text:10001548                 mov     esi, esp
.text:1000154A                 push    0               ; lpOverlapped
.text:1000154C                 lea     eax, [ebp+NumberOfBytesRead]
.text:1000154F                 push    eax             ; lpNumberOfBytesRead
.text:10001550                 push    10h             ; nNumberOfBytesToRead
.text:10001552                 lea     ecx, [ebp+Buffer]
.text:10001555                 push    ecx             ; lpBuffer
.text:10001556                 mov     edx, hDevice
.text:1000155C                 push    edx             ; hFile
.text:1000155D                 call    ds:ReadFile
.text:10001563                 cmp     esi, esp
.text:10001565                 call    __chkesp
.text:1000156A                 test    eax, eax
.text:1000156C                 jz      short loc_100015AF
.text:1000156E                 mov     esi, esp
.text:10001570                 push    0               ; lpOverlapped
.text:10001572                 lea     eax, [ebp+NumberOfBytesRead]
.text:10001575                 push    eax             ; lpNumberOfBytesRead
.text:10001576                 push    10h             ; nNumberOfBytesToRead
.text:10001578                 lea     ecx, [ebp+Buffer]
.text:1000157B                 push    ecx             ; lpBuffer
.text:1000157C                 mov     edx, hDevice
.text:10001582                 push    edx             ; hFile
.text:10001583                 call    ds:ReadFile
.text:10001589                 cmp     esi, esp
.text:1000158B                 call    __chkesp
.text:10001590                 movsx   eax, [ebp+Buffer]
.text:10001594                 mov     [ebp+var_20], eax
.text:10001597                 fild    [ebp+var_20]
.text:1000159A                 fmul    ds:dbl_10111130
.text:100015A0                 fmul    ds:dbl_10111120
.text:100015A6                 fdiv    ds:dbl_10111110
.text:100015AC                 fstp    [ebp+var_18]
.text:100015AF
.text:100015AF loc_100015AF:                           ; CODE XREF: GetData_0+3Cj
.text:100015AF                 fld     [ebp+var_18]
.text:100015B2                 pop     edi
.text:100015B3                 pop     esi
.text:100015B4                 pop     ebx
.text:100015B5                 add     esp, 60h
.text:100015B8                 cmp     ebp, esp
.text:100015BA                 call    __chkesp
.text:100015BF                 mov     esp, ebp
.text:100015C1                 pop     ebp
.text:100015C2                 retn
.text:100015C2 GetData_0        endp

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 2110
活跃值: (21)
能力值: (RANK:260 )
在线值:
发帖
回帖
粉丝
2
通常逆向一个函数的功能需要动静结合。不过这个例子比较简单,直接看静态代码也能猜测个差不离了。

1.参数:

从堆栈和寄存器入手。该函数IDA分析出的栈帧上的偏移量都为负数,那么意味着应该是没有堆栈参数(实际上应该看代码有没有访问栈上“参数”的位置,在本例中没有)。

再看寄存器。可以看到EAX、ECX、EDX中原来的值都没有使用,直接被覆盖,那么该函数也没有寄存器参数。

所以,该函数的参数表极有可能是void

返回值:

根据调用约定,整形或指针型从EAX(及EDX)寄存器返回,浮点结果直接从浮点寄存器返回。

看这个函数结尾处的几条指令,没有对EAX的有意识地赋值,但看到了这样几条指令:

.text:10001590 movsx eax, [ebp+Buffer]
.text:10001594 mov [ebp+var_20], eax
.text:10001597 fild [ebp+var_20]
.text:1000159A fmul ds:dbl_10111130
.text:100015A0 fmul ds:dbl_10111120
.text:100015A6 fdiv ds:dbl_10111110
.text:100015AC fstp [ebp+var_18]
.text:100015AF
.text:100015AF loc_100015AF: ; CODE XREF: GetData_0+3Cj
.text:100015AF fld [ebp+var_18]


而根据IDA的分析,var_18 = qword ptr -18h,所以该函数的返回值推测应该是double

为了更加确定,你可以动态跟踪一下函数的调用过程。
2008-12-11 13:23
0
雪    币: 217
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
感谢“书呆彭”的分析,能帮我在汇编码上写点注释么?谢谢!!

2008-12-11 14:50
0
雪    币: 200
活跃值: (46)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
8错,这样的分析很容易理解,书呆是个好银,新版版很有耐心~
2008-12-23 15:56
0
雪    币: 200
活跃值: (46)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
汇编代码加注释,这个我看您还是翻翻书先吧。或者自己编译点小例程对比对比
2008-12-23 15:57
0
游客
登录 | 注册 方可回帖
返回
//