[Register]
rbx = 0x401A40
=================================
[Memory]
0x401a40 | 0x0000000012345678
0x401a48 | 0x0000000000C0FFEE
0x401a50 | 0x00000000DEADBEEF
0x401a58 | 0x00000000CAFEBABE
0x401a60 | 0x0000000087654321
=================================
[Code]
1: mov rax, [rbx+8]
2: lea rax, [rbx+8]
mov(rax값에 rbx+8을 대입) 실행: 0x0000000000C0FFEE
[Register]
rcx = 0
rdx = 0
rsi = 0x400000
=======================
[Memory]
0x400000 | 0x67 0x55 0x5c 0x53 0x5f 0x5d 0x55 0x10
0x400008 | 0x44 0x5f 0x10 0x51 0x43 0x43 0x55 0x5d
0x400010 | 0x52 0x5c 0x49 0x10 0x47 0x5f 0x42 0x5c
0x400018 | 0x54 0x11 0x00 0x00 0x00 0x00 0x00 0x00
=======================
[code]
1: mov dl, BYTE PTR[rsi+rcx]
// dl에 BYTE PTR[0x400000] 대입 => 0x67
2: xor dl, 0x30
// 0x67 xor 0x30 = 0x57
3: mov BYTE PTR[rsi+rcx], dl
// PTR[0x400000에 dl 대입
// dl은 0x57이 됨
4: inc rcx
// rcx값을 1늘림
5: cmp rcx, 0x19
// rcx를 0x19와 비교 (0x19번)
6: jg end
// rcx가 클 시 종료
7: jmp 1
0x400000 | 0x57 0x65 0x6c 0x63 0x6f 0x6d 0x65 0x20
0x400008 | 0x74 0x6f 0x20 0x61 0x73 0x73 0x65 0x6d
0x400010 | 0x62 0x6c 0x79 0x20 0x77 0x6f 0x72 0x6c
0x400018 | 0x64 0x21 0x00 0x00 0x00 0x00 0x00 0x00
위 데이터를 아스키코드로 변환하면
Welcome to assembly world!
[Code]
main:
push rbp
mov rbp, rsp
// rbp에 rsp 대입
mov esi, 0xf
// esi는 0xf
mov rdi, 0x400500
// rdi는 0x400500
call 0x400497 <write_n>
//
mov eax, 0x0
// eax는 0x0
pop rbp
ret
write_n:
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-0x8],rdi
// rbp-0x8=0x400500
mov DWORD PTR [rbp-0xc],esi
// rbp-0xc=0xf
xor rdx, rdx
// 0
mov edx, DWORD PTR [rbp-0xc]
// edx=0xf
mov rsi,QWORD PTR [rbp-0x8]
// rsi=0x400500
mov rdi, 0x1
// rdi는 0x1
mov rax, 0x1
// rax는 0x1
syscall
pop rbp
ret
==================================
[Memory]
0x400500 | 0x3037207964343372
0x400508 | 0x003f367562336420
3037207964343372 = 07 yd43r
003f367562336420 = ?6ub3d
=> 리틀엔디안 방식: r34dy 07 d3bu6?