본문 바로가기

Security/Reversing30

[Dreamhack Reverse Engineering] STAGE 6 보호되어 있는 글 입니다. 2022. 5. 17.
[Dreamhack Reverse Engineering] STAGE 5 Tools: IDA IDA(The Interactive Disassembler)는 Hex-Rays 사에서 제작한 디스어셈블러이다. IDA의 메인 기능은 disassemble이지만 이 외에도 여러 환경에서의 디버깅과 다양한 아키텍처 디컴일과 같이 여러가지 기능을 제공한다. 이 때문에 바이너리를 분석해야 하는 리버스 엔지니어링 업무에는 대부분 IDA를 사용한다. 리버싱을 처음 공부하는 개인이 사용하기 적합한 IDA Freeware는 x64 아키텍처에 한해 디컴파일 기능을 지원하며, 상업적 목적 이외의 교육적 목적으로만 사용 가능하다. IDA 설치 IDA Freeware는 https://hex-rays.com/ida-free/ 에서 다운로드할 수 있다. 설치가 완료된 후 IDA를 실행시키면 위와 같은 창이 뜬.. 2022. 5. 10.
[어셈블리어 분석 실습] example 5 example5.asm의 코드는 아래와 같다. # example5.asm .file"example5.c" .section.rodata .LC0: .string"number %d \n" .LC1: .string"%d * %d = %d \n" .text .globlmain .typemain, @function main: .LFB0: .cfi_startproc pushq%rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 subq$16, %rsp movl$0, -8(%rbp) jmp.L2 .L3: movl-8(%rbp), %eax movl%eax, %esi movl$.LC0, %edi movl$0, %eax c.. 2022. 5. 8.
[어셈블리어 분석 실습] example 4 example4.asm의 코드는 아래와 같다. # example4.asm .file"example4.c" .section.rodata .LC0: .string"result : %d\n" .text .globlfunction .typefunction, @function function: .LFB0: .cfi_startproc pushq%rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 subq$16, %rsp movl%edi, -4(%rbp) movl%esi, -8(%rbp) movl-4(%rbp), %eax imull-8(%rbp), %eax movl%eax, %esi movl$.LC0, %edi mov.. 2022. 5. 8.
[어셈블리어 분석 실습] example 3 example3.asm의 코드는 아래와 같다. # example3.asm .file"example3.c" .section.rodata .LC0: .string"a is 10" .LC1: .string"b is 10" .LC2: .string"b is 20" .LC3: .string"a=b" .LC4: .string"a!=b" .text .globlmain .typemain, @function main: .LFB0: .cfi_startproc pushq%rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 subq$16, %rsp movl$10, -8(%rbp) movl$20, -4(%rbp) cmpl$10,.. 2022. 5. 8.
[어셈블리어 분석 실습] example 2 example2.asm의 코드는 아래와 같다. # example2.asm .file"example2.c" .section.rodata .LC0: .string"result : %d \n" .text .globlmain .typemain, @function main: .LFB0: .cfi_startproc pushq%rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 subq$16, %rsp movl$10, -12(%rbp) movl$20, -8(%rbp) movl-8(%rbp), %eax movl-12(%rbp), %edx addl%edx, %eax movl%eax, -4(%rbp) movl-8(%rbp).. 2022. 5. 8.
[어셈블리어 분석 실습] example 1 example1.asm의 코드는 아래와 같다. # example1.asm .file"example1.c" .section.rodata .LC0: .string"Hello world" .text .globlmain .typemain, @function main: .LFB0: .cfi_startproc pushq%rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 movl$.LC0, %edi movl$0, %eax callprintf movl$0, %eax popq%rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .sizemain, .-main .ident"GCC: (Ubun.. 2022. 5. 8.
[어셈블리어 분석 실습] 기본 내용 이번 실습에서 어셈블리어는 AT&T 문법을 바탕으로 되어 있다. 기본적인 내용은 아래와 같으니 참고하자. .file "example1.c" # 디버거에서 사용하는 원본 파일 이름을 가리킴 (Intel 문법이 아니기 때문에 오른쪽 값을 왼쪽으로 넣음!!) .section .rodata # ./rodatd 섹션 정의, 이 섹션은 읽기 전용 데이터 변수 .text # text section. 코드들을장한 섹션/프로그램 코드 실행할 때 사용 .globl main # 전 코드에 걸쳐 접근 가능한 함수 .type main, @function # main 함수 정의. 이것을 해야만 global main 코드 얻을 수 있음 main: # main:~ret까지가 실제 코드 .LFB0: # 함수의 시작을 의미하는 'loc.. 2022. 5. 8.
[Dreamhack Reverse Engineering] STAGE 4 [x86 Assembly] 1. 어셈블리 언어 1) 어셈블리 언어 - 컴퓨터의 기계어와 치환되는 언어 - CPU에 사용되는 ISA의 종류만큼 많은 수의 어셈블리어가 존재 ex. x64에는 x64의 어셈블리어 존재 2. x64 어셈블리 언어 1) 기본 구조 - 명령어 + 피연산자로 구성 - 명령어 : 동사에 해당 - 피연산자 : 목적어에 해당 - 예시 2) 명령어 데이터 이동 mov, lea 산술 연산 inc, dec, add, sub 논리 연산 and, or, xor, not 비교 cmp, test 분기 jmp, je, jg 스택 push, pop 프로시저 call, ret, leave 시스템 콜 syscall 3) 피연산자 - 상수, 레지스터, 메모리 - 메모리 피연산자는 []으로 둘러싸인 것으로 표현.. 2022. 5. 6.