한컴 오피스 악성코드 분석하다 화딱지 나서 알아두면 좋은 Post Script 정보..

 

gs 9.21 버전 이하 기준.

 

 

---------------------------------------------------------------------------------------------------------------------

Ghost Script Engine에서는 피연산자 Stack을 구조체로 관리하는데 다음과 같다.

struct ref_stack_s {
    /* Following are updated dynamically. */
    s_ptr p;			/* current top element */
    /* Following are updated when adding or deleting blocks. */
    s_ptr bot;			/* bottommost valid element */
    s_ptr top;			/* topmost valid element = */
                                /* bot + data_size */
    ref current;		/* t_array for current top block */
    uint extension_size;	/* total sizes of extn. blocks */
    uint extension_used;	/* total used sizes of extn. blocks */
    /* Following are updated rarely. */
    ref max_stack;		/* t_integer, Max...Stack user param */
    uint requested;		/* amount of last failing */
                                /* push or pop request */
    uint margin;		/* # of slots to leave between limit */
                                /* and top */
    uint body_size;		/* data_size - margin */
    /* Following are set only at initialization. */
    ref_stack_params_t *params;
    gs_ref_memory_t *memory;	/* allocator for params and blocks */
};

https://github.com/plangrid/ghostpdl/blob/master/psi/isdata.h

크게 현재 스택의 위치를 알려주는 p, 스택의 base pointer를 알려주는 bot, 스택의 최상단을 알려주는 top 3가지다.

 

 

 

예제코드)

1. /test_array 16#31E array def
2. 16#100{test_array aload} repeat

1. 16진수 0x31E 크기의 배열 test_array를 정의

2. test_array 배열을 0x100번 Stack에 Push

 

* aload 연산자 - 피연산자 배열의 모든 Element를 Stack에 Push 하는 기능.

 

 

 

 

 

 

 

 

 

 

'# technic > - reversing' 카테고리의 다른 글

IDA 사용법  (2) 2020.06.30
kakaotalk pc - 취약점 분석  (0) 2019.07.14
백신 분석 보고서. - 1 -  (0) 2018.10.20
z3 모든 경우의 수  (0) 2018.09.30
ARM 32bit  (0) 2018.09.29

+ Recent posts