๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ Web Hacking/Dreamhack

[Dreamhack] Simple_Sqli ๋“œ๋ฆผํ•ต ์›Œ๊ฒŒ์ž„ ๋ฌธ์ œ ํ’€์ด

by A Lim Han 2022. 9. 23.

2 - 1 - 4. Simple_Sqli ์ทจ์•ฝ์  ๋ถ„์„ ์‹ค์Šต

 

 

 

# Simple_Sqli ์ทจ์•ฝ์  ๋ถ„์„ ์‹ค์Šต

1. ๋ฌธ์ œ ์ •๋ณด ํ™•์ธ ํ›„ ๋ฌธ์ œ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ

 

 

 

2. ๋ฌธ์ œ ํŒŒ์ผ ์ฝ”๋“œ ๋ถ„์„

+ << Line 15 >>

: database ์˜ ํŒŒ์ผ๋ช… ์„ค์ •

 

+ << Line 16 ~ 17 >>

: ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํŒŒ์ผ์ด ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์ƒˆ๋กœ์šด ํŒŒ์ผ์„ ์ƒ์„ฑ ํ›„ ์—ฐ๊ฒฐ

 

+ << Line 18 ~ 19 >>

: ์œ ์ € ํ…Œ์ด๋ธ” ์ƒ์„ฑ ํ›„ ์œ ์ € ํ…Œ์ด๋ธ”์— admin, guest ๊ณ„์ • ์ƒ์„ฑ ๋ฐ ๋‚œ์ˆ˜๋กœ password ์ƒ์„ฑ

 

+ << Line 20 ~ 21 >>

: ์ฟผ๋ฆฌ ์‹คํ–‰ ๋ฐ ์‹คํ–‰ ํ›„ ์ข…๋ฃŒ ์ฝ”๋“œ

 

 

+ << Line 23 ~ 28 >>

: ์ž…๋ ฅ๋ฐ›์€ ๊ฐ’์„ ๊ธฐ์ค€์œผ๋กœ ๋™์  ์ฟผ๋ฆฌ ์ƒ์„ฑ  -->  ์ด์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์ด ์ฟผ๋ฆฌ๋ฌธ์— ํฌํ•จ๋  ๊ฒฝ์šฐ SQL Injection ๋ฐœ์ƒ

 

 

+ << Line 46 >>

: GET, POST 2๊ฐœ์˜ ๋ฉ”์†Œ๋“œ๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅ

 

+ << Line 48 ~ 52 >>

: GET ๋ฐฉ์‹์œผ๋กœ ์š”์ฒญ ์‹œ  -->  ํ™ˆ ํ™”๋ฉด์—์„œ login ํŽ˜์ด์ง€ ํด๋ฆญ ์‹œ login ํŽ˜์ด์ง€ ์ถœ๋ ฅ

: POST ๋ฐฉ์‹์œผ๋กœ ์š”์ฒญ ์‹œ  -->  ์ด์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์„ userid, password ์— ์ €์žฅ

 

+ << Line 53 >>

: ์œ„ ์ฝ”๋“œ์—์„œ์˜ Res๋Š” Result, ์ฆ‰ ๊ฒฐ๊ณผ๊ฐ’์„ ์˜๋ฏธ  -->  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ์งˆ์˜ํ•˜๋Š” ์ฝ”๋“œ ๋ฐ ID, password์— ์ด์ „ ์ž…๋ ฅ๊ฐ’์„ ์‚ฝ์ž…

 

+ << Line 54 ~ 59 >>

: ์งˆ์˜ ์‹œ ์ผ์น˜ํ•˜๋Š” ํšŒ์›์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ res์˜ ์ฒซ ๋ฒˆ์งธ ๋ฐฐ์—ด(๊ฐ’)์„ ๋ถˆ๋Ÿฌ์˜จ๋‹ค.

-->  ๋ถˆ๋Ÿฌ์˜จ userid = admin ์ผ ๊ฒฝ์šฐ FLAG ์ถœ๋ ฅ

: ID์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ๊ฐ’์ด ์„œ๋กœ ๋‹ค๋ฅด๋ฉด ์˜ค๋ฅ˜ ๋ฉ”์„ธ์ง€์™€ ํ•จ๊ป˜ ์ด์ „ ํŽ˜์ด์ง€๋กœ ๋Œ์•„๊ฐ€๋Š” ์ฝ”๋“œ

 

 

 

3. ์ ‘์† ์ •๋ณด ํ™•์ธ ํ›„ http://host3.dreamhack.games:15708/ ์œผ๋กœ ์ ‘์† 

 

 

 

 

4. Login ํŽ˜์ด์ง€ ์ ‘์† ํ›„ userid์— admin"-- " AND userpassword="Love๋ฅผ, password ์— Love ์ž…๋ ฅ  -->  Flag ์ถœ๋ ฅ

 

Flag ๋Š”&nbsp;DH{1f136225e316add7bff3349ab1dd5400}

+ "admin"-- " AND userpassword="Love" ๊ฐ€ ์•„๋‹Œ admin"-- " AND userpassword="Love ๋กœ ์ž‘์„ฑํ•œ ์ด์œ ?

-->  ์ปดํ“จํ„ฐ์—์„œ ๋งจ ์•ž๊ณผ ๋งจ ๋งˆ์ง€๋ง‰ ๋ถ€๋ถ„์˜ "์€ ์ž๋™์œผ๋กœ ๋ถ™์—ฌ์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ์ค‘๋ณต์„ ํ”ผํ•˜๊ธฐ ์œ„ํ•จ

 

 

+ ์œ„์˜ ๋ฐฉ๋ฒ• ์™ธ์—๋„ ๋‹ค์–‘ํ•œ ์ฝ”ํŠธ ํ˜•ํƒœ๊ฐ€ ์กด์žฌํ•จ