์‰˜์ฝ”๋“œ ์ž‘์„ฑํ•ด๋ณด๊ธฐ (2)
ยท
Study/Pwnable
1.execve ์‰˜์ฝ”๋“œ์‰˜์€ ์šด์˜์ฒด์ œ๋ฅผ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ๊ป์งˆ์ด๋‹ค.์ฆ‰, ์‚ฌ์šฉ์ž๊ฐ€ ์šด์˜์ฒด์ œ์— ๋ช…๋ น์„ ๋‚ด๋ฆฌ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ์‚ฌ์šฉ์ž์˜ ์ธํ„ฐํŽ˜์ด์Šค๋กœ,  ์‰˜์„ ํš๋“ํ•˜๋ฉด ์‹œ์Šคํ…œ์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋ฏ€๋กœ ํ†ต์ƒ์ ์œผ๋กœ ์…ธ ํš๋“์„ ์‹œ์Šคํ…œ ํ•ดํ‚น์˜ ์„ฑ๊ณต์œผ๋กœ ์—ฌ๊ธฐ๋Š” ๊ฒƒ์ด๋‹ค. execve ์…ธ์ฝ”๋“œ๋Š” ์ž„์˜์˜ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๋Š” ์‰˜์ฝ”๋“œ์ธ๋ฐ, ์ด๋ฅผ ์ด์šฉํ•ด์„œ execve("/bin/sh") ์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰์‹œ์ผœ ์„œ๋ฒ„์˜ ์‰˜์„ ํš๋“ํ•  ์ˆ˜ ์žˆ๋‹ค.//๋”ฐ๋ผ์„œ ๋‹ค๋ฅธ ์–ธ๊ธ‰์—†์ด ์…ธ์ฝ”๋“œ๋ผ๊ณ  ํ•˜๋ฉด ์ด๋ฅผ ์˜๋ฏธํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค. ์ตœ์‹ ์˜ ๋ฆฌ๋ˆ…์Šค๋Š” ๋Œ€๋ถ€๋ถ„ sh, bash๋ฅผ ๊ธฐ๋ณธ ์…ธ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ํƒ‘์žฌํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ์ด ์™ธ์—๋„ zsh, tsh ๋“ฑ์˜ ์…ธ์„ ์œ ์ €๊ฐ€ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.  Ubuntu 22.04์—๋„ /bin/sh๊ฐ€ ์กด์žฌํ•˜๋ฏ€๋กœ, ์ด๋ฅผ ์‹คํ–‰ํ•˜๋Š” execve..
์‰˜์ฝ”๋“œ ์ž‘์„ฑํ•ด๋ณด๊ธฐ (1)
ยท
Study/Pwnable
1. ์‰˜์ฝ”๋“œ๋ž€์‰˜์ฝ”๋“œ(Shellcode)๋Š” ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ์–ด์…ˆ๋ธ”๋ฆฌ(๊ธฐ๊ณ„์–ด) ์ฝ”๋“œ ์กฐ๊ฐ์„ ์˜๋ฏธํ•œ๋‹ค.pwnable์—์„œ๋Š” ์‰˜์„ ํš๋“ํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ์‰˜์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉ๋œ๋‹ค. ๋งŒ์•ฝ ํ”„๋กœ๊ทธ๋žจ์˜ ์‹คํ–‰ ์œ„์น˜(rip)๋ฅผ ์ž์‹ ์ด ์ž‘์„ฑํ•œ ์‰˜์ฝ”๋“œ๋กœ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค๋ฉด ์–ด์…ˆ๋ธ”๋ฆฌ์–ด๋Š” ๊ธฐ๊ณ„์–ด์™€ ๊ฑฐ์˜ ์ผ๋Œ€์ผ ๋Œ€์‘๋˜๋ฏ€๋กœ ์‚ฌ์‹ค์ƒ ์›ํ•˜๋Š” ๋ชจ๋“  ๋ช…๋ น์„ CPU์— ๋‚ด๋ฆด ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์‰˜์ฝ”๋“œ๋Š” ์–ด์…ˆ๋ธ”๋ฆฌ์–ด๋กœ ๊ตฌ์„ฑ๋˜๋ฏ€๋กœ ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•  ๋Œ€์ƒ ์•„ํ‚คํ…์ฒ˜์™€ ์šด์˜์ฒด์ œ์— ๋”ฐ๋ผ, ๊ทธ๋ฆฌ๊ณ  ์…ธ์ฝ”๋“œ์˜ ๋ชฉ์ ์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒŒ ์ž‘์„ฑ๋˜๋ฏ€๋กœ, ์ง์ ‘ ์ž‘์„ฑํ•  ์ค„ ์•Œ์•„์•ผ ํ•œ๋‹ค. 2. orw ์‰˜์ฝ”๋“œ ์ž‘์„ฑ “/tmp/flag”๊ฒฝ๋กœ์˜ ํŒŒ์ผ์„ readํ•˜๋Š” ์‰˜์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์ž์ด์ฒ˜๋Ÿผ ํŒŒ์ผ๊ณผ ๊ด€๋ จ๋œ ์‰˜์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ ํ•„์š”ํ•œ syscall์€ open(), read(), writ..
pwntools ์„ค์น˜
ยท
Study/Pwnable
https://github.com/Gallopsled/pwntools GitHub - Gallopsled/pwntools: CTF framework and exploit development libraryCTF framework and exploit development library. Contribute to Gallopsled/pwntools development by creating an account on GitHub.github.com  pwntools๋Š” ํŒŒ์ด์ฌ์œผ๋กœ ์ต์Šคํ”Œ๋กœ์ž‡ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋Š” ํ•จ์ˆ˜๋“ค์„ ๋ชจ์•„๋‘” ๊ฒƒ์ด๋‹ค.(ex. ์ •์ˆ˜๋ฅผ ๋ฆฌํ‹€ ์—”๋””์–ธ์˜ ๋ฐ”์ดํŠธ ๋ฐฐ์—ด๋กœ ๋ฐ”๊พธ๋Š” ํŒจํ‚น ํ•จ์ˆ˜, ๊ทธ ์—ญ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ์–ธํŒจํ‚น ํ•จ์ˆ˜ ๋“ฑ  ์„ค์น˜ ๋ฐฉ๋ฒ•์€ ๊นƒํ—ˆ๋ธŒ์— ๊ฐ€์ด๋“œ๋Œ€๋กœ ์ง„ํ–‰ํ•˜๋ฉด ๋œ๋‹ค. sudo ..
gdb ์ •๋ฆฌ
ยท
Study/Pwnable
1. pwndbg ์„ค์น˜ (ubuntu 22.04) https://github.com/pwndbg/pwndbg GitHub - pwndbg/pwndbg: Exploit Development and Reverse Engineering with GDB Made EasyExploit Development and Reverse Engineering with GDB Made Easy - pwndbg/pwndbggithub.com 2. ๋””๋ฒ„๊น…(1) ํŒŒ์ผ ์ƒ์„ฑ// Name: debugee.c// Compile: gcc -o debugee debugee.c -no-pie#include int main(void) { int sum = 0; int val1 = 1; int val2 = 2; sum = val1 + v..
mnzy๐ŸŒฑ
'Study/Pwnable' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก
-->