python3-print

date
Apr 28, 2023
slug
python3-print
status
Published
tags
Pwnable
summary
type
Post
python3์—์„œ ์‚ฌ์šฉํ•˜์—ฌ ์ž…๋ ฅ ๊ฐ’์„ ๋„ฃ์œผ๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ ์ƒ๊ฐํ–ˆ๋˜ ๊ฒฐ๊ณผ์™€ ๋‹ค๋ฅธ ๊ฐ’์ด ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅ๋˜์—ˆ๋‹ค.
์›์ธ์„ ์•Œ์•„๋ณด๊ธฐ ์œ„ํ•ด xxd ๋ช…๋ น์–ด๋กœ ํ™•์ธํ•ด๋ดค๋”๋‹ˆ ๊ฐ’์ด ๋‹ค๋ฅด๊ฒŒ ๋‚จ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
notion image
๋งˆ์ง€๋ง‰์— ๋‚จ๋Š” 0x0a๋Š” ๊ฐœํ–‰(LF)์„ ์˜๋ฏธํ•œ๋‹ค.

์ฒซ ๋ฒˆ์งธ ๊ฒฐ๊ณผ

python3์€ ascii์—์„œ unicode๋กœ ๋ฐ”๋€Œ๋ฉด์„œ b"A"์ฒ˜๋Ÿผ b๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”๋ฐ ์ฒซ ๋ฒˆ์งธ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด A๊ฐ€ 24๊ฐœ์ด๋ฏ€๋กœ *24๋Š” ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ–ˆ๋‹ค.
ํ•˜์ง€๋งŒ \x96\x11\x40\x00, b' ๋ฌธ์ž ์ž์ฒด๊ฐ€ ascii ์ฝ”๋“œ๋กœ ์ถœ๋ ฅ๋จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
gdb๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ์— ์ •๋ง ๊ทธ๋ ‡๊ฒŒ ๋‚จ๋Š”์ง€๋„ ํ™•์ธํ•˜์˜€๋‹ค.
notion image

๋‘ ๋ฒˆ์งธ ๊ฒฐ๊ณผ

๋‘๋ฒˆ์งธ๋Š” 0x41 ascii ๊ฐ’์ด ์ •์ƒ์ ์œผ๋กœ ๋“ค์–ด๊ฐ”์ง€๋งŒ ๊ทธ ์ดํ›„์— 0xc2๋ผ๋Š” ์˜๋ฌธ์„ ๋ชจ๋ฅด๋Š” ๊ฐ’์ด ๋“ค์–ด๊ฐ”๊ณ  ๊ทธ ์ดํ›„์— \x96\x11\x40\x00์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.
notion image
์ถœ์ฒ˜: Tips for the challenges
0x80๋ณด๋‹ค ํฐ ๊ฐ’์ด ๋“ค์–ด์˜ค๋ฉด 0xc2๋ผ๋Š” ๊ฐ’์ด ์ถ”๊ฐ€๋œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๋‹ˆ ๊ทธ๋ ‡๊ฒŒ ๋™์ž‘ํ–ˆ๋‹ค..
notion image
notion image

๋งˆ์ง€๋ง‰ ๊ฒฐ๊ณผ

๋งˆ์ง€๋ง‰์€ ์ด์ „์— ์ฐธ๊ณ ํ•œ ๊ธ€์ฒ˜๋Ÿผ std.stdout.buffer.write๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฐ๊ณผ ๊น”๋”ํ•˜๊ฒŒ ๊ฐ’์ด ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
notion image
python2๋Š” 2๊ฐ€์ง€ ๋ฐฉ๋ฒ• ๋ชจ๋‘ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ  ์žˆ๋‹ค.
notion image
๋งˆ์ง€๋ง‰์œผ๋กœ ;cat์„ ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ดํ”„๋ผ์ธ์„ ๋„˜๊ฒจ์ฃผ๋ฉด ๋˜๊ฒ ๋‹ค.
notion image
notion image

cat์˜ ์—ญํ• 

์ฐธ๊ณ 


ยฉ hyuunnn 2024