[EXERCISE 0004] Identify Variables

One of the most important capabilities during binary auditing is to identify variables within assembly code. Sometimes such variables are not that clear to identify for beginners as it is by reading C++ code. This time we have a look at many different variables at once. What I can do is to give you some hints. The original source code contained: double, long double, unsigned char, signed char, unsigned long int, signed long int, unsigned short int, signed short int, unsigned int, signed int, bool, float, and wchar_t. Can you get which variable type is corresponding to which lines of the assembly code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main proc near
.text:00401000
.text:00401000 var_38= qword ptr -38h
.text:00401000 var_2C= dword ptr -2Ch
.text:00401000 var_25= byte ptr -25h
.text:00401000 var_24= dword ptr -24h
.text:00401000 var_20= word ptr -20h
.text:00401000 var_1C= dword ptr -1Ch
.text:00401000 var_18= word ptr -18h
.text:00401000 var_14= word ptr -14h
.text:00401000 var_F= byte ptr -0Fh
.text:00401000 var_E= byte ptr -0Eh
.text:00401000 var_D= byte ptr -0Dh
.text:00401000 var_C= dword ptr -0Ch
.text:00401000 var_8= qword ptr -8
.text:00401000 argc= dword ptr  8
.text:00401000 argv= dword ptr  0Ch
.text:00401000 envp= dword ptr  10h
.text:00401000
.text:00401000 push    ebp
.text:00401001 mov     ebp, esp
.text:00401003 sub     esp, 3Ch
.text:00401006 mov     [ebp+var_D], 0
.text:0040100A mov     [ebp+var_D], 0FFh
.text:0040100E mov     [ebp+var_25], 80h
.text:00401012 mov     [ebp+var_25], 7Fh
.text:00401016 xor     eax, eax
.text:00401018 mov     [ebp+var_18], ax
.text:0040101C mov     ecx, 0FFFFh
.text:00401021 mov     [ebp+var_18], cx
.text:00401025 mov     edx, 0FFFF8000h
.text:0040102A mov     [ebp+var_14], dx
.text:0040102E mov     eax, 7FFFh
.text:00401033 mov     [ebp+var_14], ax
.text:00401037 mov     [ebp+var_1C], 0
.text:0040103E mov     [ebp+var_1C], 0FFFFFFFFh
.text:00401045 mov     [ebp+var_1C], 80000000h
.text:0040104C mov     [ebp+var_1C], 7FFFFFFFh
.text:00401053 mov     [ebp+var_24], 0
.text:0040105A mov     [ebp+var_24], 0FFFFFFFFh
.text:00401061 mov     [ebp+var_2C], 80000000h
.text:00401068 mov     [ebp+var_2C], 7FFFFFFFh
.text:0040106F mov     [ebp+var_F], 1
.text:00401073 mov     [ebp+var_E], 0
.text:00401077 fld     ds:__real@40aafae0
.text:0040107D fstp    [ebp+var_C]
.text:00401080 fld     ds:__real@40155f5bff2d92cd
.text:00401086 fstp    [ebp+var_8]
.text:00401089 fld     ds:__real@40155f5bff2d92cd
.text:0040108F fstp    [ebp+var_38]
.text:00401092 mov     ecx, 41h
.text:00401097 mov     [ebp+var_20], cx
.text:0040109B xor     eax, eax
.text:0040109D mov     esp, ebp
.text:0040109F pop     ebp
.text:004010A0 retn
.text:004010A0 _main