๐Ÿ“š์บก์Šคํ†ค ๋””์ž์ธ1 <CodeEngn Basic RCE L01 >

Loopy ยท2022๋…„ 5์›” 21์ผ
0

๐Ÿ”Ž์บก์Šคํ†ค ๋””์ž์ธ1

๋ชฉ๋ก ๋ณด๊ธฐ
5/19

๐Ÿ”ฅ๋ชฉํ‘œ:์ฝ”๋“œ์—”์ง„ ๋ฒ ์ด์ง L01 ๋ฌธ์ œ๐Ÿ”ฅ

Basic RCE L01: HDD๋ฅผ CD-Rom์œผ๋กœ ์ธ์‹์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ๋Š” GetDriveTypeA์˜ ๋ฆฌํ„ด๊ฐ’์ด ๋ฌด์—‡์ด ๋˜์–ด์•ผ ํ•˜๋Š”๊ฐ€

๋ฌธ์ œ ๋‹ค์šด๋กœ๋“œ -> zip ์••์ถ• ํ•ด์ œ
๋น„๋ฐ€๋ฒˆํ˜ธ: codeengn

ํŒŒ์ผ ์‹คํ–‰ ํ›„ -> Make me think your HD is a CD-Rom
Nah.... This is not a CD-Rom Drive!

-> ์—ฌ๊ธฐ๊นŒ์ง€ ์•Œ ์ˆ˜ ์žˆ๋Š” ์ 
(1) CD-Rom์œผ๋กœ ์ธ์‹ํ•˜๊ฒŒ ๋ฐ”๊ฟ”์•ผํ•œ๋‹ค.
(2) GetDriveTypeA์˜ ๋ฆฌํ„ด ๊ฐ’์„ ๊ตฌํ•ด์•ผ ํ•œ๋‹ค.
(3) ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ฉด, ํ™”๋ฉด ์ฐฝ์ด ์ƒ๊ธด๋‹ค. (๋ฉ”์‹œ์ง€ ๋ฐ•์Šค ํ•จ์ˆ˜ ์‚ฌ์šฉ)

ํŒŒ์ผ์„ X64dbg์— ๋Œ๋ ค๋ณด๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๋ฐ‘์—
"์ด ํŒŒ์ผ์„ ๋””๋ฒ„๊น…ํ•˜๊ธฐ ์œ„ํ•ด์„œ x32dbg๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค!" ๋ผ๋Š” ๊ธ€์ด ๋‚˜์™”๋‹ค.

x32dbg๋ฅผ ์ด์šฉํ•ด์„œ ์ญ‰์ญ‰ ๋‚ด๋ ค๊ฐ€๋ฉด์„œ ์ฝ์–ด๋ณด์ž,,,,
๊ณ„์† ์ฝ๋˜ ์ค‘, GetDriveTypeA ํ•จ์ˆ˜๊ฐ€ ๋ณด์—ฌ์„œ, ํ•จ์ˆ˜ ๋‚ด๋ถ€ ์ง„์ž… ์ „!Break Point๋ฅผ ๊ฑด๋‹ค.

๋ฐ‘์— ๋ถ€๋ถ„ ๋ณด๋ฉด CMP eax, esi๊ฐ€ ์žˆ๋‹ค.
cmp eax, esi
je 01.40103D

cmp๋Š” ๋น„๊ต๋ฅผ ์˜๋ฏธํ•œ๋‹ค.
๋”ฐ๋ผ์„œ eax, esi๋ฅผ ๋น„๊ตํ•˜์—ฌ ๋ฉ”์‹œ์ง€ ์ฐฝ์„ ํ™”๋ฉด์— ๋„์šฐ๊ธฐ ๋•Œ๋ฌธ์— ์—ฌ๊ธฐ๋„ ์ž˜ ๋ด์•ผํ•œ๋‹ค.
eax์™€ esi๋ฅผ ๋น„๊ตํ–ˆ์„ ๋•Œ, ๋‹ค๋ฅด๋ฉด(jne) 40103D ์ฃผ์†Œ๋กœ ์ด๋™ํ•œ๋‹ค.

ESI = EAX ๊ฐ’ = ok ๋ฉ˜ํŠธ ์ถœ๋ ฅ
๋‹ค๋ฅด๋ฉด(jne) = not CD-Rom ๋ฉ”์‹œ์ง€ ๋ฐ•์Šค ํ™”๋ฉด์— ๋œจ๋ฉด์„œ, 40103D์ฃผ์†Œ๋กœ ์ด๋™

EAX ๊ฐ’๊ณผ ESI ๊ฐ’์ด ๊ฐ™๊ฒŒ ๋˜์–ด์•ผ Ok๋ฉ˜ํŠธ๊ฐ€ ๋‚˜์˜ค๋ฉฐ,
GetDriveType A ๋ถ€๋ถ„ ์ง€๋‚˜๋ฉด EAX = 3

-> EAX = 3์ด๋ฏ€๋กœ, 3๋ง๊ณ  ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ ์—†๋‚˜ ๊ตฌ๊ธ€๋ง ํ•ด๋ดค๋‹ค.
๊ฒฐ๊ณผ ์‚ฌ์ง„์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

-> ๋”ฐ๋ผ์„œ, 5๋กœ ์ฝ”๋“œ๋ฅผ ๋ฐ”๊ฟ”์คฌ๋”๋‹ˆ
Ok, I really think that your HD is a CD-ROM! :P ๋กœ ์•Œ๋ฆผ์ฐฝ์ด ๋œจ๋ฉด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ :0

----------References

profile
์ •๋ณด๋ณดํ˜ธํ•™๊ณผ ๋Œ€ํ•™์ƒ ๐Ÿ˜Š

0๊ฐœ์˜ ๋Œ“๊ธ€