본문으로 바로가기

ASM to C with IDA - 038

category Reversing/ASM to C 2018. 7. 6. 10:19

C300_038



C300_소스코드



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h> 
 
struct tagSungJuk
{
    int kor;
    int eng;
    int math;
};
 
main()
{
    struct tagSungJuk SJ;
 
    SJ.kor = 100;
    SJ.eng = 95;
    SJ.math = 99;
 
    printf("총합 = %d ", SJ.kor + SJ.eng + SJ.math);        
}
 
cs



IDA - Layout Graph




IDA - Text View





지역변수를 12byte 할당한것을 확인할 수 있다.

하지만 12byte 자료형이 없기 때문에 구조체 혹은 배열로 생각할 수 있다.

변수 이름을 확인하면 SJ.math 와 같이 구조체 변수에 접근 하고 있기 때문에 구조체임을 추측했다.



pseudo 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
#include <stdio.h> 
 
struct SJ_sj
{
    int kor;
    int eng;
    int math;
}
 
main()
{
    struct Sj_sj SJ;
    SJ.kor = 100;
    SJ.eng = 95;
    SJ.math = 99;
 
    eax = SJ.kor;
    eax = eax + SJ.eng;
    eax = eax + SJ.math;            
    
    printf(_Format, eax);
 
    eax = 0;
}    
 
cs



pseudo code - 최종 의사코드



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h> 
 
struct SJ_sj
{
    int kor;
    int eng;
    int math;
}
 
main()
{
    struct Sj_sj SJ;
    SJ.kor = 100;
    SJ.eng = 95;
    SJ.math = 99;
 
    printf(_Format, SJ.kor + SJ.eng + SJ.math);
 
    return 0;
}    
 
cs





'Reversing > ASM to C' 카테고리의 다른 글

ASM to C with IDA - 040  (0) 2018.07.06
ASM to C with IDA - 039  (2) 2018.07.06
ASM to C with IDA - 037  (0) 2018.07.05
ASM to C with IDA - 036  (0) 2018.07.05
ASM to C with IDA - 035  (0) 2018.07.05